[Libreoffice-commits] .: Branch 'feature/cmclayout' - vcl/inc vcl/source
Caolán McNamara
caolan at kemper.freedesktop.org
Wed May 23 05:18:08 PDT 2012
vcl/inc/vcl/builder.hxx | 1
vcl/inc/vcl/button.hxx | 3 -
vcl/inc/vcl/ctrl.hxx | 1
vcl/inc/vcl/edit.hxx | 2 -
vcl/inc/vcl/spinfld.hxx | 2 +
vcl/inc/vcl/window.hxx | 10 ++---
vcl/source/control/ctrl.cxx | 8 ++++
vcl/source/control/edit.cxx | 24 +++++++++++++
vcl/source/control/field.cxx | 2 -
vcl/source/control/spinfld.cxx | 25 +++++++++++++-
vcl/source/window/builder.cxx | 71 +++++++++++++++++++++++++++++------------
vcl/source/window/window.cxx | 8 ++++
12 files changed, 124 insertions(+), 33 deletions(-)
New commits:
commit 10514df993ea2b6f7ec87872e845d2913aadb81c
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed May 23 13:17:44 2012 +0100
blasted BorderWindows are a pain
diff --git a/vcl/inc/vcl/builder.hxx b/vcl/inc/vcl/builder.hxx
index 6839a79..6b23372 100644
--- a/vcl/inc/vcl/builder.hxx
+++ b/vcl/inc/vcl/builder.hxx
@@ -92,6 +92,7 @@ private:
//Helpers to retrofit all the existing code the the builder
static void swapGuts(Window &rOrig, Window &rReplacement);
static sal_uInt16 getPositionWithinParent(Window &rWindow);
+ static void reorderWithinParent(Window &rWindow, sal_uInt16 nNewPosition);
};
#endif
diff --git a/vcl/inc/vcl/button.hxx b/vcl/inc/vcl/button.hxx
index ecfa0f1..5522b29 100644
--- a/vcl/inc/vcl/button.hxx
+++ b/vcl/inc/vcl/button.hxx
@@ -318,8 +318,6 @@ protected:
SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId );
- virtual void take_properties(Window &rOther);
-
public:
SAL_DLLPRIVATE void ImplCallClick( sal_Bool bGrabFocus = sal_False, sal_uInt16 nFocusFlags = 0 );
SAL_DLLPRIVATE void ImplSetMinimumNWFSize();
@@ -404,6 +402,7 @@ public:
* Group this RadioButton with another
*/
void group(RadioButton &rOther);
+ virtual void take_properties(Window &rOther);
};
// ------------
diff --git a/vcl/inc/vcl/ctrl.hxx b/vcl/inc/vcl/ctrl.hxx
index fdb0607..9f98635 100644
--- a/vcl/inc/vcl/ctrl.hxx
+++ b/vcl/inc/vcl/ctrl.hxx
@@ -193,6 +193,7 @@ public:
aFont.Merge( GetControlFont() );
return aFont;
}
+ virtual void take_properties(Window &rOther);
};
#endif // _SV_CTRL_HXX
diff --git a/vcl/inc/vcl/edit.hxx b/vcl/inc/vcl/edit.hxx
index 9ca82bd..3c71458 100644
--- a/vcl/inc/vcl/edit.hxx
+++ b/vcl/inc/vcl/edit.hxx
@@ -148,7 +148,6 @@ protected:
protected:
virtual void FillLayoutData() const;
-
Edit( WindowType nType );
public:
@@ -248,6 +247,7 @@ public:
virtual XubString GetSurroundingText() const;
virtual Selection GetSurroundingTextSelection() const;
+ virtual void take_properties(Window &rOther);
// returns the minimum size a bordered Edit should have given the current
// global style settings (needed by sc's inputwin.cxx)
diff --git a/vcl/inc/vcl/spinfld.hxx b/vcl/inc/vcl/spinfld.hxx
index becfe4b..6ee6ff6 100644
--- a/vcl/inc/vcl/spinfld.hxx
+++ b/vcl/inc/vcl/spinfld.hxx
@@ -77,6 +77,7 @@ protected:
virtual void FillLayoutData() const;
Rectangle * ImplFindPartRect( const Point& rPt );
+
public:
SpinField( Window* pParent, WinBits nWinStyle = 0 );
SpinField( Window* pParent, const ResId& rResId );
@@ -111,6 +112,7 @@ public:
virtual Size CalcMinimumSize() const;
virtual Size GetOptimalSize(WindowSizeType eType) const;
virtual Size CalcSize( sal_uInt16 nChars ) const;
+ virtual void take_properties(Window &rOther);
};
#endif // _SV_SPINFLD_HXX
diff --git a/vcl/inc/vcl/window.hxx b/vcl/inc/vcl/window.hxx
index 6ee1d61..1b07f66 100644
--- a/vcl/inc/vcl/window.hxx
+++ b/vcl/inc/vcl/window.hxx
@@ -597,11 +597,6 @@ protected:
*/
SAL_DLLPRIVATE void queue_resize();
- /*
- * Takes ownership of the rOther properties
- */
- virtual void take_properties(Window &rOther);
-
// FIXME: this is a hack to workaround missing layout functionality
SAL_DLLPRIVATE void ImplAdjustNWFSizes();
public:
@@ -1142,6 +1137,11 @@ public:
void reorderWithinParent(sal_uInt16 nNewPosition);
+ /*
+ * Takes ownership of the rOther properties
+ */
+ virtual void take_properties(Window &rOther);
+
//-------------------------------------
// Native Widget Rendering functions
//-------------------------------------
diff --git a/vcl/source/control/ctrl.cxx b/vcl/source/control/ctrl.cxx
index 0bfe0de..29438ee 100644
--- a/vcl/source/control/ctrl.cxx
+++ b/vcl/source/control/ctrl.cxx
@@ -68,7 +68,13 @@ Control::Control( Window* pParent, WinBits nStyle ) :
Window::ImplInit( pParent, nStyle, NULL );
}
-// -----------------------------------------------------------------------
+void Control::take_properties(Window &rOther)
+{
+ Control &rOtherControl = static_cast<Control&>(rOther);
+ std::swap(mpControlData, rOtherControl.mpControlData);
+ mbHasFocus = rOtherControl.mbHasFocus;
+ Window::take_properties(rOther);
+}
Control::Control( Window* pParent, const ResId& rResId ) :
Window( WINDOW_CONTROL )
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index 2bb7ae2..cc648ae 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -202,7 +202,29 @@ Edit::Edit( Window* pParent, WinBits nStyle ) :
ImplInit( pParent, nStyle );
}
-// -----------------------------------------------------------------------
+void Edit::take_properties(Window &rOther)
+{
+ Edit &rOtherEdit = static_cast<Edit&>(rOther);
+ maText = rOtherEdit.maText;
+ maSaveValue = rOtherEdit.maSaveValue;
+ maUndoText = rOtherEdit.maUndoText;
+ maRedoText = rOtherEdit.maRedoText;
+ mnXOffset = rOtherEdit.mnXOffset;
+ maSelection = rOtherEdit.maSelection;
+ mnAlign = rOtherEdit.mnAlign;
+ mnMaxTextLen = rOtherEdit.mnMaxTextLen;
+ meAutocompleteAction = rOtherEdit.meAutocompleteAction;
+ mcEchoChar = rOtherEdit.mcEchoChar;
+ mbModified = rOtherEdit.mbModified;
+ mbInternModified = rOtherEdit.mbInternModified;
+ mbReadOnly = rOtherEdit.mbReadOnly;
+ mbInsertMode = rOtherEdit.mbInsertMode;
+ mbClickedInSelection = rOtherEdit.mbClickedInSelection;
+ mbIsSubEdit = rOtherEdit.mbIsSubEdit;
+ mbInMBDown = rOtherEdit.mbInMBDown;
+ mbActivePopup = rOtherEdit.mbActivePopup;
+ Control::take_properties(rOther);
+}
Edit::Edit( Window* pParent, const ResId& rResId ) :
Control( WINDOW_EDIT )
diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx
index 2f8bcd6..2259648 100644
--- a/vcl/source/control/field.cxx
+++ b/vcl/source/control/field.cxx
@@ -1656,8 +1656,6 @@ MetricField::MetricField( Window* pParent, WinBits nWinStyle ) :
Reformat();
}
-// -----------------------------------------------------------------------
-
MetricField::MetricField( Window* pParent, const ResId& rResId ) :
SpinField( WINDOW_METRICFIELD )
{
diff --git a/vcl/source/control/spinfld.cxx b/vcl/source/control/spinfld.cxx
index 5f8c825..4ec6cb9 100644
--- a/vcl/source/control/spinfld.cxx
+++ b/vcl/source/control/spinfld.cxx
@@ -361,7 +361,30 @@ SpinField::SpinField( Window* pParent, WinBits nWinStyle ) :
ImplInit( pParent, nWinStyle );
}
-// --------------------------------------------------------------------
+void SpinField::take_properties(Window &rOther)
+{
+ fprintf(stderr, "SpinField::take_properties\n");
+ SpinField &rOtherField = static_cast<SpinField&>(rOther);
+ assert(!mpEdit && rOther.mpEdit);
+ mpEdit = new Edit(this, WB_NOBORDER);
+ SetSubEdit(mpEdit);
+ mpEdit->take_properties(*rOtherField.mpEdit);
+ maUpperRect = rOtherField.maUpperRect;
+ maLowerRect = rOtherField.maLowerRect;
+ maDropDownRect = rOtherField.maDropDownRect;
+ mbRepeat = rOtherField.mbRepeat;
+ mbSpin = rOtherField.mbSpin;
+ mbInitialUp = rOtherField.mbInitialUp;
+ mbInitialDown = rOtherField.mbInitialDown;
+ mbNoSelect = rOtherField.mbNoSelect;
+ mbUpperIn = rOtherField.mbUpperIn;
+ mbLowerIn = rOtherField.mbLowerIn;
+ mbInDropDown = rOtherField.mbInDropDown;
+
+ Edit::take_properties(rOther);
+
+ fprintf(stderr, "SpinField::take_properties %p %d\n", this, IsVisible());
+}
SpinField::SpinField( Window* pParent, const ResId& rResId ) :
Edit( WINDOW_SPINFIELD )
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 4ea8739..edbae65 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -189,7 +189,7 @@ Window *VclBuilder::makeObject(Window *pParent, const rtl::OString &name, const
pWindow = new Edit(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK );
else
fprintf(stderr, "TO-DO, implement %s\n", name.getStr());
- fprintf(stderr, "for %s, created %p child of %p\n", name.getStr(), pWindow, pParent);
+ fprintf(stderr, "for %s, created %p child of %p (%p/%p/%p)\n", name.getStr(), pWindow, pParent, pWindow->mpWindowImpl->mpParent, pWindow->mpWindowImpl->mpRealParent, pWindow->mpWindowImpl->mpBorderWindow);
return pWindow;
}
@@ -233,6 +233,45 @@ Window *VclBuilder::insertObject(Window *pParent, const rtl::OString &rClass, co
return pCurrentChild;
}
+sal_uInt16 VclBuilder::getPositionWithinParent(Window &rWindow)
+{
+ if (rWindow.mpWindowImpl->mpParent != rWindow.mpWindowImpl->mpRealParent)
+ {
+ assert(rWindow.mpWindowImpl->mpBorderWindow ==
+ rWindow.mpWindowImpl->mpParent);
+ assert(rWindow.mpWindowImpl->mpBorderWindow->mpParent ==
+ rWindow.mpWindowImpl->mpRealParent);
+ return getPositionWithinParent(*rWindow.mpWindowImpl->mpBorderWindow);
+ }
+
+ assert(rWindow.GetParent() == rWindow.GetRealParent());
+
+ sal_uInt16 nPosition = 0;
+ Window* pChild = rWindow.GetParent()->mpWindowImpl->mpFirstChild;
+ while (pChild)
+ {
+ if (pChild == &rWindow)
+ break;
+ pChild = pChild->mpWindowImpl->mpNext;
+ ++nPosition;
+ }
+ return nPosition;
+}
+
+void VclBuilder::reorderWithinParent(Window &rWindow, sal_uInt16 nNewPosition)
+{
+ if (rWindow.mpWindowImpl->mpParent != rWindow.mpWindowImpl->mpRealParent)
+ {
+ assert(rWindow.mpWindowImpl->mpBorderWindow ==
+ rWindow.mpWindowImpl->mpParent);
+ assert(rWindow.mpWindowImpl->mpBorderWindow->mpParent ==
+ rWindow.mpWindowImpl->mpRealParent);
+ reorderWithinParent(*rWindow.mpWindowImpl->mpBorderWindow, nNewPosition);
+ return;
+ }
+ rWindow.reorderWithinParent(nNewPosition);
+}
+
void VclBuilder::handleChild(Window *pParent, xmlreader::XmlReader &reader)
{
int nLevel = 1;
@@ -267,7 +306,7 @@ void VclBuilder::handleChild(Window *pParent, xmlreader::XmlReader &reader)
sal_uInt16 nPosition = aChilds[i]->getWidgetProperty<sal_uInt16>(sPosition, 0xFFFF);
if (nPosition == 0xFFFF)
continue;
- aChilds[i]->reorderWithinParent(nPosition);
+ reorderWithinParent(*aChilds[i], nPosition);
}
#if TODO
@@ -279,7 +318,7 @@ void VclBuilder::handleChild(Window *pParent, xmlreader::XmlReader &reader)
sal_uInt16 nPosition = aChilds[i]->getWidgetProperty<sal_uInt16>(sPosition, 0xFFFF);
if (nPosition == 0xFFFF)
continue;
- aChilds[i]->reorderWithinParent(nPosition);
+ reorderWithinParent(*aChilds[i], nPosition);
}
#endif
@@ -498,30 +537,22 @@ Window *VclBuilder::get_by_name(rtl::OString sID)
return NULL;
}
-sal_uInt16 VclBuilder::getPositionWithinParent(Window &rWindow)
-{
- sal_uInt16 nPosition = 0;
- Window* pChild = rWindow.GetParent()->mpWindowImpl->mpFirstChild;
- while (pChild)
- {
- if (pChild == &rWindow)
- break;
- pChild = pChild->mpWindowImpl->mpNext;
- ++nPosition;
- }
- return nPosition;
-}
-
void VclBuilder::swapGuts(Window &rOrig, Window &rReplacement)
{
#if 1
+ if (rOrig.mpWindowImpl->mpBorderWindow)
+ fprintf(stderr, "problem one\n");
+
sal_uInt16 nPosition = getPositionWithinParent(rOrig);
- rReplacement.ImplInit(rOrig.GetParent(), rOrig.GetStyle(), NULL);
+ rReplacement.ImplInit(rOrig.mpWindowImpl->mpRealParent, rOrig.GetStyle(), NULL);
+
+ if (rReplacement.mpWindowImpl->mpBorderWindow)
+ fprintf(stderr, "problem two\n");
rReplacement.take_properties(rOrig);
- rReplacement.reorderWithinParent(nPosition);
+ reorderWithinParent(rReplacement, nPosition);
assert(nPosition == getPositionWithinParent(rReplacement));
#else
@@ -554,7 +585,7 @@ void VclBuilder::swapGuts(Window &rOrig, Window &rReplacement)
//now put this at the end of the window list
rOrig.ImplInsertWindow(pParent);
#endif
- fprintf(stderr, "swapped %p for %p\n", &rReplacement, &rOrig);
+ fprintf(stderr, "swapped %p for %p %p/%p/%p\n", &rReplacement, &rOrig, rReplacement.mpWindowImpl->mpParent, rReplacement.mpWindowImpl->mpRealParent, rReplacement.mpWindowImpl->mpBorderWindow);
}
bool VclBuilder::replace(rtl::OString sID, Window &rReplacement)
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index c1e8b87..0bcdd31 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -9794,6 +9794,14 @@ void Window::take_properties(Window &rOther)
mpWindowImpl->mbInterceptChildWindowKeyDown = pWindowImpl->mbInterceptChildWindowKeyDown;
std::swap(m_aWidgetProperties, rOther.m_aWidgetProperties);
+
+ bool bHasBorderWindow = mpWindowImpl->mpBorderWindow;
+ bool bOtherHasBorderWindow = pWindowImpl->mpBorderWindow;
+
+ assert(bHasBorderWindow == bOtherHasBorderWindow);
+
+ if (bHasBorderWindow && bOtherHasBorderWindow)
+ mpWindowImpl->mpBorderWindow->take_properties(*pWindowImpl->mpBorderWindow);
}
bool Window::set_property(const rtl::OString &rKey, const rtl::OString &rValue)
More information about the Libreoffice-commits
mailing list