/////////////////////////////////////////////////////////////////////////////// // Name: main.cpp (Silkpad 0.1 Main Source File) // Purpose: Multi-Platform Text Editor // Author: Jesse Ray // Created: 08/05/2004 // Copyright: (c) Jesse Ray /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// // Compilation Headers. /////////////////////////////////////////////////////////////////////////////// #include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif #ifndef WX_PRECOMP #include "wx/wx.h" #endif /////////////////////////////////////////////////////////////////////////////// // Application Resources. /////////////////////////////////////////////////////////////////////////////// #if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) || defined(__WXX11__) #include "mondrian.xpm" #endif /////////////////////////////////////////////////////////////////////////////// // Silkpad Application Type Derived From wxApp. /////////////////////////////////////////////////////////////////////////////// class MyApp : public wxApp { public: virtual bool OnInit(); }; /////////////////////////////////////////////////////////////////////////////// // Silkpad Application Frame Type Derived From wxFrame. /////////////////////////////////////////////////////////////////////////////// class MyFrame : public wxFrame { public: MyFrame(const wxString& title,const wxPoint& pos,const wxSize& size,long style = wxDEFAULT_FRAME_STYLE); void OnNew(wxCommandEvent& event); void OnOpen(wxCommandEvent& event); void OnSave(wxCommandEvent& event); void OnSaveAs(wxCommandEvent& event); void OnQuit(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); private: DECLARE_EVENT_TABLE() }; enum { Minimal_New = 2, Minimal_Open = 3, Minimal_Save = 4, Minimal_SaveAs = 5, Minimal_Quit = 1, Minimal_About = wxID_ABOUT /* wxID_ABOUT is used for Mac compatibility */ }; BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(Minimal_New, MyFrame::OnNew) EVT_MENU(Minimal_Open, MyFrame::OnOpen) EVT_MENU(Minimal_Save, MyFrame::OnSave) EVT_MENU(Minimal_SaveAs, MyFrame::OnSaveAs) EVT_MENU(Minimal_Quit, MyFrame::OnQuit) EVT_MENU(Minimal_About, MyFrame::OnAbout) END_EVENT_TABLE() IMPLEMENT_APP(MyApp) /////////////////////////////////////////////////////////////////////////////// // Main Application Class Constructor. /////////////////////////////////////////////////////////////////////////////// bool MyApp::OnInit() { MyFrame *frame = new MyFrame(_T("Silkpad 0.1 Public Development Release 1"),wxPoint(50,50),wxSize(450,340)); frame->Show(TRUE); return TRUE; } /////////////////////////////////////////////////////////////////////////////// // Main Application Frame. /////////////////////////////////////////////////////////////////////////////// MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxFrame(NULL, -1, title, pos, size, style) { SetIcon(wxICON(mondrian)); #if wxUSE_MENUS wxMenu *menuFile = new wxMenu; menuFile->Append(Minimal_New, _T("&New\tCtrl+N"), _T("Create A New Document.")); menuFile->Append(Minimal_Open, _T("&Open...\tCtrl+O"), _T("Open An Existing Document.")); menuFile->Append(Minimal_Save, _T("&Save\tCtrl+S"), _T("Save Document To File.")); menuFile->Append(Minimal_SaveAs, _T("Save As..."), _T("Save Document As A New File.")); menuFile->AppendSeperator(); menuFile->Append(Minimal_Quit, _T("E&xit\tEsc"), _T("Exit The Application.")); wxMenu *helpMenu = new wxMenu; helpMenu->Append(Minimal_About, _T("&About...\tF1"), _T("About Silkpad")); wxMenuBar *menuBar = new wxMenuBar(); menuBar->Append(menuFile, _T("&File")); menuBar->Append(helpMenu, _T("&Help")); SetMenuBar(menuBar); #endif #if wxUSE_STATUSBAR CreateStatusBar(); #endif } /////////////////////////////////////////////////////////////////////////////// // MyFrame::OnNew - Creates New Document. // MyFrame::OnOpen - Opens Existing Document. // MyFrame::OnSave - Saves Current Document. // MyFrame::OnSaveAs - Saves Current Document As A New File. // MyFrame::OnQuit - Forces Application To Close Window. // MyFrame::OnAbout - Shows About Dialog. /////////////////////////////////////////////////////////////////////////////// void MyFrame::OnNew(wxCommandEvent& WXUNUSED(event)) {/* Currently Blank */} void MyFrame::OnOpen(wxCommandEvent& WXUNUSED(event)) {/* Currently Blank */} void MyFrame::OnSave(wxCommandEvent& WXUNUSED(event)) {/* Currently Blank */} void MyFrame::OnSaveAs(wxCommandEvent& WXUNUSED(event)) {/* Currently Blank */} void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) { Close(TRUE); } void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { wxString msg; msg.Printf(_T("Silkpad 0.1 Public Development Release 1\nCopyright 2004 Jesse Ray")); wxMessageBox(msg, _T("About Silkpad 0.1"), wxOK | wxICON_INFORMATION, this); }