]>
git.saurik.com Git - wxWidgets.git/blob - mobile/wxedit/wxedit.cpp
98c5d0bbee2d3e6cd54309c348ba47ec143d8f54
1 /////////////////////////////////////////////////////////////////////////////
3 // Author: Robert Roebling
6 /////////////////////////////////////////////////////////////////////////////
9 #pragma implementation "wxedit.cpp"
12 // For compilers that support precompilation
13 #include "wx/wxprec.h"
19 #include "wx/filename.h"
21 // Include private headers
24 //------------------------------------------------------------------------------
26 //------------------------------------------------------------------------------
28 BEGIN_EVENT_TABLE(MyFrame
,wxFrame
)
29 EVT_MENU(ID_ABOUT
, MyFrame::OnAbout
)
30 EVT_MENU(ID_NEW
, MyFrame::OnNew
)
31 EVT_MENU(ID_OPEN
, MyFrame::OnOpen
)
32 EVT_MENU(ID_SAVE
, MyFrame::OnSave
)
33 EVT_MENU(ID_SAVEAS
, MyFrame::OnSaveAs
)
34 EVT_MENU(ID_QUIT
, MyFrame::OnQuit
)
35 EVT_CLOSE(MyFrame::OnCloseWindow
)
38 MyFrame::MyFrame( wxWindow
*parent
, wxWindowID id
, const wxString
&title
,
39 const wxPoint
&position
, const wxSize
& size
, long style
) :
40 wxFrame( parent
, id
, title
, position
, size
, style
)
45 SetStatusText( "Welcome!" );
47 m_text
= new wxTextCtrl( this, -1, "", wxDefaultPosition
, wxDefaultSize
, wxTE_MULTILINE
);
50 void MyFrame::CreateMyMenuBar()
52 wxMenu
*file_menu
= new wxMenu
;
53 file_menu
->Append( ID_ABOUT
, "About...", "Program info" );
54 file_menu
->AppendSeparator();
55 file_menu
->Append( ID_NEW
, "New...", "New text" );
56 file_menu
->Append( ID_OPEN
, "Open...", "Open text" );
57 file_menu
->Append( ID_SAVE
, "Save", "Save text" );
58 file_menu
->Append( ID_SAVEAS
, "Save as...", "Save text as..." );
59 file_menu
->AppendSeparator();
60 file_menu
->Append( ID_QUIT
, "Quit...", "Quit program" );
62 wxMenuBar
*menu_bar
= new wxMenuBar();
63 menu_bar
->Append( file_menu
, "File" );
65 SetMenuBar( menu_bar
);
68 void MyFrame::OnNew( wxCommandEvent
&event
)
73 void MyFrame::OnOpen( wxCommandEvent
&event
)
75 wxFileDialog
dialog( this, "Open text", "", "",
76 "Text file (*.txt)|*.txt|"
78 wxOPEN
|wxFILE_MUST_EXIST
);
79 if (dialog
.ShowModal() == wxID_OK
)
84 wxFileName
fname( dialog
.GetPath() );
85 if ((fname
.GetExt() == "cpp") ||
86 (fname
.GetExt() == "c") ||
87 (fname
.GetExt() == "h") ||
88 (fname
.GetExt() == "cxx") ||
89 (fname
.GetExt() == "hxx"))
91 m_text
->SetLanguage( wxSOURCE_LANG_CPP
);
94 if (fname
.GetExt() == "py")
96 m_text
->SetLanguage( wxSOURCE_LANG_PYTHON
);
99 if ((fname
.GetExt() == "pl") ||
100 (fname
.GetExt() == "pm"))
102 m_text
->SetLanguage( wxSOURCE_LANG_PYTHON
);
106 m_text
->SetLanguage( wxSOURCE_LANG_NONE
);
110 m_text
->LoadFile( dialog
.GetPath() );
114 void MyFrame::OnSave( wxCommandEvent
&event
)
118 void MyFrame::OnSaveAs( wxCommandEvent
&event
)
122 void MyFrame::OnAbout( wxCommandEvent
&event
)
124 wxMessageDialog
dialog( this, "Welcome to SuperApp 1.0\n(C)opyright Joe Hacker",
125 "About SuperApp", wxOK
|wxICON_INFORMATION
);
129 void MyFrame::OnQuit( wxCommandEvent
&event
)
134 void MyFrame::OnCloseWindow( wxCloseEvent
&event
)
136 // if ! saved changes -> return
141 //------------------------------------------------------------------------------
143 //------------------------------------------------------------------------------
153 MyFrame
*frame
= new MyFrame( NULL
, -1, "SuperApp", wxPoint(20,20), wxSize(500,340) );