From e0dc13d470f31c31f38927a2565b94cd126ddf9a Mon Sep 17 00:00:00 2001 From: Benjamin Williams Date: Wed, 8 Nov 2006 19:07:52 +0000 Subject: [PATCH 1/1] wxAuiMDI* patches through images to wxAuiNotebook git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43206 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/aui/auibook.h | 7 +++++-- include/wx/aui/tabmdi.h | 36 ++++++++++++++++++++--------------- src/aui/auibook.cpp | 41 ++++++++++++++++++++++++++++++++++++++-- src/aui/tabmdi.cpp | 40 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 105 insertions(+), 19 deletions(-) diff --git a/include/wx/aui/auibook.h b/include/wx/aui/auibook.h index 0d1dd76910..a5dd8de96b 100644 --- a/include/wx/aui/auibook.h +++ b/include/wx/aui/auibook.h @@ -385,7 +385,7 @@ public: virtual ~wxAuiTabContainer(); void SetArtProvider(wxAuiTabArt* art); - wxAuiTabArt* GetArtProvider(); + wxAuiTabArt* GetArtProvider() const; void SetFlags(unsigned int flags); unsigned int GetFlags() const; @@ -517,13 +517,16 @@ public: void SetWindowStyleFlag(long style); bool SetPageText(size_t page, const wxString& text); + bool SetPageBitmap(size_t page, const wxBitmap& bitmap); size_t SetSelection(size_t new_page); int GetSelection() const; size_t GetPageCount() const; wxWindow* GetPage(size_t page_idx) const; + int GetPageIndex(wxWindow* page_wnd) const; + void SetArtProvider(wxAuiTabArt* art); - wxAuiTabArt* GetArtProvider(); + wxAuiTabArt* GetArtProvider() const; protected: diff --git a/include/wx/aui/tabmdi.h b/include/wx/aui/tabmdi.h index d5c3a8ebe3..cf0d4b9a59 100644 --- a/include/wx/aui/tabmdi.h +++ b/include/wx/aui/tabmdi.h @@ -144,6 +144,12 @@ public: virtual void SetTitle(const wxString& title); virtual wxString GetTitle() const; + virtual void SetIcons(const wxIconBundle& icons); + virtual const wxIconBundle& GetIcons() const; + + virtual void SetIcon(const wxIcon& icon); + virtual const wxIcon& GetIcon() const; + virtual void Activate(); virtual bool Destroy(); @@ -176,9 +182,6 @@ public: virtual wxToolBar *GetToolBar() const { return (wxToolBar*)NULL; } #endif - // no icon - void SetIcon(const wxIcon& WXUNUSED(icon)) { } - void SetIcons(const wxIconBundle& WXUNUSED(icons)) { } // no maximize etc virtual void Maximize(bool WXUNUSED(maximize) = true) { /* Has no effect */ } @@ -197,20 +200,9 @@ public: void SetMDIParentFrame(wxAuiMDIParentFrame* parent); wxAuiMDIParentFrame* GetMDIParentFrame() const; - -protected: - wxAuiMDIParentFrame *m_pMDIParentFrame; - wxRect m_mdi_newrect; - wxRect m_mdi_currect; - wxString m_title; - -#if wxUSE_MENUS - wxMenuBar *m_pMenuBar; -#endif // wxUSE_MENUS - + protected: void Init(); - virtual bool Show(bool show = true); virtual void DoSetSize(int x, int y, int width, int height, int size_flags); virtual void DoMoveWindow(int x, int y, int width, int height); @@ -222,6 +214,20 @@ public: void ApplyMDIChildFrameRect(); void DoShow(bool show); +protected: + wxAuiMDIParentFrame* m_pMDIParentFrame; + wxRect m_mdi_newrect; + wxRect m_mdi_currect; + wxString m_title; + wxIcon m_icon; + wxIconBundle m_icon_bundle; + +#if wxUSE_MENUS + wxMenuBar* m_pMenuBar; +#endif // wxUSE_MENUS + + + private: DECLARE_DYNAMIC_CLASS(wxAuiMDIChildFrame) DECLARE_EVENT_TABLE() diff --git a/src/aui/auibook.cpp b/src/aui/auibook.cpp index faf1c52a02..99276ef5eb 100644 --- a/src/aui/auibook.cpp +++ b/src/aui/auibook.cpp @@ -1181,7 +1181,7 @@ void wxAuiTabContainer::SetArtProvider(wxAuiTabArt* art) } } -wxAuiTabArt* wxAuiTabContainer::GetArtProvider() +wxAuiTabArt* wxAuiTabContainer::GetArtProvider() const { return m_art; } @@ -2381,7 +2381,7 @@ int wxAuiNotebook::CalculateTabCtrlHeight() } -wxAuiTabArt* wxAuiNotebook::GetArtProvider() +wxAuiTabArt* wxAuiNotebook::GetArtProvider() const { return m_tabs.GetArtProvider(); } @@ -2548,6 +2548,15 @@ bool wxAuiNotebook::RemovePage(size_t page_idx) return true; } +// GetPageIndex() returns the index of the page, or -1 if the +// page could not be located in the notebook +int wxAuiNotebook::GetPageIndex(wxWindow* page_wnd) const +{ + return m_tabs.GetIdxFromWindow(page_wnd); +} + + + // SetPageText() changes the tab caption of the specified page bool wxAuiNotebook::SetPageText(size_t page_idx, const wxString& text) { @@ -2572,6 +2581,34 @@ bool wxAuiNotebook::SetPageText(size_t page_idx, const wxString& text) return true; } + +bool wxAuiNotebook::SetPageBitmap(size_t page_idx, const wxBitmap& bitmap) +{ + if (page_idx >= m_tabs.GetPageCount()) + return false; + + // update our own tab catalog + wxAuiNotebookPage& page_info = m_tabs.GetPage(page_idx); + page_info.bitmap = bitmap; + + // tab height might have changed + SetTabCtrlHeight(CalculateTabCtrlHeight()); + + // update what's on screen + wxAuiTabCtrl* ctrl; + int ctrl_idx; + if (FindTab(page_info.window, &ctrl, &ctrl_idx)) + { + wxAuiNotebookPage& info = ctrl->GetPage(ctrl_idx); + info.bitmap = bitmap; + ctrl->Refresh(); + ctrl->Update(); + } + + return true; +} + + // GetSelection() returns the index of the currently active page int wxAuiNotebook::GetSelection() const { diff --git a/src/aui/tabmdi.cpp b/src/aui/tabmdi.cpp index 53ecc2bf2a..c216c63588 100644 --- a/src/aui/tabmdi.cpp +++ b/src/aui/tabmdi.cpp @@ -495,6 +495,46 @@ wxString wxAuiMDIChildFrame::GetTitle() const return m_title; } +void wxAuiMDIChildFrame::SetIcons(const wxIconBundle& icons) +{ + // get icon with the system icon size + SetIcon(icons.GetIcon(-1)); + m_icon_bundle = icons; +} + +const wxIconBundle& wxAuiMDIChildFrame::GetIcons() const +{ + return m_icon_bundle; +} + +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); + + wxAuiMDIClientWindow* pClientWindow = pParentFrame->GetClientWindow(); + if (pClientWindow != NULL) + { + int idx = pClientWindow->GetPageIndex(this); + + if (idx != -1) + { + pClientWindow->SetPageBitmap((size_t)idx, bmp); + } + } +} + +const wxIcon& wxAuiMDIChildFrame::GetIcon() const +{ + return m_icon; +} + + void wxAuiMDIChildFrame::Activate() { wxAuiMDIParentFrame* pParentFrame = GetMDIParentFrame(); -- 2.47.2