From 65768692fb4fcdfad9272e1da1d80d8169b7e7a0 Mon Sep 17 00:00:00 2001 From: Tim Warren Date: Wed, 15 Apr 2015 12:17:25 -0400 Subject: [PATCH] Add a few more toolbar icons --- src/settings/Config.cpp | 6 +++++ src/settings/Config.h | 1 + src/widgets/EditPane.cpp | 8 ++++--- src/widgets/MainFrame.cpp | 45 +++++++++++++++++++++--------------- src/widgets/TabContainer.cpp | 12 +++++++--- 5 files changed, 47 insertions(+), 25 deletions(-) diff --git a/src/settings/Config.cpp b/src/settings/Config.cpp index b4126f1..671ffd2 100644 --- a/src/settings/Config.cpp +++ b/src/settings/Config.cpp @@ -7,6 +7,7 @@ TyroConfig::TyroConfig() { // Defines languages_json + // Generated on compile from languages.json #include "../../config/languages_json.h" string json_string(languages_json); @@ -29,4 +30,9 @@ JsonValue TyroConfig::GetRoot() JsonValue TyroConfig::GetLang(string name) { return default_root.get(name, JsonValue()); +} + +JsonValue TyroConfig::GetLangKeywords(string name) +{ + return this->GetLang(name).get("keywords", JsonValue()); } \ No newline at end of file diff --git a/src/settings/Config.h b/src/settings/Config.h index 1e69297..d1dc881 100644 --- a/src/settings/Config.h +++ b/src/settings/Config.h @@ -14,6 +14,7 @@ public: ~TyroConfig(); JsonValue GetRoot(); JsonValue GetLang(string name); + JsonValue GetLangKeywords(string name); private: JsonValue default_root; JsonReader reader; diff --git a/src/widgets/EditPane.cpp b/src/widgets/EditPane.cpp index 84852bb..7d36d10 100644 --- a/src/widgets/EditPane.cpp +++ b/src/widgets/EditPane.cpp @@ -36,7 +36,7 @@ bool EditPane::LoadAndHighlight(wxString filePath) } // Get the list of keywords for the current language - JsonValue keywords_array = config->GetLang("cpp").get("keywords", JsonValue()); + JsonValue keywords_array = config->GetLangKeywords("cpp"); this->StyleSetForeground (wxSTC_STYLE_DEFAULT, wxColor(101, 123, 131)); this->StyleSetForeground(wxSTC_STYLE_INDENTGUIDE, wxColor(147, 161, 161)); @@ -74,8 +74,10 @@ bool EditPane::LoadAndHighlight(wxString filePath) if (keywords_array.isArray()) { - this->SetKeyWords(0, keywords_array[0].asString()); - this->SetKeyWords(1, keywords_array[1].asString()); + for(int i = 0; i < keywords_array.size(); i++) + { + this->SetKeyWords(i, keywords_array[i].asString()); + } } else { diff --git a/src/widgets/MainFrame.cpp b/src/widgets/MainFrame.cpp index 3e29a22..784ecfd 100644 --- a/src/widgets/MainFrame.cpp +++ b/src/widgets/MainFrame.cpp @@ -48,19 +48,13 @@ void MainFrame::SetupStatusBar() void MainFrame::SetupToolbar() { // Icon files -#ifdef __WXMAC__ - #include "../../resources/xpm/48/file-empty.xpm" - #include "../../resources/xpm/48/folder.xpm" - #include "../../resources/xpm/48/floppy.xpm" - #include "../../resources/xpm/48/sign-error.xpm" - #include "../../resources/xpm/48/wrench-screwdriver.xpm" -#else - #include "../../resources/xpm/24/file-empty.xpm" - #include "../../resources/xpm/24/folder.xpm" - #include "../../resources/xpm/24/floppy.xpm" - #include "../../resources/xpm/24/sign-error.xpm" - #include "../../resources/xpm/24/wrench-screwdriver.xpm" -#endif + #include "../../resources/xpm/file_add.xpm" + #include "../../resources/xpm/folder.xpm" + #include "../../resources/xpm/diskette.xpm" + #include "../../resources/xpm/close.xpm" + #include "../../resources/xpm/copy.xpm" + #include "../../resources/xpm/scissors.xpm" + #include "../../resources/xpm/clipboard.xpm" CreateToolBar(wxNO_BORDER | wxTB_FLAT | wxTB_HORIZONTAL); @@ -68,17 +62,22 @@ void MainFrame::SetupToolbar() vector bitmaps; - bitmaps.push_back(wxBitmap(file_empty)); + bitmaps.push_back(wxBitmap(file_add)); bitmaps.push_back(wxBitmap(folder)); - bitmaps.push_back(wxBitmap(floppy)); - bitmaps.push_back(wxBitmap(sign_error)); - bitmaps.push_back(wxBitmap(wrench_screwdriver)); + bitmaps.push_back(wxBitmap(diskette)); + bitmaps.push_back(wxBitmap(close)); + bitmaps.push_back(wxBitmap(copy)); + bitmaps.push_back(wxBitmap(scissors)); + bitmaps.push_back(wxBitmap(clipboard)); toolBar->AddTool(wxID_NEW, "New", bitmaps[0], "New file"); 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_CLOSE, "Close", bitmaps[3], "Close file"); + toolBar->AddSeparator(); + toolBar->AddTool(wxID_COPY, "Copy", bitmaps[4], "Copy"); + toolBar->AddTool(wxID_CUT, "Cut", bitmaps[5], "Cut"); + toolBar->AddTool(wxID_PASTE, "Paste", bitmaps[6], "Paste"); //toolBar->AddTool(wxID_ANY, "Settings", bitmaps[4], "Change Settings"); toolBar->Realize(); @@ -263,6 +262,10 @@ void MainFrame::EnableEditControls() editMenu->Enable(wxID_SELECTALL, true); toolBar->EnableTool(wxID_SAVE, true); + toolBar->EnableTool(wxID_CLOSE, true); + toolBar->EnableTool(wxID_COPY, true); + toolBar->EnableTool(wxID_CUT, true); + toolBar->EnableTool(wxID_PASTE, true); } /** @@ -284,4 +287,8 @@ void MainFrame::DisableEditControls() editMenu->Enable(wxID_SELECTALL, false); toolBar->EnableTool(wxID_SAVE, false); + toolBar->EnableTool(wxID_CLOSE, false); + toolBar->EnableTool(wxID_COPY, false); + toolBar->EnableTool(wxID_CUT, false); + toolBar->EnableTool(wxID_PASTE, false); } diff --git a/src/widgets/TabContainer.cpp b/src/widgets/TabContainer.cpp index ad6d0a8..ab4d767 100644 --- a/src/widgets/TabContainer.cpp +++ b/src/widgets/TabContainer.cpp @@ -30,7 +30,7 @@ void TabContainer::AddTab() EditPane *editor = new EditPane(this, wxID_ANY); - this->AddPage(editor, caption); + this->AddPage(editor, caption, true); } void TabContainer::AddTab(wxString filePath) @@ -46,11 +46,17 @@ void TabContainer::AddTab(wxString filePath) if (loaded_file) { - this->AddPage(editor, caption); + this->AddPage(editor, caption, true); } else { - // @TODO Add Error dialog here + wxMessageDialog err( + this, + _T("Failed to open the specified file. Do you have permission to open it?"), + _T("Could not open file."), + wxOK|wxCENTER|wxICON_WARNING + ); + err.ShowModal(); } }