]>
git.saurik.com Git - wxWidgets.git/blob - samples/memcheck/memcheck.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Memory-checking sample
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation
17 // For compilers that support precompilation, includes "wx.h".
18 #include "wx/wxprec.h"
31 #include "mondrian.xpm"
35 #error You must set WXDEBUG to 1 on the 'make' command line (MSW) or with configure (GTK)
38 // Define a new application type
39 class MyApp
: public wxApp
44 // Define a new frame type
45 class MyFrame
: public wxFrame
47 MyFrame(wxFrame
*parent
);
48 void OnQuit(wxCommandEvent
& event
);
55 // `Main program' equivalent, creating windows and returning main app frame
56 bool MyApp::OnInit(void)
58 // Create the main frame window
59 MyFrame
*frame
= new MyFrame((wxFrame
*) NULL
);
63 frame
->SetIcon(wxIcon("mondrian"));
65 frame
->SetIcon(wxIcon(mondrian_xpm
));
69 wxMenu
*file_menu
= new wxMenu
;
71 file_menu
->Append(wxID_EXIT
, "E&xit");
72 wxMenuBar
*menu_bar
= new wxMenuBar
;
73 menu_bar
->Append(file_menu
, "File");
74 frame
->SetMenuBar(menu_bar
);
76 // Make a panel with a message
77 wxPanel
*panel
= new wxPanel(frame
);
79 (void)new wxStaticText(panel
, -1, "Hello, this is a minimal debugging wxWindows program!", wxPoint(10, 10));
84 wxDebugContext::SetCheckpoint();
85 wxDebugContext::SetFile("debug.log");
87 wxString
*thing
= new wxString
;
88 wxDate
* date
= new wxDate
;
90 // non-object allocation
91 char *ordinaryNonObject
= new char[1000];
93 const char *data
= (const char*) thing
;
95 wxDebugContext::PrintClasses();
96 wxDebugContext::Dump();
97 wxDebugContext::PrintStatistics();
99 // Don't delete these two objects, to force wxApp to flag a memory leak.
102 // delete[] ordinaryNonObject;
107 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
108 EVT_MENU(wxID_EXIT
, MyFrame::OnQuit
)
111 // My frame constructor
112 MyFrame::MyFrame(wxFrame
*parent
):
113 wxFrame(parent
, -1, "MemCheck wxWindows Sample", wxPoint(-1, -1), wxSize(400, 200))
116 // Intercept menu commands
117 void MyFrame::OnQuit(wxCommandEvent
& WXUNUSED(event
))