diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-10-24 10:10:56 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-10-24 15:39:26 +0100 |
commit | 0853819285861e896e370bb5c10bf9108f3d74d8 (patch) | |
tree | 120dec3d2f40db781b9f81b94490c5e6d6d4b04e /vcl | |
parent | map some more stock images (diff) | |
download | core-0853819285861e896e370bb5c10bf9108f3d74d8.tar.gz core-0853819285861e896e370bb5c10bf9108f3d74d8.zip |
merge and correct buttonbox spacing calculation
Change-Id: Ibd378c85c6b7cf774ed2a6f652264a2a78bfe366
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/vcl/layout.hxx | 21 | ||||
-rw-r--r-- | vcl/source/window/layout.cxx | 73 |
2 files changed, 45 insertions, 49 deletions
diff --git a/vcl/inc/vcl/layout.hxx b/vcl/inc/vcl/layout.hxx index 38ad29e8ef02..fb533dbc9e32 100644 --- a/vcl/inc/vcl/layout.hxx +++ b/vcl/inc/vcl/layout.hxx @@ -45,6 +45,7 @@ private: class VCL_DLLPUBLIC VclBox : public VclContainer { protected: + Size m_aMinChildSize; bool m_bHomogeneous; int m_nSpacing; public: @@ -70,8 +71,10 @@ public: { return m_bHomogeneous; } - virtual bool set_property(const rtl::OString &rKey, const rtl::OString &rValue); + virtual bool set_property(const OString &rKey, const OString &rValue); protected: + Size finalizeMaxes(const Size &rSize, sal_uInt16 nVisibleChildren) const; + virtual Size calculateRequisition() const; virtual void setAllocation(const Size &rAllocation); @@ -182,11 +185,7 @@ enum VclButtonBoxStyle class VCL_DLLPUBLIC VclButtonBox : public VclBox { public: - VclButtonBox(Window *pParent, int nSpacing) - : VclBox(pParent, true, nSpacing) - , m_eLayoutStyle(VCL_BUTTONBOX_DEFAULT_STYLE) - { - } + VclButtonBox(Window *pParent, int nSpacing); void set_layout(VclButtonBoxStyle eStyle) { m_eLayoutStyle = eStyle; @@ -195,7 +194,7 @@ public: { return m_eLayoutStyle; } - virtual bool set_property(const rtl::OString &rKey, const rtl::OString &rValue); + virtual bool set_property(const OString &rKey, const OString &rValue); protected: virtual Size calculateRequisition() const; virtual void setAllocation(const Size &rAllocation); @@ -388,7 +387,7 @@ public: { return m_nColumnSpacing; } - virtual bool set_property(const rtl::OString &rKey, const rtl::OString &rValue); + virtual bool set_property(const OString &rKey, const OString &rValue); }; VCL_DLLPUBLIC void setGridAttach(Window &rWidget, sal_Int32 nLeft, sal_Int32 nTop, @@ -408,7 +407,7 @@ class VCL_DLLPUBLIC VclFrame : public VclBin { public: VclFrame(Window *pParent) : VclBin(pParent) {} - void set_label(const rtl::OUString &rLabel); + void set_label(const OUString &rLabel); Window *get_label_widget(); const Window *get_label_widget() const; protected: @@ -431,7 +430,7 @@ public: , m_fYScale(1.0) { } - virtual bool set_property(const rtl::OString &rKey, const rtl::OString &rValue); + virtual bool set_property(const OString &rKey, const OString &rValue); protected: virtual Size calculateRequisition() const; virtual void setAllocation(const Size &rAllocation); @@ -459,7 +458,7 @@ public: } virtual Window *get_child(); virtual const Window *get_child() const; - virtual bool set_property(const rtl::OString &rKey, const rtl::OString &rValue); + virtual bool set_property(const OString &rKey, const OString &rValue); protected: virtual Size calculateRequisition() const; virtual void setAllocation(const Size &rAllocation); diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index 607fa20fc57e..6d321cf03118 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -88,8 +88,6 @@ void VclContainer::SetSizePixel(const Size& rAllocation) Size VclBox::calculateRequisition() const { - long nMaxChildDimension = 0; - sal_uInt16 nVisibleChildren = 0; Size aSize; @@ -99,31 +97,20 @@ Size VclBox::calculateRequisition() const continue; ++nVisibleChildren; Size aChildSize = getLayoutRequisition(*pChild); - long nSecondaryDimension = getSecondaryDimension(aChildSize); - if (nSecondaryDimension > getSecondaryDimension(aSize)) - setSecondaryDimension(aSize, nSecondaryDimension); - if (m_bHomogeneous) - { - long nPrimaryDimension = getPrimaryDimension(aChildSize); - if (nPrimaryDimension > nMaxChildDimension) - nMaxChildDimension = nPrimaryDimension; - } - else - { - long nPrimaryDimension = getPrimaryDimension(aSize); - setPrimaryDimension(aSize, nPrimaryDimension + getPrimaryDimension(aChildSize)); - } - } - if (nVisibleChildren) - { - long nPrimaryDimension = getPrimaryDimension(aSize); + long nSecondaryChildDimension = getSecondaryDimension(aChildSize); + long nSecondaryBoxDimension = getSecondaryDimension(aSize); + setSecondaryDimension(aSize, std::max(nSecondaryChildDimension, nSecondaryBoxDimension)); + + long nPrimaryChildDimension = getPrimaryDimension(aChildSize); + long nPrimaryBoxDimension = getPrimaryDimension(aSize); if (m_bHomogeneous) - nPrimaryDimension += nMaxChildDimension * nVisibleChildren; - setPrimaryDimension(aSize, nPrimaryDimension + m_nSpacing * (nVisibleChildren-1)); + setPrimaryDimension(aSize, std::max(nPrimaryBoxDimension, nPrimaryChildDimension)); + else + setPrimaryDimension(aSize, nPrimaryBoxDimension + nPrimaryChildDimension); } - return aSize; + return finalizeMaxes(aSize, nVisibleChildren); } void VclBox::setAllocation(const Size &rAllocation) @@ -238,18 +225,37 @@ bool VclBox::set_property(const rtl::OString &rKey, const rtl::OString &rValue) return true; } -#define DEFAULT_CHILD_INTERNAL_PAD_X 4 -#define DEFAULT_CHILD_INTERNAL_PAD_Y 0 #define DEFAULT_CHILD_MIN_WIDTH 85 #define DEFAULT_CHILD_MIN_HEIGHT 27 +VclButtonBox::VclButtonBox(Window *pParent, int nSpacing) + : VclBox(pParent, true, nSpacing) + , m_eLayoutStyle(VCL_BUTTONBOX_DEFAULT_STYLE) +{ + m_aMinChildSize = Size(DEFAULT_CHILD_MIN_WIDTH, DEFAULT_CHILD_MIN_HEIGHT); //to-do, pull from theme +} + +Size VclBox::finalizeMaxes(const Size &rSize, sal_uInt16 nVisibleChildren) const +{ + Size aRet; + + if (nVisibleChildren) + { + long nPrimaryDimension = getPrimaryDimension(rSize); + if (m_bHomogeneous) + nPrimaryDimension *= nVisibleChildren; + setPrimaryDimension(aRet, nPrimaryDimension + m_nSpacing * (nVisibleChildren-1)); + setSecondaryDimension(aRet, getSecondaryDimension(rSize)); + } + + return aRet; +} + VclButtonBox::Requisition VclButtonBox::calculatePrimarySecondaryRequisitions() const { Requisition aReq; - sal_Int32 nChildMinWidth = DEFAULT_CHILD_MIN_WIDTH; //to-do, pull from theme - sal_Int32 nChildMinHeight = DEFAULT_CHILD_MIN_HEIGHT; //to-do, pull from theme - Size aSize(nChildMinWidth, nChildMinHeight); + Size aSize(m_aMinChildSize); for (Window *pChild = GetWindow(WINDOW_FIRSTCHILD); pChild; pChild = pChild->GetWindow(WINDOW_NEXT)) { @@ -268,16 +274,7 @@ VclButtonBox::Requisition VclButtonBox::calculatePrimarySecondaryRequisitions() sal_uInt16 nVisibleChildren = aReq.m_nPrimaryChildren + aReq.m_nSecondaryChildren; - if (!nVisibleChildren) - return aReq; - - long nPrimaryDimension = - (getPrimaryDimension(aSize) * nVisibleChildren) + - (m_nSpacing * (nVisibleChildren-1)); - setPrimaryDimension(aReq.m_aSize, nPrimaryDimension + m_nSpacing); - - long nSecondaryDimension = getSecondaryDimension(aSize); - setSecondaryDimension(aReq.m_aSize, nSecondaryDimension); + aReq.m_aSize = finalizeMaxes(aSize, nVisibleChildren); return aReq; } |