diff options
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/uipreviewer/previewer.cxx | 19 | ||||
-rw-r--r-- | vcl/source/window/builder.cxx | 41 | ||||
-rw-r--r-- | vcl/source/window/dialog.cxx | 19 | ||||
-rw-r--r-- | vcl/source/window/floatwin.cxx | 20 | ||||
-rw-r--r-- | vcl/source/window/syswin.cxx | 17 |
5 files changed, 80 insertions, 36 deletions
diff --git a/vcl/source/uipreviewer/previewer.cxx b/vcl/source/uipreviewer/previewer.cxx index 346f4d3ccc0b..80400595f40b 100644 --- a/vcl/source/uipreviewer/previewer.cxx +++ b/vcl/source/uipreviewer/previewer.cxx @@ -70,17 +70,22 @@ int UIPreviewApp::Main() { VclBuilder aBuilder(pDialog, OUString(), uifiles[0]); - Dialog *pRealDialog = dynamic_cast<Dialog*>(aBuilder.get_widget_root()); + Window *pRoot = aBuilder.get_widget_root(); + Dialog *pRealDialog = dynamic_cast<Dialog*>(pRoot); if (!pRealDialog) pRealDialog = pDialog; - if (pRealDialog) - { - pRealDialog->SetText(OUString("LibreOffice ui-previewer")); - pRealDialog->SetStyle(pDialog->GetStyle()|WB_CLOSEABLE); - pRealDialog->Execute(); - } + pRealDialog->SetText(OUString("LibreOffice ui-previewer")); + pRealDialog->SetStyle(pDialog->GetStyle()|WB_CLOSEABLE); + /* + Force a new STATE_CHANGE_INITSHOW for the edge case where pRoot + is not a dialog or contents of a dialog, but instead a visible floating window + which may have had initshow already done before it was given children + */ + pRoot->Hide(); + pRoot->Show(); + pRealDialog->Execute(); } delete pDialog; diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 636e2278535a..3016ea67de54 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -176,7 +176,7 @@ VclBuilder::VclBuilder(Window *pParent, const OUString& sUIDir, const OUString& , m_pParserState(new ParserState) , m_xFrame(rFrame) { - m_bToplevelHasDeferredInit = pParent && pParent->IsDialog() && static_cast<Dialog*>(pParent)->isDeferredInit(); + m_bToplevelHasDeferredInit = pParent && pParent->IsSystemWindow() && static_cast<SystemWindow*>(pParent)->isDeferredInit(); m_bToplevelHasDeferredProperties = m_bToplevelHasDeferredInit; sal_Int32 nIdx = m_sHelpRoot.lastIndexOf('.'); @@ -571,6 +571,18 @@ OString VclBuilder::extractCustomProperty(VclBuilder::stringmap &rMap) namespace { + OString extractTypeHint(VclBuilder::stringmap &rMap) + { + OString sRet("normal"); + VclBuilder::stringmap::iterator aFind = rMap.find(OString("type-hint")); + if (aFind != rMap.end()) + { + sRet = aFind->second; + rMap.erase(aFind); + } + return sRet; + } + bool extractResizable(VclBuilder::stringmap &rMap) { bool bResizable = true; @@ -1571,6 +1583,21 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri return NULL; // no widget to be created } } + else if (name == "GtkWindow") + { + WinBits nBits = WB_SYSTEMWINDOW|WB_MOVEABLE|WB_3DLOOK|WB_CLOSEABLE|WB_HIDE; + if (extractResizable(rMap)) + nBits |= WB_SIZEABLE; + OString sType(extractTypeHint(rMap)); + if (sType == "utility") + { + pWindow = new FloatingWindow(pParent, nBits); + } + else + { + SAL_WARN("vcl.layout", "no mapping yet for GtkWindow of type " << sType.getStr() << " yet"); + } + } else { sal_Int32 nDelim = name.indexOf('-'); @@ -1660,13 +1687,17 @@ Window *VclBuilder::insertObject(Window *pParent, const OString &rClass, if (m_pParent && !isConsideredGtkPseudo(m_pParent) && !m_sID.isEmpty() && rID.equals(m_sID)) { pCurrentChild = m_pParent; - //toplevels default to resizable - if (pCurrentChild->IsDialog()) + + //toplevels default to resizable and apparently you can't change them + //afterwards, so we need to wait until now before we can truly + //initialize the dialog. + if (pParent->IsSystemWindow()) { - Dialog *pDialog = static_cast<Dialog*>(pCurrentChild); - pDialog->doDeferredInit(extractResizable(rProps)); + SystemWindow *pSysWin = static_cast<SystemWindow*>(pCurrentChild); + pSysWin->doDeferredInit(extractResizable(rProps)); m_bToplevelHasDeferredInit = false; } + 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 1fa6f40c9994..d23d2af64f3e 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -339,7 +339,6 @@ struct DialogImpl void Dialog::ImplInitDialogData() { mpWindowImpl->mbDialog = true; - mpDialogParent = NULL; mpPrevExecuteDlg = NULL; mbInExecute = false; mbOldSaveBack = false; @@ -450,7 +449,6 @@ void Dialog::ImplInitSettings() Dialog::Dialog( WindowType nType ) : SystemWindow( nType ) - , mbIsDefferedInit(false) { ImplInitDialogData(); } @@ -491,26 +489,21 @@ void Dialog::doDeferredInit(bool bResizable) } Dialog::Dialog(Window* pParent, const OString& rID, const OUString& rUIXMLDescription) - : SystemWindow( WINDOW_DIALOG ) - , mbIsDefferedInit(true) + : SystemWindow(WINDOW_DIALOG) { ImplInitDialogData(); - mpDialogParent = pParent; //will be unset in doDeferredInit - m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID); + loadUI(pParent, rID, rUIXMLDescription); } Dialog::Dialog(Window* pParent, const OString& rID, const OUString& rUIXMLDescription, WindowType nType) - : SystemWindow( nType ) - , mbIsDefferedInit(true) + : SystemWindow(nType) { ImplInitDialogData(); - mpDialogParent = pParent; //will be unset in doDeferredInit - m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID); + loadUI(pParent, rID, rUIXMLDescription); } -Dialog::Dialog( Window* pParent, WinBits nStyle ) - : SystemWindow( WINDOW_DIALOG ) - , mbIsDefferedInit(false) +Dialog::Dialog(Window* pParent, WinBits nStyle) + : SystemWindow(WINDOW_DIALOG) { ImplInitDialogData(); ImplInit( pParent, nStyle ); diff --git a/vcl/source/window/floatwin.cxx b/vcl/source/window/floatwin.cxx index cda5def119c9..5b35585847a4 100644 --- a/vcl/source/window/floatwin.cxx +++ b/vcl/source/window/floatwin.cxx @@ -165,8 +165,21 @@ FloatingWindow::FloatingWindow( Window* pParent, const ResId& rResId ) : } FloatingWindow::FloatingWindow(Window* pParent, const OString& rID, const OUString& rUIXMLDescription) - : SystemWindow(pParent, rID, rUIXMLDescription, WINDOW_FLOATINGWINDOW) + : SystemWindow(WINDOW_FLOATINGWINDOW) { + loadUI(pParent, rID, rUIXMLDescription); +} + +//Find the real parent stashed in mpDialogParent. +void FloatingWindow::doDeferredInit(bool bResizable) +{ + WinBits nBits = WB_MOVEABLE|WB_3DLOOK; + if (bResizable) + nBits |= WB_SIZEABLE; + Window *pParent = mpDialogParent; + mpDialogParent = NULL; + ImplInit(pParent, nBits); + mbIsDefferedInit = false; } void FloatingWindow::ImplLoadRes( const ResId& rResId ) @@ -554,6 +567,11 @@ bool FloatingWindow::Notify( NotifyEvent& rNEvt ) void FloatingWindow::StateChanged( StateChangedType nType ) { + if (nType == STATE_CHANGE_INITSHOW) + { + DoInitialLayout(); + } + SystemWindow::StateChanged( nType ); if ( nType == STATE_CHANGE_CONTROLBACKGROUND ) diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx index a3e6ef7b395e..db072cce083f 100644 --- a/vcl/source/window/syswin.cxx +++ b/vcl/source/window/syswin.cxx @@ -81,6 +81,7 @@ void SystemWindow::Init() mbInitialLayoutDone = false; mnMenuBarMode = MENUBAR_MODE_NORMAL; mnIcon = 0; + mpDialogParent = NULL; //To-Do, reuse maResizeTimer maLayoutTimer.SetTimeout(50); @@ -89,14 +90,15 @@ void SystemWindow::Init() SystemWindow::SystemWindow(WindowType nType) : Window(nType) + , mbIsDefferedInit(false) { Init(); } -SystemWindow::SystemWindow(Window* pParent, const OString& rID, const OUString& rUIXMLDescription, WindowType nType) - : Window(pParent, nType) +void SystemWindow::loadUI(Window* pParent, const OString& rID, const OUString& rUIXMLDescription) { - Init(); + mbIsDefferedInit = true; + mpDialogParent = pParent; //should be unset in doDeferredInit m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID); } @@ -1102,14 +1104,9 @@ void SystemWindow::DoInitialLayout() } } -void SystemWindow::StateChanged( StateChangedType nType ) +void SystemWindow::doDeferredInit(bool /*bResizable*/) { - Window::StateChanged(nType); - - if (nType == STATE_CHANGE_INITSHOW && !mbInitialLayoutDone) - { - DoInitialLayout(); - } + SAL_WARN("vcl.layout", "SystemWindow in layout without doDeferredInit impl"); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |