]> git.saurik.com Git - wxWidgets.git/blob - mobile/wxedit/wxedit.cpp
Added first test app to "mobile".
[wxWidgets.git] / mobile / wxedit / wxedit.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wxedit.cpp
3 // Author: Robert Roebling
4 // Created: 04/07/02
5 // Copyright:
6 /////////////////////////////////////////////////////////////////////////////
7
8 #ifdef __GNUG__
9 #pragma implementation "wxedit.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 "wxedit.h"
21
22 //------------------------------------------------------------------------------
23 // MyFrame
24 //------------------------------------------------------------------------------
25
26 BEGIN_EVENT_TABLE(MyFrame,wxFrame)
27 EVT_MENU(ID_ABOUT, MyFrame::OnAbout)
28 EVT_MENU(ID_NEW, MyFrame::OnNew)
29 EVT_MENU(ID_OPEN, MyFrame::OnOpen)
30 EVT_MENU(ID_SAVE, MyFrame::OnSave)
31 EVT_MENU(ID_SAVEAS, MyFrame::OnSaveAs)
32 EVT_MENU(ID_QUIT, MyFrame::OnQuit)
33 EVT_CLOSE(MyFrame::OnCloseWindow)
34 END_EVENT_TABLE()
35
36 MyFrame::MyFrame( wxWindow *parent, wxWindowID id, const wxString &title,
37 const wxPoint &position, const wxSize& size, long style ) :
38 wxFrame( parent, id, title, position, size, style )
39 {
40 CreateMyMenuBar();
41
42 CreateStatusBar(1);
43 SetStatusText( "Welcome!" );
44
45 m_text = new wxTextCtrl( this, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
46 }
47
48 void MyFrame::CreateMyMenuBar()
49 {
50 wxMenu *file_menu = new wxMenu;
51 file_menu->Append( ID_ABOUT, "About...", "Program info" );
52 file_menu->AppendSeparator();
53 file_menu->Append( ID_NEW, "New...", "New text" );
54 file_menu->Append( ID_OPEN, "Open...", "Open text" );
55 file_menu->Append( ID_SAVE, "Save", "Save text" );
56 file_menu->Append( ID_SAVEAS, "Save as...", "Save text as..." );
57 file_menu->AppendSeparator();
58 file_menu->Append( ID_QUIT, "Quit...", "Quit program" );
59
60 wxMenuBar *menu_bar = new wxMenuBar();
61 menu_bar->Append( file_menu, "File" );
62
63 SetMenuBar( menu_bar );
64 }
65
66 void MyFrame::OnNew( wxCommandEvent &event )
67 {
68 m_text->Clear();
69 }
70
71 void MyFrame::OnOpen( wxCommandEvent &event )
72 {
73 wxFileDialog dialog( this, "Open text", "", "",
74 "Text file (*.txt)|*.txt|"
75 "Any file (*)|*",
76 wxOPEN|wxFILE_MUST_EXIST );
77 dialog.ShowModal();
78 }
79
80 void MyFrame::OnSave( wxCommandEvent &event )
81 {
82 }
83
84 void MyFrame::OnSaveAs( wxCommandEvent &event )
85 {
86 }
87
88 void MyFrame::OnAbout( wxCommandEvent &event )
89 {
90 wxMessageDialog dialog( this, "Welcome to SuperApp 1.0\n(C)opyright Joe Hacker",
91 "About SuperApp", wxOK|wxICON_INFORMATION );
92 dialog.ShowModal();
93 }
94
95 void MyFrame::OnQuit( wxCommandEvent &event )
96 {
97 Close( TRUE );
98 }
99
100 void MyFrame::OnCloseWindow( wxCloseEvent &event )
101 {
102 // if ! saved changes -> return
103
104 Destroy();
105 }
106
107 //------------------------------------------------------------------------------
108 // MyApp
109 //------------------------------------------------------------------------------
110
111 IMPLEMENT_APP(MyApp)
112
113 MyApp::MyApp()
114 {
115 }
116
117 bool MyApp::OnInit()
118 {
119 MyFrame *frame = new MyFrame( NULL, -1, "SuperApp", wxPoint(20,20), wxSize(500,340) );
120 frame->Show( TRUE );
121
122 return TRUE;
123 }
124
125 int MyApp::OnExit()
126 {
127 return 0;
128 }
129