summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-05-23 13:17:44 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-09-28 08:48:21 +0100
commit8846ba52c5df9bcac77c3ba128d401d51ce81813 (patch)
treeb0d004efb38b111ddcd4c1de8fa0f69b1ff394b2
parentsteal radiobutton guts (diff)
downloadcore-8846ba52c5df9bcac77c3ba128d401d51ce81813.tar.gz
core-8846ba52c5df9bcac77c3ba128d401d51ce81813.zip
blasted BorderWindows are a pain
-rw-r--r--vcl/inc/vcl/builder.hxx1
-rw-r--r--vcl/inc/vcl/button.hxx3
-rw-r--r--vcl/inc/vcl/ctrl.hxx1
-rw-r--r--vcl/inc/vcl/edit.hxx2
-rw-r--r--vcl/inc/vcl/spinfld.hxx2
-rw-r--r--vcl/inc/vcl/window.hxx10
-rw-r--r--vcl/source/control/ctrl.cxx8
-rw-r--r--vcl/source/control/edit.cxx24
-rw-r--r--vcl/source/control/field.cxx2
-rw-r--r--vcl/source/control/spinfld.cxx25
-rw-r--r--vcl/source/window/builder.cxx71
-rw-r--r--vcl/source/window/window.cxx8
12 files changed, 124 insertions, 33 deletions
diff --git a/vcl/inc/vcl/builder.hxx b/vcl/inc/vcl/builder.hxx
index 6839a79c2f80..6b2337283c16 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 3db8f2e78991..492f59a8da68 100644
--- a/vcl/inc/vcl/button.hxx
+++ b/vcl/inc/vcl/button.hxx
@@ -323,8 +323,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();
@@ -409,6 +407,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 98dd33bea000..03927eae4482 100644
--- a/vcl/inc/vcl/ctrl.hxx
+++ b/vcl/inc/vcl/ctrl.hxx
@@ -197,6 +197,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 58f88be84125..a382bc83f82b 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 rtl::OUString 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 25393b8eb242..fbe2fb451e19 100644
--- a/vcl/inc/vcl/spinfld.hxx
+++ b/vcl/inc/vcl/spinfld.hxx
@@ -68,6 +68,7 @@ protected:
virtual void FillLayoutData() const;
Rectangle * ImplFindPartRect( const Point& rPt );
+
public:
SpinField( Window* pParent, WinBits nWinStyle = 0 );
SpinField( Window* pParent, const ResId& rResId );
@@ -102,6 +103,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 705ba9faaf32..9e2932917d47 100644
--- a/vcl/inc/vcl/window.hxx
+++ b/vcl/inc/vcl/window.hxx
@@ -598,11 +598,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:
@@ -1145,6 +1140,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 b0e796d3ba37..3d7ac2172e91 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 1ac20e3d45ac..8365dc8a8c98 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -200,7 +200,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 cefb8e6ff85b..cc80afe75110 100644
--- a/vcl/source/control/field.cxx
+++ b/vcl/source/control/field.cxx
@@ -1650,8 +1650,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 82921f2b27d8..5570ae8f2309 100644
--- a/vcl/source/control/spinfld.cxx
+++ b/vcl/source/control/spinfld.cxx
@@ -352,7 +352,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 4ea8739b2917..edbae65938d0 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 70e7799b38f7..1321a4242d0d 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -9776,6 +9776,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)