diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/MainWindow.cpp | 8 | ||||
| -rw-r--r-- | src/MainWindow.hpp | 2 | ||||
| -rw-r--r-- | src/base_tab/AppendGameDialog.cpp | 2 | ||||
| -rw-r--r-- | src/base_tab/BaseImportTab.cpp | 9 | ||||
| -rw-r--r-- | src/base_tab/BaseImportTab.hpp | 2 | ||||
| -rw-r--r-- | src/gui.cpp | 4 | ||||
| -rw-r--r-- | src/gui.h | 4 | ||||
| -rw-r--r-- | src/ochess.cpp | 10 | ||||
| -rw-r--r-- | src/ochess.hpp | 29 |
9 files changed, 38 insertions, 32 deletions
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 53403ba..a0e2ce6 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -174,14 +174,6 @@ void MainWindow::ApplyPreferences() { } } -std::vector<TabInfos *> MainWindow::ListTabInfos() { - std::vector<TabInfos *> tinfos; - for (int i = 0; i < notebook->GetPageCount(); i++) { - tinfos.push_back(dynamic_cast<TabInfos *>(notebook->GetPage(i))); - } - return (tinfos); -} - void MainWindow::OnClose(wxCloseEvent &e) { if (prefsEditor != NULL) { prefsEditor->Dismiss(); diff --git a/src/MainWindow.hpp b/src/MainWindow.hpp index 94131fc..5bff035 100644 --- a/src/MainWindow.hpp +++ b/src/MainWindow.hpp @@ -2,7 +2,6 @@ #include "base_tab/BaseTab.hpp" #include "game_tab/GameTab.hpp" -#include "ochess.hpp" #include <wx/aui/auibook.h> #include <wx/filedlg.h> #include <wx/preferences.h> @@ -35,5 +34,4 @@ class MainWindow : public MainFrame { public: MainWindow(); void ApplyPreferences(); - std::vector<TabInfos *> ListTabInfos(); };
\ No newline at end of file diff --git a/src/base_tab/AppendGameDialog.cpp b/src/base_tab/AppendGameDialog.cpp index 52a6f3d..260ba90 100644 --- a/src/base_tab/AppendGameDialog.cpp +++ b/src/base_tab/AppendGameDialog.cpp @@ -5,7 +5,7 @@ AppendGameDialog::AppendGameDialog(wxWindow *parent, std::shared_ptr<GameBase> base) : DialogAppendGame(parent), base(base) { - for (TabInfos *i : MAINWIN->ListTabInfos()) { + for (TabInfos *i : wxGetApp().ListTabInfos()) { if (i->type == TabInfos::GAME || i->type == TabInfos::BASE) { wxWindow *win = dynamic_cast<wxWindow *>(i); game_list->Append(win->GetLabel()); diff --git a/src/base_tab/BaseImportTab.cpp b/src/base_tab/BaseImportTab.cpp index 6c3ef5d..cd0d980 100644 --- a/src/base_tab/BaseImportTab.cpp +++ b/src/base_tab/BaseImportTab.cpp @@ -1,8 +1,13 @@ #include "BaseImportTab.hpp" - BaseImportTab::BaseImportTab(wxFrame *parent): TabBase_TabImport(parent) { - + for (TabInfos *i : wxGetApp().ListTabInfos()) { + if (i->type == TabInfos::GAME || i->type == TabInfos::BASE) { + wxWindow *win = dynamic_cast<wxWindow *>(i); + opened_game_list->Append(win->GetLabel(),i); + opened_game_list->SetSelection(0); + } + } } diff --git a/src/base_tab/BaseImportTab.hpp b/src/base_tab/BaseImportTab.hpp index e39f921..3d15e51 100644 --- a/src/base_tab/BaseImportTab.hpp +++ b/src/base_tab/BaseImportTab.hpp @@ -1,7 +1,5 @@ #include "ochess.hpp" - - class BaseImportTab : public TabBase_TabImport { diff --git a/src/gui.cpp b/src/gui.cpp index 3169b1e..7390b73 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -581,8 +581,8 @@ TabBase_TabImport::TabBase_TabImport( wxWindow* parent, wxWindowID id, const wxP from_game_label->Wrap( -1 ); top_sizer->Add( from_game_label, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - m_comboBox1 = new wxComboBox( this, wxID_ANY, wxT("Combo!"), wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); - top_sizer->Add( m_comboBox1, 100, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + opened_game_list = new wxComboBox( this, wxID_ANY, wxT("No game opened"), wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); + top_sizer->Add( opened_game_list, 100, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); import_from_game_button = new wxButton( this, wxID_ANY, wxT("Import"), wxDefaultPosition, wxDefaultSize, 0 ); top_sizer->Add( import_from_game_button, 0, wxALL, 5 ); @@ -74,9 +74,9 @@ class MainFrame : public wxFrame wxMenu* menu_db; wxMenu* menu_engine; wxStatusBar* status_bar; - wxAuiNotebook* notebook; public: + wxAuiNotebook* notebook; MainFrame( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("OChess"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,300 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL ); @@ -333,7 +333,7 @@ class TabBase_TabImport : public wxPanel protected: wxStaticText* from_game_label; - wxComboBox* m_comboBox1; + wxComboBox* opened_game_list; wxButton* import_from_game_button; wxStaticLine* m_staticline4; wxStaticText* from_db_label; diff --git a/src/ochess.cpp b/src/ochess.cpp index 82d88be..74ffc88 100644 --- a/src/ochess.cpp +++ b/src/ochess.cpp @@ -8,6 +8,16 @@ bool MyApp::OnInit() { frame->Show(true); return true; } + +std::vector<TabInfos *> MyApp::ListTabInfos() { + std::vector<TabInfos *> tinfos; + wxAuiNotebook *notebook=((MainWindow *)this->GetTopWindow())->notebook; + for (int i = 0; i < notebook->GetPageCount(); i++) { + tinfos.push_back(dynamic_cast<TabInfos *>(notebook->GetPage(i))); + } + return (tinfos); +} + wxIMPLEMENT_APP(MyApp); void Abort(std::string msg) { diff --git a/src/ochess.hpp b/src/ochess.hpp index 47e08e4..9b3bd3e 100644 --- a/src/ochess.hpp +++ b/src/ochess.hpp @@ -32,19 +32,6 @@ #define CONFIG_OPEN(name) wxConfig *name = new wxConfig("ochess") #define CONFIG_CLOSE(name) delete name -/** - * @brief Main application - * - */ -class MyApp : public wxApp { -public: - virtual bool OnInit(); -}; - -wxDECLARE_APP(MyApp); - -///@brief Abort ochess with a message -void Abort(std::string msg); class Game; class GameBase; @@ -69,3 +56,19 @@ public: virtual std::shared_ptr<Game> GetGame() = 0; virtual std::shared_ptr<GameBase> GetBase() = 0; }; + + +/** + * @brief Main application + * + */ +class MyApp : public wxApp { +public: + virtual bool OnInit(); + std::vector<TabInfos *> ListTabInfos(); +}; + +wxDECLARE_APP(MyApp); + +///@brief Abort ochess with a message +void Abort(std::string msg); |
