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

Caolán McNamara caolan at kemper.freedesktop.org
Fri May 18 07:58:52 PDT 2012


 vcl/inc/vcl/layout.hxx        |    1 +
 vcl/source/window/builder.cxx |    4 +++-
 vcl/source/window/dialog.cxx  |   29 +++++++++++++++++++++++++++++
 vcl/source/window/dlgctrl.cxx |   10 ++++------
 vcl/source/window/layout.cxx  |    6 +++---
 5 files changed, 40 insertions(+), 10 deletions(-)

New commits:
commit df9ba567c4c0e506848c6face127ab6a5f930aac
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri May 18 15:54:19 2012 +0100

    add prevLogicalChildOfParent

diff --git a/vcl/inc/vcl/layout.hxx b/vcl/inc/vcl/layout.hxx
index c2ed2ed..c146087 100644
--- a/vcl/inc/vcl/layout.hxx
+++ b/vcl/inc/vcl/layout.hxx
@@ -414,6 +414,7 @@ Window* getLegacyNonLayoutParent(Window *pParent);
 //in a flat hierarchy where dialogs only have one layer
 //of children
 Window* nextLogicalChildOfParent(Window *pTopLevel, Window *pChild);
+Window* prevLogicalChildOfParent(Window *pTopLevel, Window *pChild);
 
 #endif
 
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index d484213..4ffa8ba 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -137,6 +137,35 @@ Window * nextLogicalChildOfParent(Window *pTopLevel, Window *pChild)
         pChild = pParent->GetWindow(WINDOW_NEXT);
     }
 
+    if (dynamic_cast<VclContainer*>(pChild))
+        pChild = nextLogicalChildOfParent(pTopLevel, pChild);
+
+    return pChild;
+}
+
+Window * prevLogicalChildOfParent(Window *pTopLevel, Window *pChild)
+{
+    Window *pLastChild = pChild;
+
+    if (dynamic_cast<VclContainer*>(pChild))
+        pChild = pChild->GetWindow(WINDOW_LASTCHILD);
+    else
+        pChild = pChild->GetWindow(WINDOW_PREV);
+
+    while (!pChild)
+    {
+        Window *pParent = pLastChild->GetParent();
+        if (!pParent)
+            return NULL;
+        if (pParent == pTopLevel)
+            return NULL;
+        pLastChild = pParent;
+        pChild = pParent->GetWindow(WINDOW_PREV);
+    }
+
+    if (dynamic_cast<VclContainer*>(pChild))
+        pChild = prevLogicalChildOfParent(pTopLevel, pChild);
+
     return pChild;
 }
 
diff --git a/vcl/source/window/dlgctrl.cxx b/vcl/source/window/dlgctrl.cxx
index f7fd592..f7941ff 100644
--- a/vcl/source/window/dlgctrl.cxx
+++ b/vcl/source/window/dlgctrl.cxx
@@ -804,7 +804,7 @@ sal_Bool Window::ImplDlgCtrl( const KeyEvent& rKEvt, sal_Bool bKeyInput )
             WinBits nStyle = pSWindow->GetStyle();
             if ( !(nStyle & WB_GROUP) )
             {
-                pWindow = pWindow->GetWindow( WINDOW_PREV );
+                pWindow = prevLogicalChildOfParent(this, pWindow);
                 while ( pWindow )
                 {
                     pWindow = pWindow->ImplGetWindow();
@@ -821,20 +821,18 @@ sal_Bool Window::ImplDlgCtrl( const KeyEvent& rKEvt, sal_Bool bKeyInput )
                     if ( nStyle & WB_GROUP )
                         break;
 
-                    pWindow = pWindow->GetWindow( WINDOW_PREV );
+                    pWindow = prevLogicalChildOfParent(this, pWindow);
                 }
             }
         }
         else if ( (nKeyCode == KEY_RIGHT) || (nKeyCode == KEY_DOWN) )
         {
-            Window* pWindow;
-            WinBits nStyle;
-            pWindow = nextLogicalChildOfParent(this, pSWindow);
+            Window* pWindow = nextLogicalChildOfParent(this, pSWindow);
             while ( pWindow )
             {
                 pWindow = pWindow->ImplGetWindow();
 
-                nStyle = pWindow->GetStyle();
+                WinBits nStyle = pWindow->GetStyle();
 
                 if ( nStyle & WB_GROUP )
                     break;
commit 018d94881c90bc69bed4c8408fa78dc63e5dec4f
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri May 18 15:54:03 2012 +0100

    don't reorder children without position properties

diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 380bebc..32829ee 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -263,7 +263,9 @@ void VclBuilder::handleChild(Window *pParent, xmlreader::XmlReader &reader)
 
                     for (size_t i = 0; i < aChilds.size(); ++i)
                     {
-                        sal_uInt16 nPosition = aChilds[i]->getWidgetProperty<sal_uInt16>(sPosition);
+                        sal_uInt16 nPosition = aChilds[i]->getWidgetProperty<sal_uInt16>(sPosition, 0xFFFF);
+                        if (nPosition == 0xFFFF)
+                            continue;
                         aChilds[i]->reorderWithinParent(nPosition);
                     }
                 }
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index ef31201..a482770 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -529,7 +529,7 @@ const Window *VclBin::get_child() const
 {
     const WindowImpl* pWindowImpl = ImplGetWindowImpl();
 
-    return pWindowImpl->mpLastChild;
+    return pWindowImpl->mpFirstChild;
 }
 
 Window *VclBin::get_child()
@@ -546,7 +546,7 @@ Size VclFrame::calculateRequisition() const
     WindowImpl* pWindowImpl = ImplGetWindowImpl();
 
     const Window *pChild = get_child();
-    const Window *pLabel = pChild != pWindowImpl->mpFirstChild ? pWindowImpl->mpFirstChild : NULL;
+    const Window *pLabel = pChild != pWindowImpl->mpLastChild ? pWindowImpl->mpLastChild : NULL;
 
     if (pChild && pChild->IsVisible())
         aRet = pChild->GetOptimalSize(WINDOWSIZE_PREFERRED);
@@ -578,7 +578,7 @@ void VclFrame::setAllocation(const Size &rAllocation)
 
     //The label widget is the last (of two) children
     Window *pChild = get_child();
-    Window *pLabel = pChild != pWindowImpl->mpFirstChild ? pWindowImpl->mpFirstChild : NULL;
+    Window *pLabel = pChild != pWindowImpl->mpLastChild ? pWindowImpl->mpLastChild : NULL;
 
     if (pLabel && pLabel->IsVisible())
     {


More information about the Libreoffice-commits mailing list