added EVT_AUI_PANECLOSE and updated sample accordingly
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40009 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include "wx/aui/framemanager.h"
|
||||
#include "wx/aui/dockart.h"
|
||||
#include "wx/aui/floatpane.h"
|
||||
#include "wx/aui/notebook.h"
|
||||
|
||||
#endif
|
||||
// _WX_AUI_H_
|
||||
|
@@ -436,7 +436,7 @@ protected:
|
||||
void OnFloatingPaneMoving(wxWindow* window);
|
||||
void OnFloatingPaneMoved(wxWindow* window);
|
||||
void OnFloatingPaneActivated(wxWindow* window);
|
||||
void OnFloatingPaneClosed(wxWindow* window);
|
||||
void OnFloatingPaneClosed(wxWindow* window, wxCloseEvent& evt);
|
||||
void OnFloatingPaneResized(wxWindow* window, const wxSize& size);
|
||||
void Render(wxDC* dc);
|
||||
void Repaint(wxDC* dc = NULL);
|
||||
@@ -514,12 +514,16 @@ public:
|
||||
{
|
||||
pane = NULL;
|
||||
button = 0;
|
||||
veto_flag = false;
|
||||
canveto_flag = true;
|
||||
}
|
||||
|
||||
wxFrameManagerEvent(const wxFrameManagerEvent& c) : wxEvent(c)
|
||||
{
|
||||
pane = c.pane;
|
||||
button = c.button;
|
||||
veto_flag = c.veto_flag;
|
||||
canveto_flag = c.canveto_flag;
|
||||
}
|
||||
|
||||
wxEvent *Clone() const { return new wxFrameManagerEvent(*this); }
|
||||
@@ -528,10 +532,17 @@ public:
|
||||
void SetButton(int b) { button = b; }
|
||||
wxPaneInfo* GetPane() { return pane; }
|
||||
int GetButton() { return button; }
|
||||
|
||||
|
||||
void Veto(bool veto = true) { veto_flag = veto; }
|
||||
bool GetVeto() const { return veto_flag; }
|
||||
void SetCanVeto(bool can_veto) { canveto_flag = can_veto; }
|
||||
bool CanVeto() const { return canveto_flag && veto_flag; }
|
||||
|
||||
public:
|
||||
wxPaneInfo* pane;
|
||||
int button;
|
||||
bool veto_flag;
|
||||
bool canveto_flag;
|
||||
};
|
||||
|
||||
|
||||
@@ -638,12 +649,9 @@ public:
|
||||
|
||||
// wx event machinery
|
||||
|
||||
|
||||
// right now the only event that works is wxEVT_AUI_PANEBUTTON. A full
|
||||
// spectrum of events will be implemented in the next incremental version
|
||||
|
||||
BEGIN_DECLARE_EVENT_TYPES()
|
||||
DECLARE_EVENT_TYPE(wxEVT_AUI_PANEBUTTON, 0)
|
||||
DECLARE_EVENT_TYPE(wxEVT_AUI_PANECLOSE, 0)
|
||||
END_DECLARE_EVENT_TYPES()
|
||||
|
||||
typedef void (wxEvtHandler::*wxFrameManagerEventFunction)(wxFrameManagerEvent&);
|
||||
@@ -653,6 +661,9 @@ typedef void (wxEvtHandler::*wxFrameManagerEventFunction)(wxFrameManagerEvent&);
|
||||
|
||||
#define EVT_AUI_PANEBUTTON(func) \
|
||||
wx__DECLARE_EVT0(wxEVT_AUI_PANEBUTTON, wxFrameManagerEventHandler(func))
|
||||
#define EVT_AUI_PANECLOSE(func) \
|
||||
wx__DECLARE_EVT0(wxEVT_AUI_PANECLOSE, wxFrameManagerEventHandler(func))
|
||||
|
||||
|
||||
#endif // wxUSE_AUI
|
||||
#endif //_WX_FRAMEMANAGER_H_
|
||||
|
@@ -90,7 +90,7 @@ public:
|
||||
void DoUpdate();
|
||||
|
||||
private:
|
||||
wxTextCtrl* CreateTextCtrl();
|
||||
wxTextCtrl* CreateTextCtrl(const wxString& text = wxEmptyString);
|
||||
wxGrid* CreateGrid();
|
||||
wxTreeCtrl* CreateTreeCtrl();
|
||||
wxSizeReportCtrl* CreateSizeReportCtrl(int width = 80, int height = 80);
|
||||
@@ -101,26 +101,28 @@ private:
|
||||
|
||||
private:
|
||||
|
||||
void OnEraseBackground(wxEraseEvent& event);
|
||||
void OnSize(wxSizeEvent& event);
|
||||
void OnEraseBackground(wxEraseEvent& evt);
|
||||
void OnSize(wxSizeEvent& evt);
|
||||
|
||||
void OnCreateTree(wxCommandEvent& event);
|
||||
void OnCreateGrid(wxCommandEvent& event);
|
||||
void OnCreateHTML(wxCommandEvent& event);
|
||||
void OnCreateText(wxCommandEvent& event);
|
||||
void OnCreateSizeReport(wxCommandEvent& event);
|
||||
void OnChangeContentPane(wxCommandEvent& event);
|
||||
void OnCreatePerspective(wxCommandEvent& event);
|
||||
void OnCopyPerspectiveCode(wxCommandEvent& event);
|
||||
void OnRestorePerspective(wxCommandEvent& event);
|
||||
void OnSettings(wxCommandEvent& event);
|
||||
void OnExit(wxCommandEvent& event);
|
||||
void OnAbout(wxCommandEvent& event);
|
||||
void OnCreateTree(wxCommandEvent& evt);
|
||||
void OnCreateGrid(wxCommandEvent& evt);
|
||||
void OnCreateHTML(wxCommandEvent& evt);
|
||||
void OnCreateText(wxCommandEvent& evt);
|
||||
void OnCreateSizeReport(wxCommandEvent& evt);
|
||||
void OnChangeContentPane(wxCommandEvent& evt);
|
||||
void OnCreatePerspective(wxCommandEvent& evt);
|
||||
void OnCopyPerspectiveCode(wxCommandEvent& evt);
|
||||
void OnRestorePerspective(wxCommandEvent& evt);
|
||||
void OnSettings(wxCommandEvent& evt);
|
||||
void OnExit(wxCommandEvent& evt);
|
||||
void OnAbout(wxCommandEvent& evt);
|
||||
|
||||
void OnGradient(wxCommandEvent& event);
|
||||
void OnManagerFlag(wxCommandEvent& event);
|
||||
void OnUpdateUI(wxUpdateUIEvent& event);
|
||||
void OnGradient(wxCommandEvent& evt);
|
||||
void OnManagerFlag(wxCommandEvent& evt);
|
||||
void OnUpdateUI(wxUpdateUIEvent& evt);
|
||||
|
||||
void OnPaneClose(wxFrameManagerEvent& evt);
|
||||
|
||||
private:
|
||||
|
||||
wxFrameManager m_mgr;
|
||||
@@ -573,6 +575,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_UPDATE_UI(ID_HorizontalGradient, MyFrame::OnUpdateUI)
|
||||
EVT_MENU_RANGE(MyFrame::ID_FirstPerspective, MyFrame::ID_FirstPerspective+1000,
|
||||
MyFrame::OnRestorePerspective)
|
||||
EVT_AUI_PANECLOSE(MyFrame::OnPaneClose)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
@@ -765,8 +768,9 @@ MyFrame::MyFrame(wxWindow* parent,
|
||||
BestSize(wxSize(200,100)).MinSize(wxSize(200,100)).
|
||||
Bottom().Layer(1));
|
||||
|
||||
m_mgr.AddPane(CreateTextCtrl(), wxPaneInfo().
|
||||
Name(wxT("test10")).Caption(wxT("Text Pane")).
|
||||
wxWindow* wnd10 = CreateTextCtrl(wxT("This pane will prompt the user before hiding."));
|
||||
m_mgr.AddPane(wnd10, wxPaneInfo().
|
||||
Name(wxT("test10")).Caption(wxT("Text Pane with Hide Prompt")).
|
||||
Bottom().Layer(1).Position(1));
|
||||
|
||||
m_mgr.AddPane(CreateSizeReportCtrl(), wxPaneInfo().
|
||||
@@ -829,7 +833,6 @@ MyFrame::MyFrame(wxWindow* parent,
|
||||
LeftDockable(false).RightDockable(false));
|
||||
|
||||
|
||||
|
||||
// make some default perspectives
|
||||
|
||||
wxString perspective_all = m_mgr.SavePerspective();
|
||||
@@ -962,6 +965,21 @@ void MyFrame::OnUpdateUI(wxUpdateUIEvent& event)
|
||||
}
|
||||
}
|
||||
|
||||
void MyFrame::OnPaneClose(wxFrameManagerEvent& evt)
|
||||
{
|
||||
if (evt.pane->name == wxT("test10"))
|
||||
{
|
||||
int res = wxMessageBox(wxT("Are you sure you want to close/hide this pane?"),
|
||||
wxT("wxAUI"),
|
||||
wxYES_NO,
|
||||
this);
|
||||
if (res != wxYES)
|
||||
evt.Veto();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MyFrame::OnCreatePerspective(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxTextEntryDialog dlg(this, wxT("Enter a name for the new perspective:"),
|
||||
@@ -1070,12 +1088,15 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||
wxMessageBox(_("wxAUI Demo\nAn advanced window management library for wxWidgets\n(c) Copyright 2005-2006, Kirix Corporation"), _("About wxAUI Demo"), wxOK, this);
|
||||
}
|
||||
|
||||
wxTextCtrl* MyFrame::CreateTextCtrl()
|
||||
wxTextCtrl* MyFrame::CreateTextCtrl(const wxString& ctrl_text)
|
||||
{
|
||||
wxString text;
|
||||
static int n = 0;
|
||||
|
||||
text.Printf(wxT("This is text box %d"), ++n);
|
||||
wxString text;
|
||||
if (ctrl_text.Length() > 0)
|
||||
text = ctrl_text;
|
||||
else
|
||||
text.Printf(wxT("This is text box %d"), ++n);
|
||||
|
||||
return new wxTextCtrl(this,wxID_ANY, text,
|
||||
wxPoint(0,0), wxSize(150,90),
|
||||
|
@@ -112,28 +112,11 @@ void wxFloatingPane::OnSize(wxSizeEvent& event)
|
||||
m_owner_mgr->OnFloatingPaneResized(m_pane_window, event.GetSize());
|
||||
}
|
||||
|
||||
void wxFloatingPane::OnClose(wxCloseEvent& WXUNUSED(event))
|
||||
void wxFloatingPane::OnClose(wxCloseEvent& evt)
|
||||
{
|
||||
static wxList s_closing;
|
||||
|
||||
if (!s_closing.Member(this))
|
||||
{
|
||||
s_closing.Append(this);
|
||||
|
||||
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
|
||||
cancelEvent.SetEventObject( m_pane_window );
|
||||
m_pane_window->GetEventHandler()->ProcessEvent(cancelEvent);
|
||||
s_closing.DeleteObject(this);
|
||||
// we should really return here without doing anything if the close was vetoed
|
||||
}
|
||||
|
||||
// The problem here is that the above can cause the window itself to be destroyed
|
||||
if (!IsBeingDeleted() && m_pane_window && !m_pane_window->IsBeingDeleted()
|
||||
&& (m_pane_window->GetParent()==this))
|
||||
{
|
||||
m_owner_mgr->OnFloatingPaneClosed(m_pane_window);
|
||||
m_owner_mgr->OnFloatingPaneClosed(m_pane_window, evt);
|
||||
if (!evt.GetVeto())
|
||||
Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
void wxFloatingPane::OnMoveEvent(wxMoveEvent& event)
|
||||
|
@@ -52,6 +52,7 @@ WX_DEFINE_OBJARRAY(wxPaneInfoArray)
|
||||
wxPaneInfo wxNullPaneInfo;
|
||||
wxDockInfo wxNullDockInfo;
|
||||
DEFINE_EVENT_TYPE(wxEVT_AUI_PANEBUTTON)
|
||||
DEFINE_EVENT_TYPE(wxEVT_AUI_PANECLOSE)
|
||||
|
||||
#ifdef __WXMAC__
|
||||
// a few defines to avoid nameclashes
|
||||
@@ -2771,20 +2772,38 @@ void wxFrameManager::OnFloatingPaneResized(wxWindow* wnd, const wxSize& size)
|
||||
pane.floating_size = size;
|
||||
}
|
||||
|
||||
void wxFrameManager::OnFloatingPaneClosed(wxWindow* wnd)
|
||||
|
||||
void wxFrameManager::OnFloatingPaneClosed(wxWindow* wnd, wxCloseEvent& evt)
|
||||
{
|
||||
// try to find the pane
|
||||
wxPaneInfo& pane = GetPane(wnd);
|
||||
wxASSERT_MSG(pane.IsOk(), wxT("Pane window not found"));
|
||||
|
||||
// reparent the pane window back to us and
|
||||
// prepare the frame window for destruction
|
||||
pane.window->Show(false);
|
||||
pane.window->Reparent(m_frame);
|
||||
pane.frame = NULL;
|
||||
pane.Hide();
|
||||
|
||||
// fire pane close event
|
||||
wxFrameManagerEvent e(wxEVT_AUI_PANECLOSE);
|
||||
e.SetPane(&pane);
|
||||
e.SetCanVeto(evt.CanVeto());
|
||||
ProcessMgrEvent(e);
|
||||
|
||||
if (e.GetVeto())
|
||||
{
|
||||
evt.Veto();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// reparent the pane window back to us and
|
||||
// prepare the frame window for destruction
|
||||
pane.window->Show(false);
|
||||
pane.window->Reparent(m_frame);
|
||||
pane.frame = NULL;
|
||||
pane.Hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void wxFrameManager::OnFloatingPaneActivated(wxWindow* wnd)
|
||||
{
|
||||
if (GetFlags() & wxAUI_MGR_ALLOW_ACTIVE_PANE)
|
||||
@@ -3480,28 +3499,26 @@ void wxFrameManager::OnChildFocus(wxChildFocusEvent& event)
|
||||
|
||||
// OnPaneButton() is an event handler that is called
|
||||
// when a pane button has been pressed.
|
||||
void wxFrameManager::OnPaneButton(wxFrameManagerEvent& event)
|
||||
void wxFrameManager::OnPaneButton(wxFrameManagerEvent& evt)
|
||||
{
|
||||
wxPaneInfo& pane = *(event.pane);
|
||||
wxASSERT_MSG(evt.pane, wxT("Pane Info passed to wxFrameManager::OnPaneButton must be non-null"));
|
||||
|
||||
wxPaneInfo& pane = *(evt.pane);
|
||||
|
||||
if (event.button == wxPaneInfo::buttonClose)
|
||||
if (evt.button == wxPaneInfo::buttonClose)
|
||||
{
|
||||
if (pane.IsOk())
|
||||
// fire button-click event
|
||||
wxFrameManagerEvent e(wxEVT_AUI_PANECLOSE);
|
||||
e.SetPane(evt.pane);
|
||||
ProcessMgrEvent(e);
|
||||
|
||||
if (!e.GetVeto())
|
||||
{
|
||||
wxWindow * pane_window = pane.window;
|
||||
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
|
||||
cancelEvent.SetEventObject( pane_window );
|
||||
pane_window->GetEventHandler()->ProcessEvent(cancelEvent);
|
||||
|
||||
// The problem here is that the above can cause the window itself to be destroyed
|
||||
if (!pane_window->IsBeingDeleted() && pane.IsOk())
|
||||
{
|
||||
pane.Hide();
|
||||
Update();
|
||||
}
|
||||
pane.Hide();
|
||||
Update();
|
||||
}
|
||||
}
|
||||
else if (event.button == wxPaneInfo::buttonPin)
|
||||
else if (evt.button == wxPaneInfo::buttonPin)
|
||||
{
|
||||
if ((m_flags & wxAUI_MGR_ALLOW_FLOATING) &&
|
||||
pane.IsFloatable())
|
||||
|
Reference in New Issue
Block a user