]>
Commit | Line | Data |
---|---|---|
f9032263 RR |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: simple.cpp | |
3 | // Author: XX | |
4 | // Created: XX/XX/XX | |
5 | // Copyright: | |
6 | ///////////////////////////////////////////////////////////////////////////// | |
7 | ||
8 | #ifdef __GNUG__ | |
9 | #pragma implementation "simple.cpp" | |
10 | #endif | |
11 | ||
12 | // For compilers that support precompilation | |
13 | #include "wx/wxprec.h" | |
14 | ||
15 | #ifdef __BORLANDC__ | |
16 | #pragma hdrstop | |
17 | #endif | |
18 | ||
19 | // Include private headers | |
20 | #include "simple.h" | |
21 | ||
22 | // Include icon header | |
23 | #if defined(__WXGTK__) || defined(__WXMOTIF__) | |
24 | #include "mondrian.xpm" | |
25 | #endif | |
26 | ||
27 | // Include image | |
28 | #include "smile.xpm" | |
29 | ||
30 | // WDR: class implementations | |
31 | ||
32 | //------------------------------------------------------------------------------ | |
33 | // MyFrame | |
34 | //------------------------------------------------------------------------------ | |
35 | ||
36 | // WDR: event table for MyFrame | |
37 | ||
38 | BEGIN_EVENT_TABLE(MyFrame,wxFrame) | |
39 | EVT_MENU(ID_QUIT, MyFrame::OnQuit) | |
40 | EVT_CLOSE(MyFrame::OnCloseWindow) | |
41 | END_EVENT_TABLE() | |
42 | ||
43 | MyFrame::MyFrame( wxWindow *parent, wxWindowID id, const wxString &title, | |
44 | const wxPoint &position, const wxSize& size, long style ) : | |
45 | wxFrame( parent, id, title, position, size, style ) | |
46 | { | |
47 | CreateMyMenuBar(); | |
48 | ||
49 | CreateStatusBar(1); | |
50 | SetStatusText( "Welcome!" ); | |
51 | ||
52 | SetIcon(wxICON(mondrian)); | |
53 | ||
54 | // wxCanvas from here | |
55 | ||
56 | m_admin = new wxCanvasAdmin; | |
57 | wxCanvas *canvas = new wxCanvas( m_admin, this, -1 ); | |
58 | m_admin->Append( canvas ); | |
59 | m_admin->SetActive( canvas ); | |
60 | ||
61 | ||
62 | wxCanvasObjectGroup *root = new wxCanvasObjectGroup(0,0); | |
63 | root->DeleteContents( TRUE ); | |
64 | ||
65 | wxCanvasRect *rect; | |
66 | ||
67 | rect = new wxCanvasRect( 120,10,120,140 ); | |
68 | rect->SetBrush( *wxRED_BRUSH ); | |
69 | root->Append( rect ); | |
70 | ||
71 | /* | |
72 | wxBitmap bitmap( smile_xpm ); | |
73 | wxImage image( bitmap ); | |
74 | ||
75 | m_smile1 = new wxCanvasImage( image, 0,70,32,32 ); | |
76 | root->Append( m_smile1 ); | |
77 | ||
78 | int i; | |
79 | for (i = 10; i < 300; i+=10) | |
80 | { | |
81 | wxCanvasRect *r = new wxCanvasRect( i,50,3,140 ); | |
82 | r->SetBrush( *wxRED_BRUSH ); | |
83 | root->Append( r ); | |
84 | } | |
85 | ||
86 | m_smile2 = new wxCanvasImage( image, 0,110,32,32 ); | |
87 | root->Append( m_smile2 ); | |
88 | ||
89 | for (i = 15; i < 300; i+=10) | |
90 | { | |
91 | wxCanvasRect *r = new wxCanvasRect( i,50,3,140 ); | |
92 | r->SetBrush( *wxRED_BRUSH ); | |
93 | root->Append( r ); | |
94 | } | |
95 | */ | |
96 | ||
97 | canvas->SetRoot( root ); | |
98 | } | |
99 | ||
100 | void MyFrame::CreateMyMenuBar() | |
101 | { | |
102 | wxMenu *file_menu = new wxMenu; | |
103 | file_menu->Append( ID_QUIT, "Quit...", "Quit program" ); | |
104 | ||
105 | wxMenuBar *menu_bar = new wxMenuBar(); | |
106 | menu_bar->Append( file_menu, "File" ); | |
107 | ||
108 | SetMenuBar( menu_bar ); | |
109 | } | |
110 | ||
111 | // WDR: handler implementations for MyFrame | |
112 | ||
113 | void MyFrame::OnQuit( wxCommandEvent &event ) | |
114 | { | |
115 | Close( TRUE ); | |
116 | } | |
117 | ||
118 | void MyFrame::OnCloseWindow( wxCloseEvent &event ) | |
119 | { | |
120 | // if ! saved changes -> return | |
121 | ||
122 | Destroy(); | |
123 | } | |
124 | ||
125 | //------------------------------------------------------------------------------ | |
126 | // MyApp | |
127 | //------------------------------------------------------------------------------ | |
128 | ||
129 | IMPLEMENT_APP(MyApp) | |
130 | ||
131 | MyApp::MyApp() | |
132 | { | |
133 | } | |
134 | ||
135 | bool MyApp::OnInit() | |
136 | { | |
137 | MyFrame *frame = new MyFrame( NULL, -1, "SuperApp", wxPoint(20,20), wxSize(500,340) ); | |
138 | frame->Show( TRUE ); | |
139 | ||
140 | return TRUE; | |
141 | } | |
142 | ||
143 | int MyApp::OnExit() | |
144 | { | |
145 | return 0; | |
146 | } | |
147 |