vcl/inc/vcl/window.hxx | 2 vcl/qa/cppunit/builder/demo.ui | 116 ++++++++++++++++++++--------------------- vcl/source/window/builder.cxx | 21 +++++++ vcl/source/window/window.cxx | 32 +++++++++++ 4 files changed, 113 insertions(+), 58 deletions(-)
New commits: commit 43b1a06faf7bde3e04be95f6e6c35bd3926da52e Author: Caolán McNamara <caol...@redhat.com> Date: Wed Mar 28 14:10:13 2012 +0100 allow reordering widget according to packing::position diff --git a/vcl/inc/vcl/window.hxx b/vcl/inc/vcl/window.hxx index d6028b7..625e9f5 100644 --- a/vcl/inc/vcl/window.hxx +++ b/vcl/inc/vcl/window.hxx @@ -1098,6 +1098,8 @@ public: return nValue; } + void reorderWithinParent(sal_uInt16 nNewPosition); + //------------------------------------- // Native Widget Rendering functions //------------------------------------- diff --git a/vcl/qa/cppunit/builder/demo.ui b/vcl/qa/cppunit/builder/demo.ui index 786ad76..044a45e 100644 --- a/vcl/qa/cppunit/builder/demo.ui +++ b/vcl/qa/cppunit/builder/demo.ui @@ -49,64 +49,6 @@ <property name="position">0</property> </packing> </child> - <child> - <object class="GtkBox" id="box2"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <child> - <object class="GtkButton" id="button3"> - <property name="label" translatable="yes">button</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="use_action_appearance">False</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkRadioButton" id="radiobutton1"> - <property name="label" translatable="yes">radiobutton</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_action_appearance">False</property> - <property name="xalign">0</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="checkbutton1"> - <property name="label" translatable="yes">checkbutton</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_action_appearance">False</property> - <property name="xalign">0</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">2</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> <child internal-child="action_area"> <object class="GtkButtonBox" id="dialog-action_area1"> <property name="can_focus">False</property> @@ -210,6 +152,64 @@ <property name="position">1</property> </packing> </child> + <child> + <object class="GtkBox" id="box2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkButton" id="button3"> + <property name="label" translatable="yes">button</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="radiobutton1"> + <property name="label" translatable="yes">radiobutton</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_action_appearance">False</property> + <property name="xalign">0</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="checkbutton1"> + <property name="label" translatable="yes">checkbutton</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_action_appearance">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> </object> </child> <action-widgets> diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index cbfc274..bf66d05 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -206,6 +206,23 @@ void VclBuilder::handleChild(Window *pParent, xmlreader::XmlReader &reader) if (name.equals(RTL_CONSTASCII_STRINGPARAM("object"))) { pCurrentChild = handleObject(pParent, reader); + + if (pCurrentChild) + { + rtl::OString sPosition(RTL_CONSTASCII_STRINGPARAM("position")); + std::vector<Window*> aChilds; + for (Window* pChild = pCurrentChild->GetWindow(WINDOW_FIRSTCHILD); pChild; + pChild = pChild->GetWindow(WINDOW_NEXT)) + { + aChilds.push_back(pChild); + } + + for (size_t i = 0; i < aChilds.size(); ++i) + { + sal_uInt16 nPosition = aChilds[i]->getWidgetProperty<sal_uInt16>(sPosition); + aChilds[i]->reorderWithinParent(nPosition); + } + } } else if (name.equals(RTL_CONSTASCII_STRINGPARAM("packing"))) { @@ -345,6 +362,10 @@ void VclBuilder::applyPackingProperty(Window *pCurrent, bool bTrue = (sValue[0] == 't' || sValue[0] == 'T' || sValue[0] == '1'); pCurrent->setChildProperty(sKey, bTrue); } + else if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("position"))) + { + pCurrent->setChildProperty(sKey, static_cast<sal_uInt16>(sValue.toInt32())); + } else fprintf(stderr, "unknown packing %s\n", sKey.getStr()); } diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index 407cc18..bf251be 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -1128,6 +1128,38 @@ void Window::ImplRemoveWindow( sal_Bool bRemoveFrameData ) } } +void Window::reorderWithinParent(sal_uInt16 nNewPosition) +{ + sal_uInt16 nChildCount = 0; + Window *pSource = mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild; + while (pSource) + { + if (nChildCount == nNewPosition) + break; + pSource = pSource->mpWindowImpl->mpNext; + nChildCount++; + } + + if (pSource == this) //already at the right place + return; + + ImplRemoveWindow(false); + + if (pSource) + { + mpWindowImpl->mpNext = pSource; + mpWindowImpl->mpPrev = pSource->mpWindowImpl->mpPrev; + pSource->mpWindowImpl->mpPrev = this; + } + else + mpWindowImpl->mpParent->mpWindowImpl->mpLastChild = this; + + if (mpWindowImpl->mpPrev) + mpWindowImpl->mpPrev->mpWindowImpl->mpNext = this; + else + mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild = this; +} + // ----------------------------------------------------------------------- void Window::ImplCallResize()
_______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits