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.
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}
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.
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
\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
\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?}
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:
\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)
{
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;
}
}
\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?}
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
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.
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
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.
#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)
// 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
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; }
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);
void OnMouseEvent(wxMouseEvent& event);
void OnPaint(wxPaintEvent& event);
- bool OnClose(void);
-
virtual void CalculateMeasurements(void);
virtual void CreateWidgets(void);
virtual void InitializeColours(void);
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()
};
// Internal functions
void OnPaint(wxPaintEvent& event);
- bool OnClose(void);
+ void OnCloseWindow(wxCloseEvent& event);
virtual void CreateWidgets(void);
virtual void InitializeFont(void);
void SetTitle(const wxString& title);
wxString GetTitle() const ;
- bool OnClose();
void OnCharHook(wxKeyEvent& event);
void OnCloseWindow(wxCloseEvent& event);
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);
/*
* 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.
*
*/
void SetTitle(const wxString& title);
wxString GetTitle() const ;
- bool OnClose();
+// bool OnClose();
void OnCharHook(wxKeyEvent& event);
void OnCloseWindow(wxCloseEvent& event);
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);
/*
* 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.
*
*/
#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;
wxString GetTitle() const ;
void OnSize(wxSizeEvent& event);
- bool OnClose();
void OnCharHook(wxKeyEvent& event);
void OnPaint(wxPaintEvent& event);
void OnCloseWindow(wxCloseEvent& event);
virtual void ScreenToClient(int *x, int *y) const;
- virtual bool OnClose();
-
void OnSize(wxSizeEvent& event);
void OnMenuHighlight(wxMenuEvent& event);
void OnActivate(wxActivateEvent& event);
/*
* 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.
*
*/
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();
wxWindow* m_previewCanvas;
wxPreviewControlBar* m_controlBar;
wxPrintPreviewBase* m_printPreview;
+
+DECLARE_EVENT_TABLE()
};
/*
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...???
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);
private:
wxPropertyFormView* m_view;
+
+DECLARE_EVENT_TABLE()
};
/*
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);
private:
wxPropertyFormView* m_view;
wxPanel* m_propertyPanel;
+
+DECLARE_EVENT_TABLE()
};
#endif
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);
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);
private:
wxPropertyListView* m_view;
wxPropertyListPanel* m_propertyPanel;
+
+DECLARE_EVENT_TABLE()
};
/*
void SetTitle(const wxString& title);
wxString GetTitle() const ;
- bool OnClose();
void OnCharHook(wxKeyEvent& event);
void OnCloseWindow(wxCloseEvent& event);
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);
void SetTitle(const wxString& title);
wxString GetTitle() const ;
- bool OnClose();
void OnCharHook(wxKeyEvent& event);
void OnCloseWindow(wxCloseEvent& event);
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);
/*
* 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.
*
*/
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);
}
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();
}
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();
}
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
void OnDelete(wxCommandEvent& event);
- bool OnClose() { return TRUE; }
+ void OnCloseWindow(wxCloseEvent& event);
private:
wxTextCtrl *m_text;
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()
// ============================================================================
SetClientSize(w, h);
}
+void MyFrame::OnCloseWindow(wxCloseEvent& event)
+{
+ this->Destroy();
+}
+
void MyFrame::OnQuit(wxCommandEvent&)
{
Close(TRUE);
// to close the program here that is not done elsewhere
this->Destroy();
-} // DatabaseDemoFrame::OnClose()
+} // DatabaseDemoFrame::OnCloseWindow()
void DatabaseDemoFrame::CreateDataTable()
} // 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 )
/*
* 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
} // 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
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)
BEGIN_EVENT_TABLE(CqueryDlg, wxDialog)
EVT_BUTTON(-1, CqueryDlg::OnButton)
+ EVT_CLOSE(CqueryDlg::OnCloseWindow)
END_EVENT_TABLE()
// CqueryDlg() constructor
} // CqueryDlg::OnCommand
-bool CqueryDlg::OnClose()
+void CqueryDlg::OnCloseWindow(wxCloseEvent& event)
{
// Clean up
if (colInf)
GetParent()->SetFocus();
wxEndBusyCursor();
- return TRUE;
-} // CqueryDlg::OnClose()
+ this->Destroy();
+
+} // CqueryDlg::OnCloseWindow()
/*
bool CqueryDlg::SetWidgetPtrs()
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
public:
CparameterDlg(wxWindow *parent);
- bool OnClose(void);
+ void OnCloseWindow(wxCloseEvent& event);
void OnCommand(wxWindow& win, wxCommandEvent& event);
void OnActivate(bool) {}; // necessary for hot keys
bool Save();
void FillDataSourceList();
+DECLARE_EVENT_TABLE()
}; // CparameterDlg
#define PARAMETER_DIALOG 400
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();
{ 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);
void OnLeftDown(wxMouseEvent& event);
void OnRightDown(wxMouseEvent& event);
- bool OnClose();
-
DECLARE_EVENT_TABLE()
private:
m_ctrlLog->Clear();
}
-bool DnDFrame::OnClose()
-{
- return TRUE;
-}
-
void DnDFrame::OnLeftDown(wxMouseEvent &WXUNUSED(event) )
{
if ( !m_strText.IsEmpty() )
public:
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
- bool OnClose(void) { return TRUE; }
};
// ID for the menu commands
/*
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;
}
virtual ~FortyCanvas();
virtual void OnDraw(wxDC& dc);
- bool OnClose();
+ bool OnCloseCanvas();
void OnMouseEvent(wxMouseEvent& event);
void SetCursorStyle(int x, int y);
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);
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
{
}
-bool FortyFrame::OnClose()
+void FortyFrame::OnCloseWindow(wxCloseEvent& event)
{
- return m_canvas->OnClose();
+ if (m_canvas->OnCloseCanvas())
+ {
+ this->Destroy();
+ }
+ else
+ event.Veto();
}
void
{
#ifdef __WXGTK__
// wxGTK doesn't call OnClose() so we do it here
- if (OnClose())
+// if (OnClose())
#endif
Close(TRUE);
}
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(
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)
protected:
friend void SelectCallback(wxListBox&, wxCommandEvent&);
- bool OnClose();
+ void OnCloseWindow(wxCloseEvent& event);
private:
ScoreFile* m_scoreFile;
}
}
+BEGIN_EVENT_TABLE(ScoreDialog, wxDialog)
+ EVT_CLOSE(ScoreDialog::OnCloseWindow)
+END_EVENT_TABLE()
ScoreDialog::ScoreDialog(
wxWindow* parent,
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);
}
void Display();
protected:
- bool OnClose();
+ void OnCloseWindow(wxCloseEvent& event);
private:
ScoreFile* m_scoreFile;
wxButton* m_OK;
+
+DECLARE_EVENT_TABLE()
};
#endif
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);
void OnAbout(wxCommandEvent& event);
void OnPlay(wxCommandEvent& event);
void OnOpen(wxCommandEvent& event);
- bool OnClose() { return TRUE; }
-
+
DECLARE_EVENT_TABLE()
};
if (event.GetActive() && canvas)
canvas->SetFocus();
}
-
-bool MyFrame::OnClose(void)
-{
- return TRUE;
-}
\ No newline at end of file
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);
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))
panel->Layout();
}
-bool SizerFrame::OnClose(void)
-{
- Show(FALSE);
-
- return TRUE;
-}
-
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);
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()
};
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);
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;
canvas->SetFocus();
}
-bool MyChild::OnClose(void)
-{
- return TRUE;
-}
-
void MyFrame::InitToolBar(wxToolBar* toolBar)
{
wxBitmap* bitmaps[8];
void InitToolBar(wxToolBar* toolBar);
- bool OnClose(void);
void OnSize(wxSizeEvent& event);
void OnAbout(wxCommandEvent& event);
void OnNewWindow(wxCommandEvent& event);
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);
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);
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()
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)
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);
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();
}
}
}
-// Define the behaviour for the frame closing
-// - must delete all frames except for the main one.
-bool MyFrame::OnClose(void)
-{
- Show(FALSE);
-
- return TRUE;
-}
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);
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)
{
}
-bool MyFrame::OnClose(void)
-{
- Show(FALSE);
- delete wxGetApp().m_testFont;
-
- return TRUE;
-}
-
bool MyPrintout::OnPrintPage(int page)
{
wxDC *dc = GetDC();
class MyApp: public wxApp
{
public:
- MyApp(void) ;
- bool OnInit(void);
+ MyApp() ;
+ bool OnInit();
+ int OnExit();
wxFont* m_testFont;
};
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);
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)
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);
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;
canvas->SetFocus();
}
-bool MyChild::OnClose(void)
-{
- return TRUE;
-}
-
-
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);
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);
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);
{
}
-bool MyFrame::OnClose()
-{
- return TRUE;
-}
-
void MyFrame::Quit(wxCommandEvent& WXUNUSED(event) )
{
Close(TRUE);
void OnResumeThread(wxCommandEvent& event);
void OnIdle(wxIdleEvent &event);
- bool OnClose() { return TRUE; }
// called by dying thread _in_that_thread_context_
void OnThreadExit(wxThread *thread);
public:
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
- bool OnClose(void) { return TRUE; }
DECLARE_EVENT_TABLE()
public:
void OnQuit(wxCommandEvent& event);
void OnTestDialog(wxCommandEvent& event);
- bool OnClose(void) { return TRUE; }
DECLARE_EVENT_TABLE()
#include <string.h>
#include <time.h>
+#ifdef __WINDOWS__
+#include <windows.h>
+#ifdef DrawText
+#undef DrawText
+#endif
+#endif
+
#define buf_size 10000
#define DEFAULT_POETRY_DAT "wxpoem"
#define DEFAULT_POETRY_IND "wxpoem"
return FALSE;
};
+#if WXWIN_COMPATIBILITY
bool wxEvtHandler::OnClose()
{
if (GetNextHandler())
else
return FALSE;
}
+#endif
+
* 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)
{
}
-bool wxPreviewFrame::OnClose()
+void wxPreviewFrame::OnCloseWindow(wxCloseEvent& event)
{
MakeModal(FALSE);
m_printPreview->SetFrame(NULL);
}
delete m_printPreview;
- return TRUE;
+
+ Destroy();
}
void wxPreviewFrame::Initialize()
EVT_SLIDER(wxID_BLUE_SLIDER, wxGenericColourDialog::OnBlueSlider)
EVT_PAINT(wxGenericColourDialog::OnPaint)
EVT_MOUSE_EVENTS(wxGenericColourDialog::OnMouseEvent)
+ EVT_CLOSE(wxGenericColourDialog::OnCloseWindow)
END_EVENT_TABLE()
#endif
{
}
-bool wxGenericColourDialog::OnClose(void)
+void wxGenericColourDialog::OnCloseWindow(wxCloseEvent& event)
{
- Show(FALSE);
- return FALSE;
+ EndModal(wxID_CANCEL);
}
bool wxGenericColourDialog::Create(wxWindow *parent, wxColourData *data)
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
{
}
-bool wxGenericFontDialog::OnClose(void)
+void wxGenericFontDialog::OnCloseWindow(wxCloseEvent& event)
{
- Show(FALSE);
- return FALSE;
+ EndModal(wxID_CANCEL);
}
bool wxGenericFontDialog::Create(wxWindow *parent, wxFontData *data)
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)
// 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)
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)
BEGIN_EVENT_TABLE(wxPropertyListDialog, wxDialog)
EVT_BUTTON(wxID_CANCEL, wxPropertyListDialog::OnCancel)
+ EVT_CLOSE(wxPropertyListDialog::OnCloseWindow)
END_EVENT_TABLE()
wxPropertyListDialog::wxPropertyListDialog(wxPropertyListView *v, wxWindow *parent,
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))
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)
{
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)
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 */
{
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;
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);
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) )
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 */
{
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;
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);
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) )
{
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);
{
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);
m_scaleX = 1.0;
m_scaleY = 1.0;
- m_mappingMode = MM_TEXT;
+ m_mappingMode = wxMM_TEXT;
m_needComputeScaleX = FALSE;
m_needComputeScaleY = FALSE;
{
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;
}
}
-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)
}
}
-// 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)
/*
* 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.
*
*/
modeRecord->rdSize = 4;
modeRecord->rdFunction = META_SETMAPMODE;
- modeRecord->rdParm[0] = MM_ANISOTROPIC;
+ modeRecord->rdParm[0] = wxMM_ANISOTROPIC;
originRecord->rdSize = 5;
originRecord->rdFunction = META_SETWINDOWORG;
{
wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId);
event.SetEventObject(this);
+#if WXWIN_COMPATIBILITY
event.SetForce(force);
+#endif
+ event.SetCanVeto(!force);
return GetEventHandler()->ProcessEvent(event);
}
m_scaleX = 1.0;
m_scaleY = 1.0;
- m_mappingMode = MM_TEXT;
+ m_mappingMode = wxMM_TEXT;
m_needComputeScaleX = FALSE;
m_needComputeScaleY = FALSE;
{
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;
}
}
-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)
}
}
-// 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)
/*
* 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.
*
*/
modeRecord->rdSize = 4;
modeRecord->rdFunction = META_SETMAPMODE;
- modeRecord->rdParm[0] = MM_ANISOTROPIC;
+ modeRecord->rdParm[0] = wxMM_ANISOTROPIC;
originRecord->rdSize = 5;
originRecord->rdFunction = META_SETWINDOWORG;
{
wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId);
event.SetEventObject(this);
+#if WXWIN_COMPATIBILITY
event.SetForce(force);
+#endif
+ event.SetCanVeto(!force);
return GetEventHandler()->ProcessEvent(event);
}
m_scaleX = 1.0;
m_scaleY = 1.0;
- m_mappingMode = MM_TEXT;
+ m_mappingMode = wxMM_TEXT;
m_needComputeScaleX = FALSE;
m_needComputeScaleY = FALSE;
{
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;
}
}
-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)
}
}
-// 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)
/*
* 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.
*
*/
modeRecord->rdSize = 4;
modeRecord->rdFunction = META_SETMAPMODE;
- modeRecord->rdParm[0] = MM_ANISOTROPIC;
+ modeRecord->rdParm[0] = wxMM_ANISOTROPIC;
originRecord->rdSize = 5;
originRecord->rdFunction = META_SETWINDOWORG;
{
wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId);
event.SetEventObject(this);
+#if WXWIN_COMPATIBILITY
event.SetForce(force);
+#endif
+ event.SetCanVeto(!force);
return GetEventHandler()->ProcessEvent(event);
}
#include <io.h>
#include <windows.h>
+#if defined(__MWERKS__)
+#include <wingdi.h>
+#include <winuser.h>
+#endif
+
#ifndef __TWIN32__
#ifdef __GNUWIN32__
#include "wx/msw/gnuwin32/extra.h"
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;
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;
{
// int width = GetDeviceCaps(m_hDC, VERTRES);
// int height = GetDeviceCaps(m_hDC, HORZRES);
- SetMapMode(MM_TEXT);
+ SetMapMode(wxMM_TEXT);
}
SetBrush(*wxBLACK_BRUSH);
SetPen(*wxBLACK_PEN);
{
// int width = GetDeviceCaps(m_hDC, VERTRES);
// int height = GetDeviceCaps(m_hDC, HORZRES);
- SetMapMode(MM_TEXT);
+ SetMapMode(wxMM_TEXT);
}
SetBrush(*wxBLACK_BRUSH);
SetPen(*wxBLACK_PEN);
}
}
-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))
#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
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);
}
}
-// 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)
wxMetafileRefData::wxMetafileRefData(void)
{
m_metafile = 0;
- m_windowsMappingMode = MM_ANISOTROPIC;
+ m_windowsMappingMode = wxMM_ANISOTROPIC;
}
wxMetafileRefData::~wxMetafileRefData(void)
{
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);
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
::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)
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;
/*
* 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.
*
*/
{
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());
m_scaleX = 1.0;
m_scaleY = 1.0;
- m_mappingMode = MM_TEXT;
+ m_mappingMode = wxMM_TEXT;
m_needComputeScaleX = FALSE;
m_needComputeScaleY = FALSE;
{
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;
}
}
-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)
}
}
-// 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)
{
wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId);
event.SetEventObject(this);
+#if WXWIN_COMPATIBILITY
event.SetForce(force);
+#endif
+ event.SetCanVeto(!force);
return GetEventHandler()->ProcessEvent(event);
}
m_scaleX = 1.0;
m_scaleY = 1.0;
- m_mappingMode = MM_TEXT;
+ m_mappingMode = wxMM_TEXT;
m_needComputeScaleX = FALSE;
m_needComputeScaleY = FALSE;
{
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;
}
}
-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)
}
}
-// 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)
/*
* 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.
*
*/
{
wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId);
event.SetEventObject(this);
+#if WXWIN_COMPATIBILITY
event.SetForce(force);
+#endif
+ event.SetCanVeto(!force);
return GetEventHandler()->ProcessEvent(event);
}
else
{
wxFrame *fr = m_editorFrame;
- if (m_editorFrame->OnClose())
+ if (m_editorFrame->Close())
{
- fr->Show(FALSE);
- delete fr;
m_editorFrame = NULL;
m_editorPanel = NULL;
}
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,
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())
manager->SetEditorFrame(NULL);
manager->SetEditorToolBar(NULL);
- return TRUE;
+ this->Destroy();
}
/*
long style = wxDEFAULT_FRAME_STYLE, const wxString& name = "frame");
~wxResourceEditorFrame();
- bool OnClose();
+ void OnCloseWindow(wxCloseEvent& event);
void OnNew(wxCommandEvent& event);
void OnOpen(wxCommandEvent& event);
Destroy();
}
-bool MyFrame::OnClose(void)
-{
- return TRUE;
-}
-
BEGIN_EVENT_TABLE(TestGLCanvas, wxGLCanvas)
EVT_SIZE(TestGLCanvas::OnSize)
EVT_PAINT(TestGLCanvas::OnPaint)
long style = wxDEFAULT_FRAME_STYLE);
void OnExit(wxCommandEvent& event);
- bool OnClose(void);
public:
TestGLCanvas* m_canvas;
Destroy();
}
-bool MyFrame::OnClose(void)
-{
- return TRUE;
-}
-
-
/*
* TestGLCanvas implementation
*/
long style = wxDEFAULT_FRAME_STYLE);
void OnExit(wxCommandEvent& event);
- bool OnClose(void);
public:
TestGLCanvas* m_canvas;
Destroy();
}
-bool MyFrame::OnClose(void)
-{
- return TRUE;
-}
-
BEGIN_EVENT_TABLE(TestGLCanvas, wxGLCanvas)
EVT_SIZE(TestGLCanvas::OnSize)
EVT_PAINT(TestGLCanvas::OnPaint)
long style = wxDEFAULT_FRAME_STYLE);
void OnExit(wxCommandEvent& event);
- bool OnClose(void);
public:
TestGLCanvas* m_canvas;
wxPluginFrame *frame = FindFrame(instance);
if ( frame )
{
- frame->OnClose();
- delete frame;
+ frame->Close();
}
return NPERR_NO_ERROR;
}
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,
}
}
-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
MyCanvas *CreateCanvas(wxView *view, wxFrame *parent);
void OnSize(wxSizeEvent& event);
- bool OnClose(void);
+ void OnCloseWindow(wxCloseEvent& event);
void OnAbout(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
}
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)
{