From e306597309a120f2ae91385c731a5cb2722c52aa Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Fri, 5 Feb 1999 23:55:04 +0000 Subject: [PATCH] Removed lots of OnClose functions; doc'ed OnCloseWindow better; MM_... -> wxMM_... git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1615 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/body.tex | 2 +- docs/latex/wx/dc.tex | 10 ++-- docs/latex/wx/function.tex | 2 +- docs/latex/wx/prevwin.tex | 4 +- docs/latex/wx/tdelwin.tex | 66 +++++++++++----------- docs/latex/wx/tfont.tex | 2 +- docs/latex/wx/window.tex | 6 +- docs/msw/install.txt | 4 ++ include/wx/defs.h | 13 +++++ include/wx/docview.h | 2 +- include/wx/event.h | 3 + include/wx/generic/colrdlgg.h | 9 +-- include/wx/generic/fontdlgg.h | 2 +- include/wx/mac/dialog.h | 1 - include/wx/mac/frame.h | 2 - include/wx/mac/metafile.h | 2 +- include/wx/motif/dialog.h | 2 +- include/wx/motif/frame.h | 2 - include/wx/motif/metafile.h | 2 +- include/wx/msw/dc.h | 4 +- include/wx/msw/dialog.h | 1 - include/wx/msw/frame.h | 2 - include/wx/msw/metafile.h | 2 +- include/wx/prntbase.h | 4 +- include/wx/propform.h | 11 +++- include/wx/proplist.h | 6 +- include/wx/qt/dialog.h | 1 - include/wx/qt/frame.h | 2 - include/wx/stubs/dialog.h | 1 - include/wx/stubs/frame.h | 2 - include/wx/stubs/metafile.h | 2 +- samples/bombs/bombs.cpp | 4 +- samples/checklst/checklst.cpp | 2 +- samples/config/conftest.cpp | 8 ++- samples/db/dbtest.cpp | 35 ++++++++---- samples/db/dbtest.h | 7 ++- samples/dialogs/dialogs.h | 1 - samples/dnd/dnd.cpp | 7 --- samples/dynamic/dynamic.cpp | 1 - samples/forty/canvas.cpp | 4 +- samples/forty/canvas.h | 2 +- samples/forty/forty.cpp | 14 +++-- samples/forty/playerdg.cpp | 8 +-- samples/forty/playerdg.h | 2 +- samples/forty/scoredg.cpp | 10 ++-- samples/forty/scoredg.h | 4 +- samples/grid/test.cpp | 2 - samples/internat/internat.cpp | 3 +- samples/joytest/joytest.cpp | 5 -- samples/joytest/joytest.h | 1 - samples/layout/layout.cpp | 15 ----- samples/layout/layout.h | 2 - samples/listctrl/listtest.h | 1 - samples/mdi/mdi.cpp | 22 -------- samples/mdi/mdi.h | 2 - samples/mfc/mfctest.cpp | 7 --- samples/nativdlg/nativdlg.cpp | 7 --- samples/nativdlg/nativdlg.h | 1 - samples/ownerdrw/ownerdrw.cpp | 3 +- samples/png/pngdemo.cpp | 8 --- samples/png/pngdemo.h | 1 - samples/printing/printing.cpp | 14 ++--- samples/printing/printing.h | 7 +-- samples/resource/resource.cpp | 7 --- samples/resource/resource.h | 1 - samples/sashtest/sashtest.cpp | 23 -------- samples/sashtest/sashtest.h | 2 - samples/splitter/test.cpp | 7 --- samples/thread/test.cpp | 1 - samples/typetest/typetest.h | 1 - samples/validate/validate.h | 1 - samples/wxpoem/wxpoem.cpp | 7 +++ src/common/event.cpp | 3 + src/common/prntbase.cpp | 9 ++- src/generic/colrdlgg.cpp | 6 +- src/generic/fontdlgg.cpp | 6 +- src/generic/propform.cpp | 22 +++++--- src/generic/proplist.cpp | 21 +++++-- src/gtk/dc.cpp | 14 ++--- src/gtk/dialog.cpp | 17 +++++- src/gtk/frame.cpp | 4 +- src/gtk1/dc.cpp | 14 ++--- src/gtk1/dialog.cpp | 17 +++++- src/gtk1/frame.cpp | 4 +- src/mac/app.cpp | 4 ++ src/mac/carbon/app.cpp | 4 ++ src/mac/carbon/dc.cpp | 14 ++--- src/mac/carbon/dialog.cpp | 43 +++++++------- src/mac/carbon/frame.cpp | 17 +----- src/mac/carbon/metafile.cpp | 4 +- src/mac/carbon/window.cpp | 3 + src/mac/dc.cpp | 14 ++--- src/mac/dialog.cpp | 43 +++++++------- src/mac/frame.cpp | 17 +----- src/mac/metafile.cpp | 4 +- src/mac/window.cpp | 3 + src/motif/dc.cpp | 14 ++--- src/motif/dialog.cpp | 37 ++++++------ src/motif/frame.cpp | 15 +---- src/motif/metafile.cpp | 4 +- src/motif/window.cpp | 3 + src/msw/curico.cpp | 5 ++ src/msw/dc.cpp | 12 ++-- src/msw/dcprint.cpp | 4 +- src/msw/dialog.cpp | 53 ++++++++--------- src/msw/dibutils.cpp | 2 +- src/msw/frame.cpp | 17 +----- src/msw/metafile.cpp | 28 ++++----- src/msw/window.cpp | 2 + src/qt/dc.cpp | 14 ++--- src/qt/dialog.cpp | 43 +++++++------- src/qt/frame.cpp | 17 +----- src/qt/window.cpp | 3 + src/stubs/dc.cpp | 14 ++--- src/stubs/dialog.cpp | 43 +++++++------- src/stubs/frame.cpp | 16 +----- src/stubs/metafile.cpp | 2 +- src/stubs/window.cpp | 3 + utils/dialoged/src/reseditr.cpp | 16 +++--- utils/dialoged/src/reseditr.h | 2 +- utils/glcanvas/samples/cube/cube.cpp | 5 -- utils/glcanvas/samples/cube/cube.h | 1 - utils/glcanvas/samples/isosurf/isosurf.cpp | 6 -- utils/glcanvas/samples/isosurf/isosurf.h | 1 - utils/glcanvas/samples/penguin/penguin.cpp | 5 -- utils/glcanvas/samples/penguin/penguin.h | 1 - utils/nplugin/src/npapp.cpp | 3 +- utils/ogl/samples/ogledit/ogledit.cpp | 7 ++- utils/ogl/samples/ogledit/ogledit.h | 2 +- utils/tex2rtf/src/tex2rtf.cpp | 3 +- 130 files changed, 509 insertions(+), 635 deletions(-) diff --git a/docs/latex/wx/body.tex b/docs/latex/wx/body.tex index b78e3f6c25..2c82cd9080 100644 --- a/docs/latex/wx/body.tex +++ b/docs/latex/wx/body.tex @@ -148,7 +148,7 @@ same API; temporarily with the window as an argument; \item events from sliders and scrollbars can be handled more flexibly; \item the handling of window close events has been changed in line with the new -event system, but backward {\bf OnClose} compatibility has been retained; +event system; \item the concept of {\it validator} has been added to allow much easier coding of the relationship between controls and application data; \item the documentation has been revised, with more cross-referencing. diff --git a/docs/latex/wx/dc.tex b/docs/latex/wx/dc.tex index ed3c32073c..26aa80fc9a 100644 --- a/docs/latex/wx/dc.tex +++ b/docs/latex/wx/dc.tex @@ -644,12 +644,12 @@ PostScript output. The mapping mode can be one of the following: \begin{twocollist}\itemsep=0pt -\twocolitem{MM\_TWIPS}{Each logical unit is 1/20 of a point, or 1/1440 of +\twocolitem{wxMM\_TWIPS}{Each logical unit is 1/20 of a point, or 1/1440 of an inch.} -\twocolitem{MM\_POINTS}{Each logical unit is a point, or 1/72 of an inch.} -\twocolitem{MM\_METRIC}{Each logical unit is 1 mm.} -\twocolitem{MM\_LOMETRIC}{Each logical unit is 1/10 of a mm.} -\twocolitem{MM\_TEXT}{Each logical unit is 1 pixel.} +\twocolitem{wxMM\_POINTS}{Each logical unit is a point, or 1/72 of an inch.} +\twocolitem{wxMM\_METRIC}{Each logical unit is 1 mm.} +\twocolitem{wxMM\_LOMETRIC}{Each logical unit is 1/10 of a mm.} +\twocolitem{wxMM\_TEXT}{Each logical unit is 1 pixel.} \end{twocollist} \membersection{wxDC::SetOptimization}\label{wxsetoptimization} diff --git a/docs/latex/wx/function.tex b/docs/latex/wx/function.tex index 6062e1acb7..f9487cdb4d 100644 --- a/docs/latex/wx/function.tex +++ b/docs/latex/wx/function.tex @@ -463,7 +463,7 @@ the equivalent of the following code to the start of the metafile data: SetWindowExt(dc, maxX - minX, maxY - minY); \end{verbatim} -This simulates the MM\_TEXT mapping mode, which wxWindows assumes. +This simulates the wxMM\_TEXT mapping mode, which wxWindows assumes. Placeable metafiles may be imported by many Windows applications, and can be used in RTF (Rich Text Format) files. diff --git a/docs/latex/wx/prevwin.tex b/docs/latex/wx/prevwin.tex index 30793384b0..fbf2203a4f 100644 --- a/docs/latex/wx/prevwin.tex +++ b/docs/latex/wx/prevwin.tex @@ -167,9 +167,9 @@ in the application. This function should be called by the application prior to showing the frame. -\membersection{wxPreviewFrame::OnClose} +\membersection{wxPreviewFrame::OnCloseWindow} -\func{bool}{OnClose}{\void} +\func{void}{OnCloseWindow}{\param{wxCloseEvent\&}{ event}} Enables the other frames in the application, and deletes the print preview object, implicitly deleting any printout objects associated with the print diff --git a/docs/latex/wx/tdelwin.tex b/docs/latex/wx/tdelwin.tex index 33e368dd68..4600573cd4 100644 --- a/docs/latex/wx/tdelwin.tex +++ b/docs/latex/wx/tdelwin.tex @@ -9,15 +9,18 @@ to close windows. \wxheading{What is the sequence of events in a window deletion?} When the user clicks on the system close button or system close command, -in a frame or a dialog, wxWindows calls \helpref{wxWindow::Close}{wxwindowclose}. +in a frame or a dialog, wxWindows calls \helpref{wxWindow::Close}{wxwindowclose}. This +in turn generates an EVT\_CLOSE event: see \helpref{wxWindow::OnCloseWindow}{wxwindowonclosewindow}. -This function then generates a \helpref{wxCloseEvent}{wxcloseevent} event which -can be handled by the application (by using an EVT\_CLOSE event table entry). It is the duty of the application to -define a suitable event handler, and decide whether or not to destroy the window. -If the application is for some reason forcing the application to close, -the window should always be destroyed, otherwise there is the option to +It is the duty of the application to define a suitable event handler, and +decide whether or not to destroy the window. +If the application is for some reason forcing the application to close +(\helpref{wxCloseEvent::CanVeto}{wxcloseeventcanveto} returns FALSE), the window should always be destroyed, otherwise there is the option to ignore the request, or maybe wait until the user has answered a question -before deciding whether it's safe to close. +before deciding whether it's safe to close. The handler for EVT\_CLOSE should +signal to the calling code if it does not destroy the window, by calling +\helpref{wxCloseEvent::Veto}{wxcloseeventveto}. Calling this provides useful information +to the calling code. The wxCloseEvent handler should only call \helpref{wxWindow::Destroy}{wxwindowdestroy} to delete the window, and not use the {\bf delete} operator. This is because @@ -26,24 +29,28 @@ since otherwise there is the danger that events will be sent to a non-existent w \wxheading{How can the application close a window itself?} -Your application can use the \helpref{wxWindow::Close}{wxwindowclose} event just as -the framework does. Pass a TRUE argument to this function to tell the event handler -that we definitely want to delete the frame. +Your application can either use \helpref{wxWindow::Close}{wxwindowclose} event just as +the framework does, or it can call \helpref{wxWindow::Destroy}{wxwindowdestroy} directly. +If using Close(), you can pass a TRUE argument to this function to tell the event handler +that we definitely want to delete the frame and it cannot be vetoed. -If for some reason you don't wish to use the {\bf Close} function to delete a window, at least use -the {\bf Destroy} function so that wxWindows can decide when it's safe to delete the window. +The advantage of using Close instead of Destroy is that it will call any clean-up code +defined by the EVT\_CLOSE handler; for example it may close a document contained in +a window after first asking the user whether the work should be saved. Close can be vetoed +by this process (return FALSE), whereas Destroy definitely destroys the window. \wxheading{What is the default behaviour?} -By default, the close event handlers for wxFrame and wxDialog -both call the old \helpref{wxWindow::OnClose}{wxwindowonclose} handler -for backward compatibility. So you can still use the old form if you wish. - -In addition, the default close event handler for wxDialog simulates a Cancel command, +The default close event handler for wxDialog simulates a Cancel command, generating a wxID\_CANCEL event. Since the handler for this cancel event might -itself call {\bf Close}, there is a check for infinite looping. +itself call {\bf Close}, there is a check for infinite looping. The default handler +for wxID\_CANCEL hides the dialog (if modeless) or calls EndModal(wxID\_CANCEL) (if modal). +In other words, by default, the dialog is not destroyed (it might have been created +on the stack, so the assumption of dynamic creation cannot be made). + +The default close event handler for wxFrame destroys the frame using Destroy(). -Under Windows, wxDialog also defines a handler for \helpref{wxWindow::OnCharHook}{wxwindowoncharhook} that +Under Windows, wxDialog defines a handler for \helpref{wxWindow::OnCharHook}{wxwindowoncharhook} that generates a Cancel event if the Escape key has been pressed. \wxheading{What should I do when the user calls up Exit from a menu?} @@ -63,9 +70,6 @@ In wxWindows 1.xx, the {\bf OnClose} function did not actually delete 'this', bu to the calling function (either {\bf Close}, or the wxWindows framework) to delete or not delete the window. -You can still use this function unchanged in 2.0, but it's worth upgrading to -the new method in case future versions of wxWindows does not support the old one. - To update your code, you should provide an event table entry in your frame or dialog, using the EVT\_CLOSE macro. The event handler function might look like this: @@ -73,22 +77,13 @@ dialog, using the EVT\_CLOSE macro. The event handler function might look like t \begin{verbatim} void MyFrame::OnCloseWindow(wxCloseEvent& event) { - // If the application forces the deletion, - // obey without question. - if (event.GetForce()) - { - this->Destroy(); - return; - } - - // Otherwise... if (MyDataHasBeenModified()) { wxMessageDialog* dialog = new wxMessageDialog(this, "Save changed data?", "My app", wxYES_NO|wxCANCEL); int ans = dialog->ShowModal(); - dialog->Close(TRUE); + dialog->Destroy(); switch (ans) { @@ -101,6 +96,10 @@ dialog, using the EVT\_CLOSE macro. The event handler function might look like t break; case wxID_CANCEL: // Do nothing - so don't quit app. default: + if (!event.CanVeto()) // Test if we can veto this deletion + this->Destroy(); // If not, destroy the window anyway. + else + event.Veto(); // Notify the calling code that we didn't delete the frame. break; } } @@ -111,7 +110,8 @@ dialog, using the EVT\_CLOSE macro. The event handler function might look like t \wxheading{How do I exit the application gracefully?} A wxWindows application automatically exits when the designated top window, or the -last frame or dialog, is destroyed. +last frame or dialog, is destroyed. Put any application-wide cleanup code in \helpref{wxApp::OnExit}{wxapponexit} (this +is a virtual function, not an event handler). \wxheading{Do child windows get deleted automatically?} diff --git a/docs/latex/wx/tfont.tex b/docs/latex/wx/tfont.tex index 47fbfdef2b..f79794290a 100644 --- a/docs/latex/wx/tfont.tex +++ b/docs/latex/wx/tfont.tex @@ -27,7 +27,7 @@ or if allowing the user to specify a face name, store the family id with any fil might be transported to a different Windows machine or other platform. \normalbox{{\bf Note:} There is currently a difference between the appearance of fonts on the -two platforms, if the mapping mode is anything other than MM\_TEXT. +two platforms, if the mapping mode is anything other than wxMM\_TEXT. Under X, font size is always specified in points. Under MS Windows, the unit for text is points but the text is scaled according to the current mapping mode. However, user scaling on a device context will diff --git a/docs/latex/wx/window.tex b/docs/latex/wx/window.tex index add8503f92..c5421a8edb 100644 --- a/docs/latex/wx/window.tex +++ b/docs/latex/wx/window.tex @@ -898,7 +898,7 @@ the control(s) in question. Called when the user has tried to close a a frame or dialog box using the window manager (X) or system menu (Windows). -{\bf Note:} This is an obsolete function retained for backward compatibility. +{\bf Note:} This is an obsolete function. It is superceded by the \helpref{wxWindow::OnCloseWindow}{wxwindowonclosewindow} event handler. @@ -908,10 +908,6 @@ If TRUE is returned by OnClose, the window will be deleted by the system, otherw attempt will be ignored. Do not delete the window from within this handler, although you may delete other windows. -\wxheading{Remarks} - -Derive your own class to handle this message. The default handler returns TRUE. - \wxheading{See also} \helpref{Window deletion overview}{windowdeletionoverview},\rtfsp diff --git a/docs/msw/install.txt b/docs/msw/install.txt index 429760264c..ee25d87c26 100644 --- a/docs/msw/install.txt +++ b/docs/msw/install.txt @@ -296,3 +296,7 @@ General Notes and it's also on the wxWindows CD-ROM under Packages. +- If you are installing wxWindows 2 from CVS, you may find that + include/wx/msw/setup.h is missing. This is deliberate, to avoid + developers' different setup.h configurations getting confused. + Please copy setup0.h to setup.h before compiling. diff --git a/include/wx/defs.h b/include/wx/defs.h index 5aac4cbde8..25e148dd55 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -946,6 +946,19 @@ enum #define wxID_HIGHEST 5999 +// Mapping modes (as per Windows) +#define wxMM_TEXT 1 +#define wxMM_LOMETRIC 2 +#define wxMM_HIMETRIC 3 +#define wxMM_LOENGLISH 4 +#define wxMM_HIENGLISH 5 +#define wxMM_TWIPS 6 +#define wxMM_ISOTROPIC 7 +#define wxMM_ANISOTROPIC 8 + +#define wxMM_POINTS 9 +#define wxMM_METRIC 10 + /* Shortcut for easier dialog-unit-to-pixel conversion */ #define wxDLG_UNIT(parent, pt) parent->ConvertDialogToPixels(pt) diff --git a/include/wx/docview.h b/include/wx/docview.h index 86ad9c3801..b2a1d68797 100644 --- a/include/wx/docview.h +++ b/include/wx/docview.h @@ -188,7 +188,7 @@ class WXDLLEXPORT wxView: public wxEvtHandler // Override to do cleanup/veto close virtual bool OnClose(bool deleteWindow); -#ifdef WXWIN_COMPATIBILITY +#if WXWIN_COMPATIBILITY // Defeat compiler warning bool OnClose(void) { return wxEvtHandler::OnClose(); } #endif diff --git a/include/wx/event.h b/include/wx/event.h index 009336ade7..76e31ed6cd 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -771,6 +771,7 @@ public: m_veto = veto; } void SetCanVeto(bool canVeto) { m_canVeto = canVeto; } + // No more asserts here please, the one you put here was wrong. bool CanVeto() const { return m_canVeto; } bool GetVeto() const { return m_canVeto && m_veto; } @@ -1156,7 +1157,9 @@ public: virtual long Default() { return GetNextHandler() ? GetNextHandler()->Default() : 0; }; +#if WXWIN_COMPATIBILITY virtual bool OnClose(); +#endif virtual bool ProcessEvent(wxEvent& event); virtual bool SearchEventTable(wxEventTable& table, wxEvent& event); diff --git a/include/wx/generic/colrdlgg.h b/include/wx/generic/colrdlgg.h index 942d2ed8ee..35dc8fd95e 100644 --- a/include/wx/generic/colrdlgg.h +++ b/include/wx/generic/colrdlgg.h @@ -88,8 +88,6 @@ class WXDLLEXPORT wxGenericColourDialog: public wxDialog void OnMouseEvent(wxMouseEvent& event); void OnPaint(wxPaintEvent& event); - bool OnClose(void); - virtual void CalculateMeasurements(void); virtual void CreateWidgets(void); virtual void InitializeColours(void); @@ -102,17 +100,14 @@ class WXDLLEXPORT wxGenericColourDialog: public wxDialog virtual void OnBasicColourClick(int which); virtual void OnCustomColourClick(int which); -/* - virtual void OnOk(void); - virtual void OnCancel(void); - virtual void OnAddCustom(void); -*/ void OnAddCustom(wxCommandEvent& event); void OnRedSlider(wxCommandEvent& event); void OnGreenSlider(wxCommandEvent& event); void OnBlueSlider(wxCommandEvent& event); + void OnCloseWindow(wxCloseEvent& event); + DECLARE_EVENT_TABLE() }; diff --git a/include/wx/generic/fontdlgg.h b/include/wx/generic/fontdlgg.h index b02d7093b0..ade8d40404 100644 --- a/include/wx/generic/fontdlgg.h +++ b/include/wx/generic/fontdlgg.h @@ -72,7 +72,7 @@ class WXDLLEXPORT wxGenericFontDialog: public wxDialog // Internal functions void OnPaint(wxPaintEvent& event); - bool OnClose(void); + void OnCloseWindow(wxCloseEvent& event); virtual void CreateWidgets(void); virtual void InitializeFont(void); diff --git a/include/wx/mac/dialog.h b/include/wx/mac/dialog.h index ebd7bff2a8..d68cc7c9a0 100644 --- a/include/wx/mac/dialog.h +++ b/include/wx/mac/dialog.h @@ -71,7 +71,6 @@ public: void SetTitle(const wxString& title); wxString GetTitle() const ; - bool OnClose(); void OnCharHook(wxKeyEvent& event); void OnCloseWindow(wxCloseEvent& event); diff --git a/include/wx/mac/frame.h b/include/wx/mac/frame.h index c013362175..c2b5eb39a8 100644 --- a/include/wx/mac/frame.h +++ b/include/wx/mac/frame.h @@ -63,8 +63,6 @@ public: void ClientToScreen(int *x, int *y) const; void ScreenToClient(int *x, int *y) const; - virtual bool OnClose(); - void OnSize(wxSizeEvent& event); void OnMenuHighlight(wxMenuEvent& event); void OnActivate(wxActivateEvent& event); diff --git a/include/wx/mac/metafile.h b/include/wx/mac/metafile.h index eb86b97a04..e4be296d92 100644 --- a/include/wx/mac/metafile.h +++ b/include/wx/mac/metafile.h @@ -87,7 +87,7 @@ protected: /* * Pass filename of existing non-placeable metafile, and bounding box. * Adds a placeable metafile header, sets the mapping mode to anisotropic, - * and sets the window origin and extent to mimic the MM_TEXT mapping mode. + * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode. * */ diff --git a/include/wx/motif/dialog.h b/include/wx/motif/dialog.h index f1d351436b..ca8290e082 100644 --- a/include/wx/motif/dialog.h +++ b/include/wx/motif/dialog.h @@ -80,7 +80,7 @@ public: void SetTitle(const wxString& title); wxString GetTitle() const ; - bool OnClose(); +// bool OnClose(); void OnCharHook(wxKeyEvent& event); void OnCloseWindow(wxCloseEvent& event); diff --git a/include/wx/motif/frame.h b/include/wx/motif/frame.h index 25afb91bd8..bd2a51a950 100644 --- a/include/wx/motif/frame.h +++ b/include/wx/motif/frame.h @@ -79,8 +79,6 @@ public: void ScreenToClient(int *x, int *y) const; wxPoint ScreenToClient(const wxPoint& pt) const { return wxWindow::ScreenToClient(pt); } - virtual bool OnClose(); - void OnSize(wxSizeEvent& event); void OnMenuHighlight(wxMenuEvent& event); void OnActivate(wxActivateEvent& event); diff --git a/include/wx/motif/metafile.h b/include/wx/motif/metafile.h index 2a8843952c..b6f823b860 100644 --- a/include/wx/motif/metafile.h +++ b/include/wx/motif/metafile.h @@ -87,7 +87,7 @@ protected: /* * Pass filename of existing non-placeable metafile, and bounding box. * Adds a placeable metafile header, sets the mapping mode to anisotropic, - * and sets the window origin and extent to mimic the MM_TEXT mapping mode. + * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode. * */ diff --git a/include/wx/msw/dc.h b/include/wx/msw/dc.h index bba7bd5f81..29a3ca1acb 100644 --- a/include/wx/msw/dc.h +++ b/include/wx/msw/dc.h @@ -420,8 +420,8 @@ protected: #define MS_XDEV2LOGREL(x) DeviceToLogicalXRel(x) #define MS_YDEV2LOGREL(y) DeviceToLogicalYRel(y) -#define MM_POINTS 7 -#define MM_METRIC 8 +#define MM_POINTS 9 +#define MM_METRIC 10 extern int wxPageNumber; diff --git a/include/wx/msw/dialog.h b/include/wx/msw/dialog.h index b63c9875d0..235d431aa9 100644 --- a/include/wx/msw/dialog.h +++ b/include/wx/msw/dialog.h @@ -82,7 +82,6 @@ public: wxString GetTitle() const ; void OnSize(wxSizeEvent& event); - bool OnClose(); void OnCharHook(wxKeyEvent& event); void OnPaint(wxPaintEvent& event); void OnCloseWindow(wxCloseEvent& event); diff --git a/include/wx/msw/frame.h b/include/wx/msw/frame.h index d039be9de4..9e976c896a 100644 --- a/include/wx/msw/frame.h +++ b/include/wx/msw/frame.h @@ -74,8 +74,6 @@ public: virtual void ScreenToClient(int *x, int *y) const; - virtual bool OnClose(); - void OnSize(wxSizeEvent& event); void OnMenuHighlight(wxMenuEvent& event); void OnActivate(wxActivateEvent& event); diff --git a/include/wx/msw/metafile.h b/include/wx/msw/metafile.h index d5f6f3f8db..ec1237bf29 100644 --- a/include/wx/msw/metafile.h +++ b/include/wx/msw/metafile.h @@ -119,7 +119,7 @@ protected: /* * Pass filename of existing non-placeable metafile, and bounding box. * Adds a placeable metafile header, sets the mapping mode to anisotropic, - * and sets the window origin and extent to mimic the MM_TEXT mapping mode. + * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode. * */ diff --git a/include/wx/prntbase.h b/include/wx/prntbase.h index 9bd3aeb0c1..73a1b410a7 100644 --- a/include/wx/prntbase.h +++ b/include/wx/prntbase.h @@ -173,7 +173,7 @@ public: long style = wxDEFAULT_FRAME_STYLE, const wxString& name = "frame"); ~wxPreviewFrame(); - bool OnClose(); + void OnCloseWindow(wxCloseEvent& event); virtual void Initialize(); virtual void CreateCanvas(); virtual void CreateControlBar(); @@ -182,6 +182,8 @@ protected: wxWindow* m_previewCanvas; wxPreviewControlBar* m_controlBar; wxPrintPreviewBase* m_printPreview; + +DECLARE_EVENT_TABLE() }; /* diff --git a/include/wx/propform.h b/include/wx/propform.h index ede043929e..4acff593bb 100644 --- a/include/wx/propform.h +++ b/include/wx/propform.h @@ -61,7 +61,7 @@ class WXDLLEXPORT wxPropertyFormView: public wxPropertyView void OnUpdate(wxCommandEvent& event); void OnRevert(wxCommandEvent& event); - virtual bool OnClose(void); + virtual bool OnClose(); virtual void OnDoubleClick(wxControl *item); // TODO: does OnCommand still get called...??? @@ -230,7 +230,8 @@ class WXDLLEXPORT wxPropertyFormDialog: public wxDialog wxPropertyFormDialog(wxPropertyFormView *v, wxWindow *parent, const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE, const wxString& name = "dialogBox"); - bool OnClose(void); + + void OnCloseWindow(wxCloseEvent& event); void OnDefaultAction(wxControl *item); void OnCommand(wxWindow& win, wxCommandEvent& event); @@ -239,6 +240,8 @@ class WXDLLEXPORT wxPropertyFormDialog: public wxDialog private: wxPropertyFormView* m_view; + +DECLARE_EVENT_TABLE() }; /* @@ -281,7 +284,7 @@ class WXDLLEXPORT wxPropertyFormFrame: public wxFrame m_view = v; m_propertyPanel = NULL; } - bool OnClose(void); + void OnCloseWindow(wxCloseEvent& event); // Must call this to create panel and associate view virtual bool Initialize(void); @@ -291,6 +294,8 @@ class WXDLLEXPORT wxPropertyFormFrame: public wxFrame private: wxPropertyFormView* m_view; wxPanel* m_propertyPanel; + +DECLARE_EVENT_TABLE() }; #endif diff --git a/include/wx/proplist.h b/include/wx/proplist.h index a18213ae87..a3c6a5e24f 100644 --- a/include/wx/proplist.h +++ b/include/wx/proplist.h @@ -276,7 +276,7 @@ class WXDLLEXPORT wxPropertyListDialog: public wxDialog wxPropertyListDialog(wxPropertyListView *v, wxWindow *parent, const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE, const wxString& name = "dialogBox"); - bool OnClose(void); + void OnCloseWindow(wxCloseEvent& event); void OnDefaultAction(wxControl *item); void OnCancel(wxCommandEvent& event); @@ -338,7 +338,7 @@ class WXDLLEXPORT wxPropertyListFrame: public wxFrame m_view = v; m_propertyPanel = NULL; } - bool OnClose(void); + void OnCloseWindow(wxCloseEvent& event); // Must call this to create panel and associate view virtual bool Initialize(void); @@ -348,6 +348,8 @@ class WXDLLEXPORT wxPropertyListFrame: public wxFrame private: wxPropertyListView* m_view; wxPropertyListPanel* m_propertyPanel; + +DECLARE_EVENT_TABLE() }; /* diff --git a/include/wx/qt/dialog.h b/include/wx/qt/dialog.h index ebd7bff2a8..d68cc7c9a0 100644 --- a/include/wx/qt/dialog.h +++ b/include/wx/qt/dialog.h @@ -71,7 +71,6 @@ public: void SetTitle(const wxString& title); wxString GetTitle() const ; - bool OnClose(); void OnCharHook(wxKeyEvent& event); void OnCloseWindow(wxCloseEvent& event); diff --git a/include/wx/qt/frame.h b/include/wx/qt/frame.h index 70247ae171..2e76caab02 100644 --- a/include/wx/qt/frame.h +++ b/include/wx/qt/frame.h @@ -61,8 +61,6 @@ public: void GetPosition(int *x, int *y) const ; void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); - virtual bool OnClose(); - void OnSize(wxSizeEvent& event); void OnMenuHighlight(wxMenuEvent& event); void OnActivate(wxActivateEvent& event); diff --git a/include/wx/stubs/dialog.h b/include/wx/stubs/dialog.h index ebd7bff2a8..d68cc7c9a0 100644 --- a/include/wx/stubs/dialog.h +++ b/include/wx/stubs/dialog.h @@ -71,7 +71,6 @@ public: void SetTitle(const wxString& title); wxString GetTitle() const ; - bool OnClose(); void OnCharHook(wxKeyEvent& event); void OnCloseWindow(wxCloseEvent& event); diff --git a/include/wx/stubs/frame.h b/include/wx/stubs/frame.h index c013362175..c2b5eb39a8 100644 --- a/include/wx/stubs/frame.h +++ b/include/wx/stubs/frame.h @@ -63,8 +63,6 @@ public: void ClientToScreen(int *x, int *y) const; void ScreenToClient(int *x, int *y) const; - virtual bool OnClose(); - void OnSize(wxSizeEvent& event); void OnMenuHighlight(wxMenuEvent& event); void OnActivate(wxActivateEvent& event); diff --git a/include/wx/stubs/metafile.h b/include/wx/stubs/metafile.h index eb86b97a04..e4be296d92 100644 --- a/include/wx/stubs/metafile.h +++ b/include/wx/stubs/metafile.h @@ -87,7 +87,7 @@ protected: /* * Pass filename of existing non-placeable metafile, and bounding box. * Adds a placeable metafile header, sets the mapping mode to anisotropic, - * and sets the window origin and extent to mimic the MM_TEXT mapping mode. + * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode. * */ diff --git a/samples/bombs/bombs.cpp b/samples/bombs/bombs.cpp index cd652bcd46..cdf7b8570d 100644 --- a/samples/bombs/bombs.cpp +++ b/samples/bombs/bombs.cpp @@ -167,7 +167,7 @@ BombsCanvasClass::BombsCanvasClass(wxFrame *parent, const wxPoint& pos, const wx dc.GetTextExtent(buf, &chw, &chh); dc.SetFont(wxNullFont); - dc.SetMapMode(MM_METRIC); + dc.SetMapMode(wxMM_METRIC); int xcm = dc.LogicalToDeviceX(10.0); int ycm = dc.LogicalToDeviceY(10.0); @@ -183,7 +183,7 @@ BombsCanvasClass::BombsCanvasClass(wxFrame *parent, const wxPoint& pos, const wx } x_cell = (sx+3+X_UNIT)/X_UNIT; y_cell = (sy+3+Y_UNIT)/Y_UNIT; - dc.SetMapMode(MM_TEXT); + dc.SetMapMode(wxMM_TEXT); bmp=NULL; UpdateFieldSize(); } diff --git a/samples/checklst/checklst.cpp b/samples/checklst/checklst.cpp index 8f26703e8a..fcc848ded6 100644 --- a/samples/checklst/checklst.cpp +++ b/samples/checklst/checklst.cpp @@ -154,7 +154,7 @@ void CheckListBoxFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) void CheckListBoxFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { - wxMessageDialog dialog(this, "Demo of wxCheckListBox control\n" + wxMessageDialog dialog(this, "Demo of wxCheckListBox control\n", "About wxCheckListBox", wxYES_NO | wxCANCEL); dialog.ShowModal(); } diff --git a/samples/config/conftest.cpp b/samples/config/conftest.cpp index 6c47dc4bd6..b5ed3c607f 100644 --- a/samples/config/conftest.cpp +++ b/samples/config/conftest.cpp @@ -46,7 +46,7 @@ public: void OnQuit(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); void OnDelete(wxCommandEvent& event); - bool OnClose() { return TRUE; } + void OnCloseWindow(wxCloseEvent& event); private: wxTextCtrl *m_text; @@ -69,6 +69,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(Minimal_Quit, MyFrame::OnQuit) EVT_MENU(Minimal_About, MyFrame::OnAbout) EVT_MENU(Minimal_Delete, MyFrame::OnDelete) + EVT_CLOSE(MyFrame::OnCloseWindow) END_EVENT_TABLE() // ============================================================================ @@ -189,6 +190,11 @@ MyFrame::MyFrame() SetClientSize(w, h); } +void MyFrame::OnCloseWindow(wxCloseEvent& event) +{ + this->Destroy(); +} + void MyFrame::OnQuit(wxCommandEvent&) { Close(TRUE); diff --git a/samples/db/dbtest.cpp b/samples/db/dbtest.cpp index 466dfaf428..b4c08995e4 100644 --- a/samples/db/dbtest.cpp +++ b/samples/db/dbtest.cpp @@ -264,7 +264,7 @@ void DatabaseDemoFrame::OnCloseWindow(wxCloseEvent& event) // to close the program here that is not done elsewhere this->Destroy(); -} // DatabaseDemoFrame::OnClose() +} // DatabaseDemoFrame::OnCloseWindow() void DatabaseDemoFrame::CreateDataTable() @@ -651,21 +651,21 @@ CeditorDlg::CeditorDlg(wxWindow *parent) : wxPanel (parent, 1, 1, 460, 455) } // CeditorDlg constructor -bool CeditorDlg::OnClose() +void CeditorDlg::OnCloseWindow(wxCloseEvent& event) { // Clean up time if ((mode != mCreate) && (mode != mEdit)) { if (Contact) delete Contact; - return TRUE; + this->Destroy(); } else { wxMessageBox("Must finish processing the current record being created/modified before exiting","Notice...",wxOK | wxICON_INFORMATION); - return FALSE; + event.Veto(); } -} // CeditorDlg::OnClose() +} // CeditorDlg::OnCloseWindow() void CeditorDlg::OnButton( wxCommandEvent &event ) @@ -1283,6 +1283,11 @@ bool CeditorDlg::GetRec(char *whereStr) /* * CparameterDlg constructor */ + +BEGIN_EVENT_TABLE(CparameterDlg, wxDialog) + EVT_CLOSE(CparameterDlg::OnCloseWindow) +END_EVENT_TABLE() + CparameterDlg::CparameterDlg(wxWindow *parent) : wxDialog (parent, PARAMETER_DIALOG, "ODBC parameter settings", wxPoint(-1, -1), wxSize(400, 275)) { // Since the ::OnCommand() function is overridden, this prevents the widget @@ -1315,7 +1320,7 @@ CparameterDlg::CparameterDlg(wxWindow *parent) : wxDialog (parent, PARAMETER_DIA } // CparameterDlg constructor -bool CparameterDlg::OnClose() +void CparameterDlg::OnCloseWindow(wxCloseEvent& event) { // Put any additional checking necessary to make certain it is alright // to close the program here that is not done elsewhere @@ -1324,15 +1329,19 @@ bool CparameterDlg::OnClose() bool Ok = (wxMessageBox("No changes have been saved.\n\nAre you sure you wish exit the parameter screen?","Confirm",wxYES_NO|wxICON_QUESTION) == wxYES); if (!Ok) - return FALSE; + { + event.Veto(); + return; + } wxGetApp().params = savedParamSettings; } if (GetParent() != NULL) GetParent()->SetFocus(); - return TRUE; -} // Cparameter::OnClose() + this->Destroy(); + +} // Cparameter::OnCloseWindow() void CparameterDlg::OnCommand(wxWindow& win, wxCommandEvent& event) @@ -1471,6 +1480,7 @@ void CparameterDlg::FillDataSourceList() BEGIN_EVENT_TABLE(CqueryDlg, wxDialog) EVT_BUTTON(-1, CqueryDlg::OnButton) + EVT_CLOSE(CqueryDlg::OnCloseWindow) END_EVENT_TABLE() // CqueryDlg() constructor @@ -1800,7 +1810,7 @@ void CqueryDlg::OnCommand(wxWindow& win, wxCommandEvent& event) } // CqueryDlg::OnCommand -bool CqueryDlg::OnClose() +void CqueryDlg::OnCloseWindow(wxCloseEvent& event) { // Clean up if (colInf) @@ -1817,9 +1827,10 @@ bool CqueryDlg::OnClose() GetParent()->SetFocus(); wxEndBusyCursor(); - return TRUE; -} // CqueryDlg::OnClose() + this->Destroy(); + +} // CqueryDlg::OnCloseWindow() /* bool CqueryDlg::SetWidgetPtrs() diff --git a/samples/db/dbtest.h b/samples/db/dbtest.h index 516204e389..b6d1bd6ea3 100644 --- a/samples/db/dbtest.h +++ b/samples/db/dbtest.h @@ -165,7 +165,7 @@ class CeditorDlg : public wxPanel Ccontact *Contact; // this is the table object that will be being manipulated CeditorDlg(wxWindow *parent); - bool OnClose(void); + void OnCloseWindow(wxCloseEvent& event); void OnButton( wxCommandEvent &event ); void OnCommand(wxWindow& win, wxCommandEvent& event); void OnActivate(bool) {}; // necessary for hot keys @@ -243,7 +243,7 @@ class CparameterDlg : public wxDialog public: CparameterDlg(wxWindow *parent); - bool OnClose(void); + void OnCloseWindow(wxCloseEvent& event); void OnCommand(wxWindow& win, wxCommandEvent& event); void OnActivate(bool) {}; // necessary for hot keys @@ -252,6 +252,7 @@ class CparameterDlg : public wxDialog bool Save(); void FillDataSourceList(); +DECLARE_EVENT_TABLE() }; // CparameterDlg #define PARAMETER_DIALOG 400 @@ -341,7 +342,7 @@ class CqueryDlg : public wxDialog void OnButton( wxCommandEvent &event ); void OnCommand(wxWindow& win, wxCommandEvent& event); - bool OnClose(); + void OnCloseWindow(wxCloseEvent& event); void OnActivate(bool) {}; // necessary for hot keys // bool SetWidgetPtrs(); diff --git a/samples/dialogs/dialogs.h b/samples/dialogs/dialogs.h index ed541cc7e1..3141b2fd4b 100644 --- a/samples/dialogs/dialogs.h +++ b/samples/dialogs/dialogs.h @@ -26,7 +26,6 @@ class MyFrame: public wxFrame { public: MyFrame(wxWindow *parent, const wxString& title, const wxPoint& pos, const wxSize& size); - bool OnClose(void) { return TRUE; } void ChooseColour(wxCommandEvent& event); void ChooseFont(wxCommandEvent& event); diff --git a/samples/dnd/dnd.cpp b/samples/dnd/dnd.cpp index d2983beb5a..a2e20c7992 100644 --- a/samples/dnd/dnd.cpp +++ b/samples/dnd/dnd.cpp @@ -91,8 +91,6 @@ public: void OnLeftDown(wxMouseEvent& event); void OnRightDown(wxMouseEvent& event); - bool OnClose(); - DECLARE_EVENT_TABLE() private: @@ -302,11 +300,6 @@ void DnDFrame::OnLogClear(wxCommandEvent& /* event */ ) m_ctrlLog->Clear(); } -bool DnDFrame::OnClose() -{ - return TRUE; -} - void DnDFrame::OnLeftDown(wxMouseEvent &WXUNUSED(event) ) { if ( !m_strText.IsEmpty() ) diff --git a/samples/dynamic/dynamic.cpp b/samples/dynamic/dynamic.cpp index c32ca01362..06847f1253 100644 --- a/samples/dynamic/dynamic.cpp +++ b/samples/dynamic/dynamic.cpp @@ -43,7 +43,6 @@ class MyFrame: public wxFrame public: void OnQuit(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); - bool OnClose(void) { return TRUE; } }; // ID for the menu commands diff --git a/samples/forty/canvas.cpp b/samples/forty/canvas.cpp index 2ba1f15c5b..373e16942f 100644 --- a/samples/forty/canvas.cpp +++ b/samples/forty/canvas.cpp @@ -123,13 +123,13 @@ void FortyCanvas::OnDraw(wxDC& dc) /* Called when the main frame is closed */ -bool FortyCanvas::OnClose() +bool FortyCanvas::OnCloseCanvas() { if (m_game->InPlay() && wxMessageBox("Are you sure you want to\nabandon the current game?", "Warning", wxYES_NO | wxICON_QUESTION) == wxNO) { - return FALSE; + return FALSE; } return TRUE; } diff --git a/samples/forty/canvas.h b/samples/forty/canvas.h index 368d6c6b61..60abf5f2d3 100644 --- a/samples/forty/canvas.h +++ b/samples/forty/canvas.h @@ -25,7 +25,7 @@ public: virtual ~FortyCanvas(); virtual void OnDraw(wxDC& dc); - bool OnClose(); + bool OnCloseCanvas(); void OnMouseEvent(wxMouseEvent& event); void SetCursorStyle(int x, int y); diff --git a/samples/forty/forty.cpp b/samples/forty/forty.cpp index 6195e27f4b..425f420247 100644 --- a/samples/forty/forty.cpp +++ b/samples/forty/forty.cpp @@ -40,7 +40,7 @@ public: FortyFrame(wxFrame* frame, char* title, int x, int y, int w, int h); virtual ~FortyFrame(); - bool OnClose(); + void OnCloseWindow(wxCloseEvent& event); // Menu callbacks void NewGame(wxCommandEvent& event); @@ -73,6 +73,7 @@ BEGIN_EVENT_TABLE(FortyFrame, wxFrame) EVT_MENU(SCORES, FortyFrame::Scores) EVT_MENU(RIGHT_BUTTON_UNDO, FortyFrame::ToggleRightButtonUndo) EVT_MENU(HELPING_HAND, FortyFrame::ToggleHelpingHand) + EVT_CLOSE(FortyFrame::OnCloseWindow) END_EVENT_TABLE() // Create a new application object @@ -189,9 +190,14 @@ FortyFrame::~FortyFrame() { } -bool FortyFrame::OnClose() +void FortyFrame::OnCloseWindow(wxCloseEvent& event) { - return m_canvas->OnClose(); + if (m_canvas->OnCloseCanvas()) + { + this->Destroy(); + } + else + event.Veto(); } void @@ -205,7 +211,7 @@ FortyFrame::Exit(wxCommandEvent&) { #ifdef __WXGTK__ // wxGTK doesn't call OnClose() so we do it here - if (OnClose()) +// if (OnClose()) #endif Close(TRUE); } diff --git a/samples/forty/playerdg.cpp b/samples/forty/playerdg.cpp index e55cd0f93d..dc04b7f4c7 100644 --- a/samples/forty/playerdg.cpp +++ b/samples/forty/playerdg.cpp @@ -37,6 +37,7 @@ BEGIN_EVENT_TABLE(PlayerSelectionDialog, wxDialog) EVT_BUTTON(wxID_OK, PlayerSelectionDialog::ButtonCallback) EVT_BUTTON(wxID_CANCEL, PlayerSelectionDialog::ButtonCallback) EVT_LISTBOX(ID_LISTBOX, PlayerSelectionDialog::SelectCallback) + EVT_CLOSE(PlayerSelectionDialog::OnCloseWindow) END_EVENT_TABLE() PlayerSelectionDialog::PlayerSelectionDialog( @@ -142,13 +143,10 @@ const wxString& PlayerSelectionDialog::GetPlayersName() return m_player; } -bool PlayerSelectionDialog::OnClose() +void PlayerSelectionDialog::OnCloseWindow(wxCloseEvent& event) { - // hide the dialog - // NB don't return TRUE otherwise delete is called m_player = ""; - Show(FALSE); - return FALSE; + EndModal(wxID_CANCEL); } void PlayerSelectionDialog::SelectCallback(wxCommandEvent& event) diff --git a/samples/forty/playerdg.h b/samples/forty/playerdg.h index 995ac57a80..70d9cfb6cb 100644 --- a/samples/forty/playerdg.h +++ b/samples/forty/playerdg.h @@ -28,7 +28,7 @@ public: protected: friend void SelectCallback(wxListBox&, wxCommandEvent&); - bool OnClose(); + void OnCloseWindow(wxCloseEvent& event); private: ScoreFile* m_scoreFile; diff --git a/samples/forty/scoredg.cpp b/samples/forty/scoredg.cpp index befb3725cd..de7d7a6a09 100644 --- a/samples/forty/scoredg.cpp +++ b/samples/forty/scoredg.cpp @@ -137,6 +137,9 @@ void ScoreCanvas::OnDraw(wxDC& dc) } } +BEGIN_EVENT_TABLE(ScoreDialog, wxDialog) + EVT_CLOSE(ScoreDialog::OnCloseWindow) +END_EVENT_TABLE() ScoreDialog::ScoreDialog( wxWindow* parent, @@ -183,10 +186,7 @@ void ScoreDialog::Display() Show(TRUE); } -bool ScoreDialog::OnClose() +void ScoreDialog::OnCloseWindow(wxCloseEvent& event) { - // hide the dialog - // NB don't return TRUE otherwise delete is called - Show(FALSE); - return FALSE; + EndModal(wxID_OK); } diff --git a/samples/forty/scoredg.h b/samples/forty/scoredg.h index c63cf03547..8ce7a7274d 100644 --- a/samples/forty/scoredg.h +++ b/samples/forty/scoredg.h @@ -22,11 +22,13 @@ public: void Display(); protected: - bool OnClose(); + void OnCloseWindow(wxCloseEvent& event); private: ScoreFile* m_scoreFile; wxButton* m_OK; + +DECLARE_EVENT_TABLE() }; #endif diff --git a/samples/grid/test.cpp b/samples/grid/test.cpp index ceb64fce1e..7662b5b09c 100644 --- a/samples/grid/test.cpp +++ b/samples/grid/test.cpp @@ -40,8 +40,6 @@ class MyFrame: public wxFrame wxGrid *grid; MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size); - bool OnClose(void) { return TRUE; } - void ToggleEditable(wxCommandEvent& event); void ToggleRowLabel(wxCommandEvent& event); void ToggleColLabel(wxCommandEvent& event); diff --git a/samples/internat/internat.cpp b/samples/internat/internat.cpp index 6f2826b1c2..c191d76410 100644 --- a/samples/internat/internat.cpp +++ b/samples/internat/internat.cpp @@ -54,8 +54,7 @@ public: void OnAbout(wxCommandEvent& event); void OnPlay(wxCommandEvent& event); void OnOpen(wxCommandEvent& event); - bool OnClose() { return TRUE; } - + DECLARE_EVENT_TABLE() }; diff --git a/samples/joytest/joytest.cpp b/samples/joytest/joytest.cpp index 92add26604..2709bc19ff 100644 --- a/samples/joytest/joytest.cpp +++ b/samples/joytest/joytest.cpp @@ -164,8 +164,3 @@ void MyFrame::OnActivate(wxActivateEvent& event) if (event.GetActive() && canvas) canvas->SetFocus(); } - -bool MyFrame::OnClose(void) -{ - return TRUE; -} \ No newline at end of file diff --git a/samples/joytest/joytest.h b/samples/joytest/joytest.h index 68c4f68075..afa8a21a86 100644 --- a/samples/joytest/joytest.h +++ b/samples/joytest/joytest.h @@ -40,7 +40,6 @@ class MyFrame: public wxFrame MyCanvas *canvas; MyFrame(wxFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size, const long style); ~MyFrame(void); - bool OnClose(void); void OnActivate(wxActivateEvent& event); void OnQuit(wxCommandEvent& event); diff --git a/samples/layout/layout.cpp b/samples/layout/layout.cpp index e33b97fad9..ab66c79b01 100644 --- a/samples/layout/layout.cpp +++ b/samples/layout/layout.cpp @@ -244,14 +244,6 @@ void MyWindow::OnPaint(wxPaintEvent& WXUNUSED(event) ) frame->Draw(dc,TRUE); } -// Define the behaviour for the frame closing -// - must delete all frames except for the main one. -bool MyFrame::OnClose(void) -{ - Show(FALSE); - - return TRUE; -} SizerFrame::SizerFrame(wxFrame *frame, char *title, int x, int y, int w, int h): wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h)) @@ -346,10 +338,3 @@ void SizerFrame::OnSize(wxSizeEvent& event) panel->Layout(); } -bool SizerFrame::OnClose(void) -{ - Show(FALSE); - - return TRUE; -} - diff --git a/samples/layout/layout.h b/samples/layout/layout.h index 83aca0d956..15fa044a8f 100644 --- a/samples/layout/layout.h +++ b/samples/layout/layout.h @@ -29,7 +29,6 @@ class MyFrame: public wxFrame MyWindow *canvas; MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h); void OnSize(wxSizeEvent& event); - bool OnClose(void); void Draw(wxDC& dc, bool draw_bitmaps = TRUE); void LoadFile(wxCommandEvent& event); @@ -68,7 +67,6 @@ class SizerFrame: public wxFrame wxPanel *panel; SizerFrame(wxFrame *frame, char *title, int x, int y, int w, int h); void OnSize(wxSizeEvent& event); - bool OnClose(void); DECLARE_EVENT_TABLE() }; diff --git a/samples/listctrl/listtest.h b/samples/listctrl/listtest.h index c9bbb749bd..79063942a4 100644 --- a/samples/listctrl/listtest.h +++ b/samples/listctrl/listtest.h @@ -60,7 +60,6 @@ class MyFrame: public wxFrame void OnIconTextView(wxCommandEvent& event); void OnSmallIconView(wxCommandEvent& event); void OnSmallIconTextView(wxCommandEvent& event); - bool OnClose(void) { return TRUE; } void OnDeselectAll(wxCommandEvent& event); void OnSelectAll(wxCommandEvent& event); diff --git a/samples/mdi/mdi.cpp b/samples/mdi/mdi.cpp index 10deb7665c..7f4327481c 100644 --- a/samples/mdi/mdi.cpp +++ b/samples/mdi/mdi.cpp @@ -237,23 +237,6 @@ void MyCanvas::OnEvent(wxMouseEvent& event) ypos = pt.y; } -// Define the behaviour for the frame closing -// - must delete all frames except for the main one. -bool MyFrame::OnClose(void) -{ - // Must delete children - wxNode *node = my_children.First(); - while (node) - { - MyChild *child = (MyChild *)node->Data(); - wxNode *next = node->Next(); - child->OnClose(); - delete child; - node = next; - } - return TRUE; -} - void MyFrame::OnSize(wxSizeEvent& WXUNUSED(event) ) { int w, h; @@ -295,11 +278,6 @@ void MyChild::OnActivate(wxActivateEvent& event) canvas->SetFocus(); } -bool MyChild::OnClose(void) -{ - return TRUE; -} - void MyFrame::InitToolBar(wxToolBar* toolBar) { wxBitmap* bitmaps[8]; diff --git a/samples/mdi/mdi.h b/samples/mdi/mdi.h index 7415c60585..08f59a8c7e 100644 --- a/samples/mdi/mdi.h +++ b/samples/mdi/mdi.h @@ -38,7 +38,6 @@ class MyFrame: public wxMDIParentFrame void InitToolBar(wxToolBar* toolBar); - bool OnClose(void); void OnSize(wxSizeEvent& event); void OnAbout(wxCommandEvent& event); void OnNewWindow(wxCommandEvent& event); @@ -53,7 +52,6 @@ class MyChild: public wxMDIChildFrame MyCanvas *canvas; MyChild(wxMDIParentFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size, const long style); ~MyChild(void); - bool OnClose(void); void OnActivate(wxActivateEvent& event); void OnQuit(wxCommandEvent& event); diff --git a/samples/mfc/mfctest.cpp b/samples/mfc/mfctest.cpp index 79a7006bcf..91ed30dbdc 100644 --- a/samples/mfc/mfctest.cpp +++ b/samples/mfc/mfctest.cpp @@ -93,7 +93,6 @@ class MyChild: public wxFrame MyCanvas *canvas; MyChild(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size, const long style); ~MyChild(void); - bool OnClose(void); void OnQuit(wxCommandEvent& event); void OnNew(wxCommandEvent& event); @@ -376,12 +375,6 @@ void MyChild::OnActivate(wxActivateEvent& event) canvas->SetFocus(); } -bool MyChild::OnClose(void) -{ - return TRUE; -} - - // Dummy MFC window for specifying a valid main window to MFC, using // a wxWindows HWND. CDummyWindow::CDummyWindow(HWND hWnd):CWnd() diff --git a/samples/nativdlg/nativdlg.cpp b/samples/nativdlg/nativdlg.cpp index 82151d75c7..6d16c488af 100644 --- a/samples/nativdlg/nativdlg.cpp +++ b/samples/nativdlg/nativdlg.cpp @@ -108,13 +108,6 @@ void MyFrame::OnTest1(wxCommandEvent& event) dialog->Close(TRUE); } -bool MyFrame::OnClose(void) -{ - Show(FALSE); - - return TRUE; -} - BEGIN_EVENT_TABLE(MyDialog, wxDialog) EVT_BUTTON(wxID_OK, MyDialog::OnOk) EVT_BUTTON(wxID_CANCEL, MyDialog::OnCancel) diff --git a/samples/nativdlg/nativdlg.h b/samples/nativdlg/nativdlg.h index 25688ea5fc..5bc20575c2 100644 --- a/samples/nativdlg/nativdlg.h +++ b/samples/nativdlg/nativdlg.h @@ -26,7 +26,6 @@ class MyFrame: public wxFrame public: wxWindow *panel; MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size); - bool OnClose(void); void OnQuit(wxCommandEvent& event); void OnTest1(wxCommandEvent& event); diff --git a/samples/ownerdrw/ownerdrw.cpp b/samples/ownerdrw/ownerdrw.cpp index 27815e5424..741ddec001 100644 --- a/samples/ownerdrw/ownerdrw.cpp +++ b/samples/ownerdrw/ownerdrw.cpp @@ -263,7 +263,8 @@ void OwnerDrawnFrame::OnQuit(wxCommandEvent& event) void OwnerDrawnFrame::OnAbout(wxCommandEvent& event) { - wxMessageDialog dialog(this, "Demo of owner-drawn controls\n" + wxMessageDialog dialog(this, + "Demo of owner-drawn controls\n", "About wxOwnerDrawn", wxYES_NO | wxCANCEL); dialog.ShowModal(); } diff --git a/samples/png/pngdemo.cpp b/samples/png/pngdemo.cpp index be10ff0534..da50f96d5d 100644 --- a/samples/png/pngdemo.cpp +++ b/samples/png/pngdemo.cpp @@ -207,12 +207,4 @@ void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) } } -// Define the behaviour for the frame closing -// - must delete all frames except for the main one. -bool MyFrame::OnClose(void) -{ - Show(FALSE); - - return TRUE; -} diff --git a/samples/png/pngdemo.h b/samples/png/pngdemo.h index eef3432f11..e250aa69d2 100644 --- a/samples/png/pngdemo.h +++ b/samples/png/pngdemo.h @@ -32,7 +32,6 @@ class MyFrame: public wxFrame MyCanvas *canvas; MyFrame(wxFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size); - bool OnClose(void); void OnActivate(bool) {} void OnLoadFile(wxCommandEvent& event); void OnSaveFile(wxCommandEvent& event); diff --git a/samples/printing/printing.cpp b/samples/printing/printing.cpp index 89743d913b..4ace50d72a 100644 --- a/samples/printing/printing.cpp +++ b/samples/printing/printing.cpp @@ -131,6 +131,12 @@ bool MyApp::OnInit(void) return TRUE; } +int MyApp::OnExit() +{ + delete wxGetApp().m_testFont; + return 1; +} + BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(WXPRINT_QUIT, MyFrame::OnExit) EVT_MENU(WXPRINT_PRINT, MyFrame::OnPrint) @@ -317,14 +323,6 @@ void MyCanvas::OnEvent(wxMouseEvent& WXUNUSED(event)) { } -bool MyFrame::OnClose(void) -{ - Show(FALSE); - delete wxGetApp().m_testFont; - - return TRUE; -} - bool MyPrintout::OnPrintPage(int page) { wxDC *dc = GetDC(); diff --git a/samples/printing/printing.h b/samples/printing/printing.h index 1b56be4d70..d9df02dfbb 100644 --- a/samples/printing/printing.h +++ b/samples/printing/printing.h @@ -17,8 +17,9 @@ class MyApp: public wxApp { public: - MyApp(void) ; - bool OnInit(void); + MyApp() ; + bool OnInit(); + int OnExit(); wxFont* m_testFont; }; @@ -34,8 +35,6 @@ class MyFrame: public wxFrame MyCanvas *canvas; MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size); - bool OnClose(void); - void Draw(wxDC& dc); void OnSize(wxSizeEvent& event); diff --git a/samples/resource/resource.cpp b/samples/resource/resource.cpp index 836cf563a4..588b3873ff 100644 --- a/samples/resource/resource.cpp +++ b/samples/resource/resource.cpp @@ -173,13 +173,6 @@ void MyFrame::OnTestDialog(wxCommandEvent& WXUNUSED(event) ) dialog->Close(TRUE); } -bool MyFrame::OnClose(void) -{ - Show(FALSE); - - return TRUE; -} - BEGIN_EVENT_TABLE(MyDialog, wxDialog) // EVT_BUTTON(RESOURCE_OK, MyDialog::OnOk) EVT_BUTTON(ID_BUTTON109, MyDialog::OnCancel) diff --git a/samples/resource/resource.h b/samples/resource/resource.h index 714d982ffd..5975b871c7 100644 --- a/samples/resource/resource.h +++ b/samples/resource/resource.h @@ -40,7 +40,6 @@ class MyFrame: public wxFrame public: MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size); - bool OnClose(); void OnQuit(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); void OnTestDialog(wxCommandEvent& event); diff --git a/samples/sashtest/sashtest.cpp b/samples/sashtest/sashtest.cpp index 3917a31ab2..d5f42bacd4 100644 --- a/samples/sashtest/sashtest.cpp +++ b/samples/sashtest/sashtest.cpp @@ -312,23 +312,6 @@ void MyCanvas::OnEvent(wxMouseEvent& event) ypos = pt.y; } -// Define the behaviour for the frame closing -// - must delete all frames except for the main one. -bool MyFrame::OnClose(void) -{ - // Must delete children - wxNode *node = my_children.First(); - while (node) - { - MyChild *child = (MyChild *)node->Data(); - wxNode *next = node->Next(); - child->OnClose(); - delete child; - node = next; - } - return TRUE; -} - void MyFrame::OnSize(wxSizeEvent& WXUNUSED(event)) { wxLayoutAlgorithm layout; @@ -367,9 +350,3 @@ void MyChild::OnActivate(wxActivateEvent& event) canvas->SetFocus(); } -bool MyChild::OnClose(void) -{ - return TRUE; -} - - diff --git a/samples/sashtest/sashtest.h b/samples/sashtest/sashtest.h index ed5fa54197..fd2737f82e 100644 --- a/samples/sashtest/sashtest.h +++ b/samples/sashtest/sashtest.h @@ -35,7 +35,6 @@ class MyFrame: public wxMDIParentFrame MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, const long style); - bool OnClose(void); void OnSize(wxSizeEvent& event); void OnAbout(wxCommandEvent& event); void OnNewWindow(wxCommandEvent& event); @@ -58,7 +57,6 @@ class MyChild: public wxMDIChildFrame MyCanvas *canvas; MyChild(wxMDIParentFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size, const long style); ~MyChild(void); - bool OnClose(void); void OnActivate(wxActivateEvent& event); void OnQuit(wxCommandEvent& event); diff --git a/samples/splitter/test.cpp b/samples/splitter/test.cpp index 33a25ed12a..dcd6718c68 100644 --- a/samples/splitter/test.cpp +++ b/samples/splitter/test.cpp @@ -62,8 +62,6 @@ public: MyFrame(wxFrame* frame, const wxString& title, const wxPoint& pos, const wxSize& size); virtual ~MyFrame(); - bool OnClose(); - // Menu commands void SplitHorizontal(wxCommandEvent& event); void SplitVertical(wxCommandEvent& event); @@ -185,11 +183,6 @@ MyFrame::~MyFrame() { } -bool MyFrame::OnClose() -{ - return TRUE; -} - void MyFrame::Quit(wxCommandEvent& WXUNUSED(event) ) { Close(TRUE); diff --git a/samples/thread/test.cpp b/samples/thread/test.cpp index dce914e8e6..71f34019dc 100644 --- a/samples/thread/test.cpp +++ b/samples/thread/test.cpp @@ -73,7 +73,6 @@ public: void OnResumeThread(wxCommandEvent& event); void OnIdle(wxIdleEvent &event); - bool OnClose() { return TRUE; } // called by dying thread _in_that_thread_context_ void OnThreadExit(wxThread *thread); diff --git a/samples/typetest/typetest.h b/samples/typetest/typetest.h index 8cd87eac03..aa78a80bd5 100644 --- a/samples/typetest/typetest.h +++ b/samples/typetest/typetest.h @@ -47,7 +47,6 @@ public: public: void OnQuit(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); - bool OnClose(void) { return TRUE; } DECLARE_EVENT_TABLE() diff --git a/samples/validate/validate.h b/samples/validate/validate.h index b4b9046561..5b761fd321 100644 --- a/samples/validate/validate.h +++ b/samples/validate/validate.h @@ -27,7 +27,6 @@ class MyFrame: public wxFrame public: void OnQuit(wxCommandEvent& event); void OnTestDialog(wxCommandEvent& event); - bool OnClose(void) { return TRUE; } DECLARE_EVENT_TABLE() diff --git a/samples/wxpoem/wxpoem.cpp b/samples/wxpoem/wxpoem.cpp index 7ae00905cc..de5a8fc21d 100644 --- a/samples/wxpoem/wxpoem.cpp +++ b/samples/wxpoem/wxpoem.cpp @@ -47,6 +47,13 @@ #include #include +#ifdef __WINDOWS__ +#include +#ifdef DrawText +#undef DrawText +#endif +#endif + #define buf_size 10000 #define DEFAULT_POETRY_DAT "wxpoem" #define DEFAULT_POETRY_IND "wxpoem" diff --git a/src/common/event.cpp b/src/common/event.cpp index 79580ae5c1..fb469f58e1 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -476,6 +476,7 @@ bool wxEvtHandler::SearchDynamicEventTable( wxEvent& event ) return FALSE; }; +#if WXWIN_COMPATIBILITY bool wxEvtHandler::OnClose() { if (GetNextHandler()) @@ -483,3 +484,5 @@ bool wxEvtHandler::OnClose() else return FALSE; } +#endif + diff --git a/src/common/prntbase.cpp b/src/common/prntbase.cpp index c8cba869c4..23e49e721e 100644 --- a/src/common/prntbase.cpp +++ b/src/common/prntbase.cpp @@ -429,6 +429,10 @@ int wxPreviewControlBar::GetZoomControl() * Preview frame */ +BEGIN_EVENT_TABLE(wxPreviewFrame, wxFrame) + EVT_CLOSE(wxPreviewFrame::OnCloseWindow) +END_EVENT_TABLE() + wxPreviewFrame::wxPreviewFrame(wxPrintPreviewBase *preview, wxFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name): wxFrame(parent, -1, title, pos, size, style, name) @@ -442,7 +446,7 @@ wxPreviewFrame::~wxPreviewFrame() { } -bool wxPreviewFrame::OnClose() +void wxPreviewFrame::OnCloseWindow(wxCloseEvent& event) { MakeModal(FALSE); @@ -456,7 +460,8 @@ bool wxPreviewFrame::OnClose() m_printPreview->SetFrame(NULL); } delete m_printPreview; - return TRUE; + + Destroy(); } void wxPreviewFrame::Initialize() diff --git a/src/generic/colrdlgg.cpp b/src/generic/colrdlgg.cpp index daec7a16fb..192fbbcddb 100644 --- a/src/generic/colrdlgg.cpp +++ b/src/generic/colrdlgg.cpp @@ -46,6 +46,7 @@ BEGIN_EVENT_TABLE(wxGenericColourDialog, wxDialog) EVT_SLIDER(wxID_BLUE_SLIDER, wxGenericColourDialog::OnBlueSlider) EVT_PAINT(wxGenericColourDialog::OnPaint) EVT_MOUSE_EVENTS(wxGenericColourDialog::OnMouseEvent) + EVT_CLOSE(wxGenericColourDialog::OnCloseWindow) END_EVENT_TABLE() #endif @@ -129,10 +130,9 @@ wxGenericColourDialog::~wxGenericColourDialog(void) { } -bool wxGenericColourDialog::OnClose(void) +void wxGenericColourDialog::OnCloseWindow(wxCloseEvent& event) { - Show(FALSE); - return FALSE; + EndModal(wxID_CANCEL); } bool wxGenericColourDialog::Create(wxWindow *parent, wxColourData *data) diff --git a/src/generic/fontdlgg.cpp b/src/generic/fontdlgg.cpp index 8e02bee12b..31d7d202c4 100644 --- a/src/generic/fontdlgg.cpp +++ b/src/generic/fontdlgg.cpp @@ -51,6 +51,7 @@ BEGIN_EVENT_TABLE(wxGenericFontDialog, wxDialog) EVT_CHOICE(wxID_FONT_COLOUR, wxGenericFontDialog::OnChangeFont) EVT_CHOICE(wxID_FONT_SIZE, wxGenericFontDialog::OnChangeFont) EVT_PAINT(wxGenericFontDialog::OnPaint) + EVT_CLOSE(wxGenericFontDialog::OnCloseWindow) END_EVENT_TABLE() #endif @@ -132,10 +133,9 @@ wxGenericFontDialog::~wxGenericFontDialog(void) { } -bool wxGenericFontDialog::OnClose(void) +void wxGenericFontDialog::OnCloseWindow(wxCloseEvent& event) { - Show(FALSE); - return FALSE; + EndModal(wxID_CANCEL); } bool wxGenericFontDialog::Create(wxWindow *parent, wxFontData *data) diff --git a/src/generic/propform.cpp b/src/generic/propform.cpp index 2a94303a4e..e1e22a94b6 100644 --- a/src/generic/propform.cpp +++ b/src/generic/propform.cpp @@ -284,6 +284,10 @@ void wxPropertyFormView::OnDoubleClick(wxControl *item) IMPLEMENT_CLASS(wxPropertyFormDialog, wxDialog) +BEGIN_EVENT_TABLE(wxPropertyFormDialog, wxDialog) + EVT_CLOSE(wxPropertyFormDialog::OnCloseWindow) +END_EVENT_TABLE() + wxPropertyFormDialog::wxPropertyFormDialog(wxPropertyFormView *v, wxWindow *parent, const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name): wxDialog(parent, -1, title, pos, size, style, name) @@ -294,16 +298,16 @@ wxPropertyFormDialog::wxPropertyFormDialog(wxPropertyFormView *v, wxWindow *pare // SetAutoLayout(TRUE); } -bool wxPropertyFormDialog::OnClose(void) +void wxPropertyFormDialog::OnCloseWindow(wxCloseEvent& event) { if (m_view) { m_view->OnClose(); m_view = NULL; - return TRUE; + this->Destroy(); } else - return FALSE; + event.Veto(); } void wxPropertyFormDialog::OnDefaultAction(wxControl *item) @@ -358,12 +362,16 @@ bool wxPropertyFormPanel::ProcessEvent(wxEvent& event) IMPLEMENT_CLASS(wxPropertyFormFrame, wxFrame) -bool wxPropertyFormFrame::OnClose(void) +BEGIN_EVENT_TABLE(wxPropertyFormFrame, wxFrame) + EVT_CLOSE(wxPropertyFormFrame::OnCloseWindow) +END_EVENT_TABLE() + +void wxPropertyFormFrame::OnCloseWindow(wxCloseEvent& event) { - if (m_view) - return m_view->OnClose(); + if (m_view && m_view->OnClose()) + this->Destroy(); else - return FALSE; + event.Veto(); } wxPanel *wxPropertyFormFrame::OnCreatePanel(wxFrame *parent, wxPropertyFormView *v) diff --git a/src/generic/proplist.cpp b/src/generic/proplist.cpp index f78601ef00..d9256c35c8 100644 --- a/src/generic/proplist.cpp +++ b/src/generic/proplist.cpp @@ -808,6 +808,7 @@ IMPLEMENT_CLASS(wxPropertyListDialog, wxDialog) BEGIN_EVENT_TABLE(wxPropertyListDialog, wxDialog) EVT_BUTTON(wxID_CANCEL, wxPropertyListDialog::OnCancel) + EVT_CLOSE(wxPropertyListDialog::OnCloseWindow) END_EVENT_TABLE() wxPropertyListDialog::wxPropertyListDialog(wxPropertyListView *v, wxWindow *parent, @@ -821,17 +822,19 @@ wxPropertyListDialog::wxPropertyListDialog(wxPropertyListView *v, wxWindow *pare SetAutoLayout(TRUE); } -bool wxPropertyListDialog::OnClose(void) +void wxPropertyListDialog::OnCloseWindow(wxCloseEvent& event) { if (m_view) { SetReturnCode(wxID_CANCEL); m_view->OnClose(); m_view = NULL; - return TRUE; + this->Destroy(); } else - return FALSE; + { + event.Veto(); + } } void wxPropertyListDialog::OnCancel(wxCommandEvent& WXUNUSED(event)) @@ -899,7 +902,11 @@ void wxPropertyListPanel::OnSize(wxSizeEvent& WXUNUSED(event)) IMPLEMENT_CLASS(wxPropertyListFrame, wxFrame) -bool wxPropertyListFrame::OnClose(void) +BEGIN_EVENT_TABLE(wxPropertyListFrame, wxFrame) + EVT_CLOSE(wxPropertyListFrame::OnCloseWindow) +END_EVENT_TABLE() + +void wxPropertyListFrame::OnCloseWindow(wxCloseEvent& event) { if (m_view) { @@ -907,10 +914,12 @@ bool wxPropertyListFrame::OnClose(void) m_propertyPanel->SetView(NULL); m_view->OnClose(); m_view = NULL; - return TRUE; + this->Destroy(); } else - return FALSE; + { + event.Veto(); + } } wxPropertyListPanel *wxPropertyListFrame::OnCreatePanel(wxFrame *parent, wxPropertyListView *v) diff --git a/src/gtk/dc.cpp b/src/gtk/dc.cpp index 1262fc6b77..2f287d17ad 100644 --- a/src/gtk/dc.cpp +++ b/src/gtk/dc.cpp @@ -57,7 +57,7 @@ wxDC::wxDC() m_scaleX = 1.0; m_scaleY = 1.0; - m_mappingMode = MM_TEXT; + m_mappingMode = wxMM_TEXT; m_needComputeScaleX = FALSE; /* not used yet */ m_needComputeScaleY = FALSE; /* not used yet */ @@ -217,25 +217,25 @@ void wxDC::SetMapMode( int mode ) { switch (mode) { - case MM_TWIPS: + case wxMM_TWIPS: SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y ); break; - case MM_POINTS: + case wxMM_POINTS: SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y ); break; - case MM_METRIC: + case wxMM_METRIC: SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y ); break; - case MM_LOMETRIC: + case wxMM_LOMETRIC: SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 ); break; default: - case MM_TEXT: + case wxMM_TEXT: SetLogicalScale( 1.0, 1.0 ); break; } /* we don't do this mega optimisation - if (mode != MM_TEXT) + if (mode != wxMM_TEXT) { m_needComputeScaleX = TRUE; m_needComputeScaleY = TRUE; diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index 4a0e3abd26..b64413f338 100644 --- a/src/gtk/dialog.cpp +++ b/src/gtk/dialog.cpp @@ -219,14 +219,25 @@ void wxDialog::OnPaint( wxPaintEvent& WXUNUSED(event) ) void wxDialog::OnCloseWindow(wxCloseEvent& event) { + // We'll send a Cancel message by default, + // which may close the dialog. + // Check for looping if the Cancel event handler calls Close(). + + // Note that if a cancel button and handler aren't present in the dialog, + // nothing will happen when you close the dialog via the window manager, or + // via Close(). + // We wouldn't want to destroy the dialog by default, since the dialog may have been + // created on the stack. + // However, this does mean that calling dialog->Close() won't delete the dialog + // unless the handler for wxID_CANCEL does so. So use Destroy() if you want to be + // sure to destroy the dialog. + // The default OnCancel (above) simply ends a modal dialog, and hides a modeless dialog. + static wxList closing; if (closing.Member(this)) return; // no loops - if ( event.GetVeto() ) - return; - closing.Append(this); wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 25e187d39b..c314c3d28c 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -478,8 +478,8 @@ void wxFrame::OnInternalIdle() void wxFrame::OnCloseWindow( wxCloseEvent& event ) { // close the window if it wasn't vetoed by the application - if ( !event.GetVeto() ) - Destroy(); +// if ( !event.GetVeto() ) // No, this isn't the interpretation of GetVeto. + Destroy(); } void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) ) diff --git a/src/gtk1/dc.cpp b/src/gtk1/dc.cpp index 1262fc6b77..2f287d17ad 100644 --- a/src/gtk1/dc.cpp +++ b/src/gtk1/dc.cpp @@ -57,7 +57,7 @@ wxDC::wxDC() m_scaleX = 1.0; m_scaleY = 1.0; - m_mappingMode = MM_TEXT; + m_mappingMode = wxMM_TEXT; m_needComputeScaleX = FALSE; /* not used yet */ m_needComputeScaleY = FALSE; /* not used yet */ @@ -217,25 +217,25 @@ void wxDC::SetMapMode( int mode ) { switch (mode) { - case MM_TWIPS: + case wxMM_TWIPS: SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y ); break; - case MM_POINTS: + case wxMM_POINTS: SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y ); break; - case MM_METRIC: + case wxMM_METRIC: SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y ); break; - case MM_LOMETRIC: + case wxMM_LOMETRIC: SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 ); break; default: - case MM_TEXT: + case wxMM_TEXT: SetLogicalScale( 1.0, 1.0 ); break; } /* we don't do this mega optimisation - if (mode != MM_TEXT) + if (mode != wxMM_TEXT) { m_needComputeScaleX = TRUE; m_needComputeScaleY = TRUE; diff --git a/src/gtk1/dialog.cpp b/src/gtk1/dialog.cpp index 4a0e3abd26..b64413f338 100644 --- a/src/gtk1/dialog.cpp +++ b/src/gtk1/dialog.cpp @@ -219,14 +219,25 @@ void wxDialog::OnPaint( wxPaintEvent& WXUNUSED(event) ) void wxDialog::OnCloseWindow(wxCloseEvent& event) { + // We'll send a Cancel message by default, + // which may close the dialog. + // Check for looping if the Cancel event handler calls Close(). + + // Note that if a cancel button and handler aren't present in the dialog, + // nothing will happen when you close the dialog via the window manager, or + // via Close(). + // We wouldn't want to destroy the dialog by default, since the dialog may have been + // created on the stack. + // However, this does mean that calling dialog->Close() won't delete the dialog + // unless the handler for wxID_CANCEL does so. So use Destroy() if you want to be + // sure to destroy the dialog. + // The default OnCancel (above) simply ends a modal dialog, and hides a modeless dialog. + static wxList closing; if (closing.Member(this)) return; // no loops - if ( event.GetVeto() ) - return; - closing.Append(this); wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index 25e187d39b..c314c3d28c 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -478,8 +478,8 @@ void wxFrame::OnInternalIdle() void wxFrame::OnCloseWindow( wxCloseEvent& event ) { // close the window if it wasn't vetoed by the application - if ( !event.GetVeto() ) - Destroy(); +// if ( !event.GetVeto() ) // No, this isn't the interpretation of GetVeto. + Destroy(); } void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) ) diff --git a/src/mac/app.cpp b/src/mac/app.cpp index c1ea01dc9f..be346f0a57 100644 --- a/src/mac/app.cpp +++ b/src/mac/app.cpp @@ -1414,6 +1414,10 @@ void wxApp::doMacInGoAway(WindowPtr window) { if (TrackGoAway(window, m_event.where)) { + // TODO: Stefan, I think you need to send a wxCloseEvent to the window + // here. The OnCloseWindow handler will take care of delete the frame + // if it wishes to (there should be a default wxFrame::OnCloseWindow + // that destroys the frame). if (theMacWxFrame->OnClose()) { #if WXGARBAGE_COLLECTION_ON theMacWxFrame->Show(FALSE); diff --git a/src/mac/carbon/app.cpp b/src/mac/carbon/app.cpp index c1ea01dc9f..be346f0a57 100644 --- a/src/mac/carbon/app.cpp +++ b/src/mac/carbon/app.cpp @@ -1414,6 +1414,10 @@ void wxApp::doMacInGoAway(WindowPtr window) { if (TrackGoAway(window, m_event.where)) { + // TODO: Stefan, I think you need to send a wxCloseEvent to the window + // here. The OnCloseWindow handler will take care of delete the frame + // if it wishes to (there should be a default wxFrame::OnCloseWindow + // that destroys the frame). if (theMacWxFrame->OnClose()) { #if WXGARBAGE_COLLECTION_ON theMacWxFrame->Show(FALSE); diff --git a/src/mac/carbon/dc.cpp b/src/mac/carbon/dc.cpp index 642dc1edc5..2c1c613595 100644 --- a/src/mac/carbon/dc.cpp +++ b/src/mac/carbon/dc.cpp @@ -61,7 +61,7 @@ wxDC::wxDC(void) m_scaleX = 1.0; m_scaleY = 1.0; - m_mappingMode = MM_TEXT; + m_mappingMode = wxMM_TEXT; m_needComputeScaleX = FALSE; m_needComputeScaleY = FALSE; @@ -211,24 +211,24 @@ void wxDC::SetMapMode( int mode ) { switch (mode) { - case MM_TWIPS: + case wxMM_TWIPS: SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y ); break; - case MM_POINTS: + case wxMM_POINTS: SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y ); break; - case MM_METRIC: + case wxMM_METRIC: SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y ); break; - case MM_LOMETRIC: + case wxMM_LOMETRIC: SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 ); break; default: - case MM_TEXT: + case wxMM_TEXT: SetLogicalScale( 1.0, 1.0 ); break; }; - if (mode != MM_TEXT) + if (mode != wxMM_TEXT) { m_needComputeScaleX = TRUE; m_needComputeScaleY = TRUE; diff --git a/src/mac/carbon/dialog.cpp b/src/mac/carbon/dialog.cpp index e2bdb7c984..bf3cae5e35 100644 --- a/src/mac/carbon/dialog.cpp +++ b/src/mac/carbon/dialog.cpp @@ -237,37 +237,34 @@ void wxDialog::OnCancel(wxCommandEvent& event) } } -bool wxDialog::OnClose() +void wxDialog::OnCloseWindow(wxCloseEvent& event) { - // Behaviour changed in 2.0: we'll send a Cancel message by default, + // We'll send a Cancel message by default, // which may close the dialog. - // Check for looping if the Cancel event handler calls Close() + // Check for looping if the Cancel event handler calls Close(). + + // Note that if a cancel button and handler aren't present in the dialog, + // nothing will happen when you close the dialog via the window manager, or + // via Close(). + // We wouldn't want to destroy the dialog by default, since the dialog may have been + // created on the stack. + // However, this does mean that calling dialog->Close() won't delete the dialog + // unless the handler for wxID_CANCEL does so. So use Destroy() if you want to be + // sure to destroy the dialog. + // The default OnCancel (above) simply ends a modal dialog, and hides a modeless dialog. static wxList closing; - + if ( closing.Member(this) ) - return FALSE; - + return; + closing.Append(this); - - wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); - cancelEvent.SetEventObject( this ); - GetEventHandler()->ProcessEvent(cancelEvent); + + wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); + cancelEvent.SetEventObject( this ); + GetEventHandler()->ProcessEvent(cancelEvent); // This may close the dialog closing.DeleteObject(this); - - return FALSE; -} - -void wxDialog::OnCloseWindow(wxCloseEvent& event) -{ - // Compatibility - if ( GetEventHandler()->OnClose() || !event.CanVeto()) - { - this->Destroy(); - } - else - event.Veto(TRUE); } // Destroy the window (delayed, if a managed window) diff --git a/src/mac/carbon/frame.cpp b/src/mac/carbon/frame.cpp index a961e3616f..b370f7b108 100644 --- a/src/mac/carbon/frame.cpp +++ b/src/mac/carbon/frame.cpp @@ -371,23 +371,10 @@ void wxFrame::OnActivate(wxActivateEvent& event) } } -// The default implementation for the close window event - calls -// OnClose for backward compatibility. - +// The default implementation for the close window event. void wxFrame::OnCloseWindow(wxCloseEvent& event) { - // Compatibility - if ( GetEventHandler()->OnClose() || !event.CanVeto()) - { - this->Destroy(); - } - else - event.Veto(TRUE); -} - -bool wxFrame::OnClose() -{ - return TRUE; + this->Destroy(); } // Destroy the window (delayed, if a managed window) diff --git a/src/mac/carbon/metafile.cpp b/src/mac/carbon/metafile.cpp index a92874b336..ddbfb8402f 100644 --- a/src/mac/carbon/metafile.cpp +++ b/src/mac/carbon/metafile.cpp @@ -128,7 +128,7 @@ struct mfPLACEABLEHEADER { /* * Pass filename of existing non-placeable metafile, and bounding box. * Adds a placeable metafile header, sets the mapping mode to anisotropic, - * and sets the window origin and extent to mimic the MM_TEXT mapping mode. + * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode. * */ @@ -198,7 +198,7 @@ bool wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, i modeRecord->rdSize = 4; modeRecord->rdFunction = META_SETMAPMODE; - modeRecord->rdParm[0] = MM_ANISOTROPIC; + modeRecord->rdParm[0] = wxMM_ANISOTROPIC; originRecord->rdSize = 5; originRecord->rdFunction = META_SETWINDOWORG; diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index 10ec3976dd..a54fd3331d 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -1110,7 +1110,10 @@ bool wxWindow::Close(bool force) { wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId); event.SetEventObject(this); +#if WXWIN_COMPATIBILITY event.SetForce(force); +#endif + event.SetCanVeto(!force); return GetEventHandler()->ProcessEvent(event); } diff --git a/src/mac/dc.cpp b/src/mac/dc.cpp index 642dc1edc5..2c1c613595 100644 --- a/src/mac/dc.cpp +++ b/src/mac/dc.cpp @@ -61,7 +61,7 @@ wxDC::wxDC(void) m_scaleX = 1.0; m_scaleY = 1.0; - m_mappingMode = MM_TEXT; + m_mappingMode = wxMM_TEXT; m_needComputeScaleX = FALSE; m_needComputeScaleY = FALSE; @@ -211,24 +211,24 @@ void wxDC::SetMapMode( int mode ) { switch (mode) { - case MM_TWIPS: + case wxMM_TWIPS: SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y ); break; - case MM_POINTS: + case wxMM_POINTS: SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y ); break; - case MM_METRIC: + case wxMM_METRIC: SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y ); break; - case MM_LOMETRIC: + case wxMM_LOMETRIC: SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 ); break; default: - case MM_TEXT: + case wxMM_TEXT: SetLogicalScale( 1.0, 1.0 ); break; }; - if (mode != MM_TEXT) + if (mode != wxMM_TEXT) { m_needComputeScaleX = TRUE; m_needComputeScaleY = TRUE; diff --git a/src/mac/dialog.cpp b/src/mac/dialog.cpp index e2bdb7c984..bf3cae5e35 100644 --- a/src/mac/dialog.cpp +++ b/src/mac/dialog.cpp @@ -237,37 +237,34 @@ void wxDialog::OnCancel(wxCommandEvent& event) } } -bool wxDialog::OnClose() +void wxDialog::OnCloseWindow(wxCloseEvent& event) { - // Behaviour changed in 2.0: we'll send a Cancel message by default, + // We'll send a Cancel message by default, // which may close the dialog. - // Check for looping if the Cancel event handler calls Close() + // Check for looping if the Cancel event handler calls Close(). + + // Note that if a cancel button and handler aren't present in the dialog, + // nothing will happen when you close the dialog via the window manager, or + // via Close(). + // We wouldn't want to destroy the dialog by default, since the dialog may have been + // created on the stack. + // However, this does mean that calling dialog->Close() won't delete the dialog + // unless the handler for wxID_CANCEL does so. So use Destroy() if you want to be + // sure to destroy the dialog. + // The default OnCancel (above) simply ends a modal dialog, and hides a modeless dialog. static wxList closing; - + if ( closing.Member(this) ) - return FALSE; - + return; + closing.Append(this); - - wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); - cancelEvent.SetEventObject( this ); - GetEventHandler()->ProcessEvent(cancelEvent); + + wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); + cancelEvent.SetEventObject( this ); + GetEventHandler()->ProcessEvent(cancelEvent); // This may close the dialog closing.DeleteObject(this); - - return FALSE; -} - -void wxDialog::OnCloseWindow(wxCloseEvent& event) -{ - // Compatibility - if ( GetEventHandler()->OnClose() || !event.CanVeto()) - { - this->Destroy(); - } - else - event.Veto(TRUE); } // Destroy the window (delayed, if a managed window) diff --git a/src/mac/frame.cpp b/src/mac/frame.cpp index a961e3616f..b370f7b108 100644 --- a/src/mac/frame.cpp +++ b/src/mac/frame.cpp @@ -371,23 +371,10 @@ void wxFrame::OnActivate(wxActivateEvent& event) } } -// The default implementation for the close window event - calls -// OnClose for backward compatibility. - +// The default implementation for the close window event. void wxFrame::OnCloseWindow(wxCloseEvent& event) { - // Compatibility - if ( GetEventHandler()->OnClose() || !event.CanVeto()) - { - this->Destroy(); - } - else - event.Veto(TRUE); -} - -bool wxFrame::OnClose() -{ - return TRUE; + this->Destroy(); } // Destroy the window (delayed, if a managed window) diff --git a/src/mac/metafile.cpp b/src/mac/metafile.cpp index a92874b336..ddbfb8402f 100644 --- a/src/mac/metafile.cpp +++ b/src/mac/metafile.cpp @@ -128,7 +128,7 @@ struct mfPLACEABLEHEADER { /* * Pass filename of existing non-placeable metafile, and bounding box. * Adds a placeable metafile header, sets the mapping mode to anisotropic, - * and sets the window origin and extent to mimic the MM_TEXT mapping mode. + * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode. * */ @@ -198,7 +198,7 @@ bool wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, i modeRecord->rdSize = 4; modeRecord->rdFunction = META_SETMAPMODE; - modeRecord->rdParm[0] = MM_ANISOTROPIC; + modeRecord->rdParm[0] = wxMM_ANISOTROPIC; originRecord->rdSize = 5; originRecord->rdFunction = META_SETWINDOWORG; diff --git a/src/mac/window.cpp b/src/mac/window.cpp index 10ec3976dd..a54fd3331d 100644 --- a/src/mac/window.cpp +++ b/src/mac/window.cpp @@ -1110,7 +1110,10 @@ bool wxWindow::Close(bool force) { wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId); event.SetEventObject(this); +#if WXWIN_COMPATIBILITY event.SetForce(force); +#endif + event.SetCanVeto(!force); return GetEventHandler()->ProcessEvent(event); } diff --git a/src/motif/dc.cpp b/src/motif/dc.cpp index 4c60da90ed..319fe79b5f 100644 --- a/src/motif/dc.cpp +++ b/src/motif/dc.cpp @@ -61,7 +61,7 @@ wxDC::wxDC(void) m_scaleX = 1.0; m_scaleY = 1.0; - m_mappingMode = MM_TEXT; + m_mappingMode = wxMM_TEXT; m_needComputeScaleX = FALSE; m_needComputeScaleY = FALSE; @@ -238,24 +238,24 @@ void wxDC::SetMapMode( int mode ) { switch (mode) { - case MM_TWIPS: + case wxMM_TWIPS: SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y ); break; - case MM_POINTS: + case wxMM_POINTS: SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y ); break; - case MM_METRIC: + case wxMM_METRIC: SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y ); break; - case MM_LOMETRIC: + case wxMM_LOMETRIC: SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 ); break; default: - case MM_TEXT: + case wxMM_TEXT: SetLogicalScale( 1.0, 1.0 ); break; }; - if (mode != MM_TEXT) + if (mode != wxMM_TEXT) { m_needComputeScaleX = TRUE; m_needComputeScaleY = TRUE; diff --git a/src/motif/dialog.cpp b/src/motif/dialog.cpp index d67152d0fc..84712cd4e1 100644 --- a/src/motif/dialog.cpp +++ b/src/motif/dialog.cpp @@ -564,37 +564,34 @@ void wxDialog::OnCancel(wxCommandEvent& WXUNUSED(event)) } } -bool wxDialog::OnClose() +void wxDialog::OnCloseWindow(wxCloseEvent& event) { - // Behaviour changed in 2.0: we'll send a Cancel message by default, + // We'll send a Cancel message by default, // which may close the dialog. - // Check for looping if the Cancel event handler calls Close() - + // Check for looping if the Cancel event handler calls Close(). + + // Note that if a cancel button and handler aren't present in the dialog, + // nothing will happen when you close the dialog via the window manager, or + // via Close(). + // We wouldn't want to destroy the dialog by default, since the dialog may have been + // created on the stack. + // However, this does mean that calling dialog->Close() won't delete the dialog + // unless the handler for wxID_CANCEL does so. So use Destroy() if you want to be + // sure to destroy the dialog. + // The default OnCancel (above) simply ends a modal dialog, and hides a modeless dialog. + static wxList closing; if ( closing.Member(this) ) - return FALSE; + return; closing.Append(this); wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); cancelEvent.SetEventObject( this ); - GetEventHandler()->ProcessEvent(cancelEvent); - - closing.DeleteObject(this); - - return FALSE; -} + GetEventHandler()->ProcessEvent(cancelEvent); // This may close the dialog -void wxDialog::OnCloseWindow(wxCloseEvent& event) -{ - // Compatibility - if ( GetEventHandler()->OnClose() || !event.CanVeto()) - { - this->Destroy(); - } - else - event.Veto(TRUE); + closing.DeleteObject(this); } // Destroy the window (delayed, if a managed window) diff --git a/src/motif/frame.cpp b/src/motif/frame.cpp index d12ac787a5..024c031119 100644 --- a/src/motif/frame.cpp +++ b/src/motif/frame.cpp @@ -782,23 +782,12 @@ void wxFrame::OnActivate(wxActivateEvent& event) } } -// The default implementation for the close window event - calls +// The default implementation for the close window event. // OnClose for backward compatibility. void wxFrame::OnCloseWindow(wxCloseEvent& event) { - // Compatibility - if ( GetEventHandler()->OnClose() || !event.CanVeto()) - { - this->Destroy(); - } - else - event.Veto(TRUE); -} - -bool wxFrame::OnClose() -{ - return TRUE; + this->Destroy(); } // Destroy the window (delayed, if a managed window) diff --git a/src/motif/metafile.cpp b/src/motif/metafile.cpp index 7380a03402..e8c45e00e3 100644 --- a/src/motif/metafile.cpp +++ b/src/motif/metafile.cpp @@ -128,7 +128,7 @@ struct mfPLACEABLEHEADER { /* * Pass filename of existing non-placeable metafile, and bounding box. * Adds a placeable metafile header, sets the mapping mode to anisotropic, - * and sets the window origin and extent to mimic the MM_TEXT mapping mode. + * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode. * */ @@ -198,7 +198,7 @@ bool wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, i modeRecord->rdSize = 4; modeRecord->rdFunction = META_SETMAPMODE; - modeRecord->rdParm[0] = MM_ANISOTROPIC; + modeRecord->rdParm[0] = wxMM_ANISOTROPIC; originRecord->rdSize = 5; originRecord->rdFunction = META_SETWINDOWORG; diff --git a/src/motif/window.cpp b/src/motif/window.cpp index a37d58c0bd..5af5f87602 100644 --- a/src/motif/window.cpp +++ b/src/motif/window.cpp @@ -2064,7 +2064,10 @@ bool wxWindow::Close(bool force) { wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId); event.SetEventObject(this); +#if WXWIN_COMPATIBILITY event.SetForce(force); +#endif + event.SetCanVeto(!force); return GetEventHandler()->ProcessEvent(event); } diff --git a/src/msw/curico.cpp b/src/msw/curico.cpp index 4811882fac..9338e438fd 100644 --- a/src/msw/curico.cpp +++ b/src/msw/curico.cpp @@ -19,6 +19,11 @@ #include #include +#if defined(__MWERKS__) +#include +#include +#endif + #ifndef __TWIN32__ #ifdef __GNUWIN32__ #include "wx/msw/gnuwin32/extra.h" diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 73f3390952..45e37fc9a2 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -92,7 +92,7 @@ wxDC::wxDC(void) m_signY = 1; m_systemScaleX = 1.0; m_systemScaleY = 1.0; - m_mappingMode = MM_TEXT; + m_mappingMode = wxMM_TEXT; m_bOwnsDC = FALSE; m_hDC = 0; m_clipping = FALSE; @@ -998,32 +998,32 @@ void wxDC::SetMapMode(int mode) switch (mode) { - case MM_TWIPS: + case wxMM_TWIPS: { m_logicalScaleX = (twips2mm * mm2pixelsX); m_logicalScaleY = (twips2mm * mm2pixelsY); break; } - case MM_POINTS: + case wxMM_POINTS: { m_logicalScaleX = (pt2mm * mm2pixelsX); m_logicalScaleY = (pt2mm * mm2pixelsY); break; } - case MM_METRIC: + case wxMM_METRIC: { m_logicalScaleX = mm2pixelsX; m_logicalScaleY = mm2pixelsY; break; } - case MM_LOMETRIC: + case wxMM_LOMETRIC: { m_logicalScaleX = (mm2pixelsX/10.0); m_logicalScaleY = (mm2pixelsY/10.0); break; } default: - case MM_TEXT: + case wxMM_TEXT: { m_logicalScaleX = 1.0; m_logicalScaleY = 1.0; diff --git a/src/msw/dcprint.cpp b/src/msw/dcprint.cpp index 43a6be9b8d..23593c665a 100644 --- a/src/msw/dcprint.cpp +++ b/src/msw/dcprint.cpp @@ -108,7 +108,7 @@ wxPrinterDC::wxPrinterDC(const wxString& driver_name, const wxString& device_nam { // int width = GetDeviceCaps(m_hDC, VERTRES); // int height = GetDeviceCaps(m_hDC, HORZRES); - SetMapMode(MM_TEXT); + SetMapMode(wxMM_TEXT); } SetBrush(*wxBLACK_BRUSH); SetPen(*wxBLACK_PEN); @@ -124,7 +124,7 @@ wxPrinterDC::wxPrinterDC(WXHDC theDC) { // int width = GetDeviceCaps(m_hDC, VERTRES); // int height = GetDeviceCaps(m_hDC, HORZRES); - SetMapMode(MM_TEXT); + SetMapMode(wxMM_TEXT); } SetBrush(*wxBLACK_BRUSH); SetPen(*wxBLACK_PEN); diff --git a/src/msw/dialog.cpp b/src/msw/dialog.cpp index 9f5bbaa74b..af5d9461e7 100644 --- a/src/msw/dialog.cpp +++ b/src/msw/dialog.cpp @@ -554,26 +554,42 @@ void wxDialog::OnCancel(wxCommandEvent& event) } } -bool wxDialog::OnClose(void) +void wxDialog::OnCloseWindow(wxCloseEvent& event) { - // Behaviour changed in 2.0: we'll send a Cancel message by default, + // We'll send a Cancel message by default, // which may close the dialog. - // Check for looping if the Cancel event handler calls Close() + // Check for looping if the Cancel event handler calls Close(). + + // Note that if a cancel button and handler aren't present in the dialog, + // nothing will happen when you close the dialog via the window manager, or + // via Close(). + // We wouldn't want to destroy the dialog by default, since the dialog may have been + // created on the stack. + // However, this does mean that calling dialog->Close() won't delete the dialog + // unless the handler for wxID_CANCEL does so. So use Destroy() if you want to be + // sure to destroy the dialog. + // The default OnCancel (above) simply ends a modal dialog, and hides a modeless dialog. static wxList closing; - + if ( closing.Member(this) ) - return FALSE; - + return; + closing.Append(this); - + wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); cancelEvent.SetEventObject( this ); - GetEventHandler()->ProcessEvent(cancelEvent); + GetEventHandler()->ProcessEvent(cancelEvent); // This may close the dialog closing.DeleteObject(this); +} - return FALSE; +// Destroy the window (delayed, if a managed window) +bool wxDialog::Destroy(void) +{ + if (!wxPendingDelete.Member(this)) + wxPendingDelete.Append(this); + return TRUE; } void wxDialog::OnSize(wxSizeEvent& WXUNUSED(event)) @@ -586,25 +602,6 @@ void wxDialog::OnSize(wxSizeEvent& WXUNUSED(event)) #endif } -void wxDialog::OnCloseWindow(wxCloseEvent& event) -{ - // Compatibility - if ( GetEventHandler()->OnClose() || !event.CanVeto()) - { - this->Destroy(); - } - else - event.Veto(TRUE); -} - -// Destroy the window (delayed, if a managed window) -bool wxDialog::Destroy(void) -{ - if (!wxPendingDelete.Member(this)) - wxPendingDelete.Append(this); - return TRUE; -} - void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& event) { #if wxUSE_CTL3D diff --git a/src/msw/dibutils.cpp b/src/msw/dibutils.cpp index 3ae1f94dc9..d1f3e95c77 100644 --- a/src/msw/dibutils.cpp +++ b/src/msw/dibutils.cpp @@ -134,7 +134,7 @@ int DibWriteFile(LPSTR szFile, LPBITMAPINFOHEADER lpbi) bmf.bfReserved1 = 0; bmf.bfReserved2 = 0; bmf.bfOffBits = sizeof(bmf) + (char far*)(DibPtr(lpbi)) - (char far*)lpbi; -#if defined( __WATCOMC__) || defined(__VISUALC__) || defined(__SC__) || defined(__SALFORDC__) +#if defined( __WATCOMC__) || defined(__VISUALC__) || defined(__SC__) || defined(__SALFORDC__) || defined(__MWERKS__) if (_hwrite(fh, (LPCSTR)(&bmf), sizeof(bmf))<0 || _hwrite(fh, (LPCSTR)lpbi, size)<0) { _lclose(fh); diff --git a/src/msw/frame.cpp b/src/msw/frame.cpp index d849fbc4a9..368784f459 100644 --- a/src/msw/frame.cpp +++ b/src/msw/frame.cpp @@ -859,23 +859,10 @@ void wxFrame::OnActivate(wxActivateEvent& event) } } -// The default implementation for the close window event - calls -// OnClose for backward compatibility. - +// The default implementation for the close window event. void wxFrame::OnCloseWindow(wxCloseEvent& event) { - // Compatibility - if ( GetEventHandler()->OnClose() || !event.CanVeto()) - { - this->Destroy(); - } - else - event.Veto(TRUE); -} - -bool wxFrame::OnClose(void) -{ - return TRUE; + this->Destroy(); } // Destroy the window (delayed, if a managed window) diff --git a/src/msw/metafile.cpp b/src/msw/metafile.cpp index d750762bb6..4a7b28900f 100644 --- a/src/msw/metafile.cpp +++ b/src/msw/metafile.cpp @@ -54,7 +54,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxMetafileDC, wxDC) wxMetafileRefData::wxMetafileRefData(void) { m_metafile = 0; - m_windowsMappingMode = MM_ANISOTROPIC; + m_windowsMappingMode = wxMM_ANISOTROPIC; } wxMetafileRefData::~wxMetafileRefData(void) @@ -70,7 +70,7 @@ wxMetafile::wxMetafile(const wxString& file) { m_refData = new wxMetafileRefData; - M_METAFILEDATA->m_windowsMappingMode = MM_ANISOTROPIC; + M_METAFILEDATA->m_windowsMappingMode = wxMM_ANISOTROPIC; M_METAFILEDATA->m_metafile = 0; if (!file.IsNull() && (file.Cmp("") == 0)) M_METAFILEDATA->m_metafile = (WXHANDLE) GetMetaFile(file); @@ -154,9 +154,9 @@ wxMetafileDC::wxMetafileDC(const wxString& file) m_ok = (m_hDC != (WXHDC) 0) ; // Actual Windows mapping mode, for future reference. - m_windowsMappingMode = MM_TEXT; - - SetMapMode(MM_TEXT); // NOTE: does not set HDC mapmode (this is correct) + m_windowsMappingMode = wxMM_TEXT; + + SetMapMode(wxMM_TEXT); // NOTE: does not set HDC mapmode (this is correct) } // New constructor that takes origin and extent. If you use this, don't @@ -176,9 +176,9 @@ wxMetafileDC::wxMetafileDC(const wxString& file, int xext, int yext, int xorg, i ::SetWindowExtEx((HDC) m_hDC,xext,yext, NULL); // Actual Windows mapping mode, for future reference. - m_windowsMappingMode = MM_ANISOTROPIC; - - SetMapMode(MM_TEXT); // NOTE: does not set HDC mapmode (this is correct) + m_windowsMappingMode = wxMM_ANISOTROPIC; + + SetMapMode(wxMM_TEXT); // NOTE: does not set HDC mapmode (this is correct) } wxMetafileDC::~wxMetafileDC(void) @@ -237,32 +237,32 @@ void wxMetafileDC::SetMapMode(int mode) switch (mode) { - case MM_TWIPS: + case wxMM_TWIPS: { m_logicalScaleX = (float)(twips2mm * mm2pixelsX); m_logicalScaleY = (float)(twips2mm * mm2pixelsY); break; } - case MM_POINTS: + case wxMM_POINTS: { m_logicalScaleX = (float)(pt2mm * mm2pixelsX); m_logicalScaleY = (float)(pt2mm * mm2pixelsY); break; } - case MM_METRIC: + case wxMM_METRIC: { m_logicalScaleX = mm2pixelsX; m_logicalScaleY = mm2pixelsY; break; } - case MM_LOMETRIC: + case wxMM_LOMETRIC: { m_logicalScaleX = (float)(mm2pixelsX/10.0); m_logicalScaleY = (float)(mm2pixelsY/10.0); break; } default: - case MM_TEXT: + case wxMM_TEXT: { m_logicalScaleX = 1.0; m_logicalScaleY = 1.0; @@ -304,7 +304,7 @@ struct mfPLACEABLEHEADER { /* * Pass filename of existing non-placeable metafile, and bounding box. * Adds a placeable metafile header, sets the mapping mode to anisotropic, - * and sets the window origin and extent to mimic the MM_TEXT mapping mode. + * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode. * */ diff --git a/src/msw/window.cpp b/src/msw/window.cpp index ddda342c66..ff224f8492 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -4201,7 +4201,9 @@ bool wxWindow::Close(bool force) { wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId); event.SetEventObject(this); +#if WXWIN_COMPATIBILITY event.SetForce(force); +#endif event.SetCanVeto(!force); return (GetEventHandler()->ProcessEvent(event) && !event.GetVeto()); diff --git a/src/qt/dc.cpp b/src/qt/dc.cpp index 4cfe7305cc..e56f268e35 100644 --- a/src/qt/dc.cpp +++ b/src/qt/dc.cpp @@ -63,7 +63,7 @@ wxDC::wxDC(void) m_scaleX = 1.0; m_scaleY = 1.0; - m_mappingMode = MM_TEXT; + m_mappingMode = wxMM_TEXT; m_needComputeScaleX = FALSE; m_needComputeScaleY = FALSE; @@ -218,24 +218,24 @@ void wxDC::SetMapMode( int mode ) { switch (mode) { - case MM_TWIPS: + case wxMM_TWIPS: SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y ); break; - case MM_POINTS: + case wxMM_POINTS: SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y ); break; - case MM_METRIC: + case wxMM_METRIC: SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y ); break; - case MM_LOMETRIC: + case wxMM_LOMETRIC: SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 ); break; default: - case MM_TEXT: + case wxMM_TEXT: SetLogicalScale( 1.0, 1.0 ); break; }; - if (mode != MM_TEXT) + if (mode != wxMM_TEXT) { m_needComputeScaleX = TRUE; m_needComputeScaleY = TRUE; diff --git a/src/qt/dialog.cpp b/src/qt/dialog.cpp index 3042b1f1eb..c486c876cb 100644 --- a/src/qt/dialog.cpp +++ b/src/qt/dialog.cpp @@ -247,37 +247,34 @@ void wxDialog::OnCancel(wxCommandEvent& event) } } -bool wxDialog::OnClose() +void wxDialog::OnCloseWindow(wxCloseEvent& event) { - // Behaviour changed in 2.0: we'll send a Cancel message by default, + // We'll send a Cancel message by default, // which may close the dialog. - // Check for looping if the Cancel event handler calls Close() + // Check for looping if the Cancel event handler calls Close(). + + // Note that if a cancel button and handler aren't present in the dialog, + // nothing will happen when you close the dialog via the window manager, or + // via Close(). + // We wouldn't want to destroy the dialog by default, since the dialog may have been + // created on the stack. + // However, this does mean that calling dialog->Close() won't delete the dialog + // unless the handler for wxID_CANCEL does so. So use Destroy() if you want to be + // sure to destroy the dialog. + // The default OnCancel (above) simply ends a modal dialog, and hides a modeless dialog. static wxList closing; - + if ( closing.Member(this) ) - return FALSE; - + return; + closing.Append(this); - - wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); - cancelEvent.SetEventObject( this ); - GetEventHandler()->ProcessEvent(cancelEvent); + + wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); + cancelEvent.SetEventObject( this ); + GetEventHandler()->ProcessEvent(cancelEvent); // This may close the dialog closing.DeleteObject(this); - - return FALSE; -} - -void wxDialog::OnCloseWindow(wxCloseEvent& event) -{ - // Compatibility - if ( GetEventHandler()->OnClose() || !event.CanVeto()) - { - this->Destroy(); - } - else - event.Veto(TRUE); } // Destroy the window (delayed, if a managed window) diff --git a/src/qt/frame.cpp b/src/qt/frame.cpp index cd830e4f10..f371fe0724 100644 --- a/src/qt/frame.cpp +++ b/src/qt/frame.cpp @@ -367,23 +367,10 @@ void wxFrame::OnActivate(wxActivateEvent& event) } } -// The default implementation for the close window event - calls -// OnClose for backward compatibility. - +// The default implementation for the close window event. void wxFrame::OnCloseWindow(wxCloseEvent& event) { - // Compatibility - if ( GetEventHandler()->OnClose() || !event.CanVeto()) - { - this->Destroy(); - } - else - event.Veto(TRUE); -} - -bool wxFrame::OnClose() -{ - return TRUE; + this->Destroy(); } // Destroy the window (delayed, if a managed window) diff --git a/src/qt/window.cpp b/src/qt/window.cpp index ed842eb30b..dce26c84da 100644 --- a/src/qt/window.cpp +++ b/src/qt/window.cpp @@ -1113,7 +1113,10 @@ bool wxWindow::Close(bool force) { wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId); event.SetEventObject(this); +#if WXWIN_COMPATIBILITY event.SetForce(force); +#endif + event.SetCanVeto(!force); return GetEventHandler()->ProcessEvent(event); } diff --git a/src/stubs/dc.cpp b/src/stubs/dc.cpp index 642dc1edc5..2c1c613595 100644 --- a/src/stubs/dc.cpp +++ b/src/stubs/dc.cpp @@ -61,7 +61,7 @@ wxDC::wxDC(void) m_scaleX = 1.0; m_scaleY = 1.0; - m_mappingMode = MM_TEXT; + m_mappingMode = wxMM_TEXT; m_needComputeScaleX = FALSE; m_needComputeScaleY = FALSE; @@ -211,24 +211,24 @@ void wxDC::SetMapMode( int mode ) { switch (mode) { - case MM_TWIPS: + case wxMM_TWIPS: SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y ); break; - case MM_POINTS: + case wxMM_POINTS: SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y ); break; - case MM_METRIC: + case wxMM_METRIC: SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y ); break; - case MM_LOMETRIC: + case wxMM_LOMETRIC: SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 ); break; default: - case MM_TEXT: + case wxMM_TEXT: SetLogicalScale( 1.0, 1.0 ); break; }; - if (mode != MM_TEXT) + if (mode != wxMM_TEXT) { m_needComputeScaleX = TRUE; m_needComputeScaleY = TRUE; diff --git a/src/stubs/dialog.cpp b/src/stubs/dialog.cpp index e2bdb7c984..bf3cae5e35 100644 --- a/src/stubs/dialog.cpp +++ b/src/stubs/dialog.cpp @@ -237,37 +237,34 @@ void wxDialog::OnCancel(wxCommandEvent& event) } } -bool wxDialog::OnClose() +void wxDialog::OnCloseWindow(wxCloseEvent& event) { - // Behaviour changed in 2.0: we'll send a Cancel message by default, + // We'll send a Cancel message by default, // which may close the dialog. - // Check for looping if the Cancel event handler calls Close() + // Check for looping if the Cancel event handler calls Close(). + + // Note that if a cancel button and handler aren't present in the dialog, + // nothing will happen when you close the dialog via the window manager, or + // via Close(). + // We wouldn't want to destroy the dialog by default, since the dialog may have been + // created on the stack. + // However, this does mean that calling dialog->Close() won't delete the dialog + // unless the handler for wxID_CANCEL does so. So use Destroy() if you want to be + // sure to destroy the dialog. + // The default OnCancel (above) simply ends a modal dialog, and hides a modeless dialog. static wxList closing; - + if ( closing.Member(this) ) - return FALSE; - + return; + closing.Append(this); - - wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); - cancelEvent.SetEventObject( this ); - GetEventHandler()->ProcessEvent(cancelEvent); + + wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); + cancelEvent.SetEventObject( this ); + GetEventHandler()->ProcessEvent(cancelEvent); // This may close the dialog closing.DeleteObject(this); - - return FALSE; -} - -void wxDialog::OnCloseWindow(wxCloseEvent& event) -{ - // Compatibility - if ( GetEventHandler()->OnClose() || !event.CanVeto()) - { - this->Destroy(); - } - else - event.Veto(TRUE); } // Destroy the window (delayed, if a managed window) diff --git a/src/stubs/frame.cpp b/src/stubs/frame.cpp index a961e3616f..c0b6d6b932 100644 --- a/src/stubs/frame.cpp +++ b/src/stubs/frame.cpp @@ -371,23 +371,11 @@ void wxFrame::OnActivate(wxActivateEvent& event) } } -// The default implementation for the close window event - calls -// OnClose for backward compatibility. +// The default implementation for the close window event. void wxFrame::OnCloseWindow(wxCloseEvent& event) { - // Compatibility - if ( GetEventHandler()->OnClose() || !event.CanVeto()) - { - this->Destroy(); - } - else - event.Veto(TRUE); -} - -bool wxFrame::OnClose() -{ - return TRUE; + this->Destroy(); } // Destroy the window (delayed, if a managed window) diff --git a/src/stubs/metafile.cpp b/src/stubs/metafile.cpp index a92874b336..03c29bcb79 100644 --- a/src/stubs/metafile.cpp +++ b/src/stubs/metafile.cpp @@ -128,7 +128,7 @@ struct mfPLACEABLEHEADER { /* * Pass filename of existing non-placeable metafile, and bounding box. * Adds a placeable metafile header, sets the mapping mode to anisotropic, - * and sets the window origin and extent to mimic the MM_TEXT mapping mode. + * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode. * */ diff --git a/src/stubs/window.cpp b/src/stubs/window.cpp index 8a4e50edb7..ef493b14ad 100644 --- a/src/stubs/window.cpp +++ b/src/stubs/window.cpp @@ -1125,7 +1125,10 @@ bool wxWindow::Close(bool force) { wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId); event.SetEventObject(this); +#if WXWIN_COMPATIBILITY event.SetForce(force); +#endif + event.SetCanVeto(!force); return GetEventHandler()->ProcessEvent(event); } diff --git a/utils/dialoged/src/reseditr.cpp b/utils/dialoged/src/reseditr.cpp index 61dbed5776..a6a17293a5 100644 --- a/utils/dialoged/src/reseditr.cpp +++ b/utils/dialoged/src/reseditr.cpp @@ -340,10 +340,8 @@ bool wxResourceManager::ShowResourceEditor(bool show, wxWindow *WXUNUSED(parent) else { wxFrame *fr = m_editorFrame; - if (m_editorFrame->OnClose()) + if (m_editorFrame->Close()) { - fr->Show(FALSE); - delete fr; m_editorFrame = NULL; m_editorPanel = NULL; } @@ -2076,6 +2074,7 @@ BEGIN_EVENT_TABLE(wxResourceEditorFrame, wxFrame) EVT_MENU(RESED_DELETE, wxResourceEditorFrame::OnDeleteSelection) EVT_MENU(RESED_RECREATE, wxResourceEditorFrame::OnRecreateSelection) EVT_MENU(RESED_TEST, wxResourceEditorFrame::OnTest) + EVT_CLOSE(wxResourceEditorFrame::OnCloseWindow) END_EVENT_TABLE() wxResourceEditorFrame::wxResourceEditorFrame(wxResourceManager *resMan, wxFrame *parent, const wxString& title, @@ -2157,12 +2156,15 @@ void wxResourceEditorFrame::OnRecreateSelection(wxCommandEvent& WXUNUSED(event)) manager->RecreateSelection(); } -bool wxResourceEditorFrame::OnClose() +void wxResourceEditorFrame::OnCloseWindow(wxCloseEvent& event) { if (manager->Modified()) { - if (!manager->Clear(TRUE, FALSE)) - return FALSE; + if (!manager->Clear(TRUE, FALSE)) + { + event.Veto(); + return; + } } if (!Iconized()) @@ -2181,7 +2183,7 @@ bool wxResourceEditorFrame::OnClose() manager->SetEditorFrame(NULL); manager->SetEditorToolBar(NULL); - return TRUE; + this->Destroy(); } /* diff --git a/utils/dialoged/src/reseditr.h b/utils/dialoged/src/reseditr.h index 8a8c6c2b3e..5a87b10d06 100644 --- a/utils/dialoged/src/reseditr.h +++ b/utils/dialoged/src/reseditr.h @@ -357,7 +357,7 @@ class wxResourceEditorFrame: public wxFrame long style = wxDEFAULT_FRAME_STYLE, const wxString& name = "frame"); ~wxResourceEditorFrame(); - bool OnClose(); + void OnCloseWindow(wxCloseEvent& event); void OnNew(wxCommandEvent& event); void OnOpen(wxCommandEvent& event); diff --git a/utils/glcanvas/samples/cube/cube.cpp b/utils/glcanvas/samples/cube/cube.cpp index 6b4fc01e6e..7a9735c98b 100644 --- a/utils/glcanvas/samples/cube/cube.cpp +++ b/utils/glcanvas/samples/cube/cube.cpp @@ -78,11 +78,6 @@ void MyFrame::OnExit(wxCommandEvent& event) Destroy(); } -bool MyFrame::OnClose(void) -{ - return TRUE; -} - BEGIN_EVENT_TABLE(TestGLCanvas, wxGLCanvas) EVT_SIZE(TestGLCanvas::OnSize) EVT_PAINT(TestGLCanvas::OnPaint) diff --git a/utils/glcanvas/samples/cube/cube.h b/utils/glcanvas/samples/cube/cube.h index 5ae1fd9f7f..74d3219ece 100644 --- a/utils/glcanvas/samples/cube/cube.h +++ b/utils/glcanvas/samples/cube/cube.h @@ -30,7 +30,6 @@ public: long style = wxDEFAULT_FRAME_STYLE); void OnExit(wxCommandEvent& event); - bool OnClose(void); public: TestGLCanvas* m_canvas; diff --git a/utils/glcanvas/samples/isosurf/isosurf.cpp b/utils/glcanvas/samples/isosurf/isosurf.cpp index fe456fa33d..3d9d966655 100644 --- a/utils/glcanvas/samples/isosurf/isosurf.cpp +++ b/utils/glcanvas/samples/isosurf/isosurf.cpp @@ -298,12 +298,6 @@ void MyFrame::OnExit(wxCommandEvent& event) Destroy(); } -bool MyFrame::OnClose(void) -{ - return TRUE; -} - - /* * TestGLCanvas implementation */ diff --git a/utils/glcanvas/samples/isosurf/isosurf.h b/utils/glcanvas/samples/isosurf/isosurf.h index 0a747deb74..e84098c56b 100644 --- a/utils/glcanvas/samples/isosurf/isosurf.h +++ b/utils/glcanvas/samples/isosurf/isosurf.h @@ -42,7 +42,6 @@ public: long style = wxDEFAULT_FRAME_STYLE); void OnExit(wxCommandEvent& event); - bool OnClose(void); public: TestGLCanvas* m_canvas; diff --git a/utils/glcanvas/samples/penguin/penguin.cpp b/utils/glcanvas/samples/penguin/penguin.cpp index aed5156e5b..f4a118daa2 100644 --- a/utils/glcanvas/samples/penguin/penguin.cpp +++ b/utils/glcanvas/samples/penguin/penguin.cpp @@ -76,11 +76,6 @@ void MyFrame::OnExit(wxCommandEvent& event) Destroy(); } -bool MyFrame::OnClose(void) -{ - return TRUE; -} - BEGIN_EVENT_TABLE(TestGLCanvas, wxGLCanvas) EVT_SIZE(TestGLCanvas::OnSize) EVT_PAINT(TestGLCanvas::OnPaint) diff --git a/utils/glcanvas/samples/penguin/penguin.h b/utils/glcanvas/samples/penguin/penguin.h index 5f17311513..d94c6a8565 100644 --- a/utils/glcanvas/samples/penguin/penguin.h +++ b/utils/glcanvas/samples/penguin/penguin.h @@ -53,7 +53,6 @@ public: long style = wxDEFAULT_FRAME_STYLE); void OnExit(wxCommandEvent& event); - bool OnClose(void); public: TestGLCanvas* m_canvas; diff --git a/utils/nplugin/src/npapp.cpp b/utils/nplugin/src/npapp.cpp index b5aff25ab1..b9e28cc159 100644 --- a/utils/nplugin/src/npapp.cpp +++ b/utils/nplugin/src/npapp.cpp @@ -103,8 +103,7 @@ NPError wxPluginApp::NPP_Destroy(NPP instance, NPSavedData** save) wxPluginFrame *frame = FindFrame(instance); if ( frame ) { - frame->OnClose(); - delete frame; + frame->Close(); } return NPERR_NO_ERROR; } diff --git a/utils/ogl/samples/ogledit/ogledit.cpp b/utils/ogl/samples/ogledit/ogledit.cpp index f58c265293..d6172e37db 100644 --- a/utils/ogl/samples/ogledit/ogledit.cpp +++ b/utils/ogl/samples/ogledit/ogledit.cpp @@ -143,6 +143,7 @@ IMPLEMENT_CLASS(MyFrame, wxDocParentFrame) BEGIN_EVENT_TABLE(MyFrame, wxDocParentFrame) EVT_MENU(OGLEDIT_ABOUT, MyFrame::OnAbout) EVT_SIZE(MyFrame::OnSize) + EVT_CLOSE(MyFrame::OnCloseWindow) END_EVENT_TABLE() MyFrame::MyFrame(wxDocManager *manager, wxFrame *frame, const wxString& title, @@ -174,15 +175,15 @@ void MyFrame::OnSize(wxSizeEvent& event) } } -bool MyFrame::OnClose(void) +void MyFrame::OnCloseWindow(wxCloseEvent& event) { if (wxDocParentFrame::OnClose()) { wxOGLCleanUp(); - return TRUE; + this->Destroy(); } else - return FALSE; + event.Veto(); } // Intercept menu commands diff --git a/utils/ogl/samples/ogledit/ogledit.h b/utils/ogl/samples/ogledit/ogledit.h index 3f0408c949..62dfb9bced 100644 --- a/utils/ogl/samples/ogledit/ogledit.h +++ b/utils/ogl/samples/ogledit/ogledit.h @@ -55,7 +55,7 @@ class MyFrame: public wxDocParentFrame MyCanvas *CreateCanvas(wxView *view, wxFrame *parent); void OnSize(wxSizeEvent& event); - bool OnClose(void); + void OnCloseWindow(wxCloseEvent& event); void OnAbout(wxCommandEvent& event); DECLARE_EVENT_TABLE() diff --git a/utils/tex2rtf/src/tex2rtf.cpp b/utils/tex2rtf/src/tex2rtf.cpp index d99f913439..e115c0d4dc 100644 --- a/utils/tex2rtf/src/tex2rtf.cpp +++ b/utils/tex2rtf/src/tex2rtf.cpp @@ -1026,8 +1026,7 @@ bool Tex2RTFConnection::OnExecute(const wxString& topic, char *data, int size, i } else if (strcmp(firstArg, "EXIT") == 0) { - if (frame && frame->OnClose()) - delete frame; + if (frame) frame->Close(); } else if (strcmp(firstArg, "MINIMIZE") == 0 || strcmp(firstArg, "ICONIZE") == 0) { -- 2.45.2