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 MainWindow::ListTabInfos() { - std::vector tinfos; - for (int i = 0; i < notebook->GetPageCount(); i++) { - tinfos.push_back(dynamic_cast(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 #include #include @@ -35,5 +34,4 @@ class MainWindow : public MainFrame { public: MainWindow(); void ApplyPreferences(); - std::vector 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 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(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(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 ); diff --git a/src/gui.h b/src/gui.h index 455d2cc..5ed2a05 100644 --- a/src/gui.h +++ b/src/gui.h @@ -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 MyApp::ListTabInfos() { + std::vector tinfos; + wxAuiNotebook *notebook=((MainWindow *)this->GetTopWindow())->notebook; + for (int i = 0; i < notebook->GetPageCount(); i++) { + tinfos.push_back(dynamic_cast(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 GetGame() = 0; virtual std::shared_ptr GetBase() = 0; }; + + +/** + * @brief Main application + * + */ +class MyApp : public wxApp { +public: + virtual bool OnInit(); + std::vector ListTabInfos(); +}; + +wxDECLARE_APP(MyApp); + +///@brief Abort ochess with a message +void Abort(std::string msg); diff --git a/tools/wxFrameBuilder.fbp b/tools/wxFrameBuilder.fbp index 0f96547..3087087 100644 --- a/tools/wxFrameBuilder.fbp +++ b/tools/wxFrameBuilder.fbp @@ -29,7 +29,7 @@ 0 0 0 - + 0 wxAUI_MGR_DEFAULT @@ -122,7 +122,7 @@ - + main_sizer wxVERTICAL @@ -170,7 +170,7 @@ 1 - protected + public 1 Resizable @@ -5670,7 +5670,7 @@ - + 0 wxAUI_MGR_DEFAULT @@ -5693,16 +5693,16 @@ wxTAB_TRAVERSAL - + main_sizer wxVERTICAL none - + 5 wxEXPAND 1 - + top_sizer wxHORIZONTAL @@ -5808,7 +5808,7 @@ 0 1 - m_comboBox1 + opened_game_list 1 @@ -5827,7 +5827,7 @@ wxFILTER_NONE wxDefaultValidator - Combo! + No game opened