Fix windows build, use a closure for some event handlers

This commit is contained in:
Tim Warren 2015-06-01 14:10:02 -04:00
parent c70ac21da4
commit 0e64bdc1ba
4 changed files with 57 additions and 106 deletions

View File

@ -8,6 +8,7 @@ before_install:
# Upgrade gcc # Upgrade gcc
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- sudo apt-get -qq update - sudo apt-get -qq update
- sudo apt-get install -qq gcc-4.8
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 98 - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 98
# Install dependencies # Install dependencies

View File

@ -45,7 +45,7 @@ endif
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
CXXFLAGS += -static CXXFLAGS += -static
CXX += -std=gnu++11 -Wno-unknown-pragmas -Wno-missing-field-initializers -DWIN32 CXX += -std=gnu++11 -Wno-unknown-pragmas -Wno-missing-field-initializers -I/include -DWIN32
LDLIBS += -L/lib -lwsock32 LDLIBS += -L/lib -lwsock32
endif endif

View File

@ -15,10 +15,8 @@ static TabContainer *notebook;
* Constructor * Constructor
*/ */
MainFrame::MainFrame(wxFrame *frame, const wxString &title) MainFrame::MainFrame(wxFrame *frame, const wxString &title)
: wxFrame(frame, -1, title) : wxFrame(frame, -1, title, wxDefaultPosition, wxSize(800,600))
{ {
this->findReplaceData = new wxFindReplaceData(wxFR_DOWN);
// Create the tab container // Create the tab container
notebook = new TabContainer(this); notebook = new TabContainer(this);
@ -148,15 +146,52 @@ void MainFrame::BindEvents()
Bind(wxEVT_MENU, &MainFrame::OnQuit, this, wxID_EXIT); Bind(wxEVT_MENU, &MainFrame::OnQuit, this, wxID_EXIT);
// Edit Menu Events // Edit Menu Events
Bind(wxEVT_MENU, &MainFrame::OnEditCut, this, wxID_CUT); this->Bind(wxEVT_MENU, [=](wxCommandEvent& event) {
Bind(wxEVT_MENU, &MainFrame::OnEditCopy, this, wxID_COPY); EditPane *editor = notebook->GetCurrentEditor();
Bind(wxEVT_MENU, &MainFrame::OnEditPaste, this, wxID_PASTE);
Bind(wxEVT_MENU, &MainFrame::OnEditSelectAll, this, wxID_SELECTALL); switch(event.GetId())
Bind(wxEVT_MENU, &MainFrame::OnEditUndo, this, wxID_UNDO); {
Bind(wxEVT_MENU, &MainFrame::OnEditRedo, this, wxID_REDO); case wxID_CUT:
Bind(wxEVT_MENU, &MainFrame::OnEditFind, this, wxID_FIND); editor->Cut();
Bind(wxEVT_MENU, &MainFrame::OnEditReplace, this, wxID_REPLACE); break;
Bind(wxEVT_MENU, &MainFrame::OnEditPreferences, this, wxID_PREFERENCES);
case wxID_COPY:
editor->Copy();
break;
case wxID_PASTE:
if (editor->CanPaste()) editor->Paste();
break;
case wxID_SELECTALL:
editor->SelectAll();
break;
case wxID_UNDO:
if (editor->CanUndo()) editor->Undo();
break;
case wxID_REDO:
if (editor->CanRedo()) editor->Redo();
break;
case wxID_PREFERENCES:
Glob_pref_pane->Show(this);
break;
case wxID_FIND:
this->OnEditFind(event);
break;
case wxID_REPLACE:
this->OnEditReplace(event);
break;
default:
event.Skip(true);
break;
}
});
// View Menu Events // View Menu Events
Bind(wxEVT_MENU, &MainFrame::OnToggleWhitespace, this, myID_VIEW_WHITESPACE); Bind(wxEVT_MENU, &MainFrame::OnToggleWhitespace, this, myID_VIEW_WHITESPACE);
@ -339,76 +374,7 @@ void MainFrame::OnSaveAs(wxCommandEvent &WXUNUSED(event))
*/ */
void MainFrame::OnQuit(wxCommandEvent &WXUNUSED(event)) void MainFrame::OnQuit(wxCommandEvent &WXUNUSED(event))
{ {
Destroy(); this->Destroy();
}
/**
* Cut to the clipboard
*
* @return void
*/
void MainFrame::OnEditCut(wxCommandEvent &WXUNUSED(event))
{
notebook->GetCurrentEditor()->Cut();
}
/**
* Copy to the clipboard
*
* @return void
*/
void MainFrame::OnEditCopy(wxCommandEvent &WXUNUSED(event))
{
notebook->GetCurrentEditor()->Copy();
}
/**
* Paste from the clipboard
*
* @return void
*/
void MainFrame::OnEditPaste(wxCommandEvent &WXUNUSED(event))
{
if (notebook->GetCurrentEditor()->CanPaste())
{
notebook->GetCurrentEditor()->Paste();
}
}
/**
* Select all the text in the current document
*
* @return void
*/
void MainFrame::OnEditSelectAll(wxCommandEvent &WXUNUSED(event))
{
notebook->GetCurrentEditor()->SelectAll();
}
/**
* Undo recent change(s)
*
* @return void
*/
void MainFrame::OnEditUndo(wxCommandEvent &WXUNUSED(event))
{
if (notebook->GetCurrentEditor()->CanUndo())
{
notebook->GetCurrentEditor()->Undo();
}
}
/**
* Redo recent change(s)
*
* @return void
*/
void MainFrame::OnEditRedo(wxCommandEvent &WXUNUSED(event))
{
if (notebook->GetCurrentEditor()->CanRedo())
{
notebook->GetCurrentEditor()->Redo();
}
} }
/** /**
@ -462,9 +428,9 @@ void MainFrame::OnEditFind(wxCommandEvent &WXUNUSED(event))
} }
else else
{ {
this->findReplaceData = new wxFindReplaceData(wxFR_DOWN); this->findData = new wxFindReplaceData(wxFR_DOWN);
findDlg = new wxFindReplaceDialog(this, this->findReplaceData, "Find"); this->findDlg = new wxFindReplaceDialog(this, this->findData, "Find");
findDlg->Show(true); this->findDlg->Show(true);
} }
} }
@ -482,10 +448,10 @@ void MainFrame::OnEditReplace(wxCommandEvent &WXUNUSED(event))
else else
{ {
this->findReplaceData = new wxFindReplaceData(wxFR_DOWN); this->findReplaceData = new wxFindReplaceData(wxFR_DOWN);
replaceDlg = new wxFindReplaceDialog(this, this->findReplaceData, this->replaceDlg = new wxFindReplaceDialog(this, this->findReplaceData,
"Find and Replace", wxFR_REPLACEDIALOG); "Find and Replace", wxFR_REPLACEDIALOG);
replaceDlg->Show(true); this->replaceDlg->Show(true);
} }
} }
@ -634,16 +600,6 @@ void MainFrame::OnLangSelect(wxCommandEvent &event)
} }
} }
/**
* Show the preferences dialog
*
* @return void
*/
void MainFrame::OnEditPreferences(wxCommandEvent &WXUNUSED(event))
{
Glob_pref_pane->Show(this);
}
/** /**
* Applies settings when prefs are changed * Applies settings when prefs are changed
* *

View File

@ -19,6 +19,7 @@ class MainFrame: public wxFrame
wxAuiManager *manager; wxAuiManager *manager;
wxAuiToolBar *toolBar; wxAuiToolBar *toolBar;
wxFindReplaceData *findReplaceData; wxFindReplaceData *findReplaceData;
wxFindReplaceData *findData;
wxFindReplaceDialog *findDlg; wxFindReplaceDialog *findDlg;
wxFindReplaceDialog *replaceDlg; wxFindReplaceDialog *replaceDlg;
void SetupToolbar(); void SetupToolbar();
@ -34,17 +35,10 @@ class MainFrame: public wxFrame
void OnSave(wxCommandEvent &event); void OnSave(wxCommandEvent &event);
void OnSaveAs(wxCommandEvent &event); void OnSaveAs(wxCommandEvent &event);
void OnEditCut(wxCommandEvent &event);
void OnEditCopy(wxCommandEvent &event);
void OnEditPaste(wxCommandEvent &event);
void OnEditSelectAll(wxCommandEvent &event);
void OnEditUndo(wxCommandEvent &event);
void OnEditRedo(wxCommandEvent &event);
void OnEditPreferences(wxCommandEvent &event);
void OnEditFind(wxCommandEvent &event); void OnEditFind(wxCommandEvent &event);
void OnEditReplace(wxCommandEvent &event); void OnEditReplace(wxCommandEvent &event);
void OnFindDialog(wxFindDialogEvent &event); void OnFindDialog(wxFindDialogEvent &event);
void OnToggleWhitespace(wxCommandEvent &event); void OnToggleWhitespace(wxCommandEvent &event);
void OnToggleLineWrap(wxCommandEvent &event); void OnToggleLineWrap(wxCommandEvent &event);
void OnToggleLineEndings(wxCommandEvent &event); void OnToggleLineEndings(wxCommandEvent &event);