Moved the popup menu event handlers to dialog event handler
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13629 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -32,8 +32,6 @@
|
||||
IMPLEMENT_APP(MyApp)
|
||||
|
||||
BEGIN_EVENT_TABLE(MyApp, wxApp)
|
||||
EVT_MENU(OBJECT_MENU_EDIT, MyApp::OnObjectPopupMenu)
|
||||
EVT_MENU(OBJECT_MENU_DELETE, MyApp::OnObjectPopupMenu)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
MyApp::MyApp(void)
|
||||
|
@@ -19,8 +19,6 @@
|
||||
#include "wx/proplist.h"
|
||||
#include "reseditr.h"
|
||||
|
||||
extern void ObjectMenuProc(wxMenu *menu, wxCommandEvent& event);
|
||||
|
||||
class MyChild;
|
||||
|
||||
// Define a new application
|
||||
@@ -31,11 +29,6 @@ public:
|
||||
bool OnInit(void);
|
||||
int OnExit(void);
|
||||
|
||||
void OnObjectPopupMenu(wxCommandEvent& event)
|
||||
{
|
||||
ObjectMenuProc((wxMenu *)event.GetEventObject(), event);
|
||||
}
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
@@ -42,6 +42,8 @@ BEGIN_EVENT_TABLE(wxResourceEditorDialogHandler, wxEvtHandler)
|
||||
EVT_PAINT(wxResourceEditorDialogHandler::OnPaint)
|
||||
EVT_MOUSE_EVENTS(wxResourceEditorDialogHandler::OnMouseEvent)
|
||||
EVT_SIZE(wxResourceEditorDialogHandler::OnSize)
|
||||
EVT_MENU(OBJECT_MENU_EDIT, wxResourceEditorDialogHandler::OnObjectEdit)
|
||||
EVT_MENU(OBJECT_MENU_DELETE, wxResourceEditorDialogHandler::OnObjectDelete)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
BEGIN_EVENT_TABLE(wxResourceEditorControlHandler, wxEvtHandler)
|
||||
@@ -867,6 +869,43 @@ void wxResourceEditorDialogHandler::OnDragEnd(int x, int y, int WXUNUSED(keys),
|
||||
|
||||
} // wxResourceEditorDialogHandler::OnDragEnd()
|
||||
|
||||
void wxResourceEditorDialogHandler::OnObjectEdit(wxCommandEvent& event)
|
||||
{
|
||||
wxMenu* menu = (wxMenu*) event.GetEventObject();
|
||||
|
||||
wxWindow *data = (wxWindow *)menu->GetClientData();
|
||||
if (!data)
|
||||
return;
|
||||
|
||||
wxResourceManager::GetCurrentResourceManager()->EditWindow(data);
|
||||
}
|
||||
|
||||
void wxResourceEditorDialogHandler::OnObjectDelete(wxCommandEvent& event)
|
||||
{
|
||||
wxMenu* menu = (wxMenu*) event.GetEventObject();
|
||||
|
||||
wxWindow *data = (wxWindow *)menu->GetClientData();
|
||||
if (!data)
|
||||
return;
|
||||
|
||||
// Before deleting a dialog, give the user a last chance
|
||||
// change their mind, in case they accidentally right
|
||||
// clicked the dialog rather than the widget they were
|
||||
// aiming for.
|
||||
if (data->IsKindOf(CLASSINFO(wxPanel)))
|
||||
{
|
||||
wxString str(wxT("Deleting dialog : "));
|
||||
str += data->GetName();
|
||||
if (wxMessageBox(wxT("Are you sure?"), str, wxYES_NO | wxCENTRE) == wxNO)
|
||||
return;
|
||||
}
|
||||
|
||||
wxResourceManager::GetCurrentResourceManager()->DeselectItemIfNecessary(data);
|
||||
|
||||
wxResourceManager::GetCurrentResourceManager()->SaveInfoAndDeleteHandler(data);
|
||||
wxResourceManager::GetCurrentResourceManager()->DeleteResource(data);
|
||||
wxResourceManager::GetCurrentResourceManager()->DeleteWindow(data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@@ -52,6 +52,8 @@ public:
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
void OnMouseEvent(wxMouseEvent& event);
|
||||
void OnSize(wxSizeEvent& event);
|
||||
void OnObjectEdit(wxCommandEvent& event);
|
||||
void OnObjectDelete(wxCommandEvent& event);
|
||||
|
||||
virtual void OnItemEvent(wxControl *win, wxMouseEvent& event);
|
||||
virtual void OnLeftClick(int x, int y, int keys);
|
||||
|
@@ -2397,51 +2397,6 @@ void wxResourceEditorScrolledWindow::DrawTitle(wxDC& dc)
|
||||
}
|
||||
}
|
||||
|
||||
// Popup menu callback
|
||||
void ObjectMenuProc(wxMenu *menu, wxCommandEvent& event)
|
||||
{
|
||||
wxWindow *data = (wxWindow *)menu->GetClientData();
|
||||
if (!data)
|
||||
return;
|
||||
|
||||
switch (event.GetId())
|
||||
{
|
||||
case OBJECT_MENU_TITLE:
|
||||
{
|
||||
event.Skip();
|
||||
break;
|
||||
}
|
||||
case OBJECT_MENU_EDIT:
|
||||
{
|
||||
wxResourceManager::GetCurrentResourceManager()->EditWindow(data);
|
||||
break;
|
||||
}
|
||||
case OBJECT_MENU_DELETE:
|
||||
{
|
||||
// Before deleting a dialog, give the user a last chance
|
||||
// change their mind, in case they accidentally right
|
||||
// clicked the dialog rather than the widget they were
|
||||
// aiming for.
|
||||
if (data->IsKindOf(CLASSINFO(wxPanel)))
|
||||
{
|
||||
wxString str(wxT("Deleting dialog : "));
|
||||
str += data->GetName();
|
||||
if (wxMessageBox(wxT("Are you sure?"), str, wxYES_NO | wxCENTRE) == wxNO)
|
||||
return;
|
||||
}
|
||||
|
||||
wxResourceManager::GetCurrentResourceManager()->DeselectItemIfNecessary(data);
|
||||
|
||||
wxResourceManager::GetCurrentResourceManager()->SaveInfoAndDeleteHandler(data);
|
||||
wxResourceManager::GetCurrentResourceManager()->DeleteResource(data);
|
||||
wxResourceManager::GetCurrentResourceManager()->DeleteWindow(data);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Main toolbar
|
||||
*
|
||||
|
Reference in New Issue
Block a user