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

2012-06-12 Thread Caolán McNamara
 vcl/inc/vcl/builder.hxx|1 
 vcl/inc/vcl/tabctrl.hxx|3 +
 vcl/source/control/tabctrl.cxx |   30 ++---
 vcl/source/window/builder.cxx  |   90 +++--
 4 files changed, 98 insertions(+), 26 deletions(-)

New commits:
commit 4eab7331684945213897588ae3303be4c1c2453e
Author: Caolán McNamara 
Date:   Tue Jun 12 16:02:26 2012 +0100

assign tab page ids such that retrofitting existing code is easier

diff --git a/vcl/inc/vcl/builder.hxx b/vcl/inc/vcl/builder.hxx
index f98b552..b44cb3f 100644
--- a/vcl/inc/vcl/builder.hxx
+++ b/vcl/inc/vcl/builder.hxx
@@ -98,6 +98,7 @@ public:
 ~VclBuilder();
 Window *get_widget_root();
 Window *get_by_name(rtl::OString sID);
+rtl::OString get_by_window(const Window *pWindow);
 //for the purposes of retrofitting this to the existing code
 //look up sID, clone its properties into replacement and
 //splice replacement into the tree instead of it, without
diff --git a/vcl/inc/vcl/tabctrl.hxx b/vcl/inc/vcl/tabctrl.hxx
index fd064db..14c68e0 100644
--- a/vcl/inc/vcl/tabctrl.hxx
+++ b/vcl/inc/vcl/tabctrl.hxx
@@ -196,6 +196,9 @@ public:
 
 // returns the rectangle of the tab for page nPageId
 Rectangle GetTabBounds( sal_uInt16 nPageId ) const;
+
+// rename nOldId to nNewId);
+void ReassignPageId(sal_uInt16 nOldId, sal_uInt16 nNewId);
 };
 
 #endif  // _SV_TABCTRL_HXX
diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx
index 0ac4060..ccf6b4c 100644
--- a/vcl/source/control/tabctrl.cxx
+++ b/vcl/source/control/tabctrl.cxx
@@ -2228,7 +2228,20 @@ void TabControl::SetMinimumSizePixel( const Size& 
i_rSize )
 mpTabCtrlData->maMinSize = i_rSize;
 }
 
-// ---
+void TabControl::ReassignPageId(sal_uInt16 nOldId, sal_uInt16 nNewId)
+{
+for( std::vector< ImplTabItem >::iterator it = 
mpTabCtrlData->maItemList.begin();
+ it != mpTabCtrlData->maItemList.end(); ++it )
+{
+if( it->mnId == nOldId )
+it->mnId = nNewId;
+}
 
+if (mnActPageId == nOldId)
+mnActPageId = nNewId;
+
+if (mnCurPageId == nOldId)
+mnCurPageId = nOldId;
+}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 563322b..2f8e5d2 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -183,21 +183,31 @@ Window *VclBuilder::makeObject(Window *pParent, const 
rtl::OString &name, const
 if (pParent && pParent->GetType() == WINDOW_TABCONTROL)
 {
 //We have to add a page
-TabControl *pTabControl = static_cast(pParent);
-TabPage* pPage = new TabPage(pTabControl);
-m_aChildren.push_back(WinAndId(rtl::OString(), pPage));
-
-//And give the page one container as a child to make it a layout 
enabled
-//tab page
-VclBin* pContainer = new VclBin(pPage);
-m_aChildren.push_back(WinAndId(rtl::OString(), pContainer));
-pParent = pContainer;
 
-//keep it simple and make pageid == position
-sal_uInt16 nNewPageId = pTabControl->GetPageCount()+1;
+//make default pageid == -position. Partitioning the
+//id space into negative numbers for auto-generated
+//ids and positive numbers for the handleTabChild
+//derived ids
+TabControl *pTabControl = static_cast(pParent);
+sal_uInt16 nNewPageId = -(pTabControl->GetPageCount()+1);
 pTabControl->InsertPage(nNewPageId, rtl::OUString());
-pTabControl->SetTabPage(nNewPageId, pPage);
 pTabControl->SetCurPageId(nNewPageId);
+
+bool bIsPlaceHolder = name.isEmpty();
+
+if (!bIsPlaceHolder)
+{
+TabPage* pPage = new TabPage(pTabControl);
+m_aChildren.push_back(WinAndId(rtl::OString(), pPage));
+
+//And give the page one container as a child to make it a layout 
enabled
+//tab page
+VclBin* pContainer = new VclBin(pPage);
+m_aChildren.push_back(WinAndId(rtl::OString(), pContainer));
+pParent = pContainer;
+
+pTabControl->SetTabPage(nNewPageId, pPage);
+}
 }
 
 Window *pWindow = NULL;
@@ -341,6 +351,8 @@ void VclBuilder::reorderWithinParent(Window &rWindow, 
sal_uInt16 nNewPosition)
 
 void VclBuilder::handleTabChild(Window *pParent, xmlreader::XmlReader &reader)
 {
+rtl::OString sID;
+
 int nLevel = 1;
 stringmap aProperties;
 while(1)
@@ -356,6 +368,17 @@ void VclBuilder::handleTabChild(Window *pParent, 
xmlreader::XmlReader &reader)
 ++nLevel;
 if (name.equals(RTL_CONSTASCII_STRINGPARAM("property")))
 collectProperty(reader, aProperties);
+else if (name.equals(RTL_CONSTASCII_STRINGPARAM("object")))
+{
+while (reader.nextAttribute(&nsId, &name))
+   

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

2012-05-18 Thread Caolán McNamara
 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 
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(pChild))
+pChild = nextLogicalChildOfParent(pTopLevel, pChild);
+
+return pChild;
+}
+
+Window * prevLogicalChildOfParent(Window *pTopLevel, Window *pChild)
+{
+Window *pLastChild = pChild;
+
+if (dynamic_cast(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(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 
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(sPosition);
+sal_uInt16 nPosition = 
aChilds[i]->getWidgetProperty(sPosition, 0x);
+if (nPosition == 0x)
+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();
 
 con