From ff023ef6b373d331ed7cb8a0141ef7303d282419 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 12 May 2018 19:34:54 +0200 Subject: [PATCH 01/13] Don't show docview sample --mdi option in help if it's not supported No real changes, just avoid describing the "--mdi" option in the help message if it's not really supported in this library build. --- samples/docview/docview.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/samples/docview/docview.cpp b/samples/docview/docview.cpp index 6b352d5f38..5103b14d74 100644 --- a/samples/docview/docview.cpp +++ b/samples/docview/docview.cpp @@ -92,7 +92,9 @@ MyApp::MyApp() namespace CmdLineOption { +#if wxUSE_MDI_ARCHITECTURE const char * const MDI = "mdi"; +#endif // wxUSE_MDI_ARCHITECTURE const char * const SDI = "sdi"; const char * const SINGLE = "single"; @@ -102,8 +104,10 @@ void MyApp::OnInitCmdLine(wxCmdLineParser& parser) { wxApp::OnInitCmdLine(parser); +#if wxUSE_MDI_ARCHITECTURE parser.AddSwitch("", CmdLineOption::MDI, "run in MDI mode: multiple documents, single window"); +#endif // wxUSE_MDI_ARCHITECTURE parser.AddSwitch("", CmdLineOption::SDI, "run in SDI mode: multiple documents, multiple windows"); parser.AddSwitch("", CmdLineOption::SINGLE, From 826ab19ac914716726acd5f522fad9e827f7b444 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 12 May 2018 19:51:03 +0200 Subject: [PATCH 02/13] Add missing wxUSE_MDI check to wxAUI MDI header The implementation file already checked for both wxUSE_AUI && wxUSE_MDI, but wx/aui/tabmdi.h didn't check the value of the latter -- do it now. --- include/wx/aui/tabmdi.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/wx/aui/tabmdi.h b/include/wx/aui/tabmdi.h index 2922d3a84b..1e8976f9da 100644 --- a/include/wx/aui/tabmdi.h +++ b/include/wx/aui/tabmdi.h @@ -11,7 +11,7 @@ #ifndef _WX_AUITABMDI_H_ #define _WX_AUITABMDI_H_ -#if wxUSE_AUI +#if wxUSE_AUI && wxUSE_MDI // ---------------------------------------------------------------------------- // headers @@ -265,6 +265,6 @@ private: wxDECLARE_DYNAMIC_CLASS(wxAuiMDIClientWindow); wxDECLARE_EVENT_TABLE(); }; -#endif // wxUSE_AUI +#endif // wxUSE_AUI && wxUSE_MDI #endif // _WX_AUITABMDI_H_ From c1bcf16eb92db20db9dd2842e0facc116cbdb0c7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 12 May 2018 23:40:57 +0200 Subject: [PATCH 03/13] Derive wxAuiMDIChildFrame from wxFrame for consistency Make it easier to use AUI-based MDI child frame class instead of normal wxMDIChildFrame itself by inheriting it from the same base class. This also allows to get rid of duplicate stubs in wxAuiMDIChildFrame. --- include/wx/aui/tabmdi.h | 45 ++--------------------------------------- src/aui/tabmdi.cpp | 27 +++++-------------------- 2 files changed, 7 insertions(+), 65 deletions(-) diff --git a/include/wx/aui/tabmdi.h b/include/wx/aui/tabmdi.h index 1e8976f9da..bcbb2f5cad 100644 --- a/include/wx/aui/tabmdi.h +++ b/include/wx/aui/tabmdi.h @@ -21,6 +21,7 @@ #include "wx/panel.h" #include "wx/notebook.h" #include "wx/icon.h" +#include "wx/mdi.h" #include "wx/aui/auibook.h" //----------------------------------------------------------------------------- @@ -115,7 +116,7 @@ private: // wxAuiMDIChildFrame //----------------------------------------------------------------------------- -class WXDLLIMPEXP_AUI wxAuiMDIChildFrame : public wxPanel +class WXDLLIMPEXP_AUI wxAuiMDIChildFrame : public wxTDIChildFrame { public: wxAuiMDIChildFrame(); @@ -142,7 +143,6 @@ public: #endif // wxUSE_MENUS virtual void SetTitle(const wxString& title); - virtual wxString GetTitle() const; virtual void SetIcons(const wxIconBundle& icons); virtual const wxIconBundle& GetIcons() const; @@ -155,43 +155,7 @@ public: virtual bool Show(bool show = true) wxOVERRIDE; -#if wxUSE_STATUSBAR - // no status bars - virtual wxStatusBar* CreateStatusBar(int WXUNUSED(number) = 1, - long WXUNUSED(style) = 1, - wxWindowID WXUNUSED(winid) = 1, - const wxString& WXUNUSED(name) = wxEmptyString) - { return NULL; } - - virtual wxStatusBar *GetStatusBar() const { return NULL; } - virtual void SetStatusText( const wxString &WXUNUSED(text), int WXUNUSED(number)=0 ) {} - virtual void SetStatusWidths( int WXUNUSED(n), const int WXUNUSED(widths_field)[] ) {} -#endif - -#if wxUSE_TOOLBAR - // no toolbar bars - virtual wxToolBar* CreateToolBar(long WXUNUSED(style), - wxWindowID WXUNUSED(winid), - const wxString& WXUNUSED(name)) - { return NULL; } - virtual wxToolBar *GetToolBar() const { return NULL; } -#endif - - - // no maximize etc - virtual void Maximize(bool WXUNUSED(maximize) = true) { /* Has no effect */ } - virtual void Restore() { /* Has no effect */ } - virtual void Iconize(bool WXUNUSED(iconize) = true) { /* Has no effect */ } - virtual bool IsMaximized() const { return true; } - virtual bool IsIconized() const { return false; } - virtual bool ShowFullScreen(bool WXUNUSED(show), long WXUNUSED(style)) { return false; } - virtual bool IsFullScreen() const { return false; } - - virtual bool IsTopLevel() const wxOVERRIDE { return false; } - void OnMenuHighlight(wxMenuEvent& evt); - void OnActivate(wxActivateEvent& evt); - void OnCloseWindow(wxCloseEvent& evt); void SetMDIParentFrame(wxAuiMDIParentFrame* parent); wxAuiMDIParentFrame* GetMDIParentFrame() const; @@ -201,10 +165,6 @@ protected: virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags) wxOVERRIDE; virtual void DoMoveWindow(int x, int y, int width, int height) wxOVERRIDE; - // no size hints - virtual void DoSetSizeHints(int WXUNUSED(minW), int WXUNUSED(minH), - int WXUNUSED(maxW), int WXUNUSED(maxH), - int WXUNUSED(incW), int WXUNUSED(incH)) wxOVERRIDE {} public: // This function needs to be called when a size change is confirmed, // we needed this function to prevent anybody from the outside @@ -216,7 +176,6 @@ protected: wxAuiMDIParentFrame* m_pMDIParentFrame; wxRect m_mdiNewRect; wxRect m_mdiCurRect; - wxString m_title; wxIcon m_icon; wxIconBundle m_iconBundle; bool m_activateOnCreate; diff --git a/src/aui/tabmdi.cpp b/src/aui/tabmdi.cpp index c484d9b701..7d416987b9 100644 --- a/src/aui/tabmdi.cpp +++ b/src/aui/tabmdi.cpp @@ -423,12 +423,10 @@ void wxAuiMDIParentFrame::Tile(wxOrientation orient) // wxAuiMDIChildFrame //----------------------------------------------------------------------------- -wxIMPLEMENT_DYNAMIC_CLASS(wxAuiMDIChildFrame, wxPanel); +wxIMPLEMENT_DYNAMIC_CLASS(wxAuiMDIChildFrame, wxFrame); -wxBEGIN_EVENT_TABLE(wxAuiMDIChildFrame, wxPanel) +wxBEGIN_EVENT_TABLE(wxAuiMDIChildFrame, wxFrame) EVT_MENU_HIGHLIGHT_ALL(wxAuiMDIChildFrame::OnMenuHighlight) - EVT_ACTIVATE(wxAuiMDIChildFrame::OnActivate) - EVT_CLOSE(wxAuiMDIChildFrame::OnCloseWindow) wxEND_EVENT_TABLE() wxAuiMDIChildFrame::wxAuiMDIChildFrame() @@ -501,7 +499,7 @@ bool wxAuiMDIChildFrame::Create(wxAuiMDIParentFrame* parent, wxSize cli_size = pClientWindow->GetClientSize(); // create the window off-screen to prevent flicker - wxPanel::Create(pClientWindow, + wxWindow::Create(pClientWindow, id, wxPoint(cli_size.x+1, cli_size.y+1), size, @@ -609,11 +607,6 @@ void wxAuiMDIChildFrame::SetTitle(const wxString& title) } } -wxString wxAuiMDIChildFrame::GetTitle() const -{ - return m_title; -} - void wxAuiMDIChildFrame::SetIcons(const wxIconBundle& icons) { // get icon with the system icon size @@ -689,16 +682,6 @@ void wxAuiMDIChildFrame::OnMenuHighlight(wxMenuEvent& event) #endif // wxUSE_STATUSBAR } -void wxAuiMDIChildFrame::OnActivate(wxActivateEvent& WXUNUSED(event)) -{ - // do nothing -} - -void wxAuiMDIChildFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) -{ - Destroy(); -} - void wxAuiMDIChildFrame::SetMDIParentFrame(wxAuiMDIParentFrame* parentFrame) { m_pMDIParentFrame = parentFrame; @@ -743,7 +726,7 @@ void wxAuiMDIChildFrame::DoSetSize(int x, int y, int width, int height, int size { m_mdiNewRect = wxRect(x, y, width, height); #ifdef __WXGTK__ - wxPanel::DoSetSize(x,y,width, height, sizeFlags); + wxWindow::DoSetSize(x,y,width, height, sizeFlags); #else wxUnusedVar(sizeFlags); #endif @@ -758,7 +741,7 @@ void wxAuiMDIChildFrame::ApplyMDIChildFrameRect() { if (m_mdiCurRect != m_mdiNewRect) { - wxPanel::DoMoveWindow(m_mdiNewRect.x, m_mdiNewRect.y, + wxWindow::DoMoveWindow(m_mdiNewRect.x, m_mdiNewRect.y, m_mdiNewRect.width, m_mdiNewRect.height); m_mdiCurRect = m_mdiNewRect; } From ceee16c01a884bb073f0e42fa62b242f6a3ba127 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 12 May 2018 23:57:42 +0200 Subject: [PATCH 04/13] Remove sizing hacks from wxAuiMDIChildFrame There doesn't seem to be any reason for overriding DoSetSize() and DoMoveWindow(), so just stop doing it. Notice that this was already changed for wxGTK many years ago in a94476deb9c1a778001aeb84e6e95df719c9bc17 and there is no reason to use different code wxGTK and other ports. --- include/wx/aui/tabmdi.h | 5 ----- src/aui/auibook.cpp | 8 -------- src/aui/tabmdi.cpp | 35 ----------------------------------- 3 files changed, 48 deletions(-) diff --git a/include/wx/aui/tabmdi.h b/include/wx/aui/tabmdi.h index bcbb2f5cad..842e9dd805 100644 --- a/include/wx/aui/tabmdi.h +++ b/include/wx/aui/tabmdi.h @@ -162,8 +162,6 @@ public: protected: void Init(); - virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags) wxOVERRIDE; - virtual void DoMoveWindow(int x, int y, int width, int height) wxOVERRIDE; public: // This function needs to be called when a size change is confirmed, @@ -174,8 +172,6 @@ public: protected: wxAuiMDIParentFrame* m_pMDIParentFrame; - wxRect m_mdiNewRect; - wxRect m_mdiCurRect; wxIcon m_icon; wxIconBundle m_iconBundle; bool m_activateOnCreate; @@ -218,7 +214,6 @@ protected: void PageChanged(int oldSelection, int newSelection); void OnPageClose(wxAuiNotebookEvent& evt); void OnPageChanged(wxAuiNotebookEvent& evt); - void OnSize(wxSizeEvent& evt); private: wxDECLARE_DYNAMIC_CLASS(wxAuiMDIClientWindow); diff --git a/src/aui/auibook.cpp b/src/aui/auibook.cpp index d7f5d5e57b..f01a58c46b 100644 --- a/src/aui/auibook.cpp +++ b/src/aui/auibook.cpp @@ -1595,14 +1595,6 @@ public: } // TODO: else if (GetFlags() & wxAUI_NB_LEFT){} // TODO: else if (GetFlags() & wxAUI_NB_RIGHT){} - -#if wxUSE_MDI - if (wxDynamicCast(page.window, wxAuiMDIChildFrame)) - { - wxAuiMDIChildFrame* wnd = (wxAuiMDIChildFrame*)page.window; - wnd->ApplyMDIChildFrameRect(); - } -#endif } } diff --git a/src/aui/tabmdi.cpp b/src/aui/tabmdi.cpp index 7d416987b9..30a781cbc8 100644 --- a/src/aui/tabmdi.cpp +++ b/src/aui/tabmdi.cpp @@ -722,32 +722,6 @@ void wxAuiMDIChildFrame::DoShow(bool show) wxWindow::Show(show); } -void wxAuiMDIChildFrame::DoSetSize(int x, int y, int width, int height, int sizeFlags) -{ - m_mdiNewRect = wxRect(x, y, width, height); -#ifdef __WXGTK__ - wxWindow::DoSetSize(x,y,width, height, sizeFlags); -#else - wxUnusedVar(sizeFlags); -#endif -} - -void wxAuiMDIChildFrame::DoMoveWindow(int x, int y, int width, int height) -{ - m_mdiNewRect = wxRect(x, y, width, height); -} - -void wxAuiMDIChildFrame::ApplyMDIChildFrameRect() -{ - if (m_mdiCurRect != m_mdiNewRect) - { - wxWindow::DoMoveWindow(m_mdiNewRect.x, m_mdiNewRect.y, - m_mdiNewRect.width, m_mdiNewRect.height); - m_mdiCurRect = m_mdiNewRect; - } -} - - //----------------------------------------------------------------------------- // wxAuiMDIClientWindow //----------------------------------------------------------------------------- @@ -757,7 +731,6 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxAuiMDIClientWindow, wxAuiNotebook); wxBEGIN_EVENT_TABLE(wxAuiMDIClientWindow, wxAuiNotebook) EVT_AUINOTEBOOK_PAGE_CHANGED(wxID_ANY, wxAuiMDIClientWindow::OnPageChanged) EVT_AUINOTEBOOK_PAGE_CLOSE(wxID_ANY, wxAuiMDIClientWindow::OnPageClose) - EVT_SIZE(wxAuiMDIClientWindow::OnSize) wxEND_EVENT_TABLE() wxAuiMDIClientWindow::wxAuiMDIClientWindow() @@ -874,13 +847,5 @@ void wxAuiMDIClientWindow::OnPageChanged(wxAuiNotebookEvent& evt) PageChanged(evt.GetOldSelection(), evt.GetSelection()); } -void wxAuiMDIClientWindow::OnSize(wxSizeEvent& evt) -{ - wxAuiNotebook::OnSize(evt); - - for (size_t pos = 0; pos < GetPageCount(); pos++) - ((wxAuiMDIChildFrame *)GetPage(pos))->ApplyMDIChildFrameRect(); -} - #endif //wxUSE_AUI #endif // wxUSE_MDI From 24e06054fc485e2d0cf6aade6dfd459a8db996e1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 12 May 2018 23:49:45 +0200 Subject: [PATCH 05/13] Remove wxAuiMDIChildFrame::DoShow() This method is confusing as it's not used for implementing Show(), which is the usual naming convention when both Foo() and DoFoo() members exist, and gives no clear indication about what does it really do. Just call wxWindow::Show() directly instead. Also create the wxAuiMDIChildFrame window hidden from the beginning, instead of creating it in a visible state and then hiding it. --- include/wx/aui/tabmdi.h | 1 - src/aui/auibook.cpp | 2 +- src/aui/tabmdi.cpp | 14 +++----------- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/include/wx/aui/tabmdi.h b/include/wx/aui/tabmdi.h index 842e9dd805..3fa2b16993 100644 --- a/include/wx/aui/tabmdi.h +++ b/include/wx/aui/tabmdi.h @@ -168,7 +168,6 @@ public: // we needed this function to prevent anybody from the outside // changing the panel... it messes the UI layout when we would allow it. void ApplyMDIChildFrameRect(); - void DoShow(bool show); protected: wxAuiMDIParentFrame* m_pMDIParentFrame; diff --git a/src/aui/auibook.cpp b/src/aui/auibook.cpp index f01a58c46b..0a37a469ba 100644 --- a/src/aui/auibook.cpp +++ b/src/aui/auibook.cpp @@ -930,7 +930,7 @@ static void ShowWnd(wxWindow* wnd, bool show) if (wxDynamicCast(wnd, wxAuiMDIChildFrame)) { wxAuiMDIChildFrame* cf = (wxAuiMDIChildFrame*)wnd; - cf->DoShow(show); + cf->wxWindow::Show(show); } else #endif diff --git a/src/aui/tabmdi.cpp b/src/aui/tabmdi.cpp index 30a781cbc8..c088931844 100644 --- a/src/aui/tabmdi.cpp +++ b/src/aui/tabmdi.cpp @@ -496,17 +496,14 @@ bool wxAuiMDIChildFrame::Create(wxAuiMDIParentFrame* parent, if (style & wxMINIMIZE) m_activateOnCreate = false; - wxSize cli_size = pClientWindow->GetClientSize(); - - // create the window off-screen to prevent flicker + // create the window hidden to prevent flicker + wxWindow::Show(false); wxWindow::Create(pClientWindow, id, - wxPoint(cli_size.x+1, cli_size.y+1), + wxDefaultPosition, size, wxNO_BORDER, name); - DoShow(false); - SetMDIParentFrame(parent); m_title = title; @@ -717,11 +714,6 @@ bool wxAuiMDIChildFrame::Show(bool show) return true; } -void wxAuiMDIChildFrame::DoShow(bool show) -{ - wxWindow::Show(show); -} - //----------------------------------------------------------------------------- // wxAuiMDIClientWindow //----------------------------------------------------------------------------- From 2e5554019a4711172ca9dd11c7c56c7da3ccaa8b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 13 May 2018 00:10:41 +0200 Subject: [PATCH 06/13] Allow calling wxAuiMDIChildFrame::Show() Even if it doesn't do anything, allow calling this method even after creating the child frame for consistency with the normal MDI implementation. --- src/aui/tabmdi.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/aui/tabmdi.cpp b/src/aui/tabmdi.cpp index c088931844..86e7887ecf 100644 --- a/src/aui/tabmdi.cpp +++ b/src/aui/tabmdi.cpp @@ -700,14 +700,6 @@ void wxAuiMDIChildFrame::Init() bool wxAuiMDIChildFrame::Show(bool show) { - // wxAuiMDIChildFrame uses m_activateOnCreate only to decide whether to - // activate the frame when it is created. After Create() is called, - // m_activateOnCreate will never be read again. Therefore, calling this - // function after Create() is pointless and you probably want to call - // Activate() instead. - wxCHECK_MSG( !GetHandle(), false, - wxS("Show() has no effect after Create(). Do you mean Activate()?") ); - m_activateOnCreate = show; // do nothing From 6cdd564237b9ac419d20634e52da849d605deb2f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 13 May 2018 02:33:05 +0200 Subject: [PATCH 07/13] Redo layout from wxAuiMDIChildFrame::Show() This makes using this class more similar to using wxMDIChildFrame and fixes the initial appearance of docview sample child windows in AUI mode. --- src/aui/tabmdi.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/aui/tabmdi.cpp b/src/aui/tabmdi.cpp index 86e7887ecf..0d2450c65f 100644 --- a/src/aui/tabmdi.cpp +++ b/src/aui/tabmdi.cpp @@ -702,7 +702,18 @@ bool wxAuiMDIChildFrame::Show(bool show) { m_activateOnCreate = show; - // do nothing + if ( show ) + { + // This is not a real TLW, so it won't get a size event when it's + // really "mapped", i.e. appears on the screen for the first time. + // Instead, its size had been already set when it was created and we + // didn't have any opportunity to lay it out since then, i.e. since + // before its children were created. Do it now to allow the same code + // that would work with a "real" wxMDIChildFrame to also work with this + // class. + DoLayout(); + } + return true; } From c756d18bc4e9800e913643a70092a12a679b239a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 13 May 2018 00:11:41 +0200 Subject: [PATCH 08/13] Allow using AUI-based MDI classes in the docview sample For testing, allow using wxAuiMDI{Parent,Child}Frame in the sample. This change also shows that the AUI classes are now sufficiently compatible with the standard ones for switching to them to be almost trivial. --- samples/docview/Makefile.in | 5 +- samples/docview/docview.bkl | 1 + samples/docview/docview.cpp | 140 ++++++++++++++++++++--------- samples/docview/docview.h | 3 + samples/docview/docview_vc7.vcproj | 8 +- samples/docview/docview_vc8.vcproj | 16 ++-- samples/docview/docview_vc9.vcproj | 16 ++-- samples/docview/makefile.bcc | 6 +- samples/docview/makefile.gcc | 6 +- samples/docview/makefile.unx | 2 +- samples/docview/makefile.vc | 6 +- 11 files changed, 143 insertions(+), 66 deletions(-) diff --git a/samples/docview/Makefile.in b/samples/docview/Makefile.in index 8415a78332..9c174054d5 100644 --- a/samples/docview/Makefile.in +++ b/samples/docview/Makefile.in @@ -98,6 +98,9 @@ COND_PLATFORM_OS2_1___docview___os2_emxbindcmd = $(NM) docview$(EXEEXT) | if \ @COND_TOOLKIT_OSX_IPHONE@ = $(__docview_app_Contents_PkgInfo___depname) @COND_TOOLKIT_COCOA@____docview_BUNDLE_TGT_REF_DEP = \ @COND_TOOLKIT_COCOA@ $(__docview_app_Contents_PkgInfo___depname) +COND_MONOLITHIC_0___WXLIB_AUI_p = \ + -lwx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_aui-$(WX_RELEASE)$(HOST_SUFFIX) +@COND_MONOLITHIC_0@__WXLIB_AUI_p = $(COND_MONOLITHIC_0___WXLIB_AUI_p) COND_MONOLITHIC_0___WXLIB_CORE_p = \ -lwx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_core-$(WX_RELEASE)$(HOST_SUFFIX) @COND_MONOLITHIC_0@__WXLIB_CORE_p = $(COND_MONOLITHIC_0___WXLIB_CORE_p) @@ -148,7 +151,7 @@ distclean: clean rm -f config.cache config.log config.status bk-deps bk-make-pch shared-ld-sh Makefile docview$(EXEEXT): $(DOCVIEW_OBJECTS) $(__docview___win32rc) - $(CXX) -o $@ $(DOCVIEW_OBJECTS) -L$(LIBDIRNAME) $(LDFLAGS_GUI) $(SAMPLES_RPATH_FLAG) $(LDFLAGS) $(__WXLIB_CORE_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_SCINTILLA_IF_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) $(EXTRALIBS_FOR_GUI) $(__LIB_ZLIB_p) $(__LIB_REGEX_p) $(__LIB_EXPAT_p) $(EXTRALIBS_FOR_BASE) $(LIBS) + $(CXX) -o $@ $(DOCVIEW_OBJECTS) -L$(LIBDIRNAME) $(LDFLAGS_GUI) $(SAMPLES_RPATH_FLAG) $(LDFLAGS) $(__WXLIB_AUI_p) $(__WXLIB_CORE_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_SCINTILLA_IF_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) $(EXTRALIBS_FOR_GUI) $(__LIB_ZLIB_p) $(__LIB_REGEX_p) $(__LIB_EXPAT_p) $(EXTRALIBS_FOR_BASE) $(LIBS) $(__docview___os2_emxbindcmd) @COND_PLATFORM_MACOSX_1@docview.app/Contents/PkgInfo: docview$(EXEEXT) $(srcdir)/Info.plist.in $(srcdir)/doc.icns $(srcdir)/chart.icns $(srcdir)/notepad.icns diff --git a/samples/docview/docview.bkl b/samples/docview/docview.bkl index da903d0623..785f7058f5 100644 --- a/samples/docview/docview.bkl +++ b/samples/docview/docview.bkl @@ -10,6 +10,7 @@ docview.cpp doc.cpp view.cpp docview.h doc.h view.h + aui core base docview.rc diff --git a/samples/docview/docview.cpp b/samples/docview/docview.cpp index 5103b14d74..3785a06235 100644 --- a/samples/docview/docview.cpp +++ b/samples/docview/docview.cpp @@ -49,6 +49,10 @@ #include "wx/docview.h" #include "wx/docmdi.h" +#if wxUSE_AUI + #include "wx/aui/tabmdi.h" +#endif // wxUSE_AUI + #include "docview.h" #include "doc.h" #include "view.h" @@ -95,6 +99,9 @@ namespace CmdLineOption #if wxUSE_MDI_ARCHITECTURE const char * const MDI = "mdi"; #endif // wxUSE_MDI_ARCHITECTURE +#if wxUSE_AUI +const char * const AUI = "aui"; +#endif // wxUSE_AUI const char * const SDI = "sdi"; const char * const SINGLE = "single"; @@ -108,6 +115,10 @@ void MyApp::OnInitCmdLine(wxCmdLineParser& parser) parser.AddSwitch("", CmdLineOption::MDI, "run in MDI mode: multiple documents, single window"); #endif // wxUSE_MDI_ARCHITECTURE +#if wxUSE_AUI + parser.AddSwitch("", CmdLineOption::AUI, + "run in MDI mode using AUI: multiple documents, single window"); +#endif // wxUSE_AUI parser.AddSwitch("", CmdLineOption::SDI, "run in SDI mode: multiple documents, multiple windows"); parser.AddSwitch("", CmdLineOption::SINGLE, @@ -130,6 +141,14 @@ bool MyApp::OnCmdLineParsed(wxCmdLineParser& parser) } #endif // wxUSE_MDI_ARCHITECTURE +#if wxUSE_AUI + if ( parser.Found(CmdLineOption::AUI) ) + { + m_mode = Mode_AUI; + numModeOptions++; + } +#endif // wxUSE_AUI + if ( parser.Found(CmdLineOption::SDI) ) { m_mode = Mode_SDI; @@ -202,22 +221,37 @@ bool MyApp::OnInit() } // create the main frame window - wxFrame *frame; + wxFrame *frame = NULL; + switch ( m_mode ) + { #if wxUSE_MDI_ARCHITECTURE - if ( m_mode == Mode_MDI ) - { - frame = new wxDocMDIParentFrame(docManager, NULL, wxID_ANY, - GetAppDisplayName(), - wxDefaultPosition, - wxSize(500, 400)); - } - else + case Mode_MDI: + frame = new wxDocMDIParentFrame(docManager, NULL, wxID_ANY, + GetAppDisplayName(), + wxDefaultPosition, + wxSize(500, 400)); + break; #endif // wxUSE_MDI_ARCHITECTURE - { - frame = new wxDocParentFrame(docManager, NULL, wxID_ANY, - GetAppDisplayName(), - wxDefaultPosition, - wxSize(500, 400)); + +#if wxUSE_AUI + case Mode_AUI: + frame = new wxDocParentFrameAny + ( + docManager, NULL, wxID_ANY, + GetAppDisplayName(), + wxDefaultPosition, + wxSize(500, 400) + ); + break; +#endif // wxUSE_AUI + + case Mode_SDI: + case Mode_Single: + frame = new wxDocParentFrame(docManager, NULL, wxID_ANY, + GetAppDisplayName(), + wxDefaultPosition, + wxSize(500, 400)); + break; } // and its menu bar @@ -321,37 +355,55 @@ void MyApp::CreateMenuBarForFrame(wxFrame *frame, wxMenu *file, wxMenu *edit) wxFrame *MyApp::CreateChildFrame(wxView *view, bool isCanvas) { // create a child frame of appropriate class for the current mode - wxFrame *subframe; + wxFrame *subframe = NULL; wxDocument *doc = view->GetDocument(); + switch ( GetMode() ) #if wxUSE_MDI_ARCHITECTURE - if ( GetMode() == Mode_MDI ) { - subframe = new wxDocMDIChildFrame - ( - doc, - view, - wxStaticCast(GetTopWindow(), wxDocMDIParentFrame), - wxID_ANY, - "Child Frame", - wxDefaultPosition, - wxSize(300, 300) - ); - } - else + case Mode_MDI: + subframe = new wxDocMDIChildFrame + ( + doc, + view, + wxStaticCast(GetTopWindow(), wxDocMDIParentFrame), + wxID_ANY, + "Child Frame", + wxDefaultPosition, + wxSize(300, 300) + ); + break; #endif // wxUSE_MDI_ARCHITECTURE - { - subframe = new wxDocChildFrame - ( - doc, - view, - wxStaticCast(GetTopWindow(), wxDocParentFrame), - wxID_ANY, - "Child Frame", - wxDefaultPosition, - wxSize(300, 300) - ); - subframe->Centre(); +#if wxUSE_AUI + case Mode_AUI: + subframe = new wxDocChildFrameAny + ( + doc, + view, + wxStaticCast(GetTopWindow(), wxAuiMDIParentFrame), + wxID_ANY, + "Child Frame", + wxDefaultPosition, + wxSize(300, 300) + ); + break; +#endif // wxUSE_AUI + + case Mode_SDI: + case Mode_Single: + subframe = new wxDocChildFrame + ( + doc, + view, + wxStaticCast(GetTopWindow(), wxDocParentFrame), + wxID_ANY, + "Child Frame", + wxDefaultPosition, + wxSize(300, 300) + ); + + subframe->Centre(); + break; } wxMenu *menuFile = new wxMenu; @@ -396,6 +448,12 @@ void MyApp::OnAbout(wxCommandEvent& WXUNUSED(event)) break; #endif // wxUSE_MDI_ARCHITECTURE +#if wxUSE_AUI + case Mode_AUI: + modeName = "AUI"; + break; +#endif // wxUSE_AUI + case Mode_SDI: modeName = "SDI"; break; @@ -419,7 +477,7 @@ void MyApp::OnAbout(wxCommandEvent& WXUNUSED(event)) "\n" "Authors: Julian Smart, Vadim Zeitlin\n" "\n" - "Usage: docview [--{mdi,sdi,single}]", + "Usage: docview [--{mdi,aui,sdi,single}]", modeName, docsCount ); diff --git a/samples/docview/docview.h b/samples/docview/docview.h index 12e9dbc86b..27d5175f1f 100644 --- a/samples/docview/docview.h +++ b/samples/docview/docview.h @@ -27,6 +27,9 @@ public: #if wxUSE_MDI_ARCHITECTURE Mode_MDI, // MDI mode: multiple documents, single top level window #endif // wxUSE_MDI_ARCHITECTURE +#if wxUSE_AUI + Mode_AUI, // MDI AUI mode +#endif // wxUSE_AUI Mode_SDI, // SDI mode: multiple documents, multiple top level windows Mode_Single // single document mode (and hence single top level window) }; diff --git a/samples/docview/docview_vc7.vcproj b/samples/docview/docview_vc7.vcproj index c7b31a484a..cd439da1ab 100644 --- a/samples/docview/docview_vc7.vcproj +++ b/samples/docview/docview_vc7.vcproj @@ -46,7 +46,7 @@ Date: Sun, 13 May 2018 00:20:34 +0200 Subject: [PATCH 09/13] Remove useless wxAuiMDIClientWindow::SetSelection() It just called the base class version, so it's better to not have it at all. --- include/wx/aui/tabmdi.h | 1 - src/aui/tabmdi.cpp | 5 ----- 2 files changed, 6 deletions(-) diff --git a/include/wx/aui/tabmdi.h b/include/wx/aui/tabmdi.h index 3fa2b16993..e9707853fe 100644 --- a/include/wx/aui/tabmdi.h +++ b/include/wx/aui/tabmdi.h @@ -201,7 +201,6 @@ public: virtual bool CreateClient(wxAuiMDIParentFrame *parent, long style = wxVSCROLL | wxHSCROLL); - virtual int SetSelection(size_t page) wxOVERRIDE; virtual wxAuiMDIChildFrame* GetActiveChild(); virtual void SetActiveChild(wxAuiMDIChildFrame* pChildFrame) { diff --git a/src/aui/tabmdi.cpp b/src/aui/tabmdi.cpp index 0d2450c65f..0ac1316565 100644 --- a/src/aui/tabmdi.cpp +++ b/src/aui/tabmdi.cpp @@ -763,11 +763,6 @@ bool wxAuiMDIClientWindow::CreateClient(wxAuiMDIParentFrame* parent, long style) return true; } -int wxAuiMDIClientWindow::SetSelection(size_t nPage) -{ - return wxAuiNotebook::SetSelection(nPage); -} - wxAuiMDIChildFrame* wxAuiMDIClientWindow::GetActiveChild() { const int sel = GetSelection(); From be696ed8a4572d2ac8ecf6605ec4bd0b9f837c99 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 13 May 2018 02:15:30 +0200 Subject: [PATCH 10/13] Reuse base class icon-related functions in wxAuiMDIChildFrame Don't define GetIcon(), GetIcons() and SetIcon() at all as the base class already implements them and just keep SetIcons(), which can now be marked as overridden as it's inherited from wxTopLevelWindow via wxTDIChildFrame. --- include/wx/aui/tabmdi.h | 8 +------- src/aui/tabmdi.cpp | 22 ++-------------------- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/include/wx/aui/tabmdi.h b/include/wx/aui/tabmdi.h index e9707853fe..e260109ef0 100644 --- a/include/wx/aui/tabmdi.h +++ b/include/wx/aui/tabmdi.h @@ -144,11 +144,7 @@ public: virtual void SetTitle(const wxString& title); - virtual void SetIcons(const wxIconBundle& icons); - virtual const wxIconBundle& GetIcons() const; - - virtual void SetIcon(const wxIcon& icon); - virtual const wxIcon& GetIcon() const; + virtual void SetIcons(const wxIconBundle& icons) wxOVERRIDE; virtual void Activate(); virtual bool Destroy() wxOVERRIDE; @@ -171,8 +167,6 @@ public: protected: wxAuiMDIParentFrame* m_pMDIParentFrame; - wxIcon m_icon; - wxIconBundle m_iconBundle; bool m_activateOnCreate; #if wxUSE_MENUS diff --git a/src/aui/tabmdi.cpp b/src/aui/tabmdi.cpp index 0ac1316565..fc55a27e81 100644 --- a/src/aui/tabmdi.cpp +++ b/src/aui/tabmdi.cpp @@ -606,25 +606,13 @@ void wxAuiMDIChildFrame::SetTitle(const wxString& title) void wxAuiMDIChildFrame::SetIcons(const wxIconBundle& icons) { - // get icon with the system icon size - SetIcon(icons.GetIcon(-1)); - m_iconBundle = icons; -} + wxTDIChildFrame::SetIcons(icons); -const wxIconBundle& wxAuiMDIChildFrame::GetIcons() const -{ - return m_iconBundle; -} - -void wxAuiMDIChildFrame::SetIcon(const wxIcon& icon) -{ wxAuiMDIParentFrame* pParentFrame = GetMDIParentFrame(); wxASSERT_MSG(pParentFrame, wxT("Missing MDI Parent Frame")); - m_icon = icon; - wxBitmap bmp; - bmp.CopyFromIcon(m_icon); + bmp.CopyFromIcon(icons.GetIcon(-1)); wxAuiMDIClientWindow* pClientWindow = pParentFrame->GetClientWindow(); if (pClientWindow != NULL) @@ -638,12 +626,6 @@ void wxAuiMDIChildFrame::SetIcon(const wxIcon& icon) } } -const wxIcon& wxAuiMDIChildFrame::GetIcon() const -{ - return m_icon; -} - - void wxAuiMDIChildFrame::Activate() { wxAuiMDIParentFrame* pParentFrame = GetMDIParentFrame(); From a57c192023b1259f212240883421cbe7aacd5d7d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 13 May 2018 00:39:23 +0200 Subject: [PATCH 11/13] Adjust wxAuiMDIClientWindow tabs height to icons automatically Don't explicitly set the default icon size, this isn't really necessary and just prevents things from working correctly if the child frames use icons of a different (especially bigger) size. Still try to use the icons of the standard size by default, but let wxAuiNotebook adjust to bigger icons if this is what we have. --- src/aui/tabmdi.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/aui/tabmdi.cpp b/src/aui/tabmdi.cpp index fc55a27e81..97c39cf21c 100644 --- a/src/aui/tabmdi.cpp +++ b/src/aui/tabmdi.cpp @@ -611,8 +611,10 @@ void wxAuiMDIChildFrame::SetIcons(const wxIconBundle& icons) wxAuiMDIParentFrame* pParentFrame = GetMDIParentFrame(); wxASSERT_MSG(pParentFrame, wxT("Missing MDI Parent Frame")); + const wxSize sizeIcon(wxSystemSettings::GetMetric(wxSYS_SMALLICON_X), + wxSystemSettings::GetMetric(wxSYS_SMALLICON_Y)); wxBitmap bmp; - bmp.CopyFromIcon(icons.GetIcon(-1)); + bmp.CopyFromIcon(icons.GetIcon(sizeIcon)); wxAuiMDIClientWindow* pClientWindow = pParentFrame->GetClientWindow(); if (pClientWindow != NULL) @@ -723,11 +725,6 @@ bool wxAuiMDIClientWindow::CreateClient(wxAuiMDIParentFrame* parent, long style) { SetWindowStyleFlag(style); - wxSize caption_icon_size = - wxSize(wxSystemSettings::GetMetric(wxSYS_SMALLICON_X), - wxSystemSettings::GetMetric(wxSYS_SMALLICON_Y)); - SetUniformBitmapSize(caption_icon_size); - if (!wxAuiNotebook::Create(parent, wxID_ANY, wxPoint(0,0), From dca84c823c78d8f686d23a8a8efa189d17cc7d0c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 13 May 2018 02:10:34 +0200 Subject: [PATCH 12/13] Optimize away an unnecessary extra wxAuiNotebook::DoSizing() call There is no need to call DoSizing() again if it has just been called from UpdateTabCtrlHeight(). --- src/aui/auibook.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/aui/auibook.cpp b/src/aui/auibook.cpp index 0a37a469ba..2bc8d0587a 100644 --- a/src/aui/auibook.cpp +++ b/src/aui/auibook.cpp @@ -1973,8 +1973,11 @@ bool wxAuiNotebook::InsertPage(size_t page_idx, else active_tabctrl->InsertPage(page, info, page_idx); - UpdateTabCtrlHeight(); - DoSizing(); + // Note that we don't need to call DoSizing() if the height has changed, as + // it's already called from UpdateTabCtrlHeight() itself in this case. + if ( !UpdateTabCtrlHeight() ) + DoSizing(); + active_tabctrl->DoShowHide(); // adjust selected index From 4710302aecfedc7749e0dc03bc00d0f68c06c94c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 13 May 2018 02:17:47 +0200 Subject: [PATCH 13/13] Add wxOVERRIDE to all relevant wxAuiMDIChildFrame methods Now that this class derives from wxMDIChildFrameBase, SetTitle() and Activate() are inherited from it. --- include/wx/aui/tabmdi.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/wx/aui/tabmdi.h b/include/wx/aui/tabmdi.h index e260109ef0..bd98406353 100644 --- a/include/wx/aui/tabmdi.h +++ b/include/wx/aui/tabmdi.h @@ -138,15 +138,15 @@ public: const wxString& name = wxFrameNameStr); #if wxUSE_MENUS - virtual void SetMenuBar(wxMenuBar *menuBar); - virtual wxMenuBar *GetMenuBar() const; + virtual void SetMenuBar(wxMenuBar *menuBar) wxOVERRIDE; + virtual wxMenuBar *GetMenuBar() const wxOVERRIDE; #endif // wxUSE_MENUS - virtual void SetTitle(const wxString& title); + virtual void SetTitle(const wxString& title) wxOVERRIDE; virtual void SetIcons(const wxIconBundle& icons) wxOVERRIDE; - virtual void Activate(); + virtual void Activate() wxOVERRIDE; virtual bool Destroy() wxOVERRIDE; virtual bool Show(bool show = true) wxOVERRIDE;