From 03e4a93815b3ab60d767c9b8cdc3b816cde24706 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 26 Sep 2012 16:14:28 +0100 Subject: defer initializing dialog until sizeable/unsizeable is known we have to defer initializing the dialog until we have determined the sizeable/unsizable info as we can't change it after the fact Change-Id: I27c90f8f92953d919b36cddc6a99fae9d7db47eb --- vcl/inc/vcl/dialog.hxx | 1 + vcl/source/window/builder.cxx | 24 ++++++++++++++++++++++-- vcl/source/window/dialog.cxx | 16 ++++++++++++++-- vcl/source/window/window2.cxx | 4 ++-- 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/vcl/inc/vcl/dialog.hxx b/vcl/inc/vcl/dialog.hxx index deea9c7df328..63163225fb6d 100644 --- a/vcl/inc/vcl/dialog.hxx +++ b/vcl/inc/vcl/dialog.hxx @@ -80,6 +80,7 @@ protected: public: SAL_DLLPRIVATE sal_Bool IsInClose() const { return mbInClose; } SAL_DLLPRIVATE bool hasPendingLayout() const { return maLayoutTimer.IsActive(); } + SAL_DLLPRIVATE void doDeferredInit(bool bResizable); protected: Dialog( WindowType nType ); diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 3e9ed9140f01..31e72ceb0a82 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -203,6 +203,18 @@ namespace return sPattern; } + bool extractResizable(VclBuilder::stringmap &rMap) + { + bool bResizable = true; + VclBuilder::stringmap::iterator aFind = rMap.find(rtl::OString(RTL_CONSTASCII_STRINGPARAM("resizable"))); + if (aFind != rMap.end()) + { + bResizable = toBool(aFind->second); + rMap.erase(aFind); + } + return bResizable; + } + bool extractOrientation(VclBuilder::stringmap &rMap) { bool bVertical = false; @@ -432,7 +444,12 @@ Window *VclBuilder::makeObject(Window *pParent, const rtl::OString &name, const Window *pWindow = NULL; if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkDialog"))) - pWindow = new Dialog(pParent, WB_SIZEMOVE|WB_3DLOOK|WB_CLOSEABLE); + { + WinBits nBits = WB_MOVEABLE|WB_3DLOOK|WB_CLOSEABLE; + if (extractResizable(rMap)) + nBits |= WB_SIZEABLE; + pWindow = new Dialog(pParent, nBits); + } else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkBox"))) { if (extractOrientation(rMap)) @@ -601,7 +618,10 @@ Window *VclBuilder::insertObject(Window *pParent, const rtl::OString &rClass, co pCurrentChild = m_pParent; //toplevels default to resizable if (pCurrentChild->IsDialog()) - pCurrentChild->SetStyle(pCurrentChild->GetStyle() | WB_SIZEMOVE | WB_3DLOOK); + { + Dialog *pDialog = (Dialog*)pCurrentChild; + pDialog->doDeferredInit(extractResizable(rMap)); + } if (pCurrentChild->GetHelpId().isEmpty()) { pCurrentChild->SetHelpId(m_sHelpRoot + m_sID); diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index a47f338f1002..807f9d6e9964 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -504,19 +504,31 @@ rtl::OUString VclBuilderContainer::getUIRootDir() return sShareLayer; } +//we can't change sizeable after the fact, so need to defer until we know and then +//do the init. Find the real parent stashed in mpDialogParent. +void Dialog::doDeferredInit(bool bResizable) +{ + WinBits nBits = WB_3DLOOK|WB_CLOSEABLE|WB_MOVEABLE; + if (bResizable) + nBits |= WB_SIZEABLE; + Window *pParent = mpDialogParent; + mpDialogParent = NULL; + ImplInit(pParent, nBits); +} + Dialog::Dialog(Window* pParent, const rtl::OString& rID, const rtl::OUString& rUIXMLDescription) : SystemWindow( WINDOW_DIALOG ) + , mpDialogParent(pParent) //will be unset in doDeferredInit { ImplInitDialogData(); - ImplInit(pParent, WB_SIZEMOVE|WB_3DLOOK|WB_CLOSEABLE); m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID); } Dialog::Dialog(Window* pParent, const rtl::OString& rID, const rtl::OUString& rUIXMLDescription, WindowType nType) : SystemWindow( nType ) + , mpDialogParent(pParent) //will be unset in doDeferredInit { ImplInitDialogData(); - ImplInit(pParent, WB_SIZEMOVE|WB_3DLOOK|WB_CLOSEABLE); m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID); } diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx index 4edc3e99e2cf..c7189d350400 100644 --- a/vcl/source/window/window2.cxx +++ b/vcl/source/window/window2.cxx @@ -1967,9 +1967,9 @@ bool Window::set_property(const rtl::OString &rKey, const rtl::OString &rValue) else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("resizable"))) { WinBits nBits = GetStyle(); - nBits &= ~(WB_SIZEMOVE); + nBits &= ~(WB_SIZEABLE); if (toBool(rValue)) - nBits |= WB_SIZEMOVE; + nBits |= WB_SIZEABLE; SetStyle(nBits); } else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("xalign"))) -- cgit