Attempt to have a default font specified from the system

This commit is contained in:
Timothy Warren 2019-05-31 14:17:30 -04:00
parent e6e40cdaba
commit ee64ae24c4
7 changed files with 45 additions and 51 deletions

View File

@ -22,10 +22,6 @@ StringConstMap Glob_lexer_map;
PrefPane *Glob_pref_pane = nullptr;
#endif
// Static app loading variables
static wxArrayString files;
static int param_count;
/**
* Class with main method
*/
@ -58,7 +54,7 @@ public:
Glob_main_frame->Show(true);
// Open passed files
if (param_count > 0)
if (this->param_count > 0)
{
Glob_main_frame->OpenFiles(files);
}
@ -105,18 +101,22 @@ public:
{
// Get un-named parameters
int i;
param_count = parser.GetParamCount();
this->param_count = parser.GetParamCount();
wxLogDebug("%i Parameters", param_count);
wxLogDebug("%i Parameters", this->param_count);
for (i = 0; i < param_count; i++)
for (i = 0; i < this->param_count; i++)
{
files.Add(parser.GetParam(i));
this->files.Add(parser.GetParam(i));
}
return true;
}
private:
// app loading variables
wxArrayString files;
int param_count = 0;
/**
* Set up mapping for lexers
*/

View File

@ -25,7 +25,7 @@ ThemeConfig::~ThemeConfig() {}
* @param string theme_name
* @return bool
*/
bool ThemeConfig::SetTheme(string theme_name)
bool ThemeConfig::SetTheme(const string &theme_name)
{
JsonValue theme_list = this->GetRoot();
JsonValue selected_theme = theme_list.get(theme_name, JsonValue());

View File

@ -10,7 +10,7 @@ class ThemeConfig : TyroConfig {
public:
ThemeConfig();
~ThemeConfig();
bool SetTheme(string theme_name);
bool SetTheme(const string &theme_name);
JsonValue GetTheme();
JsonValue GetThemeValue(string type, string key);
wxColor GetThemeColor(string type, string key);

View File

@ -306,13 +306,8 @@ void EditPane::OnCharAdded(wxStyledTextEvent& event)
*/
void EditPane::_ApplyTheme(JsonValue &lexer_map)
{
// Font setup
wxFont defaultFont(
TYRO_DEFAULT_FONT_SIZE,
wxFONTFAMILY_TELETYPE,
wxFONTFLAG_DEFAULT,
wxFONTWEIGHT_NORMAL
);
// Make sure to have a default font, especially for Linux
wxFont globalFont = wxSystemSettings::GetFont(wxSYS_ANSI_FIXED_FONT);
static const wxColor default_background = this->theme_config->GetThemeColor("background", "default");
static const wxColor default_foreground = this->theme_config->GetThemeColor("foreground", "default");
@ -324,23 +319,17 @@ void EditPane::_ApplyTheme(JsonValue &lexer_map)
? (this->theme_config->GetThemeColor("line_numbers", "foreground"))
: default_foreground;
// Attempt to set the font according to config
Glob_config->Read("global_font", &globalFont);
// Set default colors/ fonts
for(int i = 0; i <= wxSTC_STYLE_MAX; i++)
{
this->StyleSetBackground(i, default_background);
this->StyleSetForeground(i, default_foreground);
wxFont globalFont;
wxString fontFace;
if ( ! Glob_config->Read("global_font", &globalFont))
{
this->StyleSetFont(i, defaultFont);
}
else
{
this->StyleSetFont(i, globalFont);
}
}
// Set up Code folding
if (Glob_config->ReadBool("show_code_folding", false))

View File

@ -103,10 +103,10 @@ void FilePane::CreateTree(const wxString &path)
this->AddDirToTree(root, dirs[0], wxString(""), true);
}
delete files;
// Add files that are in the root path
this->AddDirFiles(root, this->base_path);
this->AddDirFiles(root, this->base_path, files);
delete files;
}
/**
@ -199,20 +199,24 @@ void FilePane::AddDirToTree(wxTreeListItem &root, const wxString &path, const wx
this->AddDirToTree(dir_node, dirs[0], newParent, true);
}
delete files;
// Add the files, if they exist
// Defer until after recursion so that files follow folders
this->AddDirFiles(dir_node, fullPath);
this->AddDirFiles(dir_node, fullPath, files);
delete files;
}
void FilePane::AddDirFiles(wxTreeListItem &root, const wxString &path)
/**
* Add the file leaves for the current file path in the tree
*
* @param wxTreeListITem &root - The branch of the tree representing the current path
* @param wxString &path - The filesystem path
* @param wxArrayString *files - The list of files
*/
void FilePane::AddDirFiles(wxTreeListItem &root, const wxString &path, wxArrayString *files)
{
wxLogInfo("Adding files for dir: %s", path);
auto *files = new wxArrayString();
wxDir::GetAllFiles(path, files, wxEmptyString, wxDIR_FILES);
wxFileName rootPath(path);
rootPath.MakeAbsolute();
@ -235,8 +239,6 @@ void FilePane::AddDirFiles(wxTreeListItem &root, const wxString &path)
this->AppendItem(root, fileLabel, Icon_File, Icon_File, fileData);
this->file_set.insert(std::string(fileName.GetFullPath()));
}
delete files;
}
/**

View File

@ -25,6 +25,6 @@ private:
void OpenFileInEditor(wxTreeListEvent& event);
void InitImageList();
void AddDirToTree(wxTreeListItem &root, const wxString &path, const wxString &parent, bool recurse = false);
void AddDirFiles(wxTreeListItem &root, const wxString &path);
void AddDirFiles(wxTreeListItem &root, const wxString &path, wxArrayString *files);
};

View File

@ -101,10 +101,13 @@ public:
wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
wxFont globalFont = wxSystemSettings::GetFont(wxSYS_ANSI_FIXED_FONT);
Glob_config->Read("global_font", &globalFont);
this->fontPicker = new wxFontPickerCtrl(
this,
myID_PREFS_FONT,
this->GetFont(),
globalFont,
wxDefaultPosition,
wxDefaultSize,
wxFNTP_FONTDESC_AS_LABEL
@ -142,7 +145,7 @@ public:
*/
virtual bool TransferDataToWindow()
{
wxFont globalFont;
wxFont globalFont = wxSystemSettings::GetFont(wxSYS_ANSI_FIXED_FONT);
Glob_config->Read("global_font", &globalFont);
this->fontPicker->SetSelectedFont(globalFont);
@ -202,7 +205,7 @@ PrefPane::PrefPane()
{
this->pref_window = new wxPreferencesEditor();
this->pref_window->AddPage(new GeneralPrefPane());
// this->pref_window->AddPage(new FontPrefPane());
this->pref_window->AddPage(new FontPrefPane());
}
PrefPane::~PrefPane()