diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-06-16 20:23:31 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-09-28 08:48:31 +0100 |
commit | eb1e793906b26aabb4bd099c2bd8a392139ac5a3 (patch) | |
tree | 6b45177389e89cee57ba6d420232944ef2da74ce | |
parent | 15eb1c02601d8c7fa135930a3eb3787a24e8b92a (diff) |
add and use a "WINDOW_CONTAINER" type
use it instead of dynamic_cast seeing as we already are dragging
the window type information around with us
-rw-r--r-- | tools/inc/tools/wintypes.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/vcl/dialog.hxx | 4 | ||||
-rw-r--r-- | vcl/inc/vcl/layout.hxx | 2 | ||||
-rw-r--r-- | vcl/source/window/dialog.cxx | 17 | ||||
-rw-r--r-- | vcl/source/window/layout.cxx | 9 | ||||
-rw-r--r-- | vcl/source/window/tabpage.cxx | 3 |
6 files changed, 23 insertions, 14 deletions
diff --git a/tools/inc/tools/wintypes.hxx b/tools/inc/tools/wintypes.hxx index 0898cbfb38a1..c1fb936eb0cd 100644 --- a/tools/inc/tools/wintypes.hxx +++ b/tools/inc/tools/wintypes.hxx @@ -35,7 +35,7 @@ typedef sal_uInt16 WindowType; #define WINDOW_WINDOW (WINDOW_FIRST + 0x05) #define WINDOW_SYSWINDOW (WINDOW_FIRST + 0x06) #define WINDOW_WORKWINDOW (WINDOW_FIRST + 0x07) -// #define WINDOW_MDIWINDOW (WINDOW_FIRST + 0x08) +#define WINDOW_CONTAINER (WINDOW_FIRST + 0x08) #define WINDOW_FLOATINGWINDOW (WINDOW_FIRST + 0x09) #define WINDOW_DIALOG (WINDOW_FIRST + 0x0a) #define WINDOW_MODELESSDIALOG (WINDOW_FIRST + 0x0b) diff --git a/vcl/inc/vcl/dialog.hxx b/vcl/inc/vcl/dialog.hxx index 13a5520bbc23..a162522123ce 100644 --- a/vcl/inc/vcl/dialog.hxx +++ b/vcl/inc/vcl/dialog.hxx @@ -44,7 +44,7 @@ // ---------- struct DialogImpl; class VclBuilder; -class VclBox; +class VclContainer; class VCL_DLLPUBLIC Dialog : public SystemWindow @@ -78,7 +78,7 @@ protected: SAL_DLLPRIVATE void ImplDialogRes( const ResId& rResId ); SAL_DLLPRIVATE WinBits init(Window *pParent, const ResId& rResId); - SAL_DLLPRIVATE void setPosSizeOnContainee(Size aSize, VclBox &rBox); + SAL_DLLPRIVATE void setPosSizeOnContainee(Size aSize, VclContainer &rBox); public: SAL_DLLPRIVATE sal_Bool IsInClose() const { return mbInClose; } SAL_DLLPRIVATE bool hasPendingLayout() const { return maLayoutTimer.IsActive(); } diff --git a/vcl/inc/vcl/layout.hxx b/vcl/inc/vcl/layout.hxx index e5308e1fba40..e9ed52e44742 100644 --- a/vcl/inc/vcl/layout.hxx +++ b/vcl/inc/vcl/layout.hxx @@ -35,7 +35,7 @@ class VCL_DLLPUBLIC VclContainer : public Window { public: - VclContainer(Window *pParent) : Window(pParent), m_nBorderWidth(0) {} + VclContainer(Window *pParent); virtual Size GetOptimalSize(WindowSizeType eType) const; using Window::SetPosSizePixel; virtual void SetPosSizePixel(const Point& rNewPos, const Size& rNewSize); diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index ff284fcfcb47..497b4c47f9f7 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -128,7 +128,7 @@ Window * nextLogicalChildOfParent(Window *pTopLevel, Window *pChild) { Window *pLastChild = pChild; - if (dynamic_cast<VclContainer*>(pChild)) + if (pChild->GetType() == WINDOW_CONTAINER) pChild = pChild->GetWindow(WINDOW_FIRSTCHILD); else pChild = pChild->GetWindow(WINDOW_NEXT); @@ -144,7 +144,7 @@ Window * nextLogicalChildOfParent(Window *pTopLevel, Window *pChild) pChild = pParent->GetWindow(WINDOW_NEXT); } - if (dynamic_cast<VclContainer*>(pChild)) + if (pChild && pChild->GetType() == WINDOW_CONTAINER) pChild = nextLogicalChildOfParent(pTopLevel, pChild); return pChild; @@ -154,7 +154,7 @@ Window * prevLogicalChildOfParent(Window *pTopLevel, Window *pChild) { Window *pLastChild = pChild; - if (dynamic_cast<VclContainer*>(pChild)) + if (pChild->GetType() == WINDOW_CONTAINER) pChild = pChild->GetWindow(WINDOW_LASTCHILD); else pChild = pChild->GetWindow(WINDOW_PREV); @@ -170,7 +170,7 @@ Window * prevLogicalChildOfParent(Window *pTopLevel, Window *pChild) pChild = pParent->GetWindow(WINDOW_PREV); } - if (dynamic_cast<VclContainer*>(pChild)) + if (pChild && pChild->GetType() == WINDOW_CONTAINER) pChild = prevLogicalChildOfParent(pTopLevel, pChild); return pChild; @@ -656,7 +656,7 @@ void Dialog::StateChanged( StateChangedType nType ) maLayoutTimer.Stop(); //resize dialog to fit requisition on initial show - VclBox *pBox = dynamic_cast<VclBox*>(GetWindow(WINDOW_FIRSTCHILD)); + VclBox *pBox = static_cast<VclBox*>(GetWindow(WINDOW_FIRSTCHILD)); const DialogStyle& rDialogStyle = GetSettings().GetStyleSettings().GetDialogStyle(); @@ -1167,7 +1167,8 @@ void Dialog::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal bool Dialog::isLayoutEnabled() const { //Child is a container => we're layout enabled - return dynamic_cast<const VclContainer*>(GetWindow(WINDOW_FIRSTCHILD)); + const Window *pChild = GetWindow(WINDOW_FIRSTCHILD); + return pChild && pChild->GetType() == WINDOW_CONTAINER; } Size Dialog::GetOptimalSize(WindowSizeType eType) const @@ -1185,7 +1186,7 @@ Size Dialog::GetOptimalSize(WindowSizeType eType) const return Window::CalcWindowSize(aSize); } -void Dialog::setPosSizeOnContainee(Size aSize, VclBox &rBox) +void Dialog::setPosSizeOnContainee(Size aSize, VclContainer &rBox) { aSize.Width() -= mpWindowImpl->mnLeftBorder + mpWindowImpl->mnRightBorder + 2 * m_nBorderWidth; @@ -1202,7 +1203,7 @@ IMPL_LINK( Dialog, ImplHandleLayoutTimerHdl, void*, EMPTYARG ) { fprintf(stderr, "ImplHandleLayoutTimerHdl\n"); - VclBox *pBox = dynamic_cast<VclBox*>(GetWindow(WINDOW_FIRSTCHILD)); + VclBox *pBox = static_cast<VclBox*>(GetWindow(WINDOW_FIRSTCHILD)); if (!pBox) { fprintf(stderr, "WTF!\n"); diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index b4ca47224382..418b05686cc3 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -29,6 +29,13 @@ #include <vcl/layout.hxx> #include "window.h" +VclContainer::VclContainer(Window *pParent) + : Window(WINDOW_CONTAINER) + , m_nBorderWidth(0) +{ + ImplInit(pParent, 0, NULL); +} + Size VclContainer::GetOptimalSize(WindowSizeType eType) const { if (eType == WINDOWSIZE_MAXIMUM) @@ -893,7 +900,7 @@ Size getLegacyBestSizeForChildren(const Window &rWindow) Window* getLegacyNonLayoutParent(Window *pParent) { - while (pParent && dynamic_cast<const VclContainer*>(pParent)) + while (pParent && pParent->GetType() == WINDOW_CONTAINER) { pParent = pParent->GetParent(); } diff --git a/vcl/source/window/tabpage.cxx b/vcl/source/window/tabpage.cxx index b39ba026fa56..c552ee4b4465 100644 --- a/vcl/source/window/tabpage.cxx +++ b/vcl/source/window/tabpage.cxx @@ -212,7 +212,8 @@ void TabPage::DeactivatePage() bool TabPage::isLayoutEnabled() const { //Child is a container => we're layout enabled - return dynamic_cast<const VclContainer*>(GetWindow(WINDOW_FIRSTCHILD)); + const Window *pChild = GetWindow(WINDOW_FIRSTCHILD); + return pChild && pChild->GetType() == WINDOW_CONTAINER; } Size TabPage::GetOptimalSize(WindowSizeType eType) const |