diff options
-rw-r--r-- | include/tools/wintypes.hxx | 1 | ||||
-rw-r--r-- | include/vcl/builder.hxx | 2 | ||||
-rw-r--r-- | include/vcl/dialog.hxx | 5 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/dataproviderdlg.cxx | 2 | ||||
-rw-r--r-- | vcl/source/window/builder.cxx | 24 | ||||
-rw-r--r-- | vcl/source/window/dialog.cxx | 11 |
6 files changed, 29 insertions, 16 deletions
diff --git a/include/tools/wintypes.hxx b/include/tools/wintypes.hxx index 5bcaec41aa17..56b2e27c9362 100644 --- a/include/tools/wintypes.hxx +++ b/include/tools/wintypes.hxx @@ -119,6 +119,7 @@ WinBits const WB_BORDER = 0x00000008; WinBits const WB_NOBORDER = 0x00000010; WinBits const WB_SIZEABLE = 0x00000020; WinBits const WB_3DLOOK = 0x00000040; +WinBits const WB_ALLOWMENUBAR = 0x00000080; // Window-Bits for SystemWindows WinBits const WB_MOVEABLE = 0x00000100; diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx index 0e7a343fafbc..488ebb6389d7 100644 --- a/include/vcl/builder.hxx +++ b/include/vcl/builder.hxx @@ -379,7 +379,7 @@ private: void handleListStore(xmlreader::XmlReader &reader, const OString &rID, const OString &rClass); void handleRow(xmlreader::XmlReader &reader, const OString &rID); void handleTabChild(vcl::Window *pParent, xmlreader::XmlReader &reader); - void handleMenu(xmlreader::XmlReader &reader, const OString &rID); + VclPtr<Menu> handleMenu(xmlreader::XmlReader &reader, const OString &rID, bool bMenuBar); std::vector<ComboBoxTextItem> handleItems(xmlreader::XmlReader &reader) const; void handleSizeGroup(xmlreader::XmlReader &reader); diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx index f0a418939cde..5e4398546d04 100644 --- a/include/vcl/dialog.hxx +++ b/include/vcl/dialog.hxx @@ -50,7 +50,6 @@ private: bool mbInSyncExecute; bool mbInClose; bool mbModalMode; - bool const mbForceBorderWindow; InitFlag const mnInitFlag; // used for deferred init VclPtr<VclButtonBox> mpActionArea; @@ -83,7 +82,7 @@ public: protected: explicit Dialog( WindowType nType ); - explicit Dialog( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription, WindowType nType, InitFlag eFlag = InitFlag::Default, bool bBorder = false ); + explicit Dialog( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription, WindowType nType, InitFlag eFlag = InitFlag::Default ); virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, DrawFlags nFlags ) override; virtual void settingOptimalLayoutSize(Window *pBox) override; @@ -170,7 +169,7 @@ public: class VCL_DLLPUBLIC ModalDialog : public Dialog { public: - explicit ModalDialog( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription, bool bBorder = false ); + explicit ModalDialog( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription ); protected: using Window::Show; diff --git a/sc/source/ui/miscdlgs/dataproviderdlg.cxx b/sc/source/ui/miscdlgs/dataproviderdlg.cxx index 108a0f6b9e74..4868b560b906 100644 --- a/sc/source/ui/miscdlgs/dataproviderdlg.cxx +++ b/sc/source/ui/miscdlgs/dataproviderdlg.cxx @@ -945,7 +945,7 @@ std::shared_ptr<sc::DataTransformation> ScDateTimeTransformation::getTransformat ScDataProviderDlg::ScDataProviderDlg(vcl::Window* pParent, std::shared_ptr<ScDocument> pDoc, const ScDocument* pDocument) - : ModalDialog(pParent, "dataproviderdlg", "modules/scalc/ui/dataproviderdlg.ui", true) + : ModalDialog(pParent, "dataproviderdlg", "modules/scalc/ui/dataproviderdlg.ui") , mpDoc(std::move(pDoc)) , mpBar(VclPtr<MenuBar>::Create()) { diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index cc0e39c53e5e..34ab3d7610ab 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -1741,7 +1741,10 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & VclPtr<vcl::Window> xWindow; if (name == "GtkDialog" || name == "GtkAboutDialog" || name == "GtkAssistant") { - WinBits nBits = WB_MOVEABLE|WB_3DLOOK|WB_CLOSEABLE; + // WB_ALLOWMENUBAR because we don't know in advance if we will encounter + // a menubar, and menubars need a BorderWindow in the toplevel, and + // such border windows need to be in created during the dialog ctor + WinBits nBits = WB_MOVEABLE|WB_3DLOOK|WB_CLOSEABLE|WB_ALLOWMENUBAR; if (extractResizable(rMap)) nBits |= WB_SIZEABLE; Dialog::InitFlag eInit = !pParent ? Dialog::InitFlag::NoParent : Dialog::InitFlag::Default; @@ -3305,9 +3308,13 @@ std::vector<ComboBoxTextItem> VclBuilder::handleItems(xmlreader::XmlReader &read return aItems; } -void VclBuilder::handleMenu(xmlreader::XmlReader &reader, const OString &rID) +VclPtr<Menu> VclBuilder::handleMenu(xmlreader::XmlReader &reader, const OString &rID, bool bMenuBar) { - VclPtr<Menu> pCurrentMenu = VclPtr<PopupMenu>::Create(); + VclPtr<Menu> pCurrentMenu; + if (bMenuBar) + pCurrentMenu = VclPtr<MenuBar>::Create(); + else + pCurrentMenu = VclPtr<PopupMenu>::Create(); int nLevel = 1; @@ -3348,6 +3355,8 @@ void VclBuilder::handleMenu(xmlreader::XmlReader &reader, const OString &rID) } m_aMenus.emplace_back(rID, pCurrentMenu); + + return pCurrentMenu; } void VclBuilder::handleMenuChild(Menu *pParent, xmlreader::XmlReader &reader) @@ -3677,7 +3686,14 @@ VclPtr<vcl::Window> VclBuilder::handleObject(vcl::Window *pParent, xmlreader::Xm } else if (sClass == "GtkMenu") { - handleMenu(reader, sID); + handleMenu(reader, sID, false); + return nullptr; + } + else if (sClass == "GtkMenuBar") + { + VclPtr<Menu> xMenu = handleMenu(reader, sID, true); + if (SystemWindow* pTopLevel = pParent ? pParent->GetSystemWindow() : nullptr) + pTopLevel->SetMenuBar(dynamic_cast<MenuBar*>(xMenu.get())); return nullptr; } else if (sClass == "GtkSizeGroup") diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index c632d2ccd682..fcb40df71d7a 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -453,7 +453,7 @@ void Dialog::ImplInit( vcl::Window* pParent, WinBits nStyle, InitFlag eFlag ) (nSysWinMode & SystemWindowFlags::DIALOG) ) { // create window with a small border ? - if (mbForceBorderWindow || ((nStyle & (WB_BORDER | WB_NOBORDER | WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE)) == WB_BORDER )) + if ((nStyle & WB_ALLOWMENUBAR) || ((nStyle & (WB_BORDER | WB_NOBORDER | WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE)) == WB_BORDER)) { AddBorderWindow(pParent, nStyle); } @@ -530,7 +530,6 @@ void Dialog::ImplLOKNotifier(vcl::Window* pParent) Dialog::Dialog( WindowType nType ) : SystemWindow( nType ) - , mbForceBorderWindow(false) , mnInitFlag(InitFlag::Default) { ImplInitDialogData(); @@ -559,9 +558,8 @@ void Dialog::doDeferredInit(WinBits nBits) mbIsDeferredInit = false; } -Dialog::Dialog(vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription, WindowType nType, InitFlag eFlag, bool bBorder) +Dialog::Dialog(vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription, WindowType nType, InitFlag eFlag) : SystemWindow(nType) - , mbForceBorderWindow(bBorder) , mnInitFlag(eFlag) { ImplLOKNotifier(pParent); @@ -571,7 +569,6 @@ Dialog::Dialog(vcl::Window* pParent, const OUString& rID, const OUString& rUIXML Dialog::Dialog(vcl::Window* pParent, WinBits nStyle, InitFlag eFlag) : SystemWindow(WindowType::DIALOG) - , mbForceBorderWindow(false) , mnInitFlag(eFlag) { ImplLOKNotifier(pParent); @@ -1520,8 +1517,8 @@ VclBuilderContainer::~VclBuilderContainer() { } -ModalDialog::ModalDialog( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription, bool bBorder ) : - Dialog(pParent, rID, rUIXMLDescription, WindowType::MODALDIALOG, InitFlag::Default, bBorder) +ModalDialog::ModalDialog( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription ) : + Dialog(pParent, rID, rUIXMLDescription, WindowType::MODALDIALOG, InitFlag::Default) { } |