]> git.saurik.com Git - wxWidgets.git/blob - samples/mobile/styles/styles.cpp
8042e2d636cfc3be7f24106f657fac70e3c0cd67
[wxWidgets.git] / samples / mobile / styles / styles.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: styles.cpp
3 // Author: Robert Roebling
4 // Created: 04/07/02
5 // Copyright:
6 /////////////////////////////////////////////////////////////////////////////
7
8 // For compilers that support precompilation
9 #include "wx/wxprec.h"
10
11 #ifdef __BORLANDC__
12 #pragma hdrstop
13 #endif
14
15 #include "wx/image.h"
16
17 // Include private headers
18 #include "styles.h"
19
20 #ifndef __WXMSW__
21 #include "../../sample.xpm"
22 #endif
23
24 //------------------------------------------------------------------------------
25 // MyFrame
26 //------------------------------------------------------------------------------
27
28 BEGIN_EVENT_TABLE(MyFrame,wxFrame)
29 EVT_MENU(ID_ABOUT, MyFrame::OnAbout)
30 EVT_MENU(ID_QUIT, MyFrame::OnQuit)
31 EVT_CLOSE(MyFrame::OnCloseWindow)
32 END_EVENT_TABLE()
33
34 MyFrame::MyFrame( wxWindow *parent, wxWindowID id, const wxString &title,
35 const wxPoint &position, const wxSize& size, long style ) :
36 wxFrame( parent, id, title, position, size, style )
37 {
38 SetIcon(wxICON(sample));
39
40 // Create menu and status bar.
41 CreateMyMenuBar();
42 #if wxUSE_STATUSBAR
43 CreateStatusBar(1);
44 SetStatusText( _T("Welcome to Styles!") );
45 #endif // wxUSE_STATUSBAR
46
47 wxImage image;
48 image.LoadFile( _T("marble.jpg"), wxBITMAP_TYPE_JPEG );
49
50 wxBitmap bitmap( image );
51 #ifdef __WXUNIVERSAL__
52 SetBackground( bitmap, 0, wxTILE );
53 #endif
54
55 new wxStaticText( this, wxID_ANY, _T("This is text"), wxPoint( 20,50 ) );
56
57 new wxCheckBox( this, wxID_ANY, _T("This is a checkbox"), wxPoint( 20,70 ) );
58 }
59
60 void MyFrame::CreateMyMenuBar()
61 {
62 wxMenu *file_menu = new wxMenu;
63 file_menu->Append( ID_ABOUT, _T("About..."), _T("Program info") );
64 file_menu->AppendSeparator();
65 file_menu->Append( ID_QUIT, _T("Quit..."), _T("Quit program") );
66
67 wxMenuBar *menu_bar = new wxMenuBar();
68 menu_bar->Append( file_menu, _T("&File") );
69
70 SetMenuBar( menu_bar );
71 }
72
73 void MyFrame::OnAbout( wxCommandEvent &WXUNUSED(event) )
74 {
75 }
76
77 void MyFrame::OnQuit( wxCommandEvent &WXUNUSED(event) )
78 {
79 Close( true );
80 }
81
82 void MyFrame::OnCloseWindow( wxCloseEvent &WXUNUSED(event) )
83 {
84 Destroy();
85 }
86
87 //------------------------------------------------------------------------------
88 // MyApp
89 //------------------------------------------------------------------------------
90
91 IMPLEMENT_APP(MyApp)
92
93 bool MyApp::OnInit()
94 {
95 if ( !wxApp::OnInit() )
96 return false;
97
98 wxInitAllImageHandlers();
99
100 SetVendorName(_T("Free world"));
101 SetAppName(_T("Styles"));
102
103 MyFrame *frame = new MyFrame( NULL, wxID_ANY, _T("Styles"), wxPoint(20,20), wxSize(500,340) );
104 frame->Show( true );
105
106 return true;
107 }
108
109 int MyApp::OnExit()
110 {
111 return 0;
112 }
113