]>
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 new WXDEBUG_NEW
40 // Define a new application type
41 class MyApp
: public wxApp
46 // Define a new frame type
47 class MyFrame
: public wxFrame
49 MyFrame(wxFrame
*parent
);
50 void OnQuit(wxCommandEvent
& event
);
57 // `Main program' equivalent, creating windows and returning main app frame
58 bool MyApp::OnInit(void)
60 // Create the main frame window
61 MyFrame
*frame
= new MyFrame(NULL
);
65 frame
->SetIcon(wxIcon("mondrian"));
66 frame
->SetIcon(wxIcon(mondrian_xpm
));
70 wxMenu
*file_menu
= new wxMenu
;
72 file_menu
->Append(wxID_EXIT
, "E&xit");
73 wxMenuBar
*menu_bar
= new wxMenuBar
;
74 menu_bar
->Append(file_menu
, "File");
75 frame
->SetMenuBar(menu_bar
);
77 // Make a panel with a message
78 wxPanel
*panel
= new wxPanel(frame
);
80 (void)new wxStaticText(panel
, -1, "Hello, this is a minimal debugging wxWindows program!", wxPoint(10, 10));
85 wxDebugContext::SetCheckpoint();
86 wxDebugContext::SetFile("debug.log");
88 wxString
*thing
= new wxString
; // WXDEBUG_NEW wxString;
89 wxDate
* date
= new wxDate
;
91 // Proves that defining 'new' to be 'WXDEBUG_NEW' doesn't mess up
92 // non-object allocation
93 char *ordinaryNonObject
= new char[1000];
95 const char *data
= (const char*) thing
;
97 wxDebugContext::PrintClasses();
98 wxDebugContext::Dump();
99 wxDebugContext::PrintStatistics();
101 // Don't delete these two objects, to force wxApp to flag a memory leak.
104 // delete[] ordinaryNonObject;
109 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
110 EVT_MENU(wxID_EXIT
, MyFrame::OnQuit
)
113 // My frame constructor
114 MyFrame::MyFrame(wxFrame
*parent
):
115 wxFrame(parent
, -1, "MemCheck wxWindows Sample", wxPoint(-1, -1), wxSize(400, 200))
118 // Intercept menu commands
119 void MyFrame::OnQuit(wxCommandEvent
& event
)