A little pointer and docblock cleanup, show current language in status bar

This commit is contained in:
Tim Warren 2015-06-03 17:06:55 -04:00
parent b39e63060b
commit 1fa24545d2
12 changed files with 78 additions and 27 deletions

View File

@ -9,11 +9,12 @@
// Some global stuff
wxConfigBase *Glob_config;
TyroMenu *Glob_menu_bar;
MainFrame *Glob_main_frame;
wxConfigBase *Glob_config = nullptr;
TyroMenu *Glob_menu_bar = nullptr;
wxStatusBar *Glob_status_bar = nullptr;
MainFrame *Glob_main_frame = nullptr;
PrefPane *Glob_pref_pane = nullptr;
StringConstMap Glob_lexer_map;
PrefPane *Glob_pref_pane;
// Static app loading variables
static wxArrayString files;
@ -69,7 +70,7 @@ public:
{
// Deallocate config object
delete wxConfigBase::Set((wxConfigBase *) NULL);
return close(true);
}

View File

@ -8,7 +8,7 @@
// Application config
const wxString APP_NAME = "Tyro";
const wxString APP_VENDOR = "Aviat Ion";
const wxString APP_VERSION = "0.5.0";
const wxString APP_VERSION = "0.9.0";
const wxString APP_VERSION_MORE = "Pre-release";
// Command-line arguments
@ -48,6 +48,13 @@ enum myMargins
MARGIN_LINE_NUMBERS
};
// Status bar sections
enum myStatusBarSections {
STATUS_MESSAGES,
STATUS_CURSOR_LOCATION,
STATUS_CURRENT_LANGUAGE
};
// Top level menus
enum myMenuIds {
myFILE_MENU,

View File

@ -1,12 +1,9 @@
/**
* Lexer configuration object
*
* @extends TyroConfig
*/
#include "LangConfig.h"
#include <config/languages_json.h>
/**
* Constructor
*/
LangConfig::LangConfig()
{
this->LoadJson(languages_json);
@ -26,6 +23,9 @@ LangConfig::LangConfig()
}
}
/**
* Destructor
*/
LangConfig::~LangConfig()
{
wxLogDebug("Called LangConfig Destructor");
@ -107,6 +107,12 @@ JsonValue LangConfig::GetLexerMap(string lang)
.get("lexer_map", JsonValue());
}
/**
* Set the selected language key
*
* @param string lang
* @return void
*/
void LangConfig::SetLang(string lang)
{
this->lang = lang;
@ -163,4 +169,4 @@ StringMap LangConfig::GetLangList()
}
return outputList;
}
}

View File

@ -5,23 +5,40 @@
#include "ThemeConfig.h"
#include <config/themes_json.h>
/**
* Constructor
*/
ThemeConfig::ThemeConfig()
{
this->LoadJson(themes_json);
this->SetTheme("Solarized");
}
/**
* Destructor
*/
ThemeConfig::~ThemeConfig()
{
wxLogDebug("Called ThemeConfig Destructor");
}
/**
* Set the current theme
*
* @param string theme_name
* @return void
*/
void ThemeConfig::SetTheme(string theme_name)
{
JsonValue theme_list = this->GetRoot();
this->current_theme = theme_list.get(theme_name, JsonValue());
}
/**
* Get the name of the currently selected theme
*
* @return string
*/
JsonValue ThemeConfig::GetTheme()
{
return this->current_theme;

View File

@ -25,8 +25,8 @@ public:
void SetCurrentLang(string name);
private:
StringConstMap::iterator lexerMapIt;
LangConfig *lang_config;
ThemeConfig *theme_config;
LangConfig *lang_config = nullptr;
ThemeConfig *theme_config = nullptr;
bool FileReadable();
bool FileWritable();
void BindEvents();

View File

@ -6,7 +6,8 @@
// Nasty globals
extern TyroMenu *Glob_menu_bar;
extern PrefPane *Glob_pref_pane;
static TabContainer *notebook;
extern wxStatusBar *Glob_status_bar;
static TabContainer *notebook = nullptr;
// Frame icon
#include "../../resources/xpm/tyro.xpm"
@ -27,9 +28,12 @@ MainFrame::MainFrame(wxFrame *frame, const wxString &title)
// Apply the menu bar to the current frame
this->SetMenuBar(Glob_menu_bar);
this->SetupStatusBar();
// Setup StatusBar
Glob_status_bar = new wxStatusBar(this, wxID_ANY);
Glob_status_bar->SetFieldsCount(3);
this->DoLayout();
this->BindEvents();
}
@ -47,6 +51,8 @@ MainFrame::~MainFrame()
wxDELETE(this->replaceDlg);
wxDELETE(this->findReplaceData);
Glob_status_bar->Destroy();
manager->UnInit();
}
@ -74,6 +80,14 @@ void MainFrame::DoLayout()
notebookPaneInfo.CenterPane();
this->manager->AddPane(notebook, notebookPaneInfo);
wxAuiPaneInfo statusPaneInfo;
statusPaneInfo.Bottom()
.ToolbarPane()
.Gripper(false)
.DockFixed(true)
.Resizable(true);
this->manager->AddPane(Glob_status_bar, statusPaneInfo);
// Update everything
this->EnableEditControls(false);
}

View File

@ -16,8 +16,8 @@ class MainFrame: public wxFrame
void OpenFiles(wxArrayString filelist);
void OnPrefsChanged(wxCommandEvent &event);
private:
wxAuiManager *manager;
wxAuiToolBar *toolBar;
wxAuiManager *manager = nullptr;
wxAuiToolBar *toolBar = nullptr;
wxFindReplaceData *findReplaceData = nullptr;
wxFindReplaceData *findData = nullptr;
wxFindReplaceDialog *findDlg = nullptr;

View File

@ -12,7 +12,7 @@ public:
void Show(wxWindow *parent);
protected:
wxPreferencesEditor *pref_window;
wxPreferencesEditor *pref_window = nullptr;
};
#endif /* TYRO_PREF_PANE_H */

View File

@ -5,6 +5,7 @@
#include "widget.h"
extern TyroMenu *Glob_menu_bar;
extern wxStatusBar *Glob_status_bar;
static unsigned long untitled_document_count = 0;
/**
@ -163,6 +164,8 @@ void TabContainer::OnClosed(wxAuiNotebookEvent &WXUNUSED(event))
if (this->GetPageCount() == 0)
{
this->parent->EnableEditControls(false);
Glob_status_bar->SetStatusText("", STATUS_CURSOR_LOCATION);
Glob_status_bar->SetStatusText("", STATUS_CURRENT_LANGUAGE);
}
}
@ -209,4 +212,7 @@ void TabContainer::OnTabSwitch(wxAuiNotebookEvent &event)
// Update language menu selection
Glob_menu_bar->SetCurrentLanguage(editor->GetCurrentLang());
// Update status bar
Glob_status_bar->SetStatusText(editor->GetCurrentLang(), STATUS_CURRENT_LANGUAGE);
}

View File

@ -29,7 +29,7 @@ public:
EditPane *GetEditor(size_t page_idx);
void OnCloseAll(wxCommandEvent &event);
private:
MainFrame *parent;
MainFrame *parent = nullptr;
void OnTabSwitch(wxAuiNotebookEvent &event);
void OnClose(wxAuiNotebookEvent &event);
void OnClosed(wxAuiNotebookEvent &event);

View File

@ -1,7 +1,7 @@
#include "widget.h"
#include "../settings/LangConfig.h"
static LangConfig *lang_config;
static LangConfig *lang_config = nullptr;
/**
* Constructor

View File

@ -14,11 +14,11 @@ public:
void SetIdChecked(int id, bool checked);
void SetCurrentLanguage(string lang);
private:
wxMenu *fileMenu;
wxMenu *editMenu;
wxMenu *viewMenu;
wxMenu *langMenu;
wxMenu *helpMenu;
wxMenu *fileMenu = nullptr;
wxMenu *editMenu = nullptr;
wxMenu *viewMenu = nullptr;
wxMenu *langMenu = nullptr;
wxMenu *helpMenu = nullptr;
void SetupMainMenus();
void SetupLangMenu();
void EnableEntireMenu(size_t menuId, wxMenu *menu, bool enable);