Refactor includes to be more sane
This commit is contained in:
parent
2d4bc24dd6
commit
37fbde33e3
@ -2,14 +2,16 @@
|
||||
* Main application file
|
||||
*/
|
||||
|
||||
#include "wx_common.h"
|
||||
#include "widgets/widget.h"
|
||||
#include "src/wx_common.h"
|
||||
#include "src/widgets/widget.h"
|
||||
|
||||
#include <wx/app.h>
|
||||
#include <wx/sysopt.h>
|
||||
#include <wx/vidmode.h>
|
||||
#include <wx/display.h>
|
||||
|
||||
#include "src/widgets/MainFrame.h"
|
||||
|
||||
|
||||
// Some global stuff
|
||||
wxConfigBase *Glob_config = nullptr;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef TYRO_CONFIG_H
|
||||
#define TYRO_CONFIG_H
|
||||
|
||||
#include "../common.h"
|
||||
#include "src/common.h"
|
||||
|
||||
class TyroConfig {
|
||||
public:
|
||||
|
@ -1,8 +1,8 @@
|
||||
#ifndef TYRO_LANG_CONFIG_H
|
||||
#define TYRO_LANG_CONFIG_H
|
||||
|
||||
#include "../wx_common.h"
|
||||
#include "Config.h"
|
||||
#include "src/wx_common.h"
|
||||
#include "src/settings/Config.h"
|
||||
|
||||
class LangConfig : TyroConfig {
|
||||
public:
|
||||
|
@ -5,8 +5,8 @@
|
||||
#ifndef TYRO_THEME_CONFIG_H
|
||||
#define TYRO_THEME_CONFIG_H
|
||||
|
||||
#include "../wx_common.h"
|
||||
#include "Config.h"
|
||||
#include "src/wx_common.h"
|
||||
#include "src/settings/Config.h"
|
||||
|
||||
class ThemeConfig : TyroConfig {
|
||||
public:
|
||||
|
@ -2,7 +2,7 @@
|
||||
* The editor widget
|
||||
*/
|
||||
|
||||
#include "widget.h"
|
||||
#include "src/widgets/EditPane.h"
|
||||
|
||||
extern StringConstMap Glob_lexer_map;
|
||||
extern wxConfig *Glob_config;
|
||||
|
@ -1,8 +1,10 @@
|
||||
#ifndef TYROEDIT_PANE_H
|
||||
#define TYROEDIT_PANE_H
|
||||
|
||||
#include "../settings/LangConfig.h"
|
||||
#include "../settings/ThemeConfig.h"
|
||||
#include "src/widgets/widget.h"
|
||||
#include "src/settings/LangConfig.h"
|
||||
#include "src/settings/ThemeConfig.h"
|
||||
|
||||
|
||||
class EditPane: public wxStyledTextCtrl
|
||||
{
|
||||
|
@ -1,98 +1,55 @@
|
||||
#include "widget.h"
|
||||
#include "src/widgets/FilePane.h"
|
||||
|
||||
extern MainFrame *Glob_main_frame;
|
||||
|
||||
enum CustomFilePaneEventIds {
|
||||
myFP_ID_OPEN = (wxID_HIGHEST * 2),
|
||||
myFP_ID_RENAME,
|
||||
myFP_ID_DELETE
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param parent
|
||||
* @param id
|
||||
* @param dir
|
||||
* @param pos
|
||||
* @param size
|
||||
* @param style
|
||||
* @param filter
|
||||
*/
|
||||
FilePane::FilePane(
|
||||
wxWindow* parent,
|
||||
const wxWindowID id,
|
||||
const wxString &dir,
|
||||
const wxPoint &pos,
|
||||
const wxSize &size,
|
||||
wxWindowID id,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString &filter
|
||||
) : wxGenericDirCtrl(parent, id, dir, pos, size, style, filter)
|
||||
const wxString &name
|
||||
) : wxTreeListCtrl(parent, id, pos, size, style, name)
|
||||
{
|
||||
this->CreateContextMenu();
|
||||
this->BindEvents();
|
||||
this->dir = new wxDir();
|
||||
this->InitImageList();
|
||||
this->SetImageList(this->img_list);
|
||||
|
||||
this->CollapseTree();
|
||||
this->dir->Open(".");
|
||||
|
||||
this->SetDefaultPath(wxStandardPaths::Get().GetDocumentsDir() + "../");
|
||||
this->SetPath(this->GetDefaultPath());
|
||||
this->AppendColumn("",
|
||||
wxCOL_WIDTH_AUTOSIZE,
|
||||
wxALIGN_LEFT,
|
||||
wxCOL_RESIZABLE | wxCOL_SORTABLE);
|
||||
|
||||
wxTreeListItem root = this->GetRootItem();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
FilePane::~FilePane()
|
||||
{
|
||||
wxLogDebug("File Pane Destructor Called.");
|
||||
delete this->contextMenu;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind event handlers
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void FilePane::BindEvents()
|
||||
void FilePane::InitImageList()
|
||||
{
|
||||
// Open files on double-click or enter
|
||||
this->Bind(wxEVT_DIRCTRL_FILEACTIVATED, [=](wxTreeEvent&) {
|
||||
wxLogDebug("File activated event fired");
|
||||
this->OpenSelectedFiles();
|
||||
}, wxID_ANY);
|
||||
wxSize iconSize = wxArtProvider::GetSizeHint(wxART_LIST);
|
||||
|
||||
// Context Menu
|
||||
this->Bind(wxEVT_TREE_ITEM_RIGHT_CLICK, [=](wxTreeEvent&) {
|
||||
this->PopupMenu(this->contextMenu);
|
||||
}, wxID_ANY);
|
||||
if (iconSize == wxDefaultSize)
|
||||
{
|
||||
iconSize = wxSize(16, 16);
|
||||
}
|
||||
|
||||
// Open file(s)
|
||||
this->Bind(wxEVT_MENU, [=](wxCommandEvent&) {
|
||||
this->OpenSelectedFiles();
|
||||
}, myFP_ID_OPEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the filePane Context Menu
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void FilePane::CreateContextMenu()
|
||||
{
|
||||
this->contextMenu = new wxMenu();
|
||||
this->contextMenu->Append(myFP_ID_OPEN, "&Open Ctrl+Shift+O", "Open the selected file(s)");
|
||||
//this->contextMenu->Append(myFP_ID_RENAME, "&Rename Ctrl+Shift+R", "Rename the selected file");
|
||||
//this->contextMenu->Append(myFP_ID_DELETE, "Delete", "Delete the selected file");
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the files that are currently selected in the file pane in the current
|
||||
* editor window
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void FilePane::OpenSelectedFiles()
|
||||
{
|
||||
wxArrayString paths;
|
||||
this->GetPaths(paths);
|
||||
Glob_main_frame->OpenFiles(paths);
|
||||
this->UnselectAll();
|
||||
this->img_list = new wxImageList(iconSize.x, iconSize.y);
|
||||
|
||||
static const char* icons[] =
|
||||
{
|
||||
wxART_NORMAL_FILE,
|
||||
wxART_FOLDER,
|
||||
wxART_FOLDER_OPEN
|
||||
};
|
||||
|
||||
for (unsigned n = 0; n < WXSIZEOF(icons); n++)
|
||||
{
|
||||
this->img_list->Add(
|
||||
wxArtProvider::GetIcon(icons[n], wxART_LIST, iconSize)
|
||||
);
|
||||
}
|
||||
}
|
@ -1,24 +1,23 @@
|
||||
#ifndef TYRO_FILE_PANE_H
|
||||
#define TYRO_FILE_PANE_H
|
||||
|
||||
class FilePane : public wxGenericDirCtrl {
|
||||
#include "src/widgets/widget.h"
|
||||
|
||||
class FilePane : public wxTreeListCtrl {
|
||||
public:
|
||||
FilePane(
|
||||
wxWindow *parent,
|
||||
const wxWindowID id = wxID_ANY,
|
||||
const wxString &dir = wxDirDialogDefaultFolderStr,
|
||||
const wxPoint &pos = wxDefaultPosition,
|
||||
const wxSize &size = wxDefaultSize,
|
||||
long style = wxDIRCTRL_3D_INTERNAL | wxDIRCTRL_EDIT_LABELS |
|
||||
wxDIRCTRL_SHOW_FILTERS | wxDIRCTRL_MULTIPLE,
|
||||
const wxString &filter = wxEmptyString
|
||||
wxWindowID id=wxID_ANY,
|
||||
const wxPoint &pos=wxDefaultPosition,
|
||||
const wxSize &size=wxDefaultSize,
|
||||
long style=wxTL_DEFAULT_STYLE,
|
||||
const wxString &name=wxTreeListCtrlNameStr
|
||||
);
|
||||
~FilePane();
|
||||
private:
|
||||
wxMenu *contextMenu = nullptr;
|
||||
void BindEvents();
|
||||
void CreateContextMenu();
|
||||
void OpenSelectedFiles();
|
||||
wxImageList *img_list = nullptr;
|
||||
wxDir *dir = nullptr;
|
||||
void InitImageList();
|
||||
};
|
||||
|
||||
#endif /* TYRO_FILE_PANE_H */
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Main Application Frame
|
||||
*/
|
||||
#include "widget.h"
|
||||
#include "src/widgets/MainFrame.h"
|
||||
|
||||
// Nasty globals
|
||||
extern TyroMenu *Glob_menu_bar;
|
||||
|
@ -5,7 +5,13 @@
|
||||
#ifndef TYROMAIN_H
|
||||
#define TYROMAIN_H
|
||||
|
||||
#include "TabContainer.h"
|
||||
#include "src/widgets/TyroMenu.h"
|
||||
#include "src/widgets/EditPane.h"
|
||||
#include "src/widgets/TabContainer.h"
|
||||
#ifndef TRAVIS
|
||||
#include "src/widgets/PrefPane.h"
|
||||
#endif
|
||||
#include "src/widgets/FilePane.h"
|
||||
|
||||
class MainFrame: public wxFrame
|
||||
{
|
||||
|
98
src/widgets/OldFilePane.cc
Normal file
98
src/widgets/OldFilePane.cc
Normal file
@ -0,0 +1,98 @@
|
||||
#include "widget.h"
|
||||
|
||||
extern MainFrame *Glob_main_frame;
|
||||
|
||||
enum CustomFilePaneEventIds {
|
||||
myFP_ID_OPEN = (wxID_HIGHEST * 2),
|
||||
myFP_ID_RENAME,
|
||||
myFP_ID_DELETE
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param parent
|
||||
* @param id
|
||||
* @param dir
|
||||
* @param pos
|
||||
* @param size
|
||||
* @param style
|
||||
* @param filter
|
||||
*/
|
||||
FilePane::FilePane(
|
||||
wxWindow* parent,
|
||||
const wxWindowID id,
|
||||
const wxString &dir,
|
||||
const wxPoint &pos,
|
||||
const wxSize &size,
|
||||
long style,
|
||||
const wxString &filter
|
||||
) : wxGenericDirCtrl(parent, id, dir, pos, size, style, filter)
|
||||
{
|
||||
this->CreateContextMenu();
|
||||
this->BindEvents();
|
||||
|
||||
this->CollapseTree();
|
||||
|
||||
this->SetDefaultPath(wxStandardPaths::Get().GetDocumentsDir() + "../");
|
||||
this->SetPath(this->GetDefaultPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
FilePane::~FilePane()
|
||||
{
|
||||
wxLogDebug("File Pane Destructor Called.");
|
||||
delete this->contextMenu;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind event handlers
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void FilePane::BindEvents()
|
||||
{
|
||||
// Open files on double-click or enter
|
||||
this->Bind(wxEVT_DIRCTRL_FILEACTIVATED, [=](wxTreeEvent&) {
|
||||
wxLogDebug("File activated event fired");
|
||||
this->OpenSelectedFiles();
|
||||
}, wxID_ANY);
|
||||
|
||||
// Context Menu
|
||||
this->Bind(wxEVT_TREE_ITEM_RIGHT_CLICK, [=](wxTreeEvent&) {
|
||||
this->PopupMenu(this->contextMenu);
|
||||
}, wxID_ANY);
|
||||
|
||||
// Open file(s)
|
||||
this->Bind(wxEVT_MENU, [=](wxCommandEvent&) {
|
||||
this->OpenSelectedFiles();
|
||||
}, myFP_ID_OPEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the filePane Context Menu
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void FilePane::CreateContextMenu()
|
||||
{
|
||||
this->contextMenu = new wxMenu();
|
||||
this->contextMenu->Append(myFP_ID_OPEN, "&Open Ctrl+Shift+O", "Open the selected file(s)");
|
||||
//this->contextMenu->Append(myFP_ID_RENAME, "&Rename Ctrl+Shift+R", "Rename the selected file");
|
||||
//this->contextMenu->Append(myFP_ID_DELETE, "Delete", "Delete the selected file");
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the files that are currently selected in the file pane in the current
|
||||
* editor window
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void FilePane::OpenSelectedFiles()
|
||||
{
|
||||
wxArrayString paths;
|
||||
this->GetPaths(paths);
|
||||
Glob_main_frame->OpenFiles(paths);
|
||||
this->UnselectAll();
|
||||
}
|
25
src/widgets/OldFilePane.hh
Normal file
25
src/widgets/OldFilePane.hh
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef TYRO_FILE_PANE_H
|
||||
#define TYRO_FILE_PANE_H
|
||||
|
||||
class FilePane : public wxGenericDirCtrl {
|
||||
public:
|
||||
FilePane(
|
||||
wxWindow *parent,
|
||||
const wxWindowID id = wxID_ANY,
|
||||
const wxString &dir = wxDirDialogDefaultFolderStr,
|
||||
const wxPoint &pos = wxDefaultPosition,
|
||||
const wxSize &size = wxDefaultSize,
|
||||
long style = wxDIRCTRL_3D_INTERNAL | wxDIRCTRL_EDIT_LABELS |
|
||||
wxDIRCTRL_SHOW_FILTERS | wxDIRCTRL_MULTIPLE,
|
||||
const wxString &filter = wxEmptyString
|
||||
);
|
||||
~FilePane();
|
||||
private:
|
||||
wxMenu *contextMenu = nullptr;
|
||||
void BindEvents();
|
||||
void CreateContextMenu();
|
||||
void OpenSelectedFiles();
|
||||
};
|
||||
|
||||
#endif /* TYRO_FILE_PANE_H */
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "widget.h"
|
||||
#include "src/widgets/PrefPane.h"
|
||||
#include "src/widgets/MainFrame.h"
|
||||
|
||||
extern wxConfigBase *Glob_config;
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
#ifndef TYRO_PREF_PANE_H
|
||||
#define TYRO_PREF_PANE_H
|
||||
|
||||
#include "src/widgets/widget.h"
|
||||
|
||||
class PrefPane {
|
||||
public:
|
||||
PrefPane();
|
||||
|
@ -2,11 +2,14 @@
|
||||
* Wrapper around wxAuiNotebook
|
||||
*/
|
||||
|
||||
#include "widget.h"
|
||||
#include "src/widgets/TabContainer.h"
|
||||
#include "src/widgets/MainFrame.h"
|
||||
|
||||
extern TyroMenu *Glob_menu_bar;
|
||||
extern wxStatusBar *Glob_status_bar;
|
||||
|
||||
static MainFrame *parentFrame = nullptr;
|
||||
|
||||
static vector<EditPane *> editors;
|
||||
static unsigned long untitled_document_count = 0;
|
||||
|
||||
@ -27,7 +30,7 @@ TabContainer::TabContainer(
|
||||
long style
|
||||
) : wxAuiNotebook(parent, id, pos, size, style)
|
||||
{
|
||||
this->parent = (MainFrame *) parent;
|
||||
parentFrame = (MainFrame *) parent;
|
||||
|
||||
this->Bind(wxEVT_AUINOTEBOOK_PAGE_CLOSE, &TabContainer::OnClose, this, wxID_ANY);
|
||||
this->Bind(wxEVT_AUINOTEBOOK_PAGE_CLOSED, &TabContainer::OnClosed, this, wxID_ANY);
|
||||
@ -173,7 +176,7 @@ void TabContainer::OnClosed(wxAuiNotebookEvent &WXUNUSED(event))
|
||||
{
|
||||
if (this->GetPageCount() == 0)
|
||||
{
|
||||
this->parent->EnableEditControls(false);
|
||||
parentFrame->EnableEditControls(false);
|
||||
Glob_status_bar->SetStatusText("", STATUS_CURSOR_LOCATION);
|
||||
Glob_status_bar->SetStatusText("", STATUS_CURRENT_LANGUAGE);
|
||||
}
|
||||
@ -203,7 +206,7 @@ void TabContainer::OnTabContextMenu(wxAuiNotebookEvent &WXUNUSED(event))
|
||||
void TabContainer::OnCloseAll(wxCommandEvent &WXUNUSED(event))
|
||||
{
|
||||
this->DeleteAllPages();
|
||||
this->parent->EnableEditControls(false);
|
||||
parentFrame->EnableEditControls(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5,8 +5,8 @@
|
||||
#ifndef TABCONTAINER_H
|
||||
#define TABCONTAINER_H
|
||||
|
||||
#include "EditPane.h"
|
||||
#include "MainFrame.h"
|
||||
#include "src/widgets/TyroMenu.h"
|
||||
#include "src/widgets/EditPane.h"
|
||||
|
||||
static long tab_style = wxBORDER_NONE | wxAUI_NB_TAB_SPLIT |wxAUI_NB_TAB_MOVE
|
||||
| wxAUI_NB_SCROLL_BUTTONS | wxAUI_NB_WINDOWLIST_BUTTON
|
||||
@ -30,7 +30,6 @@ public:
|
||||
void OnCloseAll(wxCommandEvent &event);
|
||||
void OnCloseAllButThis(wxCommandEvent &event);
|
||||
private:
|
||||
MainFrame *parent = nullptr;
|
||||
EditPane *NewEditor();
|
||||
void OnTabSwitch(wxAuiNotebookEvent &event);
|
||||
void OnClose(wxAuiNotebookEvent &event);
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "widget.h"
|
||||
#include "../settings/LangConfig.h"
|
||||
#include "src/widgets/TyroMenu.h"
|
||||
#include "src/settings/LangConfig.h"
|
||||
|
||||
static LangConfig *lang_config = nullptr;
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
#ifndef TYRO_MENU_H
|
||||
#define TYRO_MENU_H
|
||||
|
||||
#include "widget.h"
|
||||
#include "src/widgets/widget.h"
|
||||
|
||||
class TyroMenu : public wxMenuBar {
|
||||
public:
|
||||
|
@ -5,31 +5,21 @@
|
||||
#define TYRO_WIDGET_H
|
||||
|
||||
// Common wxWidgets stuff
|
||||
#include "../wx_common.h"
|
||||
#include "src/wx_common.h"
|
||||
|
||||
// Base widgets
|
||||
#include <wx/aboutdlg.h>
|
||||
#include <wx/fdrepdlg.h>
|
||||
#include <wx/aui/aui.h>
|
||||
#include <wx/stc/stc.h>
|
||||
#include <wx/treectrl.h>
|
||||
#include <wx/dir.h>
|
||||
#include <wx/dirctrl.h>
|
||||
#include <wx/fontpicker.h>
|
||||
#include <wx/treelist.h>
|
||||
|
||||
#ifndef TRAVIS
|
||||
#include <wx/preferences.h>
|
||||
#endif
|
||||
|
||||
// Tyro includes
|
||||
#include "TyroMenu.h"
|
||||
#include "EditPane.h"
|
||||
#include "TabContainer.h"
|
||||
#include "MainFrame.h"
|
||||
#ifndef TRAVIS
|
||||
#include "PrefPane.h"
|
||||
#endif
|
||||
#include "FilePane.h"
|
||||
|
||||
#endif /* TYRO_WIDGET_H */
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "catch.hpp"
|
||||
#include "../src/settings/Config.h"
|
||||
#include "tests/catch.hpp"
|
||||
#include "src/settings/Config.h"
|
||||
|
||||
TEST_CASE ("Base config class load json")
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
#include "catch.hpp"
|
||||
#include "../src/settings/LangConfig.h"
|
||||
#include "tests/catch.hpp"
|
||||
#include "src/settings/LangConfig.h"
|
||||
|
||||
TEST_CASE("Language Config Library")
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "catch.hpp"
|
||||
#include "../src/base/SFTP.h"
|
||||
#include "tests/catch.hpp"
|
||||
#include "src/base/SFTP.h"
|
||||
|
||||
TEST_CASE("SFTP Library")
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "catch.hpp"
|
||||
#include "../src/settings/ThemeConfig.h"
|
||||
#include "tests/catch.hpp"
|
||||
#include "src/settings/ThemeConfig.h"
|
||||
|
||||
TEST_CASE("Theme Config Library")
|
||||
{
|
||||
|
@ -1,2 +1,2 @@
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include "catch.hpp"
|
||||
#include "tests/catch.hpp"
|
Loading…
Reference in New Issue
Block a user