[Libreoffice-commits] .: Branch 'feature/cmclayout' - 5 commits - vcl/inc vcl/qa vcl/source

Caolán McNamara caolan at kemper.freedesktop.org
Mon Jun 11 06:50:26 PDT 2012


 vcl/inc/vcl/builder.hxx        |    2 
 vcl/inc/vcl/vclenum.hxx        |    8 
 vcl/inc/vcl/window.hxx         |   47 ++
 vcl/inc/window.h               |    8 
 vcl/qa/cppunit/builder/demo.ui |  664 ++++++++++++++++++++++++++++++++++++++++-
 vcl/source/control/tabctrl.cxx |    3 
 vcl/source/window/builder.cxx  |   13 
 vcl/source/window/layout.cxx   |   79 +++-
 vcl/source/window/window.cxx   |   76 ++++
 9 files changed, 869 insertions(+), 31 deletions(-)

New commits:
commit b75f5235271d9aa2a5b2461f7ee88806219b821e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Jun 11 12:48:24 2012 +0100

    implement widget alignment within gtkgrid

diff --git a/vcl/inc/vcl/vclenum.hxx b/vcl/inc/vcl/vclenum.hxx
index dbc1830..e69eb58 100644
--- a/vcl/inc/vcl/vclenum.hxx
+++ b/vcl/inc/vcl/vclenum.hxx
@@ -206,6 +206,14 @@ inline bool operator !=(const ItalicMatrix& a, const ItalicMatrix& b)
     return a.xx != b.xx || a.xy != b.xy || a.yx != b.yx || a.yy != b.yy;
 }
 
+enum VclAlign
+{
+    VCL_ALIGN_FILL,
+    VCL_ALIGN_START,
+    VCL_ALIGN_END,
+    VCL_ALIGN_CENTER
+};
+
 #endif  // _VCL_VCLENUM_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/vcl/window.hxx b/vcl/inc/vcl/window.hxx
index e3fa0dc..c5dae53 100644
--- a/vcl/inc/vcl/window.hxx
+++ b/vcl/inc/vcl/window.hxx
@@ -329,7 +329,8 @@ typedef sal_uInt16 StateChangedType;
 #define DLGWINDOW_NEXT                  1
 #define DLGWINDOW_FIRST                 2
 
-enum WindowSizeType {
+enum WindowSizeType
+{
     WINDOWSIZE_MINIMUM,
     WINDOWSIZE_PREFERRED,
     WINDOWSIZE_MAXIMUM
@@ -1116,6 +1117,50 @@ public:
     Size get_preferred_size() const;
 
     /*
+     * Gets the value of the "halign" property.
+     */
+    VclAlign get_halign() const;
+
+    /*
+     * Sets the horizontal alignment of widget. See the "halign" property.
+     */
+    void set_halign(VclAlign eAlign);
+
+    /*
+     * Gets the value of the "valign" property.
+     */
+    VclAlign get_valign() const;
+
+    /*
+     * Sets the horizontal alignment of widget. See the "valign" property.
+     */
+    void set_valign(VclAlign eAlign);
+
+    /*
+     * Gets whether the widget would like to use any available extra horizontal
+     * space.
+     */
+    bool get_hexpand() const;
+
+    /*
+     * Sets whether the widget would like to use any available extra horizontal
+     * space.
+     */
+    void set_hexpand(bool bExpand);
+
+    /*
+     * Gets whether the widget would like to use any available extra vertical
+     * space.
+     */
+    bool get_vexpand() const;
+
+    /*
+     * Sets whether the widget would like to use any available extra vertical
+     * space.
+     */
+    void set_vexpand(bool bExpand);
+
+    /*
      * Sets a widget property
      *
      * @return false if property is unknown
diff --git a/vcl/inc/window.h b/vcl/inc/window.h
index 040c19a..858a152 100644
--- a/vcl/inc/window.h
+++ b/vcl/inc/window.h
@@ -315,7 +315,9 @@ public:
     sal_uInt16              mnDlgCtrlFlags;
     sal_uInt16              mnLockCount;
     AlwaysInputMode     meAlwaysInputMode;
-    sal_Bool                mbFrame:1,
+    VclAlign            meHalign;
+    VclAlign            meValign;
+    sal_uInt8           mbFrame:1,
                         mbBorderWin:1,
                         mbOverlapWin:1,
                         mbSysWin:1,
@@ -389,7 +391,9 @@ public:
                         mbDisableAccessibleLabeledByRelation:1,
                         mbHelpTextDynamic:1,
                         mbFakeFocusSet:1,
-                        mbInterceptChildWindowKeyDown:1;
+                        mbInterceptChildWindowKeyDown:1,
+                        mbHexpand:1,
+                        mbVexpand:1;
 
     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxDNDListenerContainer;
 };
diff --git a/vcl/qa/cppunit/builder/demo.ui b/vcl/qa/cppunit/builder/demo.ui
index 39754e4..681212e 100644
--- a/vcl/qa/cppunit/builder/demo.ui
+++ b/vcl/qa/cppunit/builder/demo.ui
@@ -1,47 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
-  <object class="GtkListStore" id="liststore2">
-    <columns>
-      <!-- column-name gchararray1 -->
-      <column type="gchararray"/>
-    </columns>
-    <data>
-      <row>
-        <col id="0" translatable="yes">1</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">2</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">3</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">4</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">5</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">6</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">7</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">8</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">9</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">10</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">1 - 10</col>
-      </row>
-    </data>
-  </object>
   <object class="GtkDialog" id="dialog1">
     <property name="can_focus">False</property>
     <property name="border_width">5</property>
@@ -1655,9 +1614,274 @@
                 <property name="tab_fill">False</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkBox" id="box21">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="margin_left">10</property>
+                <property name="margin_right">10</property>
+                <child>
+                  <object class="GtkFrame" id="frame10">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label_xalign">0</property>
+                    <property name="shadow_type">none</property>
+                    <child>
+                      <object class="GtkAlignment" id="alignment13">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="left_padding">12</property>
+                        <child>
+                          <object class="GtkTreeView" id="treeview2">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="model">liststore2</property>
+                            <property name="headers_visible">False</property>
+                            <property name="search_column">0</property>
+                            <child internal-child="selection">
+                              <object class="GtkTreeSelection" id="treeview-selection4"/>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel" id="label26">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Level</property>
+                        <property name="use_markup">True</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkFrame" id="frame11">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label_xalign">0</property>
+                    <property name="shadow_type">none</property>
+                    <child>
+                      <object class="GtkAlignment" id="alignment14">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="left_padding">12</property>
+                        <child>
+                          <object class="GtkGrid" id="grid4">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="row_spacing">10</property>
+                            <property name="column_spacing">10</property>
+                            <child>
+                              <object class="GtkLabel" id="label27">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="xalign">0</property>
+                                <property name="label" translatable="yes">Numbering followed by</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">0</property>
+                                <property name="top_attach">0</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="label28">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="xalign">0</property>
+                                <property name="label" translatable="yes">Numbering Alignment</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">0</property>
+                                <property name="top_attach">2</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="label29">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="xalign">0</property>
+                                <property name="label" translatable="yes">Aligned at</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">0</property>
+                                <property name="top_attach">3</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="label30">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="xalign">0</property>
+                                <property name="label" translatable="yes">Indent at</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">0</property>
+                                <property name="top_attach">4</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkComboBox" id="combobox5">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="top_attach">2</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkSpinButton" id="spinbutton4">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="invisible_char">●</property>
+                                <property name="invisible_char_set">True</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="top_attach">4</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="label31">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="xalign">1</property>
+                                <property name="label" translatable="yes">at</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">0</property>
+                                <property name="top_attach">1</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkSpinButton" id="spinbutton5">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="invisible_char">●</property>
+                                <property name="invisible_char_set">True</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="top_attach">1</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkSpinButton" id="spinbutton6">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="invisible_char">●</property>
+                                <property name="invisible_char_set">True</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="top_attach">3</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkComboBox" id="combobox6">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="top_attach">0</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkDrawingArea" id="drawingarea2">
+                                <property name="width_request">300</property>
+                                <property name="height_request">150</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">0</property>
+                                <property name="top_attach">5</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkButton" id="button6">
+                                <property name="label" translatable="yes">Default</property>
+                                <property name="use_action_appearance">False</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">True</property>
+                                <property name="valign">end</property>
+                                <property name="use_action_appearance">False</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="top_attach">5</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel" id="label32">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Position and spacing</property>
+                        <property name="use_markup">True</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="position">5</property>
+              </packing>
+            </child>
+            <child type="tab">
+              <object class="GtkLabel" id="label25">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">page 6</property>
+              </object>
+              <packing>
+                <property name="position">5</property>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
           </object>
           <packing>
-            <property name="expand">False</property>
+            <property name="expand">True</property>
             <property name="fill">True</property>
             <property name="position">1</property>
           </packing>
@@ -1683,4 +1907,45 @@
       </row>
     </data>
   </object>
+  <object class="GtkListStore" id="liststore2">
+    <columns>
+      <!-- column-name gchararray1 -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">1</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">2</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">3</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">4</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">5</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">6</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">7</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">8</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">9</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">10</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">1 - 10</col>
+      </row>
+    </data>
+  </object>
 </interface>
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index bfcf73e..79c63fe 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -259,8 +259,6 @@ Size VclButtonBox::calculateRequisition() const
     long nSecondaryDimension = getSecondaryDimension(aSize);
     setSecondaryDimension(aSize, nSecondaryDimension);
 
-    fprintf(stderr, "button box asked for %ld %ld\n", aSize.Width(), aSize.Height());
-
     return aSize;
 }
 
@@ -292,8 +290,6 @@ bool VclButtonBox::set_property(const rtl::OString &rKey, const rtl::OString &rV
 
 void VclButtonBox::setAllocation(const Size &rAllocation)
 {
-    fprintf(stderr, "button box got %ld %ld\n", rAllocation.Width(), rAllocation.Height());
-
     sal_uInt16 nVisibleChildren = 0;
     for (Window *pChild = GetWindow(WINDOW_FIRSTCHILD); pChild; pChild = pChild->GetWindow(WINDOW_NEXT))
     {
@@ -506,7 +502,7 @@ void VclGrid::setAllocation(const Size& rAllocation)
     rtl::OString sWidth(RTL_CONSTASCII_STRINGPARAM("width"));
     rtl::OString sHeight(RTL_CONSTASCII_STRINGPARAM("height"));
 
-    Point aPosition(0, 0);
+    Point aAllocPos(0, 0);
     for (sal_Int32 x = 0; x < nMaxX; ++x)
     {
         for (sal_Int32 y = 0; y < nMaxY; ++y)
@@ -514,24 +510,77 @@ void VclGrid::setAllocation(const Size& rAllocation)
             Window *pChild = A[x][y];
             if (pChild)
             {
-                Size aChildSize(0, 0);
+                Size aChildAlloc(0, 0);
 
                 sal_Int32 nWidth = pChild->getWidgetProperty<sal_Int32>(sWidth, 1);
                 for (sal_Int32 nSpanX = 0; nSpanX < nWidth; ++nSpanX)
-                    aChildSize.Width() += aWidths[x+nSpanX];
-                aChildSize.Width() += get_column_spacing()*(nWidth-1);
+                    aChildAlloc.Width() += aWidths[x+nSpanX];
+                aChildAlloc.Width() += get_column_spacing()*(nWidth-1);
 
                 sal_Int32 nHeight = pChild->getWidgetProperty<sal_Int32>(sHeight, 1);
                 for (sal_Int32 nSpanY = 0; nSpanY < nHeight; ++nSpanY)
-                    aChildSize.Height() += aHeights[y+nSpanY];
-                aChildSize.Height() += get_row_spacing()*(nHeight-1);
-
-                pChild->SetPosSizePixel(aPosition, aChildSize);
+                    aChildAlloc.Height() += aHeights[y+nSpanY];
+                aChildAlloc.Height() += get_row_spacing()*(nHeight-1);
+
+                Point aChildPos(aAllocPos);
+                Size aChildSize(aChildAlloc);
+
+                VclAlign eHalign = pChild->get_halign();
+                VclAlign eValign = pChild->get_valign();
+
+                Size aChildPreferredSize;
+
+                if (eHalign != VCL_ALIGN_FILL || eValign != VCL_ALIGN_FILL)
+                    aChildPreferredSize = pChild->GetOptimalSize(WINDOWSIZE_PREFERRED);
+
+                switch (eHalign)
+                {
+                    case VCL_ALIGN_FILL:
+                        break;
+                    case VCL_ALIGN_START:
+                        if (aChildPreferredSize.Width() < aChildAlloc.Width())
+                            aChildSize.Width() = aChildPreferredSize.Width();
+                        break;
+                    case VCL_ALIGN_END:
+                        if (aChildPreferredSize.Width() < aChildAlloc.Width())
+                            aChildSize.Width() = aChildPreferredSize.Width();
+                        aChildPos.X() += aChildAlloc.Width();
+                        aChildPos.X() -= aChildSize.Width();
+                        break;
+                    case VCL_ALIGN_CENTER:
+                        if (aChildPreferredSize.Width() < aChildSize.Width())
+                            aChildSize.Width() = aChildPreferredSize.Width();
+                        aChildPos.X() += (aChildAlloc.Width() - aChildSize.Width()) / 2;
+                        break;
+                }
+
+                switch (eValign)
+                {
+                    case VCL_ALIGN_FILL:
+                        break;
+                    case VCL_ALIGN_START:
+                        if (aChildPreferredSize.Height() < aChildAlloc.Height())
+                            aChildSize.Height() = aChildPreferredSize.Height();
+                        break;
+                    case VCL_ALIGN_END:
+                        if (aChildPreferredSize.Height() < aChildAlloc.Height())
+                            aChildSize.Height() = aChildPreferredSize.Height();
+                        aChildPos.Y() += aChildAlloc.Height();
+                        aChildPos.Y() -= aChildSize.Height();
+                        break;
+                    case VCL_ALIGN_CENTER:
+                        if (aChildPreferredSize.Height() < aChildSize.Height())
+                            aChildSize.Height() = aChildPreferredSize.Height();
+                        aChildPos.Y() += (aChildAlloc.Height() - aChildSize.Height()) / 2;
+                        break;
+                }
+
+                pChild->SetPosSizePixel(aChildPos, aChildSize);
             }
-            aPosition.Y() += aHeights[y] + get_row_spacing();
+            aAllocPos.Y() += aHeights[y] + get_row_spacing();
         }
-        aPosition.X() += aWidths[x] + get_column_spacing();
-        aPosition.Y() = 0;
+        aAllocPos.X() += aWidths[x] + get_column_spacing();
+        aAllocPos.Y() = 0;
     }
 }
 
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 622fcac..d4c8a4a 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -724,6 +724,11 @@ void Window::ImplInitWindowData( WindowType nType )
     mpWindowImpl->mbDisableAccessibleLabeledByRelation = sal_False; // sal_True: do not set LabeledBy relation on accessible objects
     mpWindowImpl->mbHelpTextDynamic = sal_False;          // sal_True: append help id in HELP_DEBUG case
     mpWindowImpl->mbFakeFocusSet = sal_False; // sal_True: pretend as if the window has focus.
+    mpWindowImpl->mbHexpand = false;
+    mpWindowImpl->mbVexpand = false;
+    mpWindowImpl->meHalign = VCL_ALIGN_FILL;
+    mpWindowImpl->meValign = VCL_ALIGN_FILL;
+
 
     mbEnableRTL         = Application::GetSettings().GetLayoutRTL();         // sal_True: this outdev will be mirrored if RTL window layout (UI mirroring) is globally active
 }
@@ -9817,6 +9822,11 @@ void Window::take_properties(Window &rOther)
     mpWindowImpl->mbHelpTextDynamic = pWindowImpl->mbHelpTextDynamic;
     mpWindowImpl->mbFakeFocusSet = pWindowImpl->mbFakeFocusSet;
     mpWindowImpl->mbInterceptChildWindowKeyDown = pWindowImpl->mbInterceptChildWindowKeyDown;
+    mpWindowImpl->mbHexpand = pWindowImpl->mbHexpand;
+    mpWindowImpl->mbVexpand = pWindowImpl->mbVexpand;
+    mpWindowImpl->meHalign = pWindowImpl->meHalign;
+    mpWindowImpl->meValign = pWindowImpl->meValign;
+
 
     std::swap(m_aWidgetProperties, rOther.m_aWidgetProperties);
 
@@ -9829,6 +9839,24 @@ void Window::take_properties(Window &rOther)
         mpWindowImpl->mpBorderWindow->take_properties(*pWindowImpl->mpBorderWindow);
 }
 
+namespace
+{
+    VclAlign toAlign(const rtl::OString &rValue)
+    {
+        VclAlign eRet = VCL_ALIGN_FILL;
+
+        if (rValue.equalsL(RTL_CONSTASCII_STRINGPARAM("fill")))
+            eRet = VCL_ALIGN_FILL;
+        else if (rValue.equalsL(RTL_CONSTASCII_STRINGPARAM("start")))
+            eRet = VCL_ALIGN_START;
+        else if (rValue.equalsL(RTL_CONSTASCII_STRINGPARAM("end")))
+            eRet = VCL_ALIGN_END;
+        else if (rValue.equalsL(RTL_CONSTASCII_STRINGPARAM("center")))
+            eRet = VCL_ALIGN_CENTER;
+        return eRet;
+    }
+}
+
 bool Window::set_property(const rtl::OString &rKey, const rtl::OString &rValue)
 {
     if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("label")))
@@ -9881,6 +9909,14 @@ bool Window::set_property(const rtl::OString &rKey, const rtl::OString &rValue)
         set_height_request(rValue.toInt32());
     else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("width-request")))
         set_width_request(rValue.toInt32());
+    else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("hexpand")))
+        set_hexpand(toBool(rValue));
+    else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("vexpand")))
+        set_vexpand(toBool(rValue));
+    else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("halign")))
+        set_halign(toAlign(rValue));
+    else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("valign")))
+        set_valign(toAlign(rValue));
     else
     {
         fprintf(stderr, "unhandled property %s\n", rKey.getStr());
@@ -9889,4 +9925,44 @@ bool Window::set_property(const rtl::OString &rKey, const rtl::OString &rValue)
     return true;
 }
 
+VclAlign Window::get_halign() const
+{
+    return mpWindowImpl->meHalign;
+}
+
+void Window::set_halign(VclAlign eAlign)
+{
+    mpWindowImpl->meHalign = eAlign;
+}
+
+VclAlign Window::get_valign() const
+{
+    return mpWindowImpl->meValign;
+}
+
+void Window::set_valign(VclAlign eAlign)
+{
+    mpWindowImpl->meValign = eAlign;
+}
+
+bool Window::get_hexpand() const
+{
+    return mpWindowImpl->mbHexpand;
+}
+
+void Window::set_hexpand(bool bExpand)
+{
+    mpWindowImpl->mbHexpand = bExpand;
+}
+
+bool Window::get_vexpand() const
+{
+    return mpWindowImpl->mbVexpand;
+}
+
+void Window::set_vexpand(bool bExpand)
+{
+    mpWindowImpl->mbVexpand = bExpand;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 45caea1d3ab2992bae757015da1b2486075efde4
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Jun 11 12:42:01 2012 +0100

    increase tabcontrol optimal size by border gap

diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx
index e594207..b238e39 100644
--- a/vcl/source/control/tabctrl.cxx
+++ b/vcl/source/control/tabctrl.cxx
@@ -2207,6 +2207,9 @@ Size TabControl::GetOptimalSize(WindowSizeType eType) const
         Size aOptimalSize(aOptimalPageSize);
         aOptimalSize.Height() += aOptimalTabSize.Height();
 
+        aOptimalSize.Width() += TAB_OFFSET * 2;
+        aOptimalSize.Height() += TAB_OFFSET * 2;
+
         return aOptimalSize;
     }
     }
commit 71c4758ed0ee4ae7eb6d65c1c05ec7ea5b01fc01
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sat Jun 9 13:46:38 2012 +0100

    beef up the demo

diff --git a/vcl/qa/cppunit/builder/demo.ui b/vcl/qa/cppunit/builder/demo.ui
index 3860f5f..39754e4 100644
--- a/vcl/qa/cppunit/builder/demo.ui
+++ b/vcl/qa/cppunit/builder/demo.ui
@@ -1,6 +1,47 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
+  <object class="GtkListStore" id="liststore2">
+    <columns>
+      <!-- column-name gchararray1 -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">1</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">2</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">3</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">4</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">5</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">6</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">7</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">8</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">9</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">10</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">1 - 10</col>
+      </row>
+    </data>
+  </object>
   <object class="GtkDialog" id="dialog1">
     <property name="can_focus">False</property>
     <property name="border_width">5</property>
@@ -440,7 +481,6 @@
                                 <property name="can_focus">True</property>
                                 <property name="invisible_char">●</property>
                                 <property name="invisible_char_set">True</property>
-                                <property name="adjustment">adjustment1</property>
                                 <property name="numeric">True</property>
                               </object>
                               <packing>
@@ -459,7 +499,6 @@
                                 <property name="invisible_char_set">True</property>
                                 <property name="progress_fraction">0.040000000000000001</property>
                                 <property name="progress_pulse_step">1</property>
-                                <property name="adjustment">adjustment1</property>
                                 <property name="climb_rate">1</property>
                                 <property name="numeric">True</property>
                               </object>
@@ -625,7 +664,6 @@
                                     <property name="can_focus">True</property>
                                     <property name="invisible_char">●</property>
                                     <property name="invisible_char_set">True</property>
-                                    <property name="adjustment">adjustment1</property>
                                     <property name="numeric">True</property>
                                   </object>
                                   <packing>
@@ -681,7 +719,6 @@
                                     <property name="can_focus">True</property>
                                     <property name="invisible_char">●</property>
                                     <property name="invisible_char_set">True</property>
-                                    <property name="adjustment">adjustment1</property>
                                     <property name="numeric">True</property>
                                   </object>
                                   <packing>
@@ -1266,6 +1303,358 @@
                 <property name="tab_fill">False</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkBox" id="box18">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="margin_left">10</property>
+                <property name="margin_right">10</property>
+                <child>
+                  <object class="GtkFrame" id="frame8">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label_xalign">0</property>
+                    <property name="shadow_type">none</property>
+                    <child>
+                      <object class="GtkAlignment" id="alignment9">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="left_padding">12</property>
+                        <child>
+                          <object class="GtkTreeView" id="treeview1">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="model">liststore2</property>
+                            <property name="headers_visible">False</property>
+                            <property name="search_column">0</property>
+                            <child internal-child="selection">
+                              <object class="GtkTreeSelection" id="treeview-selection3"/>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel" id="label15">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Level</property>
+                        <property name="use_markup">True</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkFrame" id="frame9">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label_xalign">0</property>
+                    <property name="shadow_type">none</property>
+                    <child>
+                      <object class="GtkAlignment" id="alignment10">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="left_padding">12</property>
+                        <child>
+                          <object class="GtkBox" id="box19">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="spacing">10</property>
+                            <child>
+                              <object class="GtkBox" id="box20">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="orientation">vertical</property>
+                                <child>
+                                  <object class="GtkGrid" id="grid3">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="column_spacing">10</property>
+                                    <child>
+                                      <object class="GtkLabel" id="label16">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="xalign">0</property>
+                                        <property name="label" translatable="yes">Paragraph Style</property>
+                                      </object>
+                                      <packing>
+                                        <property name="left_attach">0</property>
+                                        <property name="top_attach">0</property>
+                                        <property name="width">2</property>
+                                        <property name="height">1</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkComboBox" id="combobox2">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                      </object>
+                                      <packing>
+                                        <property name="left_attach">0</property>
+                                        <property name="top_attach">1</property>
+                                        <property name="width">2</property>
+                                        <property name="height">1</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkLabel" id="label17">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="xalign">0</property>
+                                        <property name="label" translatable="yes">Number</property>
+                                      </object>
+                                      <packing>
+                                        <property name="left_attach">0</property>
+                                        <property name="top_attach">2</property>
+                                        <property name="width">1</property>
+                                        <property name="height">1</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkLabel" id="label18">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="xalign">0</property>
+                                        <property name="label" translatable="yes">Character Style</property>
+                                      </object>
+                                      <packing>
+                                        <property name="left_attach">0</property>
+                                        <property name="top_attach">3</property>
+                                        <property name="width">1</property>
+                                        <property name="height">1</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkLabel" id="label19">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="xalign">0</property>
+                                        <property name="label" translatable="yes">Show sublevels</property>
+                                      </object>
+                                      <packing>
+                                        <property name="left_attach">0</property>
+                                        <property name="top_attach">4</property>
+                                        <property name="width">1</property>
+                                        <property name="height">1</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkLabel" id="label20">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="xalign">0</property>
+                                        <property name="label" translatable="yes">Separator</property>
+                                      </object>
+                                      <packing>
+                                        <property name="left_attach">0</property>
+                                        <property name="top_attach">5</property>
+                                        <property name="width">2</property>
+                                        <property name="height">1</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkComboBox" id="combobox3">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                      </object>
+                                      <packing>
+                                        <property name="left_attach">1</property>
+                                        <property name="top_attach">2</property>
+                                        <property name="width">1</property>
+                                        <property name="height">1</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkComboBox" id="combobox4">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                      </object>
+                                      <packing>
+                                        <property name="left_attach">1</property>
+                                        <property name="top_attach">3</property>
+                                        <property name="width">1</property>
+                                        <property name="height">1</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkSpinButton" id="spinbutton2">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="invisible_char">●</property>
+                                        <property name="invisible_char_set">True</property>
+                                      </object>
+                                      <packing>
+                                        <property name="left_attach">1</property>
+                                        <property name="top_attach">4</property>
+                                        <property name="width">1</property>
+                                        <property name="height">1</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkEntry" id="entry2">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="invisible_char">●</property>
+                                        <property name="invisible_char_set">True</property>
+                                      </object>
+                                      <packing>
+                                        <property name="left_attach">1</property>
+                                        <property name="top_attach">6</property>
+                                        <property name="width">1</property>
+                                        <property name="height">1</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkEntry" id="entry3">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="invisible_char">●</property>
+                                        <property name="invisible_char_set">True</property>
+                                      </object>
+                                      <packing>
+                                        <property name="left_attach">1</property>
+                                        <property name="top_attach">7</property>
+                                        <property name="width">1</property>
+                                        <property name="height">1</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkSpinButton" id="spinbutton3">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="invisible_char">●</property>
+                                        <property name="invisible_char_set">True</property>
+                                      </object>
+                                      <packing>
+                                        <property name="left_attach">1</property>
+                                        <property name="top_attach">8</property>
+                                        <property name="width">1</property>
+                                        <property name="height">1</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkAlignment" id="alignment11">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="left_padding">20</property>
+                                        <child>
+                                          <object class="GtkLabel" id="label21">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="xalign">0</property>
+                                            <property name="label" translatable="yes">Before</property>
+                                          </object>
+                                        </child>
+                                      </object>
+                                      <packing>
+                                        <property name="left_attach">0</property>
+                                        <property name="top_attach">6</property>
+                                        <property name="width">1</property>
+                                        <property name="height">1</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkAlignment" id="alignment12">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="left_padding">20</property>
+                                        <child>
+                                          <object class="GtkLabel" id="label22">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="xalign">0</property>
+                                            <property name="label" translatable="yes">After</property>
+                                          </object>
+                                        </child>
+                                      </object>
+                                      <packing>
+                                        <property name="left_attach">0</property>
+                                        <property name="top_attach">7</property>
+                                        <property name="width">1</property>
+                                        <property name="height">1</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkLabel" id="label23">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="xalign">0</property>
+                                        <property name="label" translatable="yes">Start at</property>
+                                      </object>
+                                      <packing>
+                                        <property name="left_attach">0</property>
+                                        <property name="top_attach">8</property>
+                                        <property name="width">1</property>
+                                        <property name="height">1</property>
+                                      </packing>
+                                    </child>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkDrawingArea" id="drawingarea1">
+                                <property name="width_request">150</property>
+                                <property name="height_request">200</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                              </object>
+                              <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel" id="label24">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Numbering</property>
+                        <property name="use_markup">True</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="position">4</property>
+              </packing>
+            </child>
+            <child type="tab">
+              <object class="GtkLabel" id="label14">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">page 5</property>
+              </object>
+              <packing>
+                <property name="position">4</property>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
           </object>
           <packing>
             <property name="expand">False</property>
commit 598a34232e91f520655e106cecad290db90e5388
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sat Jun 9 10:33:31 2012 +0100

    we can extract the control type from the window

diff --git a/vcl/inc/vcl/builder.hxx b/vcl/inc/vcl/builder.hxx
index 970801a..f98b552 100644
--- a/vcl/inc/vcl/builder.hxx
+++ b/vcl/inc/vcl/builder.hxx
@@ -91,8 +91,6 @@ private:
     ListStore *get_model_by_name(rtl::OString sID);
     static void mungemodel(ListBox &rTarget, ListStore &rStore);
 
-    std::stack<rtl::OString> m_aParentTypes;
-
     rtl::OString m_sID;
     Window *m_pParent;
 public:
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 7d851ec..4877ebd 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -180,7 +180,7 @@ bool VclBuilder::extractModel(const rtl::OString &id, stringmap &rMap)
 
 Window *VclBuilder::makeObject(Window *pParent, const rtl::OString &name, const rtl::OString &id, stringmap &rMap)
 {
-    if (!m_aParentTypes.empty() && m_aParentTypes.top().equalsL(RTL_CONSTASCII_STRINGPARAM("GtkNotebook")))
+    if (pParent && pParent->GetType() == WINDOW_TABCONTROL)
     {
         //We have to add a page
         TabControl *pTabControl = static_cast<TabControl*>(pParent);
@@ -282,7 +282,6 @@ Window *VclBuilder::insertObject(Window *pParent, const rtl::OString &rClass, co
 
     if (pCurrentChild)
     {
-        m_aParentTypes.push(rClass);
         for (stringmap::iterator aI = rMap.begin(), aEnd = rMap.end(); aI != aEnd; ++aI)
         {
             const rtl::OString &rKey = aI->first;
@@ -415,7 +414,7 @@ void VclBuilder::handleChild(Window *pParent, xmlreader::XmlReader &reader)
                 if (pCurrentChild)
                 {
                     //Select the first page if its a notebook
-                    if (!m_aParentTypes.empty() && m_aParentTypes.top().equalsL(RTL_CONSTASCII_STRINGPARAM("GtkNotebook")))
+                    if (pCurrentChild->GetType() == WINDOW_TABCONTROL)
                     {
                         TabControl *pTabControl = static_cast<TabControl*>(pCurrentChild);
                         pTabControl->SetCurPageId(1);
@@ -456,9 +455,6 @@ void VclBuilder::handleChild(Window *pParent, xmlreader::XmlReader &reader)
                         }
 #endif
                     }
-
-                    if (!m_aParentTypes.empty())
-                        m_aParentTypes.pop();
                 }
             }
             else if (name.equals(RTL_CONSTASCII_STRINGPARAM("packing")))
commit 73e27badef57e0c9fdfa2d0dc1aee13acba193d4
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jun 8 20:59:06 2012 +0100

    import GtkTreeView as alternative view ListBox

diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 715cf14..7d851ec 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -239,6 +239,11 @@ Window *VclBuilder::makeObject(Window *pParent, const rtl::OString &name, const
         extractModel(id, rMap);
         pWindow = new ListBox(pParent, WB_LEFT|WB_DROPDOWN|WB_VCENTER|WB_3DLOOK);
     }
+    else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkTreeView")))
+    {
+        extractModel(id, rMap);
+        pWindow = new ListBox(pParent, WB_LEFT|WB_VCENTER|WB_3DLOOK);
+    }
     else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkLabel")))
         pWindow = new FixedText(pParent, WB_CENTER|WB_VCENTER|WB_3DLOOK);
     else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkEntry")))


More information about the Libreoffice-commits mailing list