Rename the main frame class

This commit is contained in:
Tim Warren 2015-04-02 11:01:21 -04:00
parent ce6a93929b
commit 090055ffc8
6 changed files with 41 additions and 42 deletions

View File

@ -7,7 +7,3 @@ DocFrame::DocFrame(wxWindow *parent, wxWindowID id)
{ {
editor = new wxStyledTextCtrl(parent); editor = new wxStyledTextCtrl(parent);
} }
DocFrame::~DocFrame()
{
}

View File

@ -1,6 +1,7 @@
#ifndef TYRODOC_FRAME_H #ifndef TYRODOC_FRAME_H
#define TYRODOC_FRAME_H #define TYRODOC_FRAME_H
#include "wx/wxprec.h"
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include <wx/wx.h> #include <wx/wx.h>
#endif #endif
@ -11,10 +12,9 @@ class DocFrame: public wxWindow
{ {
public: public:
DocFrame(wxWindow *parent, wxWindowID id); DocFrame(wxWindow *parent, wxWindowID id);
~DocFrame();
private: private:
wxStyledTextCtrl *editor; wxStyledTextCtrl *editor;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
#endif // TYRODOC_FRAM_H #endif // TYRODOC_FRAME_H

View File

@ -14,15 +14,15 @@
#include "Main.h" #include "Main.h"
BEGIN_EVENT_TABLE(TyroFrame, wxFrame) BEGIN_EVENT_TABLE(MainFrame, wxFrame)
EVT_CLOSE(TyroFrame::OnClose) EVT_CLOSE(MainFrame::OnClose)
EVT_MENU(wxID_OPEN, TyroFrame::OnMenuFileOpen) EVT_MENU(wxID_OPEN, MainFrame::OnMenuFileOpen)
EVT_MENU(wxID_SAVE, TyroFrame::OnMenuFileSave) EVT_MENU(wxID_SAVE, MainFrame::OnMenuFileSave)
EVT_MENU(wxID_EXIT, TyroFrame::OnQuit) EVT_MENU(wxID_EXIT, MainFrame::OnQuit)
EVT_MENU(wxID_ABOUT, TyroFrame::OnAbout) EVT_MENU(wxID_ABOUT, MainFrame::OnAbout)
END_EVENT_TABLE() END_EVENT_TABLE()
TyroFrame::TyroFrame(wxFrame *frame, const wxString& title) MainFrame::MainFrame(wxFrame *frame, const wxString& title)
: wxFrame(frame, -1, title) : wxFrame(frame, -1, title)
{ {
this->SetupMenu(); this->SetupMenu();
@ -33,12 +33,7 @@ TyroFrame::TyroFrame(wxFrame *frame, const wxString& title)
// 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(), 1, wxEXPAND | wxALL, 5);
CreateNotebook(),
1,
wxEXPAND | wxALL,
5
);
base_sizer->SetContainingWindow(this); base_sizer->SetContainingWindow(this);
base_sizer->SetMinSize(800,600); base_sizer->SetMinSize(800,600);
@ -47,20 +42,21 @@ TyroFrame::TyroFrame(wxFrame *frame, const wxString& title)
} }
TyroFrame::~TyroFrame() {} MainFrame::~MainFrame() {}
void TyroFrame::SetupStatusBar() void MainFrame::SetupStatusBar()
{ {
CreateStatusBar(2); CreateStatusBar(2);
SetStatusText(_(""), 0); SetStatusText(_(""), 0);
SetStatusText(_(""), 1); SetStatusText(_(""), 1);
} }
void TyroFrame::SetupToolbar() void MainFrame::SetupToolbar()
{ {
} }
void TyroFrame::SetupMenu() void MainFrame::SetupMenu()
{ {
// create a menu bar // create a menu bar
wxMenuBar* mbar = new wxMenuBar(); wxMenuBar* mbar = new wxMenuBar();
@ -99,24 +95,24 @@ void TyroFrame::SetupMenu()
SetMenuBar(mbar); SetMenuBar(mbar);
} }
wxAuiNotebook *TyroFrame::CreateNotebook() wxAuiNotebook *MainFrame::CreateNotebook()
{ {
wxAuiNotebook *ctrl = new wxAuiNotebook(this); wxAuiNotebook *ctrl = new wxAuiNotebook(this);
DocFrame *editor = new DocFrame(ctrl, wxID_ANY); //DocFrame *editor = new DocFrame(ctrl, wxID_ANY);
//wxWindow *editor = new wxWindow(ctrl, wxID_ANY); wxWindow *editor = new wxWindow(ctrl, wxID_ANY);
//ctrl->AddPage(editor, "Untitled"); ctrl->AddPage(editor, "Untitled");
return ctrl; return ctrl;
} }
void TyroFrame::OnClose(wxCloseEvent &WXUNUSED(event)) void MainFrame::OnClose(wxCloseEvent &WXUNUSED(event))
{ {
Destroy(); Destroy();
} }
void TyroFrame::OnMenuFileOpen(wxCommandEvent &WXUNUSED(event)) void MainFrame::OnMenuFileOpen(wxCommandEvent &WXUNUSED(event))
{ {
wxFileDialog *OpenDialog = new wxFileDialog(this, _T("Choose a file"), _(""), _(""), _("*.*"), wxFD_OPEN); wxFileDialog *OpenDialog = new wxFileDialog(this, _T("Choose a file"), _(""), _(""), _("*.*"), wxFD_OPEN);
@ -127,16 +123,16 @@ void TyroFrame::OnMenuFileOpen(wxCommandEvent &WXUNUSED(event))
OpenDialog->Close(); OpenDialog->Close();
} }
void TyroFrame::OnMenuFileSave(wxCommandEvent &WXUNUSED(event)) void MainFrame::OnMenuFileSave(wxCommandEvent &WXUNUSED(event))
{ {
} }
void TyroFrame::OnQuit(wxCommandEvent &WXUNUSED(event)) void MainFrame::OnQuit(wxCommandEvent &WXUNUSED(event))
{ {
Destroy(); Destroy();
} }
void TyroFrame::OnAbout(wxCommandEvent &WXUNUSED(event)) void MainFrame::OnAbout(wxCommandEvent &WXUNUSED(event))
{ {
wxMessageBox(_T("Tyro, a text editor for all development\n Copyright 2015, Timothy J. Warren"), wxT("About Tyro"), wxOK| wxICON_INFORMATION, this); wxMessageBox(_T("Tyro, a text editor for all development\n Copyright 2015, Timothy J. Warren"), wxT("About Tyro"), wxOK| wxICON_INFORMATION, this);
} }

View File

@ -10,18 +10,21 @@
#ifndef TYROMAIN_H #ifndef TYROMAIN_H
#define TYROMAIN_H #define TYROMAIN_H
#ifdef WX_PRECOMP
#include "wx_pch.h"
#endif
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include <wx/wx.h> #include <wx/wx.h>
#endif #endif
#include "TyroApp.h" #include "TyroApp.h"
#include "DocFrame.h" #include "DocFrame.h"
class TyroFrame: public wxFrame class MainFrame: public wxFrame
{ {
public: public:
TyroFrame(wxFrame *frame, const wxString& title); MainFrame(wxFrame *frame, const wxString& title);
~TyroFrame(); ~MainFrame();
private: private:
enum enum
{ {
@ -29,8 +32,8 @@ class TyroFrame: public wxFrame
idMenuAbout idMenuAbout
}; };
void SetupMenu(); void SetupMenu();
void SetupToolbar(); void SetupToolbar();
void SetupStatusBar(); void SetupStatusBar();
void OnMenuFileOpen(wxCommandEvent &event); void OnMenuFileOpen(wxCommandEvent &event);
void OnMenuFileSave(wxCommandEvent &event); void OnMenuFileSave(wxCommandEvent &event);
void OnClose(wxCloseEvent &event); void OnClose(wxCloseEvent &event);

View File

@ -18,7 +18,7 @@ IMPLEMENT_APP(TyroApp);
bool TyroApp::OnInit() bool TyroApp::OnInit()
{ {
TyroFrame* frame = new TyroFrame(0L, _("Tyro")); MainFrame* frame = new MainFrame(0L, _("Tyro"));
frame->CenterOnScreen(); frame->CenterOnScreen();
frame->Show(true); frame->Show(true);

View File

@ -10,13 +10,17 @@
#ifndef TYROAPP_H #ifndef TYROAPP_H
#define TYROAPP_H #define TYROAPP_H
#include "wx/wxprec.h"
#include <wx/app.h> #include <wx/app.h>
#include <wx/toolbar.h>
#include <wx/menu.h>
#include <wx/debug.h> #include <wx/debug.h>
#include <wx/aui/aui.h> #include <wx/aui/aui.h>
class TyroApp : public wxApp class TyroApp : public wxApp
{ {
friend class TyroFrame; friend class MainFrame;
public: public:
virtual bool OnInit(); virtual bool OnInit();
virtual int OnExit(wxCommandEvent &WXUNUSED(event)); virtual int OnExit(wxCommandEvent &WXUNUSED(event));