X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/63cafd2799b6e9dcbe34ce63635f1f8a807d895f..7941ba111cac53f21eafdeeeed6b543c3a2ba610:/samples/forty/forty.cpp?ds=sidebyside diff --git a/samples/forty/forty.cpp b/samples/forty/forty.cpp index 65a9c463d1..4d952a9993 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 @@ -90,37 +91,40 @@ bool FortyApp::OnInit() -1, -1, 668, 510 ); - // Show the frame + // Show the frame frame->Show(TRUE); - return true; + return TRUE; } -wxColour* FortyApp::BackgroundColour() +const wxColour& FortyApp::BackgroundColour() { if (!m_backgroundColour) { m_backgroundColour = new wxColour(0, 128, 0); } - return m_backgroundColour; + + return *m_backgroundColour; } -wxBrush* FortyApp::BackgroundBrush() +const wxBrush& FortyApp::BackgroundBrush() { if (!m_backgroundBrush) { - m_backgroundBrush = new wxBrush(*BackgroundColour(), wxSOLID); + m_backgroundBrush = new wxBrush(BackgroundColour(), wxSOLID); } - return m_backgroundBrush; + + return *m_backgroundBrush; } -wxColour* FortyApp::TextColour() +const wxColour& FortyApp::TextColour() { if (!m_textColour) { m_textColour = new wxColour("BLACK"); } - return m_textColour; + + return *m_textColour; } // My frame constructor @@ -129,10 +133,10 @@ FortyFrame::FortyFrame(wxFrame* frame, char* title, int x, int y, int w, int h): { // set the icon #ifdef __WXMSW__ - SetIcon(new wxIcon("CardsIcon")); + SetIcon(wxIcon("CardsIcon")); #else #ifdef GTK_TBD - SetIcon(new wxIcon(Cards_bits, Cards_width, Cards_height)); + SetIcon(wxIcon(Cards_bits, Cards_width, Cards_height)); #endif #endif @@ -186,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 @@ -202,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); }