Fix some AUI brokenness, add more docblocks
This commit is contained in:
parent
c5b2974c5a
commit
f7f45ade77
@ -3,10 +3,13 @@
|
|||||||
*/
|
*/
|
||||||
#include "widget.h"
|
#include "widget.h"
|
||||||
|
|
||||||
|
// Nasty globals
|
||||||
extern TyroMenu *mbar;
|
extern TyroMenu *mbar;
|
||||||
static wxAuiManager *manager;
|
|
||||||
static TabContainer *notebook;
|
static TabContainer *notebook;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
MainFrame::MainFrame(wxFrame *frame, const wxString &title)
|
MainFrame::MainFrame(wxFrame *frame, const wxString &title)
|
||||||
: wxFrame(frame, -1, title)
|
: wxFrame(frame, -1, title)
|
||||||
{
|
{
|
||||||
@ -17,7 +20,7 @@ MainFrame::MainFrame(wxFrame *frame, const wxString &title)
|
|||||||
wxIcon app_icon(tyro_icon);
|
wxIcon app_icon(tyro_icon);
|
||||||
this->SetIcon(app_icon);
|
this->SetIcon(app_icon);
|
||||||
|
|
||||||
// Create menus and bars
|
// Apply the menu bar to the current frame
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
wxMenuBar::MacSetCommonMenuBar(mbar);
|
wxMenuBar::MacSetCommonMenuBar(mbar);
|
||||||
#endif // __WXMAC__
|
#endif // __WXMAC__
|
||||||
@ -28,33 +31,49 @@ MainFrame::MainFrame(wxFrame *frame, const wxString &title)
|
|||||||
// Create the tab container
|
// Create the tab container
|
||||||
notebook = new TabContainer(this);
|
notebook = new TabContainer(this);
|
||||||
|
|
||||||
// Setup control layout
|
this->DoLayout();
|
||||||
wxAuiManager *manager = new wxAuiManager(this);
|
|
||||||
this->SetupToolbar();
|
|
||||||
|
|
||||||
wxAuiPaneInfo toolBarPaneInfo;
|
|
||||||
toolBarPaneInfo.ToolbarPane().Top();
|
|
||||||
manager->AddPane(toolBar, toolBarPaneInfo);
|
|
||||||
|
|
||||||
wxAuiPaneInfo notebookPaneInfo;
|
|
||||||
notebookPaneInfo.CenterPane();
|
|
||||||
manager->AddPane(notebook, notebookPaneInfo);
|
|
||||||
|
|
||||||
this->EnableEditControls(false);
|
|
||||||
this->BindEvents();
|
this->BindEvents();
|
||||||
|
|
||||||
// Do the layout
|
|
||||||
manager->Update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Time to clean up!
|
||||||
|
*/
|
||||||
MainFrame::~MainFrame()
|
MainFrame::~MainFrame()
|
||||||
{
|
{
|
||||||
wxLogDebug("Main Frame Destructor Called.");
|
wxLogDebug("Main Frame Destructor Called.");
|
||||||
//delete toolBar;
|
delete notebook;
|
||||||
//delete notebook;
|
delete toolBar;
|
||||||
//delete manager;
|
manager->UnInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Layout the widgets on the main frame
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
void MainFrame::DoLayout()
|
||||||
|
{
|
||||||
|
this->manager = new wxAuiManager(this);
|
||||||
|
this->SetupToolbar();
|
||||||
|
|
||||||
|
// Setup properties for each AUI pane
|
||||||
|
wxAuiPaneInfo toolBarPaneInfo;
|
||||||
|
toolBarPaneInfo.ToolbarPane().Top();
|
||||||
|
this->manager->AddPane(toolBar, toolBarPaneInfo);
|
||||||
|
|
||||||
|
wxAuiPaneInfo notebookPaneInfo;
|
||||||
|
notebookPaneInfo.CenterPane();
|
||||||
|
this->manager->AddPane(notebook, notebookPaneInfo);
|
||||||
|
|
||||||
|
// Update everything
|
||||||
|
this->EnableEditControls(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the status bar
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
void MainFrame::SetupStatusBar()
|
void MainFrame::SetupStatusBar()
|
||||||
{
|
{
|
||||||
CreateStatusBar(2);
|
CreateStatusBar(2);
|
||||||
@ -174,6 +193,9 @@ void MainFrame::OnNew(wxCommandEvent &WXUNUSED(event))
|
|||||||
{
|
{
|
||||||
this->EnableEditControls();
|
this->EnableEditControls();
|
||||||
notebook->AddTab();
|
notebook->AddTab();
|
||||||
|
|
||||||
|
// Make sure the layout is updated immediately
|
||||||
|
this->manager->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -218,6 +240,8 @@ void MainFrame::OnCloseTab(wxCommandEvent &WXUNUSED(event))
|
|||||||
{
|
{
|
||||||
this->EnableEditControls(false);
|
this->EnableEditControls(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->manager->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -291,23 +315,46 @@ void MainFrame::OnSaveAs(wxCommandEvent &WXUNUSED(event))
|
|||||||
// Update the editor highlighting
|
// Update the editor highlighting
|
||||||
editor->Highlight(filePath);
|
editor->Highlight(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the main view
|
||||||
|
this->manager->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close Tyro
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
void MainFrame::OnQuit(wxCommandEvent &WXUNUSED(event))
|
void MainFrame::OnQuit(wxCommandEvent &WXUNUSED(event))
|
||||||
{
|
{
|
||||||
Destroy();
|
Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cut to the clipboard
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
void MainFrame::OnEditCut(wxCommandEvent &WXUNUSED(event))
|
void MainFrame::OnEditCut(wxCommandEvent &WXUNUSED(event))
|
||||||
{
|
{
|
||||||
notebook->GetCurrentEditor()->Cut();
|
notebook->GetCurrentEditor()->Cut();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy to the clipboard
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
void MainFrame::OnEditCopy(wxCommandEvent &WXUNUSED(event))
|
void MainFrame::OnEditCopy(wxCommandEvent &WXUNUSED(event))
|
||||||
{
|
{
|
||||||
notebook->GetCurrentEditor()->Copy();
|
notebook->GetCurrentEditor()->Copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Paste from the clipboard
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
void MainFrame::OnEditPaste(wxCommandEvent &WXUNUSED(event))
|
void MainFrame::OnEditPaste(wxCommandEvent &WXUNUSED(event))
|
||||||
{
|
{
|
||||||
if (notebook->GetCurrentEditor()->CanPaste())
|
if (notebook->GetCurrentEditor()->CanPaste())
|
||||||
@ -316,11 +363,21 @@ void MainFrame::OnEditPaste(wxCommandEvent &WXUNUSED(event))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Select all the text in the current document
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
void MainFrame::OnEditSelectAll(wxCommandEvent &WXUNUSED(event))
|
void MainFrame::OnEditSelectAll(wxCommandEvent &WXUNUSED(event))
|
||||||
{
|
{
|
||||||
notebook->GetCurrentEditor()->SelectAll();
|
notebook->GetCurrentEditor()->SelectAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undo recent change(s)
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
void MainFrame::OnEditUndo(wxCommandEvent &WXUNUSED(event))
|
void MainFrame::OnEditUndo(wxCommandEvent &WXUNUSED(event))
|
||||||
{
|
{
|
||||||
if (notebook->GetCurrentEditor()->CanUndo())
|
if (notebook->GetCurrentEditor()->CanUndo())
|
||||||
@ -329,6 +386,11 @@ void MainFrame::OnEditUndo(wxCommandEvent &WXUNUSED(event))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redo recent change(s)
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
void MainFrame::OnEditRedo(wxCommandEvent &WXUNUSED(event))
|
void MainFrame::OnEditRedo(wxCommandEvent &WXUNUSED(event))
|
||||||
{
|
{
|
||||||
if (notebook->GetCurrentEditor()->CanRedo())
|
if (notebook->GetCurrentEditor()->CanRedo())
|
||||||
@ -337,6 +399,11 @@ void MainFrame::OnEditRedo(wxCommandEvent &WXUNUSED(event))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create and show about dialog
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
void MainFrame::OnAbout(wxCommandEvent &WXUNUSED(event))
|
void MainFrame::OnAbout(wxCommandEvent &WXUNUSED(event))
|
||||||
{
|
{
|
||||||
wxAboutDialogInfo info;
|
wxAboutDialogInfo info;
|
||||||
@ -344,8 +411,8 @@ void MainFrame::OnAbout(wxCommandEvent &WXUNUSED(event))
|
|||||||
info.SetName(APP_NAME);
|
info.SetName(APP_NAME);
|
||||||
info.SetVersion(APP_VERSION, APP_VERSION_MORE);
|
info.SetVersion(APP_VERSION, APP_VERSION_MORE);
|
||||||
|
|
||||||
info.AddDeveloper("Tim Warren, Programmer");
|
info.AddDeveloper("Tim Warren");
|
||||||
info.AddArtist("Brian Smith, Icon");
|
info.AddArtist("Brian Smith");
|
||||||
|
|
||||||
info.SetDescription("Tyro, a text editor for all development");
|
info.SetDescription("Tyro, a text editor for all development");
|
||||||
info.SetCopyright(" (C) 2015");
|
info.SetCopyright(" (C) 2015");
|
||||||
@ -522,10 +589,16 @@ void MainFrame::OnToggleLineEndings(wxCommandEvent &event)
|
|||||||
*/
|
*/
|
||||||
void MainFrame::EnableEditControls(bool enable)
|
void MainFrame::EnableEditControls(bool enable)
|
||||||
{
|
{
|
||||||
|
// Update menu items
|
||||||
mbar->EnableEditControls(enable);
|
mbar->EnableEditControls(enable);
|
||||||
|
|
||||||
|
// Toggle toolbar items
|
||||||
this->toolBar->EnableTool(wxID_SAVE, enable);
|
this->toolBar->EnableTool(wxID_SAVE, enable);
|
||||||
this->toolBar->EnableTool(wxID_CLOSE, enable);
|
this->toolBar->EnableTool(wxID_CLOSE, enable);
|
||||||
this->toolBar->EnableTool(wxID_COPY, enable);
|
this->toolBar->EnableTool(wxID_COPY, enable);
|
||||||
this->toolBar->EnableTool(wxID_CUT, enable);
|
this->toolBar->EnableTool(wxID_CUT, enable);
|
||||||
this->toolBar->EnableTool(wxID_PASTE, enable);
|
this->toolBar->EnableTool(wxID_PASTE, enable);
|
||||||
|
|
||||||
|
// Make sure the toolbar is refreshed instantly
|
||||||
|
this->manager->Update();
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ class MainFrame: public wxFrame
|
|||||||
~MainFrame();
|
~MainFrame();
|
||||||
void EnableEditControls(bool enable=true);
|
void EnableEditControls(bool enable=true);
|
||||||
private:
|
private:
|
||||||
|
wxAuiManager *manager;
|
||||||
wxAuiToolBar *toolBar;
|
wxAuiToolBar *toolBar;
|
||||||
wxFindReplaceData *findReplaceData;
|
wxFindReplaceData *findReplaceData;
|
||||||
wxFindReplaceDialog *findDlg;
|
wxFindReplaceDialog *findDlg;
|
||||||
@ -21,6 +22,7 @@ class MainFrame: public wxFrame
|
|||||||
void SetupToolbar();
|
void SetupToolbar();
|
||||||
void SetupStatusBar();
|
void SetupStatusBar();
|
||||||
void BindEvents();
|
void BindEvents();
|
||||||
|
void DoLayout();
|
||||||
|
|
||||||
// Main Menu Event handlers
|
// Main Menu Event handlers
|
||||||
void OnNew(wxCommandEvent &event);
|
void OnNew(wxCommandEvent &event);
|
||||||
|
Loading…
Reference in New Issue
Block a user