summaryrefslogtreecommitdiff
path: root/svx/source/tbxctrls/fillctrl.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-05-05 15:57:23 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-05-05 17:21:58 +0100
commit8c73b6eeb87eeac3def69e0026e80d7d951e2592 (patch)
tree1767db86c4fd3a4d58ca4368ff1fd11255c768b2 /svx/source/tbxctrls/fillctrl.cxx
parent8caebf50b3ee159da4db500f969427b49f07af80 (diff)
vertically center toolbox/listboxes
Change-Id: I01270b85e019362e8343f4b097620620674f0443
Diffstat (limited to 'svx/source/tbxctrls/fillctrl.cxx')
-rw-r--r--svx/source/tbxctrls/fillctrl.cxx78
1 files changed, 37 insertions, 41 deletions
diff --git a/svx/source/tbxctrls/fillctrl.cxx b/svx/source/tbxctrls/fillctrl.cxx
index 58673ddbb4c6..7ec5ff6611cb 100644
--- a/svx/source/tbxctrls/fillctrl.cxx
+++ b/svx/source/tbxctrls/fillctrl.cxx
@@ -445,6 +445,7 @@ VclPtr<vcl::Window> SvxFillToolBoxControl::CreateItemWindow(vcl::Window *pParent
mpLbFillType = mpFillControl->mpLbFillType;
mpLbFillAttr = mpFillControl->mpLbFillAttr;
mpToolBoxColor = mpFillControl->mpToolBoxColor;
+ mpFillControl->Resize();
mpToolBoxColor->InsertItem(".uno:FillColor", m_xFrame, ToolBoxItemBits::DROPDOWNONLY, Size(mpToolBoxColor->GetSizePixel().Width(), 0));
mpLbFillAttr->SetUniqueId(HID_FILL_ATTR_LISTBOX);
@@ -460,26 +461,12 @@ VclPtr<vcl::Window> SvxFillToolBoxControl::CreateItemWindow(vcl::Window *pParent
}
FillControl::FillControl(vcl::Window* pParent,WinBits nStyle)
-: Window(pParent,nStyle | WB_DIALOGCONTROL),
- mpLbFillType(VclPtr<SvxFillTypeBox>::Create(this)),
- mpToolBoxColor(VclPtr<sfx2::sidebar::SidebarToolBox>::Create(this)),
- mpLbFillAttr(VclPtr<SvxFillAttrBox>::Create(this)),
- maLogicalFillSize(40,80),
- maLogicalAttrSize(50,80)
+ : Window(pParent,nStyle | WB_DIALOGCONTROL)
+ , mpLbFillType(VclPtr<SvxFillTypeBox>::Create(this))
+ , mpToolBoxColor(VclPtr<sfx2::sidebar::SidebarToolBox>::Create(this))
+ , mpLbFillAttr(VclPtr<SvxFillAttrBox>::Create(this))
{
- Size aTypeSize(LogicToPixel(maLogicalFillSize,MAP_APPFONT));
- Size aAttrSize(LogicToPixel(maLogicalAttrSize,MAP_APPFONT));
- mpLbFillType->SetSizePixel(aTypeSize);
- mpToolBoxColor->SetSizePixel(aAttrSize);
- mpLbFillAttr->SetSizePixel(aAttrSize);
-
- //to get the base height
- aTypeSize = mpLbFillType->GetSizePixel();
- aAttrSize = mpLbFillAttr->GetSizePixel();
- Point aAttrPnt = mpLbFillAttr->GetPosPixel();
- SetSizePixel(
- Size(aAttrPnt.X() + aAttrSize.Width(),
- std::max(aAttrSize.Height(),aTypeSize.Height())));
+ SetOptimalSize();
}
FillControl::~FillControl()
@@ -795,14 +782,36 @@ IMPL_LINK(SvxFillToolBoxControl, SelectFillAttrHdl, ListBox *, pToolBox)
void FillControl::Resize()
{
- // Width of the two list boxes not 1/2 : 1/2, but 2/5 : 3/5
- long nW = GetOutputSizePixel().Width() / 5;
- long nH = 180;
- long nSep = 0; // was previously 4
-
- mpLbFillType->SetSizePixel(Size(nW * 2 - nSep,nH));
- mpToolBoxColor->SetPosSizePixel(Point(nW * 2 + nSep,0),Size(nW * 3 - nSep,nH));
- mpLbFillAttr->SetPosSizePixel(Point(nW * 2 + nSep,0),Size(nW * 3 - nSep,nH));
+ // Relative width of the two list boxes is 2/5 : 3/5
+ Size aSize(GetOutputSizePixel());
+ long nW = aSize.Width() / 5;
+ long nH = aSize.Height();
+
+ long nPrefHeight = mpLbFillType->get_preferred_size().Height();
+ long nOffset = (nH - nPrefHeight)/2;
+ mpLbFillType->SetPosSizePixel(Point(0, nOffset), Size(nW * 2, nPrefHeight));
+ nPrefHeight = mpToolBoxColor->get_preferred_size().Height();
+ nOffset = (nH - nPrefHeight)/2;
+ mpToolBoxColor->SetPosSizePixel(Point(nW * 2, nOffset),Size(nW * 3, nPrefHeight));
+ nPrefHeight = mpLbFillType->get_preferred_size().Height();
+ nOffset = (nH - nPrefHeight)/2;
+ mpLbFillAttr->SetPosSizePixel(Point(nW * 2, nOffset),Size(nW * 3, nPrefHeight));
+}
+
+void FillControl::SetOptimalSize()
+{
+ const Size aLogicalAttrSize(50,0);
+ Size aSize(LogicToPixel(aLogicalAttrSize,MAP_APPFONT));
+
+ Point aAttrPnt = mpLbFillAttr->GetPosPixel();
+
+ aSize.Height() = std::max(aSize.Height(), mpLbFillType->get_preferred_size().Height());
+ aSize.Height() = std::max(aSize.Height(), mpToolBoxColor->get_preferred_size().Height());
+ aSize.Height() = std::max(aSize.Height(), mpLbFillAttr->get_preferred_size().Height());
+
+ aSize.Width() = aAttrPnt.X() + aSize.Width();
+
+ SetSizePixel(aSize);
}
void FillControl::DataChanged(const DataChangedEvent& rDCEvt)
@@ -810,20 +819,7 @@ void FillControl::DataChanged(const DataChangedEvent& rDCEvt)
if((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
(rDCEvt.GetFlags() & AllSettingsFlags::STYLE))
{
- Size aTypeSize(LogicToPixel(maLogicalFillSize,MAP_APPFONT));
- Size aAttrSize(LogicToPixel(maLogicalAttrSize,MAP_APPFONT));
- mpLbFillType->SetSizePixel(aTypeSize);
- mpToolBoxColor->SetSizePixel(aAttrSize);
- mpLbFillAttr->SetSizePixel(aAttrSize);
-
- //to get the base height
- aTypeSize = mpLbFillType->GetSizePixel();
- aAttrSize = mpLbFillAttr->GetSizePixel();
- Point aAttrPnt = mpLbFillAttr->GetPosPixel();
-
- SetSizePixel(
- Size(aAttrPnt.X() + aAttrSize.Width(),
- std::max(aAttrSize.Height(), aTypeSize.Height())));
+ SetOptimalSize();
}
Window::DataChanged(rDCEvt);
}