diff options
-rw-r--r-- | include/vcl/layout.hxx | 18 | ||||
-rw-r--r-- | include/vcl/split.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/formdlg/dwfunctr.cxx | 1 | ||||
-rw-r--r-- | sc/uiconfig/scalc/ui/functionpanel.ui | 140 | ||||
-rw-r--r-- | vcl/source/window/builder.cxx | 8 | ||||
-rw-r--r-- | vcl/source/window/layout.cxx | 139 | ||||
-rw-r--r-- | vcl/source/window/split.cxx | 5 |
7 files changed, 241 insertions, 71 deletions
diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx index 74046301b108..4ed021f95d30 100644 --- a/include/vcl/layout.hxx +++ b/include/vcl/layout.hxx @@ -16,6 +16,7 @@ #include <vcl/fixed.hxx> #include <vcl/IPrioritable.hxx> #include <vcl/scrbar.hxx> +#include <vcl/split.hxx> #include <vcl/vclmedit.hxx> #include <vcl/window.hxx> #include <vcl/vclptr.hxx> @@ -375,6 +376,23 @@ public: virtual void setAllocation(const Size &rAllocation) override; }; +class VCL_DLLPUBLIC VclVPaned : public VclContainer +{ +private: + VclPtr<Splitter> m_pSplitter; + long m_nPosition; + DECL_LINK(SplitHdl, Splitter*, void); + void arrange(const Size& rAllocation, long nFirstHeight, long nSecondHeight); +public: + VclVPaned(vcl::Window *pParent, WinBits nStyle = WB_HIDE | WB_CLIPCHILDREN); + virtual ~VclVPaned() override { disposeOnce(); } + virtual void dispose() override; + virtual Size calculateRequisition() const override; + virtual void setAllocation(const Size &rAllocation) override; + long get_position() const { return m_nPosition; } + void set_position(long nPosition) { m_nPosition = nPosition; } +}; + class VCL_DLLPUBLIC VclFrame : public VclBin { private: diff --git a/include/vcl/split.hxx b/include/vcl/split.hxx index 13f9ad7c19c2..853163d2aace 100644 --- a/include/vcl/split.hxx +++ b/include/vcl/split.hxx @@ -75,6 +75,7 @@ public: virtual void LoseFocus() override; virtual void KeyInput( const KeyEvent& rKEvt ) override; virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rPaintRect ) override; + virtual Size GetOptimalSize() const override; virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; diff --git a/sc/source/ui/formdlg/dwfunctr.cxx b/sc/source/ui/formdlg/dwfunctr.cxx index a853c986d65e..51ddbff61f48 100644 --- a/sc/source/ui/formdlg/dwfunctr.cxx +++ b/sc/source/ui/formdlg/dwfunctr.cxx @@ -70,6 +70,7 @@ ScFunctionWin::ScFunctionWin(vcl::Window* pParent, const css::uno::Reference<css aFont.SetColor(Color(COL_BLACK)); aFiFuncDesc->SetFont(aFont); aFiFuncDesc->SetBackground( GetBackground() ); //! never transparent? + aFiFuncDesc->set_height_request(5 * aFiFuncDesc->GetTextHeight()); Link<ListBox&,void> aLink=LINK( this, ScFunctionWin, SelHdl); aCatBox->SetSelectHdl(aLink); diff --git a/sc/uiconfig/scalc/ui/functionpanel.ui b/sc/uiconfig/scalc/ui/functionpanel.ui index 6a6fb565aba0..c0696602c088 100644 --- a/sc/uiconfig/scalc/ui/functionpanel.ui +++ b/sc/uiconfig/scalc/ui/functionpanel.ui @@ -2,11 +2,6 @@ <!-- Generated with glade 3.20.0 --> <interface> <requires lib="gtk+" version="3.0"/> - <object class="GtkImage" id="image1"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="pixbuf">sc/res/fx.png</property> - </object> <object class="GtkGrid" id="FunctionPanel"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -20,27 +15,67 @@ <property name="border_width">6</property> <property name="row_spacing">6</property> <child> - <object class="GtkGrid"> + <object class="GtkPaned" id="splitter"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can_focus">True</property> <property name="hexpand">True</property> <property name="vexpand">True</property> - <property name="row_spacing">6</property> + <property name="orientation">vertical</property> + <property name="wide_handle">True</property> <child> <object class="GtkGrid"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="hexpand">True</property> - <property name="column_spacing">12</property> + <property name="vexpand">True</property> + <property name="row_spacing">6</property> <child> - <object class="GtkButton" id="insert"> + <object class="GtkGrid"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="has_default">True</property> - <property name="receives_default">True</property> - <property name="tooltip_text" translatable="yes">Insert Function into calculation sheet</property> - <property name="image">image1</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="column_spacing">12</property> + <child> + <object class="GtkButton" id="insert"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="can_default">True</property> + <property name="has_default">True</property> + <property name="receives_default">True</property> + <property name="tooltip_text" translatable="yes">Insert Function into calculation sheet</property> + <property name="image">image1</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="category"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <items> + <item translatable="yes">Last Used</item> + <item translatable="yes">All</item> + <item translatable="yes">Database</item> + <item translatable="yes">Date&Time</item> + <item translatable="yes">Financial</item> + <item translatable="yes">Information</item> + <item translatable="yes">Logical</item> + <item translatable="yes">Mathematical</item> + <item translatable="yes">Array</item> + <item translatable="yes">Statistical</item> + <item translatable="yes">Spreadsheet</item> + <item translatable="yes">Text</item> + <item translatable="yes">Add-in</item> + </items> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + </packing> + </child> </object> <packing> <property name="left_attach">0</property> @@ -48,51 +83,41 @@ </packing> </child> <child> - <object class="GtkComboBoxText" id="category"> + <object class="GtkTreeView" id="funclist:border"> + <property name="name">functions</property> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can_focus">True</property> <property name="hexpand">True</property> - <items> - <item translatable="yes">Last Used</item> - <item translatable="yes">All</item> - <item translatable="yes">Database</item> - <item translatable="yes">Date&Time</item> - <item translatable="yes">Financial</item> - <item translatable="yes">Information</item> - <item translatable="yes">Logical</item> - <item translatable="yes">Mathematical</item> - <item translatable="yes">Array</item> - <item translatable="yes">Statistical</item> - <item translatable="yes">Spreadsheet</item> - <item translatable="yes">Text</item> - <item translatable="yes">Add-in</item> - </items> + <property name="vexpand">True</property> + <child internal-child="selection"> + <object class="GtkTreeSelection"/> + </child> </object> <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> + <property name="left_attach">0</property> + <property name="top_attach">1</property> </packing> </child> </object> <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> + <property name="resize">True</property> + <property name="shrink">True</property> </packing> </child> <child> - <object class="GtkTreeView" id="funclist"> - <property name="name">functions</property> + <object class="GtkLabel" id="funcdesc:border"> + <property name="name">funcdesc</property> + <property name="width_request">0</property> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="vexpand">True</property> - <child internal-child="selection"> - <object class="GtkTreeSelection"/> - </child> + <property name="can_focus">False</property> + <property name="label" translatable="yes">label</property> + <property name="wrap">True</property> + <property name="xalign">0</property> + <property name="yalign">0</property> </object> <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> + <property name="resize">False</property> + <property name="shrink">True</property> </packing> </child> </object> @@ -101,22 +126,6 @@ <property name="top_attach">0</property> </packing> </child> - <child> - <object class="GtkLabel" id="funcdesc"> - <property name="name">funcdesc</property> - <property name="width_request">0</property> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">label</property> - <property name="wrap">True</property> - <property name="xalign">0</property> - <property name="yalign">0</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - </packing> - </child> </object> <packing> <property name="left_attach">0</property> @@ -124,4 +133,9 @@ </packing> </child> </object> + <object class="GtkImage" id="image1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="pixbuf">sc/res/fx.png</property> + </object> </interface> diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index ddaedf0a8fce..a117a9217f82 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -1346,6 +1346,12 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & else xWindow = VclPtr<VclHBox>::Create(pParent); } + else if (name == "GtkPaned") + { + bVertical = extractOrientation(rMap); + assert(bVertical && "hori not implemented, shouldn't be hard though"); + xWindow = VclPtr<VclVPaned>::Create(pParent); + } else if (name == "GtkHBox") xWindow = VclPtr<VclHBox>::Create(pParent); else if (name == "GtkVBox") @@ -2992,7 +2998,7 @@ void VclBuilder::applyPackingProperty(vcl::Window *pCurrent, xmlreader::XmlReader::Text::Raw, &name, &nsId); OString sValue(name.begin, name.length); - if (sKey == "expand") + if (sKey == "expand" || sKey == "resize") { bool bTrue = (!sValue.isEmpty() && (sValue[0] == 't' || sValue[0] == 'T' || sValue[0] == '1')); if (pToolBoxParent) diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index cfaec6b2a1aa..884e5e04bfd7 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -115,15 +115,23 @@ void VclContainer::setLayoutAllocation(vcl::Window &rChild, const Point &rAllocP setLayoutPosSize(rChild, aChildPos, aChildSize); } +namespace +{ + Size subtractBorder(const vcl::Window &rWindow, const Size& rSize) + { + sal_Int32 nBorderWidth = rWindow.get_border_width(); + sal_Int32 nLeft = rWindow.get_margin_left() + nBorderWidth; + sal_Int32 nTop = rWindow.get_margin_top() + nBorderWidth; + sal_Int32 nRight = rWindow.get_margin_right() + nBorderWidth; + sal_Int32 nBottom = rWindow.get_margin_bottom() + nBorderWidth; + Size aSize(rSize); + return Size(aSize.Width() + nLeft + nRight, aSize.Height() + nTop + nBottom); + } +} + Size VclContainer::getLayoutRequisition(const vcl::Window &rWindow) { - sal_Int32 nBorderWidth = rWindow.get_border_width(); - sal_Int32 nLeft = rWindow.get_margin_left() + nBorderWidth; - sal_Int32 nTop = rWindow.get_margin_top() + nBorderWidth; - sal_Int32 nRight = rWindow.get_margin_right() + nBorderWidth; - sal_Int32 nBottom = rWindow.get_margin_bottom() + nBorderWidth; - Size aSize(rWindow.get_preferred_size()); - return Size(aSize.Width() + nLeft + nRight, aSize.Height() + nTop + nBottom); + return subtractBorder(rWindow, rWindow.get_preferred_size()); } void VclContainer::SetPosSizePixel(const Point& rAllocPos, const Size& rAllocation) @@ -2515,6 +2523,123 @@ void MessageDialog::set_secondary_text(const OUString &rSecondaryString) } } +VclVPaned::VclVPaned(vcl::Window *pParent, WinBits nStyle) + : VclContainer(pParent, nStyle) + , m_pSplitter(VclPtr<Splitter>::Create(this, WB_VSCROLL)) + , m_nPosition(-1) +{ + m_pSplitter->SetSplitHdl(LINK(this, VclVPaned, SplitHdl)); + m_pSplitter->SetBackground(Wallpaper(Application::GetSettings().GetStyleSettings().GetFaceColor())); + m_pSplitter->Show(); +} + +void VclVPaned::dispose() +{ + m_pSplitter.disposeAndClear(); + VclContainer::dispose(); +} + +IMPL_LINK(VclVPaned, SplitHdl, Splitter*, pSplitter, void) +{ + double nSize = pSplitter->GetSplitPosPixel(); + Size aSplitterSize(m_pSplitter->GetSizePixel()); + Size aAllocation(GetSizePixel()); + arrange(aAllocation, nSize, aAllocation.Height() - nSize - aSplitterSize.Height()); +} + +void VclVPaned::arrange(const Size& rAllocation, long nFirstHeight, long nSecondHeight) +{ + Size aSplitterSize(rAllocation.Width(), getLayoutRequisition(*m_pSplitter).Height()); + Size aFirstChildSize(rAllocation.Width(), nFirstHeight); + Size aSecondChildSize(rAllocation.Width(), nSecondHeight); + int nElement = 0; + for (vcl::Window* pChild = GetWindow(GetWindowType::FirstChild); pChild; + pChild = pChild->GetWindow(GetWindowType::Next)) + { + if (!pChild->IsVisible()) + continue; + if (nElement == 0) + { + Point aSplitterPos(0, aFirstChildSize.Height()); + setLayoutAllocation(*m_pSplitter, aSplitterPos, aSplitterSize); + set_position(aSplitterPos.Y() + aSplitterSize.Height() / 2); + } + else if (nElement == 1) + { + Point aChildPos(0, 0); + setLayoutAllocation(*pChild, aChildPos, aFirstChildSize); + } + else if (nElement == 2) + { + Point aChildPos(0, aFirstChildSize.Height() + aSplitterSize.Height()); + setLayoutAllocation(*pChild, aChildPos, aSecondChildSize); + } + ++nElement; + } +} + +void VclVPaned::setAllocation(const Size& rAllocation) +{ + //supporting "shrink" could be done by adjusting the allowed drag rectangle + m_pSplitter->SetDragRectPixel(Rectangle(Point(0, 0), rAllocation)); + Size aSplitterSize(rAllocation.Width(), getLayoutRequisition(*m_pSplitter).Height()); + const long nHeight = rAllocation.Height() - aSplitterSize.Height(); + + long nFirstHeight = 0; + long nSecondHeight = 0; + bool bFirstCanResize = true; + bool bSecondCanResize = true; + const bool bInitialAllocation = get_position() < 0; + int nElement = 0; + for (const vcl::Window* pChild = GetWindow(GetWindowType::FirstChild); pChild; + pChild = pChild->GetWindow(GetWindowType::Next)) + { + if (!pChild->IsVisible()) + continue; + if (nElement == 1) + { + if (bInitialAllocation) + nFirstHeight = getLayoutRequisition(*pChild).Height(); + else + nFirstHeight = pChild->GetSizePixel().Height(); + bFirstCanResize = pChild->get_expand(); + } + else if (nElement == 2) + { + if (bInitialAllocation) + nSecondHeight = getLayoutRequisition(*pChild).Height(); + else + nSecondHeight = pChild->GetSizePixel().Height(); + bSecondCanResize = pChild->get_expand(); + } + ++nElement; + } + long nHeightRequest = nFirstHeight + nSecondHeight; + long nHeightDiff = nHeight - nHeightRequest; + if (bFirstCanResize == bSecondCanResize) + nFirstHeight += nHeightDiff/2; + else if (bFirstCanResize) + nFirstHeight += nHeightDiff; + arrange(rAllocation, nFirstHeight, nSecondHeight); +} + +Size VclVPaned::calculateRequisition() const +{ + Size aRet(0, 0); + + for (const vcl::Window* pChild = GetWindow(GetWindowType::FirstChild); pChild; + pChild = pChild->GetWindow(GetWindowType::Next)) + { + if (!pChild->IsVisible()) + continue; + Size aChildSize = getLayoutRequisition(*pChild); + aRet.Width() = std::max(aRet.Width(), aChildSize.Width()); + aRet.Height() += aChildSize.Height(); + } + + return aRet; +} + Size getLegacyBestSizeForChildren(const vcl::Window &rWindow) { Rectangle aBounds; diff --git a/vcl/source/window/split.cxx b/vcl/source/window/split.cxx index 2dbe388c1916..eb6da6e758fa 100644 --- a/vcl/source/window/split.cxx +++ b/vcl/source/window/split.cxx @@ -694,4 +694,9 @@ void Splitter::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rPaint } } +Size Splitter::GetOptimalSize() const +{ + return LogicToPixel(Size(3, 3), MapUnit::MapAppFont); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |