diff --git a/src/TyroApp.cpp b/src/TyroApp.cpp index 6374a47..34cb025 100644 --- a/src/TyroApp.cpp +++ b/src/TyroApp.cpp @@ -1,7 +1,7 @@ /*************************************************************** - * Name: TyroApp.cpp + * Name: TyroApp.cpp * Purpose: Code for Application Class - * Author: Timothy J Warren (tim@timshomepage.net) + * Author: Timothy J Warren (tim@timshomepage.net) * Created: 2015-03-30 * Copyright: Timothy J Warren (https://timshomepage.net) * License: @@ -18,16 +18,17 @@ IMPLEMENT_APP(TyroApp); bool TyroApp::OnInit() { - TyroFrame* frame = new TyroFrame(0L, _("Tyro")); + TyroFrame* frame = new TyroFrame(0L, _("Tyro")); - frame->Show(true); - SetTopWindow(frame); + frame->CenterOnScreen(); + frame->Show(true); + SetTopWindow(frame); - return true; + return true; } int TyroApp::OnExit(wxCommandEvent &WXUNUSED(event)) { - close(true); - return 1; + close(true); + return 1; } diff --git a/src/TyroApp.h b/src/TyroApp.h index a948961..f69eeeb 100644 --- a/src/TyroApp.h +++ b/src/TyroApp.h @@ -1,7 +1,7 @@ /*************************************************************** - * Name: TyroApp.h + * Name: TyroApp.h * Purpose: Defines Application Class - * Author: Timothy J Warren (tim@timshomepage.net) + * Author: Timothy J Warren (tim@timshomepage.net) * Created: 2015-03-30 * Copyright: Timothy J Warren (https://timshomepage.net) * License: @@ -18,10 +18,10 @@ class TyroApp : public wxApp { - friend class TyroFrame; - public: - virtual bool OnInit(); - virtual int OnExit(wxCommandEvent &WXUNUSED(event)); + friend class TyroFrame; + public: + virtual bool OnInit(); + virtual int OnExit(wxCommandEvent &WXUNUSED(event)); }; #endif // TYROAPP_H diff --git a/src/TyroMain.cpp b/src/TyroMain.cpp index c3e6868..711604f 100644 --- a/src/TyroMain.cpp +++ b/src/TyroMain.cpp @@ -1,7 +1,7 @@ /*************************************************************** - * Name: TyroMain.cpp + * Name: TyroMain.cpp * Purpose: Code for Application Frame - * Author: Timothy J Warren (tim@timshomepage.net) + * Author: Timothy J Warren (tim@timshomepage.net) * Created: 2015-03-30 * Copyright: Timothy J Warren (https://timshomepage.net) * License: @@ -13,88 +13,71 @@ #include "TyroMain.h" -//helper functions -enum wxbuildinfoformat { - short_f, long_f }; - -wxString wxbuildinfo(wxbuildinfoformat format) -{ - wxString wxbuild(wxVERSION_STRING); - - if (format == long_f ) - { -#if defined(__WXMSW__) - wxbuild << _T("-Windows"); -#elif defined(__WXMAC__) - wxbuild << _T("-Mac"); -#elif defined(__UNIX__) - wxbuild << _T("-Linux"); -#endif - -#if wxUSE_UNICODE - wxbuild << _T("-Unicode build"); -#else - wxbuild << _T("-ANSI build"); -#endif // wxUSE_UNICODE - } - - return wxbuild; -} BEGIN_EVENT_TABLE(TyroFrame, wxFrame) - EVT_CLOSE(TyroFrame::OnClose) - EVT_MENU(wxID_EXIT, TyroFrame::OnQuit) - EVT_MENU(wxID_ABOUT, TyroFrame::OnAbout) + EVT_CLOSE(TyroFrame::OnClose) + EVT_MENU(wxID_EXIT, TyroFrame::OnQuit) + EVT_MENU(wxID_ABOUT, TyroFrame::OnAbout) END_EVENT_TABLE() TyroFrame::TyroFrame(wxFrame *frame, const wxString& title) - : wxFrame(frame, -1, title) + : wxFrame(frame, -1, title) { - // create a menu bar - wxMenuBar* mbar = new wxMenuBar(); + // create a menu bar + wxMenuBar* mbar = new wxMenuBar(); - // Create Base menus - wxMenu* fileMenu = new wxMenu(_T("")); - wxMenu* editMenu = new wxMenu(_T("")); - wxMenu* helpMenu = new wxMenu(_T("")); + // Create Base menus + wxMenu* fileMenu = new wxMenu(_T("")); + wxMenu* editMenu = new wxMenu(_T("")); + wxMenu* helpMenu = new wxMenu(_T("")); - // Add items to top-level menus - fileMenu->Append(wxID_OPEN, _T("&Open"), _T("Opens an existing file")); - fileMenu->Append(wxID_SAVE, _T("&Save"), _T("Save the content")); - fileMenu->AppendSeparator(); - fileMenu->Append(wxID_EXIT, _("&Quit"), _("Quit the application")); + // Add items to top-level menus + fileMenu->Append(wxID_NEW, _T("&New\tCtrl+N"), _T("Create a new file")); + fileMenu->AppendSeparator(); + fileMenu->Append(wxID_OPEN, _T("&Open\tCtrl+0"), _T("Opens an existing file")); + fileMenu->Append(wxID_CLOSE, _T("&Close\tCtrl+W"), _T("Close the current document")); + fileMenu->Append(wxID_SAVE, _T("&Save\tCtrl+S"), _T("Save the content")); + fileMenu->AppendSeparator(); + fileMenu->Append(wxID_EXIT, _T("&Quit\tCtrl+Q"), _T("Quit the application")); - helpMenu->Append(wxID_ABOUT, _("&About"), _("Show info about this application")); + editMenu->Append(wxID_UNDO, _T("&Undo\tCtrl+Z"), _T("Undo last action")); + editMenu->Append(wxID_REDO, _T("&Redo\tCtrl+Y"), _T("Redo last action")); + editMenu->AppendSeparator(); + editMenu->Append(wxID_CUT, _T("Cu&t\tCtrl+X"), _T("Cut selected text")); + editMenu->Append(wxID_COPY, _T("&Copy\tCtrl+C"), _T("Copy selected text")); + editMenu->Append(wxID_PASTE, _T("&Paste\tCtrl+V"), _T("Paste contents of clipboard")); - // Add the menus to the menubar - mbar->Append(fileMenu, _("&File")); - mbar->Append(editMenu, _("&Edit")); - mbar->Append(helpMenu, _("&Help")); + helpMenu->Append(wxID_ABOUT, _T("&About...\tF1"), _T("Show info about this application")); + + // Add the menus to the menubar + mbar->Append(fileMenu, _("&File")); + mbar->Append(editMenu, _("&Edit")); + mbar->Append(helpMenu, _("&Help")); #ifdef __WXMAC__ - wxMenuBar::MacSetCommonMenuBar(mbar); + wxMenuBar::MacSetCommonMenuBar(mbar); #endif // __WXMAC__ SetMenuBar(mbar); - // create a status bar with some information about the used wxWidgets version - CreateStatusBar(2); - SetStatusText(_(""),0); - SetStatusText(wxbuildinfo(short_f), 1); + // create a status bar with some information about the used wxWidgets version + CreateStatusBar(2); + SetStatusText(_(""), 0); + SetStatusText(_(""), 1); - // Set up control layout - wxBoxSizer *base_sizer = new wxBoxSizer(wxVERTICAL); + // Set up control layout + wxBoxSizer *base_sizer = new wxBoxSizer(wxVERTICAL); - base_sizer->Add( - CreateNotebook(), - 1, - wxEXPAND | wxALL, - 5 - ); + base_sizer->Add( + CreateNotebook(), + 1, + wxEXPAND | wxALL, + 5 + ); - base_sizer->SetContainingWindow(this); - base_sizer->SetMinSize(800,600); + base_sizer->SetContainingWindow(this); + base_sizer->SetMinSize(800,600); - SetSizerAndFit(base_sizer); + SetSizerAndFit(base_sizer); } @@ -102,25 +85,33 @@ TyroFrame::~TyroFrame() {} wxAuiNotebook *TyroFrame::CreateNotebook() { - wxAuiNotebook *ctrl = new wxAuiNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_NB_DEFAULT_STYLE); + wxAuiNotebook *ctrl = new wxAuiNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_NB_DEFAULT_STYLE); - return ctrl; + return ctrl; } void TyroFrame::OnClose(wxCloseEvent &event) { - Destroy(); + Destroy(); +} + +void TyroFrame::OnMenuFileOpen(wxCommandEvent &event) +{ + +} + +void TyroFrame::OnMenuFileSave(wxCommandEvent &event) +{ } void TyroFrame::OnQuit(wxCommandEvent &event) { - Destroy(); + Destroy(); } void TyroFrame::OnAbout(wxCommandEvent &event) { - wxString msg = wxbuildinfo(long_f); - wxMessageBox(msg, _("Welcome to...")); + wxMessageBox(_T("Tyro, a text editor for all development\n Copyright 2015, Timothy J. Warren"), wxT("About Tyro"), wxOK| wxICON_INFORMATION, this); } diff --git a/src/TyroMain.h b/src/TyroMain.h index a37d3fe..5af386e 100644 --- a/src/TyroMain.h +++ b/src/TyroMain.h @@ -1,7 +1,7 @@ /*************************************************************** - * Name: TyroMain.h + * Name: TyroMain.h * Purpose: Defines Application Frame - * Author: Timothy J Warren (tim@timshomepage.net) + * Author: Timothy J Warren (tim@timshomepage.net) * Created: 2015-03-30 * Copyright: Timothy J Warren (https://timshomepage.net) * License: @@ -11,28 +11,29 @@ #define TYROMAIN_H #ifndef WX_PRECOMP - #include + #include #endif #include "TyroApp.h" class TyroFrame: public wxFrame { - public: - TyroFrame(wxFrame *frame, const wxString& title); - ~TyroFrame(); - private: - enum - { - idMenuQuit = 1000, - idMenuAbout - }; - wxAuiManager m_mgr; - void OnClose(wxCloseEvent& event); - void OnQuit(wxCommandEvent& event); - void OnAbout(wxCommandEvent& event); - wxAuiNotebook* CreateNotebook(); - DECLARE_EVENT_TABLE() + public: + TyroFrame(wxFrame *frame, const wxString& title); + ~TyroFrame(); + private: + enum + { + idMenuQuit = 1000, + idMenuAbout + }; +void OnMenuFileOpen(wxCommandEvent &event); +void OnMenuFileSave(wxCommandEvent &event); + void OnClose(wxCloseEvent &event); + void OnQuit(wxCommandEvent &event); + void OnAbout(wxCommandEvent &event); + wxAuiNotebook* CreateNotebook(); + DECLARE_EVENT_TABLE() };