diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-10-18 16:00:25 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-10-19 16:28:53 +0100 |
commit | 6f7cd8f4238060249de11c4ec7d167c439f7a781 (patch) | |
tree | ec0679ec4271a773368fbe6a21081995741a91d4 /vcl/source | |
parent | 7320d7a4a4dd0657f2d650a6f580ad399529f0f1 (diff) |
add menubar support to vclbuilder
Change-Id: Ibe9a820f178a955eec21b96796e346d785b835b6
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/window/builder.cxx | 24 | ||||
-rw-r--r-- | vcl/source/window/dialog.cxx | 11 |
2 files changed, 24 insertions, 11 deletions
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) { } |