More menus, about dialog, and tabs replace spaces

This commit is contained in:
Timothy Warren 2015-03-31 22:52:12 -04:00
parent 794e660b03
commit d8b673934b
4 changed files with 96 additions and 103 deletions

View File

@ -1,7 +1,7 @@
/*************************************************************** /***************************************************************
* Name: TyroApp.cpp * Name: TyroApp.cpp
* Purpose: Code for Application Class * Purpose: Code for Application Class
* Author: Timothy J Warren (tim@timshomepage.net) * Author: Timothy J Warren (tim@timshomepage.net)
* Created: 2015-03-30 * Created: 2015-03-30
* Copyright: Timothy J Warren (https://timshomepage.net) * Copyright: Timothy J Warren (https://timshomepage.net)
* License: * License:
@ -18,16 +18,17 @@ IMPLEMENT_APP(TyroApp);
bool TyroApp::OnInit() bool TyroApp::OnInit()
{ {
TyroFrame* frame = new TyroFrame(0L, _("Tyro")); TyroFrame* frame = new TyroFrame(0L, _("Tyro"));
frame->Show(true); frame->CenterOnScreen();
SetTopWindow(frame); frame->Show(true);
SetTopWindow(frame);
return true; return true;
} }
int TyroApp::OnExit(wxCommandEvent &WXUNUSED(event)) int TyroApp::OnExit(wxCommandEvent &WXUNUSED(event))
{ {
close(true); close(true);
return 1; return 1;
} }

View File

@ -1,7 +1,7 @@
/*************************************************************** /***************************************************************
* Name: TyroApp.h * Name: TyroApp.h
* Purpose: Defines Application Class * Purpose: Defines Application Class
* Author: Timothy J Warren (tim@timshomepage.net) * Author: Timothy J Warren (tim@timshomepage.net)
* Created: 2015-03-30 * Created: 2015-03-30
* Copyright: Timothy J Warren (https://timshomepage.net) * Copyright: Timothy J Warren (https://timshomepage.net)
* License: * License:
@ -18,10 +18,10 @@
class TyroApp : public wxApp class TyroApp : public wxApp
{ {
friend class TyroFrame; friend class TyroFrame;
public: public:
virtual bool OnInit(); virtual bool OnInit();
virtual int OnExit(wxCommandEvent &WXUNUSED(event)); virtual int OnExit(wxCommandEvent &WXUNUSED(event));
}; };
#endif // TYROAPP_H #endif // TYROAPP_H

View File

@ -1,7 +1,7 @@
/*************************************************************** /***************************************************************
* Name: TyroMain.cpp * Name: TyroMain.cpp
* Purpose: Code for Application Frame * Purpose: Code for Application Frame
* Author: Timothy J Warren (tim@timshomepage.net) * Author: Timothy J Warren (tim@timshomepage.net)
* Created: 2015-03-30 * Created: 2015-03-30
* Copyright: Timothy J Warren (https://timshomepage.net) * Copyright: Timothy J Warren (https://timshomepage.net)
* License: * License:
@ -13,88 +13,71 @@
#include "TyroMain.h" #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) BEGIN_EVENT_TABLE(TyroFrame, wxFrame)
EVT_CLOSE(TyroFrame::OnClose) EVT_CLOSE(TyroFrame::OnClose)
EVT_MENU(wxID_EXIT, TyroFrame::OnQuit) EVT_MENU(wxID_EXIT, TyroFrame::OnQuit)
EVT_MENU(wxID_ABOUT, TyroFrame::OnAbout) EVT_MENU(wxID_ABOUT, TyroFrame::OnAbout)
END_EVENT_TABLE() END_EVENT_TABLE()
TyroFrame::TyroFrame(wxFrame *frame, const wxString& title) TyroFrame::TyroFrame(wxFrame *frame, const wxString& title)
: wxFrame(frame, -1, title) : wxFrame(frame, -1, title)
{ {
// create a menu bar // create a menu bar
wxMenuBar* mbar = new wxMenuBar(); wxMenuBar* mbar = new wxMenuBar();
// Create Base menus // Create Base menus
wxMenu* fileMenu = new wxMenu(_T("")); wxMenu* fileMenu = new wxMenu(_T(""));
wxMenu* editMenu = new wxMenu(_T("")); wxMenu* editMenu = new wxMenu(_T(""));
wxMenu* helpMenu = new wxMenu(_T("")); wxMenu* helpMenu = new wxMenu(_T(""));
// Add items to top-level menus // Add items to top-level menus
fileMenu->Append(wxID_OPEN, _T("&Open"), _T("Opens an existing file")); fileMenu->Append(wxID_NEW, _T("&New\tCtrl+N"), _T("Create a new file"));
fileMenu->Append(wxID_SAVE, _T("&Save"), _T("Save the content")); fileMenu->AppendSeparator();
fileMenu->AppendSeparator(); fileMenu->Append(wxID_OPEN, _T("&Open\tCtrl+0"), _T("Opens an existing file"));
fileMenu->Append(wxID_EXIT, _("&Quit"), _("Quit the application")); 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 helpMenu->Append(wxID_ABOUT, _T("&About...\tF1"), _T("Show info about this application"));
mbar->Append(fileMenu, _("&File"));
mbar->Append(editMenu, _("&Edit")); // Add the menus to the menubar
mbar->Append(helpMenu, _("&Help")); mbar->Append(fileMenu, _("&File"));
mbar->Append(editMenu, _("&Edit"));
mbar->Append(helpMenu, _("&Help"));
#ifdef __WXMAC__ #ifdef __WXMAC__
wxMenuBar::MacSetCommonMenuBar(mbar); wxMenuBar::MacSetCommonMenuBar(mbar);
#endif // __WXMAC__ #endif // __WXMAC__
SetMenuBar(mbar); SetMenuBar(mbar);
// create a status bar with some information about the used wxWidgets version // create a status bar with some information about the used wxWidgets version
CreateStatusBar(2); CreateStatusBar(2);
SetStatusText(_(""),0); SetStatusText(_(""), 0);
SetStatusText(wxbuildinfo(short_f), 1); SetStatusText(_(""), 1);
// Set up control layout // Set up control layout
wxBoxSizer *base_sizer = new wxBoxSizer(wxVERTICAL); wxBoxSizer *base_sizer = new wxBoxSizer(wxVERTICAL);
base_sizer->Add( base_sizer->Add(
CreateNotebook(), CreateNotebook(),
1, 1,
wxEXPAND | wxALL, wxEXPAND | wxALL,
5 5
); );
base_sizer->SetContainingWindow(this); base_sizer->SetContainingWindow(this);
base_sizer->SetMinSize(800,600); base_sizer->SetMinSize(800,600);
SetSizerAndFit(base_sizer); SetSizerAndFit(base_sizer);
} }
@ -102,25 +85,33 @@ TyroFrame::~TyroFrame() {}
wxAuiNotebook *TyroFrame::CreateNotebook() 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) void TyroFrame::OnClose(wxCloseEvent &event)
{ {
Destroy(); Destroy();
}
void TyroFrame::OnMenuFileOpen(wxCommandEvent &event)
{
}
void TyroFrame::OnMenuFileSave(wxCommandEvent &event)
{
} }
void TyroFrame::OnQuit(wxCommandEvent &event) void TyroFrame::OnQuit(wxCommandEvent &event)
{ {
Destroy(); Destroy();
} }
void TyroFrame::OnAbout(wxCommandEvent &event) void TyroFrame::OnAbout(wxCommandEvent &event)
{ {
wxString msg = wxbuildinfo(long_f); wxMessageBox(_T("Tyro, a text editor for all development\n Copyright 2015, Timothy J. Warren"), wxT("About Tyro"), wxOK| wxICON_INFORMATION, this);
wxMessageBox(msg, _("Welcome to..."));
} }

View File

@ -1,7 +1,7 @@
/*************************************************************** /***************************************************************
* Name: TyroMain.h * Name: TyroMain.h
* Purpose: Defines Application Frame * Purpose: Defines Application Frame
* Author: Timothy J Warren (tim@timshomepage.net) * Author: Timothy J Warren (tim@timshomepage.net)
* Created: 2015-03-30 * Created: 2015-03-30
* Copyright: Timothy J Warren (https://timshomepage.net) * Copyright: Timothy J Warren (https://timshomepage.net)
* License: * License:
@ -11,28 +11,29 @@
#define TYROMAIN_H #define TYROMAIN_H
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include <wx/wx.h> #include <wx/wx.h>
#endif #endif
#include "TyroApp.h" #include "TyroApp.h"
class TyroFrame: public wxFrame class TyroFrame: public wxFrame
{ {
public: public:
TyroFrame(wxFrame *frame, const wxString& title); TyroFrame(wxFrame *frame, const wxString& title);
~TyroFrame(); ~TyroFrame();
private: private:
enum enum
{ {
idMenuQuit = 1000, idMenuQuit = 1000,
idMenuAbout idMenuAbout
}; };
wxAuiManager m_mgr; void OnMenuFileOpen(wxCommandEvent &event);
void OnClose(wxCloseEvent& event); void OnMenuFileSave(wxCommandEvent &event);
void OnQuit(wxCommandEvent& event); void OnClose(wxCloseEvent &event);
void OnAbout(wxCommandEvent& event); void OnQuit(wxCommandEvent &event);
wxAuiNotebook* CreateNotebook(); void OnAbout(wxCommandEvent &event);
DECLARE_EVENT_TABLE() wxAuiNotebook* CreateNotebook();
DECLARE_EVENT_TABLE()
}; };