]> git.saurik.com Git - wxWidgets.git/blame - samples/memcheck/memcheck.cpp
* Changed fstream.* in wfstream.*
[wxWidgets.git] / samples / memcheck / memcheck.cpp
CommitLineData
457814b5
JS
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
47908e25
RR
30#ifdef __WXGTK__
31#include "mondrian.xpm"
32#endif
33
b2aef89b 34#if !WXDEBUG
e3e65dac 35#error You must set WXDEBUG to 1 on the 'make' command line (MSW) or with configure (GTK)
457814b5
JS
36#endif
37
457814b5
JS
38// Define a new application type
39class MyApp: public wxApp
40{ public:
41 bool OnInit(void);
42};
43
44// Define a new frame type
45class MyFrame: public wxFrame
46{ public:
47 MyFrame(wxFrame *parent);
48 void OnQuit(wxCommandEvent& event);
49
50DECLARE_EVENT_TABLE()
51};
52
53IMPLEMENT_APP(MyApp)
54
55// `Main program' equivalent, creating windows and returning main app frame
56bool MyApp::OnInit(void)
57{
58 // Create the main frame window
c67daf87 59 MyFrame *frame = new MyFrame((wxFrame *) NULL);
457814b5
JS
60
61 // Give it an icon
cb43b372 62#ifdef __WXMSW__
457814b5 63 frame->SetIcon(wxIcon("mondrian"));
cb43b372 64#else
47908e25 65 frame->SetIcon(wxIcon(mondrian_xpm));
457814b5
JS
66#endif
67
68 // Make a menubar
69 wxMenu *file_menu = new wxMenu;
70
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);
75
76 // Make a panel with a message
77 wxPanel *panel = new wxPanel(frame);
78
79 (void)new wxStaticText(panel, -1, "Hello, this is a minimal debugging wxWindows program!", wxPoint(10, 10));
80
81 // Show the frame
82 frame->Show(TRUE);
83
bd7d06f2
RR
84 wxDebugContext::SetCheckpoint();
85 wxDebugContext::SetFile("debug.log");
457814b5 86
e55ad60e 87 wxString *thing = new wxString;
457814b5
JS
88 wxDate* date = new wxDate;
89
457814b5
JS
90 // non-object allocation
91 char *ordinaryNonObject = new char[1000];
92
93 const char *data = (const char*) thing ;
94
bd7d06f2
RR
95 wxDebugContext::PrintClasses();
96 wxDebugContext::Dump();
97 wxDebugContext::PrintStatistics();
457814b5
JS
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
107BEGIN_EVENT_TABLE(MyFrame, wxFrame)
108 EVT_MENU(wxID_EXIT, MyFrame::OnQuit)
109END_EVENT_TABLE()
110
111// My frame constructor
112MyFrame::MyFrame(wxFrame *parent):
113 wxFrame(parent, -1, "MemCheck wxWindows Sample", wxPoint(-1, -1), wxSize(400, 200))
114{}
115
116// Intercept menu commands
cb43b372 117void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
457814b5
JS
118{
119 Close(TRUE);
120}
121