From 673727f39c427ed1a36924748b2459a8a56a4bef Mon Sep 17 00:00:00 2001 From: Benjamin Williams Date: Tue, 11 Jul 2006 15:24:25 +0000 Subject: [PATCH] wxFrameManager::Render() now fires a new event, called wxEVT_AUI_RENDER, which allows all main window drawing operations to be overridden to provide custom drawing behavior git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40070 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/aui/framemanager.h | 40 ++++++++++++++++++++++++----------- src/aui/framemanager.cpp | 22 +++++++++++++++++-- 2 files changed, 48 insertions(+), 14 deletions(-) diff --git a/include/wx/aui/framemanager.h b/include/wx/aui/framemanager.h index b102262131..7931b602ac 100644 --- a/include/wx/aui/framemanager.h +++ b/include/wx/aui/framemanager.h @@ -464,20 +464,25 @@ protected: virtual void ShowHint(const wxRect& rect); virtual void HideHint(); +public: + + // public events (which can be invoked externally) + void OnRender(wxFrameManagerEvent& evt); + void OnPaneButton(wxFrameManagerEvent& evt); + protected: - // events - void OnPaint(wxPaintEvent& event); - void OnEraseBackground(wxEraseEvent& event); - void OnSize(wxSizeEvent& event); - void OnSetCursor(wxSetCursorEvent& event); - void OnLeftDown(wxMouseEvent& event); - void OnLeftUp(wxMouseEvent& event); - void OnMotion(wxMouseEvent& event); - void OnLeaveWindow(wxMouseEvent& event); - void OnPaneButton(wxFrameManagerEvent& event); - void OnChildFocus(wxChildFocusEvent& event); - void OnHintFadeTimer(wxTimerEvent& event); + // protected events + void OnPaint(wxPaintEvent& evt); + void OnEraseBackground(wxEraseEvent& evt); + void OnSize(wxSizeEvent& evt); + void OnSetCursor(wxSetCursorEvent& evt); + void OnLeftDown(wxMouseEvent& evt); + void OnLeftUp(wxMouseEvent& evt); + void OnMotion(wxMouseEvent& evt); + void OnLeaveWindow(wxMouseEvent& evt); + void OnChildFocus(wxChildFocusEvent& evt); + void OnHintFadeTimer(wxTimerEvent& evt); protected: @@ -533,6 +538,7 @@ public: button = 0; veto_flag = false; canveto_flag = true; + dc = NULL; } #ifndef SWIG wxFrameManagerEvent(const wxFrameManagerEvent& c) : wxEvent(c) @@ -541,14 +547,18 @@ public: button = c.button; veto_flag = c.veto_flag; canveto_flag = c.canveto_flag; + dc = c.dc; } #endif wxEvent *Clone() const { return new wxFrameManagerEvent(*this); } void SetPane(wxPaneInfo* p) { pane = p; } void SetButton(int b) { button = b; } + void SetDC(wxDC* pdc) { dc = pdc; } + wxPaneInfo* GetPane() { return pane; } int GetButton() { return button; } + wxDC* GetDC() { return dc; } void Veto(bool veto = true) { veto_flag = veto; } bool GetVeto() const { return veto_flag; } @@ -560,6 +570,7 @@ public: int button; bool veto_flag; bool canveto_flag; + wxDC* dc; #ifndef SWIG private: @@ -676,6 +687,7 @@ public: BEGIN_DECLARE_EVENT_TYPES() DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_AUI_PANEBUTTON, 0) DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_AUI_PANECLOSE, 0) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_AUI_RENDER, 0) END_DECLARE_EVENT_TYPES() typedef void (wxEvtHandler::*wxFrameManagerEventFunction)(wxFrameManagerEvent&); @@ -687,15 +699,19 @@ typedef void (wxEvtHandler::*wxFrameManagerEventFunction)(wxFrameManagerEvent&); wx__DECLARE_EVT0(wxEVT_AUI_PANEBUTTON, wxFrameManagerEventHandler(func)) #define EVT_AUI_PANECLOSE(func) \ wx__DECLARE_EVT0(wxEVT_AUI_PANECLOSE, wxFrameManagerEventHandler(func)) +#define EVT_AUI_RENDER(func) \ + wx__DECLARE_EVT0(wxEVT_AUI_RENDER, wxFrameManagerEventHandler(func)) #else %constant wxEventType wxEVT_AUI_PANEBUTTON; %constant wxEventType wxEVT_AUI_PANECLOSE; +%constant wxEventType wxEVT_AUI_RENDER; %pythoncode { EVT_AUI_PANEBUTTON = wx.PyEventBinder( wxEVT_AUI_PANEBUTTON ) EVT_AUI_PANECLOSE = wx.PyEventBinder( wxEVT_AUI_PANECLOSE ) + EVT_AUI_RENDER = wx.PyEventBinder( wxEVT_AUI_RENDER ) } #endif // SWIG diff --git a/src/aui/framemanager.cpp b/src/aui/framemanager.cpp index 6fb198ed09..6b1c211d43 100644 --- a/src/aui/framemanager.cpp +++ b/src/aui/framemanager.cpp @@ -53,6 +53,7 @@ wxPaneInfo wxNullPaneInfo; wxDockInfo wxNullDockInfo; DEFINE_EVENT_TYPE(wxEVT_AUI_PANEBUTTON) DEFINE_EVENT_TYPE(wxEVT_AUI_PANECLOSE) +DEFINE_EVENT_TYPE(wxEVT_AUI_RENDER) #ifdef __WXMAC__ // a few defines to avoid nameclashes @@ -376,6 +377,7 @@ static int PaneSortFunc(wxPaneInfo** p1, wxPaneInfo** p2) BEGIN_EVENT_TABLE(wxFrameManager, wxEvtHandler) EVT_AUI_PANEBUTTON(wxFrameManager::OnPaneButton) + EVT_AUI_RENDER(wxFrameManager::OnRender) EVT_PAINT(wxFrameManager::OnPaint) EVT_ERASE_BACKGROUND(wxFrameManager::OnEraseBackground) EVT_SIZE(wxFrameManager::OnSize) @@ -2842,12 +2844,14 @@ void wxFrameManager::OnFloatingPaneActivated(wxWindow* wnd) } } -// Render() draws all of the pane captions, sashes, +// OnRender() draws all of the pane captions, sashes, // backgrounds, captions, grippers, pane borders and buttons. // It renders the entire user interface. -void wxFrameManager::Render(wxDC* dc) +void wxFrameManager::OnRender(wxFrameManagerEvent& evt) { + wxDC* dc = evt.GetDC(); + #ifdef __WXMAC__ dc->Clear() ; #endif @@ -2887,6 +2891,20 @@ void wxFrameManager::Render(wxDC* dc) } } + +// Render() fire a render event, which is normally handled by +// wxFrameManager::OnRender(). This allows the render function to +// be overridden via the render event. This can be useful for paintin +// custom graphics in the main window. Default behavior can be +// invoked in the overridden function by calling OnRender() + +void wxFrameManager::Render(wxDC* dc) +{ + wxFrameManagerEvent e(wxEVT_AUI_RENDER); + e.SetDC(dc); + ProcessMgrEvent(e); +} + void wxFrameManager::Repaint(wxDC* dc) { #ifdef __WXMAC__