diff --git a/Makefile b/Makefile index e4e8fa1..1192ee1 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ PROGRAM_SRC = $(wildcard src/*.cpp src/widgets/*.cpp) PROGRAM = build/Tyro PROGRAM_OBJECTS = $(patsubst %.cpp,%.o, $(PROGRAM_SRC)) -LDLIBS = -ldl $(TARGET) $(shell wx-config --libs all) -lssh2 +LDLIBS = -ldl $(TARGET) $(shell wx-config --libs base core aui stc) -lssh2 WX_CXXFLAGS = $(shell wx-config --cxxflags) DEV_CXXFLAGS = -g -Wall -Wextra CXXFLAGS = -Os -I./src -I./include diff --git a/src/TyroApp.cpp b/src/TyroApp.cpp index 74c6608..b6cf528 100644 --- a/src/TyroApp.cpp +++ b/src/TyroApp.cpp @@ -17,6 +17,7 @@ bool TyroApp::OnInit() { MainFrame* frame = new MainFrame(0L, _("Tyro")); + frame->Layout(); frame->CenterOnScreen(); frame->Show(true); SetTopWindow(frame); diff --git a/src/widgets/EditPane.cpp b/src/widgets/EditPane.cpp index 4ababea..813cd8b 100644 --- a/src/widgets/EditPane.cpp +++ b/src/widgets/EditPane.cpp @@ -1,21 +1,5 @@ #include "EditPane.h" -BEGIN_EVENT_TABLE(EditPane, wxStyledTextCtrl) - // common - /*EVT_SIZE (Edit::OnSize) - // edit - EVT_MENU (wxID_CLEAR, Edit::OnEditClear) - EVT_MENU (wxID_CUT, Edit::OnEditCut) - EVT_MENU (wxID_COPY, Edit::OnEditCopy) - EVT_MENU (wxID_PASTE, Edit::OnEditPaste) - EVT_MENU (myID_INDENTINC, Edit::OnEditIndentInc) - EVT_MENU (myID_INDENTRED, Edit::OnEditIndentRed) - EVT_MENU (wxID_SELECTALL, Edit::OnEditSelectAll) - EVT_MENU (myID_SELECTLINE, Edit::OnEditSelectLine) - EVT_MENU (wxID_REDO, Edit::OnEditRedo) - EVT_MENU (wxID_UNDO, Edit::OnEditUndo)*/ -END_EVENT_TABLE() - EditPane::EditPane( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style @@ -25,18 +9,3 @@ EditPane::EditPane( } EditPane::~EditPane() {} - -void EditPane::OnMenuFileOpen(wxCommandEvent &WXUNUSED(event)) -{ - wxFileDialog *OpenDialog = new wxFileDialog(this, _T("Choose a file"), _(""), _(""), _("*.*"), wxFD_OPEN); - - if (OpenDialog->ShowModal() == wxID_OK) - { - // Load the file into a new notebook tab and styled text control - } - OpenDialog->Close(); -} - -void EditPane::OnMenuFileSave(wxCommandEvent &WXUNUSED(event)) -{ -} \ No newline at end of file diff --git a/src/widgets/EditPane.h b/src/widgets/EditPane.h index 36d5e4b..e208421 100644 --- a/src/widgets/EditPane.h +++ b/src/widgets/EditPane.h @@ -19,10 +19,7 @@ public: wxVSCROLL ); ~EditPane(); - void OnMenuFileOpen(wxCommandEvent &event); - void OnMenuFileSave(wxCommandEvent &event); private: - DECLARE_EVENT_TABLE() }; #endif // TYRODOC_FRAME_H diff --git a/src/widgets/MainFrame.cpp b/src/widgets/MainFrame.cpp index 812e247..f9c8b53 100644 --- a/src/widgets/MainFrame.cpp +++ b/src/widgets/MainFrame.cpp @@ -8,38 +8,29 @@ #include "MainFrame.h" - -BEGIN_EVENT_TABLE(MainFrame, wxFrame) - EVT_CLOSE(MainFrame::OnClose) - EVT_MENU(wxID_NEW, MainFrame::OnMenuFileNew) - EVT_MENU(wxID_OPEN, EditPane::OnMenuFileOpen) - EVT_MENU(wxID_SAVE, EditPane::OnMenuFileSave) - EVT_MENU(wxID_ABOUT, MainFrame::OnAbout) - EVT_MENU(wxID_EXIT, MainFrame::OnQuit) -END_EVENT_TABLE() - MainFrame::MainFrame(wxFrame *frame, const wxString& title) : wxFrame(frame, -1, title) { + // Create menus and bars this->SetupMenu(); - - // create a status bar with some information about the used wxWidgets version this->SetupStatusBar(); - - // create the main toolbar this->SetupToolbar(); + + // Create the tab container + notebook = new TabContainer(this); // Set up control layout wxBoxSizer *base_sizer = new wxBoxSizer(wxVERTICAL); - notebook = this->CreateTabContainer(); - base_sizer->Add(notebook, 1, wxEXPAND | wxALL, 5); base_sizer->SetContainingWindow(this); base_sizer->SetMinSize(800,600); SetSizerAndFit(base_sizer); + + // Finally, bind events + this->BindEvents(); } @@ -85,8 +76,8 @@ void MainFrame::SetupToolbar() toolBar->AddTool(wxID_OPEN, "Open", bitmaps[1], "Open file"); toolBar->AddTool(wxID_SAVE, "Save", bitmaps[2], "Save file"); toolBar->AddTool(wxID_CLOSE, "Close", bitmaps[3], "Close file"); - toolBar->AddSeparator(); - toolBar->AddTool(wxID_ANY, "Settings", bitmaps[4], "Change Settings"); + //toolBar->AddSeparator(); + //toolBar->AddTool(wxID_ANY, "Settings", bitmaps[4], "Change Settings"); toolBar->Realize(); } @@ -132,11 +123,12 @@ void MainFrame::SetupMenu() SetMenuBar(mbar); } -TabContainer *MainFrame::CreateTabContainer() +void MainFrame::BindEvents() { - TabContainer *notebook = new TabContainer(this); - - return notebook; + Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnNew, this, wxID_NEW); + Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnAbout, this, wxID_ABOUT); + Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnQuit, this, wxID_EXIT); + Bind(wxEVT_COMMAND_MENU_SELECTED, &TabContainer::OnEditSelectAll, notebook, wxID_SELECTALL); } void MainFrame::OnClose(wxCloseEvent &WXUNUSED(event)) @@ -144,7 +136,7 @@ void MainFrame::OnClose(wxCloseEvent &WXUNUSED(event)) Destroy(); } -void MainFrame::OnMenuFileNew(wxCommandEvent &WXUNUSED(event)) +void MainFrame::OnNew(wxCommandEvent &WXUNUSED(event)) { notebook->AddTab(); } diff --git a/src/widgets/MainFrame.h b/src/widgets/MainFrame.h index afbe674..df5ef60 100644 --- a/src/widgets/MainFrame.h +++ b/src/widgets/MainFrame.h @@ -11,6 +11,7 @@ class MainFrame: public wxFrame { + friend class TabContainer; public: MainFrame(wxFrame *frame, const wxString &title); ~MainFrame(); @@ -24,12 +25,11 @@ class MainFrame: public wxFrame void SetupMenu(); void SetupToolbar(); void SetupStatusBar(); - void OnMenuFileNew(wxCommandEvent &event); + void BindEvents(); + void OnNew(wxCommandEvent &event); void OnClose(wxCloseEvent &event); void OnQuit(wxCommandEvent &event); void OnAbout(wxCommandEvent &event); - TabContainer* CreateTabContainer(); - DECLARE_EVENT_TABLE() }; diff --git a/src/widgets/TabContainer.cpp b/src/widgets/TabContainer.cpp index 6be2f52..2a523d9 100644 --- a/src/widgets/TabContainer.cpp +++ b/src/widgets/TabContainer.cpp @@ -4,9 +4,6 @@ #include "TabContainer.h" -BEGIN_EVENT_TABLE(TabContainer, wxAuiNotebook) -END_EVENT_TABLE() - static unsigned long untitled_document_count = 0; TabContainer::TabContainer( @@ -22,11 +19,6 @@ TabContainer::TabContainer( TabContainer::~TabContainer() {} -EditPane *TabContainer::CreateEditor() -{ - return new EditPane(this, wxID_ANY); -} - void TabContainer::AddTab() { untitled_document_count++; @@ -34,10 +26,22 @@ void TabContainer::AddTab() caption.Printf("Untitled %lu", untitled_document_count); - this->AddPage(CreateEditor(), caption); + EditPane *editor = new EditPane(this, wxID_ANY); + + this->AddPage(editor, caption); } void TabContainer::AddTab(wxString filePath) { + wxString caption=""; + EditPane *editor = new EditPane(this, wxID_ANY); -} \ No newline at end of file + this->AddPage(editor, caption); +} + +void TabContainer::OnEditSelectAll(wxCommandEvent &WXUNUSED(event)) +{ + cout << "Edit select all event called."; + //EditPane *editor = (EditPane *) this->GetCurrentPage(); + //editor->SelectAll(); +} diff --git a/src/widgets/TabContainer.h b/src/widgets/TabContainer.h index 02f388e..b1d1c7e 100644 --- a/src/widgets/TabContainer.h +++ b/src/widgets/TabContainer.h @@ -27,9 +27,9 @@ public: ~TabContainer(); void AddTab(); void AddTab(wxString filePath); + void OnEditSelectAll(wxCommandEvent &event); + private: - EditPane *CreateEditor(); - DECLARE_EVENT_TABLE() }; #endif /* TABCONTAINER_H */