added wxAuiManager::GetManager() call

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43467 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Benjamin Williams
2006-11-17 13:07:01 +00:00
parent 28f9f58ca0
commit 4dc79cfb52
4 changed files with 69 additions and 8 deletions

View File

@@ -42,6 +42,7 @@ public:
); );
virtual ~wxAuiFloatingFrame(); virtual ~wxAuiFloatingFrame();
void SetPaneWindow(const wxAuiPaneInfo& pane); void SetPaneWindow(const wxAuiPaneInfo& pane);
wxAuiManager* GetOwnerManager() const;
protected: protected:
virtual void OnMoveStart(); virtual void OnMoveStart();
@@ -55,6 +56,7 @@ private:
void OnIdle(wxIdleEvent& event); void OnIdle(wxIdleEvent& event);
void OnActivate(wxActivateEvent& event); void OnActivate(wxActivateEvent& event);
static bool isMouseDown(); static bool isMouseDown();
private: private:
wxWindow* m_pane_window; // pane window being managed wxWindow* m_pane_window; // pane window being managed
bool m_solid_drag; // true if system uses solid window drag bool m_solid_drag; // true if system uses solid window drag
@@ -70,7 +72,7 @@ private:
#ifndef SWIG #ifndef SWIG
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
DECLARE_CLASS(wxAuiFloatingFrameBaseClass) DECLARE_CLASS(wxAuiFloatingFrame)
#endif // SWIG #endif // SWIG
}; };

View File

@@ -431,6 +431,8 @@ public:
void SetManagedWindow(wxWindow* managed_wnd); void SetManagedWindow(wxWindow* managed_wnd);
wxWindow* GetManagedWindow() const; wxWindow* GetManagedWindow() const;
static wxAuiManager* GetManager(wxWindow* window);
#ifdef SWIG #ifdef SWIG
%disownarg( wxAuiDockArt* art_provider ); %disownarg( wxAuiDockArt* art_provider );
#endif #endif
@@ -473,7 +475,6 @@ public:
void Update(); void Update();
public: public:
virtual wxAuiFloatingFrame* CreateFloatingFrame(wxWindow* parent, const wxAuiPaneInfo& p); virtual wxAuiFloatingFrame* CreateFloatingFrame(wxWindow* parent, const wxAuiPaneInfo& p);
@@ -567,6 +568,7 @@ protected:
void OnLeaveWindow(wxMouseEvent& evt); void OnLeaveWindow(wxMouseEvent& evt);
void OnChildFocus(wxChildFocusEvent& evt); void OnChildFocus(wxChildFocusEvent& evt);
void OnHintFadeTimer(wxTimerEvent& evt); void OnHintFadeTimer(wxTimerEvent& evt);
void OnFindManager(wxAuiManagerEvent& evt);
protected: protected:
@@ -610,6 +612,7 @@ protected:
#ifndef SWIG #ifndef SWIG
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
DECLARE_CLASS(wxAuiManager)
#endif // SWIG #endif // SWIG
}; };
@@ -622,6 +625,7 @@ class WXDLLIMPEXP_AUI wxAuiManagerEvent : public wxEvent
public: public:
wxAuiManagerEvent(wxEventType type=wxEVT_NULL) : wxEvent(0, type) wxAuiManagerEvent(wxEventType type=wxEVT_NULL) : wxEvent(0, type)
{ {
manager = NULL;
pane = NULL; pane = NULL;
button = 0; button = 0;
veto_flag = false; veto_flag = false;
@@ -631,6 +635,7 @@ public:
#ifndef SWIG #ifndef SWIG
wxAuiManagerEvent(const wxAuiManagerEvent& c) : wxEvent(c) wxAuiManagerEvent(const wxAuiManagerEvent& c) : wxEvent(c)
{ {
manager = c.manager;
pane = c.pane; pane = c.pane;
button = c.button; button = c.button;
veto_flag = c.veto_flag; veto_flag = c.veto_flag;
@@ -640,13 +645,15 @@ public:
#endif #endif
wxEvent *Clone() const { return new wxAuiManagerEvent(*this); } wxEvent *Clone() const { return new wxAuiManagerEvent(*this); }
void SetManager(wxAuiManager* mgr) { manager = mgr; }
void SetPane(wxAuiPaneInfo* p) { pane = p; } void SetPane(wxAuiPaneInfo* p) { pane = p; }
void SetButton(int b) { button = b; } void SetButton(int b) { button = b; }
void SetDC(wxDC* pdc) { dc = pdc; } void SetDC(wxDC* pdc) { dc = pdc; }
wxAuiPaneInfo* GetPane() { return pane; } wxAuiManager* GetManager() const { return manager; }
int GetButton() { return button; } wxAuiPaneInfo* GetPane() const { return pane; }
wxDC* GetDC() { return dc; } int GetButton() const { return button; }
wxDC* GetDC() const { return dc; }
void Veto(bool veto = true) { veto_flag = veto; } void Veto(bool veto = true) { veto_flag = veto; }
bool GetVeto() const { return veto_flag; } bool GetVeto() const { return veto_flag; }
@@ -654,6 +661,7 @@ public:
bool CanVeto() const { return canveto_flag && veto_flag; } bool CanVeto() const { return canveto_flag && veto_flag; }
public: public:
wxAuiManager* manager;
wxAuiPaneInfo* pane; wxAuiPaneInfo* pane;
int button; int button;
bool veto_flag; bool veto_flag;
@@ -778,6 +786,7 @@ BEGIN_DECLARE_EVENT_TYPES()
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_AUI_PANEMAXIMIZE, 0) DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_AUI_PANEMAXIMIZE, 0)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_AUI_PANERESTORE, 0) DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_AUI_PANERESTORE, 0)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_AUI_RENDER, 0) DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_AUI_RENDER, 0)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_AUI_FINDMANAGER, 0)
END_DECLARE_EVENT_TYPES() END_DECLARE_EVENT_TYPES()
typedef void (wxEvtHandler::*wxAuiManagerEventFunction)(wxAuiManagerEvent&); typedef void (wxEvtHandler::*wxAuiManagerEventFunction)(wxAuiManagerEvent&);
@@ -795,6 +804,8 @@ typedef void (wxEvtHandler::*wxAuiManagerEventFunction)(wxAuiManagerEvent&);
wx__DECLARE_EVT0(wxEVT_AUI_PANERESTORE, wxAuiManagerEventHandler(func)) wx__DECLARE_EVT0(wxEVT_AUI_PANERESTORE, wxAuiManagerEventHandler(func))
#define EVT_AUI_RENDER(func) \ #define EVT_AUI_RENDER(func) \
wx__DECLARE_EVT0(wxEVT_AUI_RENDER, wxAuiManagerEventHandler(func)) wx__DECLARE_EVT0(wxEVT_AUI_RENDER, wxAuiManagerEventHandler(func))
#define EVT_AUI_FINDMANAGER(func) \
wx__DECLARE_EVT0(wxEVT_AUI_FINDMANAGER, wxAuiManagerEventHandler(func))
#else #else
@@ -803,6 +814,7 @@ typedef void (wxEvtHandler::*wxAuiManagerEventFunction)(wxAuiManagerEvent&);
%constant wxEventType wxEVT_AUI_PANEMAXIMIZE; %constant wxEventType wxEVT_AUI_PANEMAXIMIZE;
%constant wxEventType wxEVT_AUI_PANERESTORE; %constant wxEventType wxEVT_AUI_PANERESTORE;
%constant wxEventType wxEVT_AUI_RENDER; %constant wxEventType wxEVT_AUI_RENDER;
%constant wxEventType wxEVT_AUI_FINDMANAGER;
%pythoncode { %pythoncode {
EVT_AUI_PANEBUTTON = wx.PyEventBinder( wxEVT_AUI_PANEBUTTON ) EVT_AUI_PANEBUTTON = wx.PyEventBinder( wxEVT_AUI_PANEBUTTON )
@@ -810,6 +822,7 @@ typedef void (wxEvtHandler::*wxAuiManagerEventFunction)(wxAuiManagerEvent&);
EVT_AUI_PANEMAXIMIZE = wx.PyEventBinder( wxEVT_AUI_PANEMAXIMIZE ) EVT_AUI_PANEMAXIMIZE = wx.PyEventBinder( wxEVT_AUI_PANEMAXIMIZE )
EVT_AUI_PANERESTORE = wx.PyEventBinder( wxEVT_AUI_PANERESTORE ) EVT_AUI_PANERESTORE = wx.PyEventBinder( wxEVT_AUI_PANERESTORE )
EVT_AUI_RENDER = wx.PyEventBinder( wxEVT_AUI_RENDER ) EVT_AUI_RENDER = wx.PyEventBinder( wxEVT_AUI_RENDER )
EVT_AUI_FINDMANAGER = wx.PyEventBinder( wxEVT_AUI_FINDMANAGER )
} }
#endif // SWIG #endif // SWIG

View File

@@ -36,7 +36,7 @@
#include "wx/msw/private.h" #include "wx/msw/private.h"
#endif #endif
IMPLEMENT_CLASS( wxAuiFloatingFrame, wxAuiFloatingFrameBaseClass ) IMPLEMENT_CLASS(wxAuiFloatingFrame, wxAuiFloatingFrameBaseClass)
wxAuiFloatingFrame::wxAuiFloatingFrame(wxWindow* parent, wxAuiFloatingFrame::wxAuiFloatingFrame(wxWindow* parent,
wxAuiManager* owner_mgr, wxAuiManager* owner_mgr,
@@ -73,7 +73,8 @@ wxAuiFloatingFrame::wxAuiFloatingFrame(wxWindow* parent,
wxAuiFloatingFrame::~wxAuiFloatingFrame() wxAuiFloatingFrame::~wxAuiFloatingFrame()
{ {
// if we do not do this, then we can crash... // if we do not do this, then we can crash...
if(m_owner_mgr && m_owner_mgr->m_action_window == this) { if(m_owner_mgr && m_owner_mgr->m_action_window == this)
{
m_owner_mgr->m_action_window = NULL; m_owner_mgr->m_action_window = NULL;
} }
m_mgr.UnInit(); m_mgr.UnInit();
@@ -131,6 +132,12 @@ void wxAuiFloatingFrame::SetPaneWindow(const wxAuiPaneInfo& pane)
} }
} }
wxAuiManager* wxAuiFloatingFrame::GetOwnerManager() const
{
return m_owner_mgr;
}
void wxAuiFloatingFrame::OnSize(wxSizeEvent& event) void wxAuiFloatingFrame::OnSize(wxSizeEvent& event)
{ {
m_owner_mgr->OnFloatingPaneResized(m_pane_window, event.GetSize()); m_owner_mgr->OnFloatingPaneResized(m_pane_window, event.GetSize());

View File

@@ -57,6 +57,7 @@ DEFINE_EVENT_TYPE(wxEVT_AUI_PANECLOSE)
DEFINE_EVENT_TYPE(wxEVT_AUI_PANEMAXIMIZE) DEFINE_EVENT_TYPE(wxEVT_AUI_PANEMAXIMIZE)
DEFINE_EVENT_TYPE(wxEVT_AUI_PANERESTORE) DEFINE_EVENT_TYPE(wxEVT_AUI_PANERESTORE)
DEFINE_EVENT_TYPE(wxEVT_AUI_RENDER) DEFINE_EVENT_TYPE(wxEVT_AUI_RENDER)
DEFINE_EVENT_TYPE(wxEVT_AUI_FINDMANAGER)
#ifdef __WXMAC__ #ifdef __WXMAC__
// a few defines to avoid nameclashes // a few defines to avoid nameclashes
@@ -66,7 +67,7 @@ DEFINE_EVENT_TYPE(wxEVT_AUI_RENDER)
#endif #endif
IMPLEMENT_DYNAMIC_CLASS(wxAuiManagerEvent, wxEvent) IMPLEMENT_DYNAMIC_CLASS(wxAuiManagerEvent, wxEvent)
IMPLEMENT_CLASS(wxAuiManager, wxEvtHandler)
// private manager flags (not yet on the public API) // private manager flags (not yet on the public API)
enum wxAuiPrivateManagerOption enum wxAuiPrivateManagerOption
@@ -485,6 +486,7 @@ BEGIN_EVENT_TABLE(wxAuiManager, wxEvtHandler)
EVT_MOTION(wxAuiManager::OnMotion) EVT_MOTION(wxAuiManager::OnMotion)
EVT_LEAVE_WINDOW(wxAuiManager::OnLeaveWindow) EVT_LEAVE_WINDOW(wxAuiManager::OnLeaveWindow)
EVT_CHILD_FOCUS(wxAuiManager::OnChildFocus) EVT_CHILD_FOCUS(wxAuiManager::OnChildFocus)
EVT_AUI_FINDMANAGER(wxAuiManager::OnFindManager)
EVT_TIMER(101, wxAuiManager::OnHintFadeTimer) EVT_TIMER(101, wxAuiManager::OnHintFadeTimer)
END_EVENT_TABLE() END_EVENT_TABLE()
@@ -635,6 +637,22 @@ wxFrame* wxAuiManager::GetFrame() const
} }
// this function will return the aui manager for a given
// window. The |window| parameter should be any child window
// or grand-child window (and so on) of the frame/window
// managed by wxAuiManager. The |window| parameter does not
// need to be managed by the manager itself.
wxAuiManager* wxAuiManager::GetManager(wxWindow* window)
{
wxAuiManagerEvent evt(wxEVT_AUI_FINDMANAGER);
evt.ResumePropagation(wxEVENT_PROPAGATE_MAX);
if (!window->ProcessEvent(evt))
return NULL;
return evt.GetManager();
}
void wxAuiManager::UpdateHintWindowConfig() void wxAuiManager::UpdateHintWindowConfig()
{ {
// find out if the the system can do transparent frames // find out if the the system can do transparent frames
@@ -3535,6 +3553,27 @@ void wxAuiManager::OnSize(wxSizeEvent& event)
event.Skip(); event.Skip();
} }
void wxAuiManager::OnFindManager(wxAuiManagerEvent& evt)
{
// get the window we are managing, if none, return NULL
wxWindow* window = GetManagedWindow();
if (!window)
{
evt.SetManager(NULL);
return;
}
// if we are managing a child frame, get the 'real' manager
if (window->IsKindOf(CLASSINFO(wxAuiFloatingFrame)))
{
wxAuiFloatingFrame* float_frame = static_cast<wxAuiFloatingFrame*>(window);
evt.SetManager(float_frame->GetOwnerManager());
return;
}
// return pointer to ourself
evt.SetManager(this);
}
void wxAuiManager::OnSetCursor(wxSetCursorEvent& event) void wxAuiManager::OnSetCursor(wxSetCursorEvent& event)
{ {