summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-03-28 14:10:13 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-09-28 08:48:12 +0100
commit6821f36f2306d667ecc48d73041f6bb7d5c70e94 (patch)
tree1677124c74aaed4bf1a776c3b51422ba86b7f191
parenta8bc8cbc5195f4c89f148f5dfb4d21a3919910f2 (diff)
allow reordering widget according to packing::position
-rw-r--r--vcl/inc/vcl/window.hxx2
-rw-r--r--vcl/qa/cppunit/builder/demo.ui116
-rw-r--r--vcl/source/window/builder.cxx21
-rw-r--r--vcl/source/window/window.cxx32
4 files changed, 113 insertions, 58 deletions
diff --git a/vcl/inc/vcl/window.hxx b/vcl/inc/vcl/window.hxx
index 54587ac4b0a8..4dde3797fa18 100644
--- a/vcl/inc/vcl/window.hxx
+++ b/vcl/inc/vcl/window.hxx
@@ -1101,6 +1101,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 786ad76a028a..044a45e38d7b 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 cbfc274df622..bf66d059de64 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 3ac0d3d13dfc..38247c39d893 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -1114,6 +1114,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()