]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/forty/forty.cpp
Added the forgotten file txtstrm.tex
[wxWidgets.git] / samples / forty / forty.cpp
index 960816e9160e23e858290a6532c03170b4ae12c2..4d952a9993cad9bc4385f17a7e90d3ec99977fda 100644 (file)
@@ -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,10 +91,10 @@ bool FortyApp::OnInit()
                        -1, -1, 668, 510
                        );
 
-       // Show the frame
+       // Show the frame
        frame->Show(TRUE);
 
-       return true;
+       return TRUE;
 }
 
 const wxColour& FortyApp::BackgroundColour()
@@ -110,7 +111,7 @@ const wxBrush& FortyApp::BackgroundBrush()
 {
        if (!m_backgroundBrush)
        {
-               m_backgroundBrush = new wxBrush(*BackgroundColour(), wxSOLID);
+               m_backgroundBrush = new wxBrush(BackgroundColour(), wxSOLID);
        }
 
        return *m_backgroundBrush;
@@ -132,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
 
@@ -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);
 }