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