]> git.saurik.com Git - wxWidgets.git/blob - samples/memcheck/memcheck.cpp
Dialog Editor edits
[wxWidgets.git] / samples / memcheck / memcheck.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: memcheck.cpp
3 // Purpose: Memory-checking sample
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #pragma interface
15 #endif
16
17 // For compilers that support precompilation, includes "wx.h".
18 #include "wx/wxprec.h"
19
20 #ifdef __BORLANDC__
21 #pragma hdrstop
22 #endif
23
24 #ifndef WX_PRECOMP
25 #include "wx/wx.h"
26 #endif
27
28 #include "wx/date.h"
29
30 #if !WXDEBUG
31 #error You must set WXDEBUG to 1 on the 'make' command line or make.env.
32 #endif
33
34 // #define new WXDEBUG_NEW
35
36 // Define a new application type
37 class MyApp: public wxApp
38 { public:
39 bool OnInit(void);
40 };
41
42 // Define a new frame type
43 class MyFrame: public wxFrame
44 { public:
45 MyFrame(wxFrame *parent);
46 void OnQuit(wxCommandEvent& event);
47
48 DECLARE_EVENT_TABLE()
49 };
50
51 IMPLEMENT_APP(MyApp)
52
53 // `Main program' equivalent, creating windows and returning main app frame
54 bool MyApp::OnInit(void)
55 {
56 // Create the main frame window
57 MyFrame *frame = new MyFrame(NULL);
58
59 // Give it an icon
60 #ifdef wx_msw
61 frame->SetIcon(wxIcon("mondrian"));
62 #endif
63 #ifdef wx_x
64 frame->SetIcon(wxIcon("mondrian.xbm"));
65 #endif
66
67 // Make a menubar
68 wxMenu *file_menu = new wxMenu;
69
70 file_menu->Append(wxID_EXIT, "E&xit");
71 wxMenuBar *menu_bar = new wxMenuBar;
72 menu_bar->Append(file_menu, "File");
73 frame->SetMenuBar(menu_bar);
74
75 // Make a panel with a message
76 wxPanel *panel = new wxPanel(frame);
77
78 (void)new wxStaticText(panel, -1, "Hello, this is a minimal debugging wxWindows program!", wxPoint(10, 10));
79
80 // Show the frame
81 frame->Show(TRUE);
82
83 // wxDebugContext::SetCheckpoint();
84 // wxDebugContext::SetFile("debug.log");
85
86 wxString *thing = new wxString; // WXDEBUG_NEW wxString;
87 wxDate* date = new wxDate;
88
89 // Proves that defining 'new' to be 'WXDEBUG_NEW' doesn't mess up
90 // non-object allocation
91 char *ordinaryNonObject = new char[1000];
92
93 const char *data = (const char*) thing ;
94
95 // wxDebugContext::PrintClasses();
96 // wxDebugContext::Dump();
97 // wxDebugContext::PrintStatistics();
98
99 // Don't delete these two objects, to force wxApp to flag a memory leak.
100 // delete thing;
101 // delete date;
102 // delete[] ordinaryNonObject;
103
104 return TRUE;
105 }
106
107 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
108 EVT_MENU(wxID_EXIT, MyFrame::OnQuit)
109 END_EVENT_TABLE()
110
111 // My frame constructor
112 MyFrame::MyFrame(wxFrame *parent):
113 wxFrame(parent, -1, "MemCheck wxWindows Sample", wxPoint(-1, -1), wxSize(400, 200))
114 {}
115
116 // Intercept menu commands
117 void MyFrame::OnQuit(wxCommandEvent& event)
118 {
119 Close(TRUE);
120 }
121