aboutsummaryrefslogtreecommitdiff
path: root/src/base_tab
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2022-02-25 09:21:26 +0100
committerLoic Guegan <manzerbredes@mailbox.org>2022-02-25 09:21:26 +0100
commit4adb5ff056d4a5a35cd7f76a9785c5cab57fdc03 (patch)
tree80b468c7325b5cd4bf87fe4a2d97def4fdd54370 /src/base_tab
parent416ab7635d74f04797c067c185df35f8476d87c1 (diff)
Improve game base panel
Diffstat (limited to 'src/base_tab')
-rw-r--r--src/base_tab/BasePanelBF.cpp31
-rw-r--r--src/base_tab/BasePanelBF.h12
-rw-r--r--src/base_tab/BaseTab.cpp15
-rw-r--r--src/base_tab/BaseTab.hpp3
4 files changed, 42 insertions, 19 deletions
diff --git a/src/base_tab/BasePanelBF.cpp b/src/base_tab/BasePanelBF.cpp
index c6b8381..e179ec0 100644
--- a/src/base_tab/BasePanelBF.cpp
+++ b/src/base_tab/BasePanelBF.cpp
@@ -17,13 +17,8 @@ BasePanelBF::BasePanelBF( wxWindow* parent, wxWindowID id, const wxPoint& pos, c
wxBoxSizer* top_sizer;
top_sizer = new wxBoxSizer( wxHORIZONTAL );
- current_base_label = new wxStaticText( this, wxID_ANY, wxT("Current base:"), wxDefaultPosition, wxDefaultSize, 0 );
- current_base_label->Wrap( -1 );
- top_sizer->Add( current_base_label, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
-
- current_base = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
- current_base->Enable( false );
-
+ current_base = new wxStaticText( this, wxID_ANY, wxT("unknown"), wxDefaultPosition, wxDefaultSize, 0 );
+ current_base->Wrap( -1 );
top_sizer->Add( current_base, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
save_button = new wxButton( this, wxID_ANY, wxT("Save"), wxDefaultPosition, wxDefaultSize, 0 );
@@ -35,18 +30,36 @@ BasePanelBF::BasePanelBF( wxWindow* parent, wxWindowID id, const wxPoint& pos, c
main_sizer->Add( top_sizer, 0, wxEXPAND, 5 );
- game_list = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), wxLC_REPORT );
- main_sizer->Add( game_list, 1, wxALL|wxEXPAND, 5 );
+ separator_1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
+ main_sizer->Add( separator_1, 0, wxEXPAND | wxALL, 5 );
wxBoxSizer* bottom_sizer;
bottom_sizer = new wxBoxSizer( wxHORIZONTAL );
+ append_choice_label = new wxStaticText( this, wxID_ANY, wxT("Import games from:"), wxDefaultPosition, wxDefaultSize, 0 );
+ append_choice_label->Wrap( -1 );
+ bottom_sizer->Add( append_choice_label, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
+
+ wxArrayString append_choiceChoices;
+ append_choice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, append_choiceChoices, 0 );
+ append_choice->SetSelection( 0 );
+ bottom_sizer->Add( append_choice, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
+
+ append_button = new wxButton( this, wxID_ANY, wxT("Append"), wxDefaultPosition, wxDefaultSize, 0 );
+ bottom_sizer->Add( append_button, 0, wxALL, 5 );
+
+
+ bottom_sizer->Add( 0, 0, 1, wxEXPAND, 5 );
+
delete_button = new wxButton( this, wxID_ANY, wxT("Delete selection"), wxDefaultPosition, wxDefaultSize, 0 );
bottom_sizer->Add( delete_button, 0, wxALL, 5 );
main_sizer->Add( bottom_sizer, 0, wxEXPAND, 5 );
+ game_list = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), wxLC_REPORT );
+ main_sizer->Add( game_list, 1, wxALL|wxEXPAND, 5 );
+
this->SetSizer( main_sizer );
this->Layout();
diff --git a/src/base_tab/BasePanelBF.h b/src/base_tab/BasePanelBF.h
index 63c4939..1bbbea1 100644
--- a/src/base_tab/BasePanelBF.h
+++ b/src/base_tab/BasePanelBF.h
@@ -15,12 +15,13 @@
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
-#include <wx/textctrl.h>
#include <wx/button.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/sizer.h>
+#include <wx/statline.h>
+#include <wx/choice.h>
#include <wx/listctrl.h>
#include <wx/panel.h>
@@ -35,12 +36,15 @@ class BasePanelBF : public wxPanel
private:
protected:
- wxStaticText* current_base_label;
- wxTextCtrl* current_base;
+ wxStaticText* current_base;
wxButton* save_button;
wxButton* export_button;
- wxListCtrl* game_list;
+ wxStaticLine* separator_1;
+ wxStaticText* append_choice_label;
+ wxChoice* append_choice;
+ wxButton* append_button;
wxButton* delete_button;
+ wxListCtrl* game_list;
public:
diff --git a/src/base_tab/BaseTab.cpp b/src/base_tab/BaseTab.cpp
index 95a1a8d..82a0db0 100644
--- a/src/base_tab/BaseTab.cpp
+++ b/src/base_tab/BaseTab.cpp
@@ -1,7 +1,7 @@
#include "BaseTab.hpp"
#include <wx/filename.h>
-BaseTab::BaseTab(wxFrame *parent)
+BaseTab::BaseTab(wxFrame *parent, std::string base_file)
: BasePanelBF(parent), TabInfos(TabInfos::BASE), base(NULL) {
game_list->InsertColumn(0, L"id", wxLIST_FORMAT_LEFT, 50);
@@ -14,11 +14,11 @@ BaseTab::BaseTab(wxFrame *parent)
this->Bind(wxEVT_BUTTON, &BaseTab::OnBim, this, wxID_ANY);
this->Bind(wxEVT_LIST_ITEM_ACTIVATED, &BaseTab::OnOpenGame, this, wxID_ANY);
+ current_base->SetLabel(base_file);
+ LoadFile(base_file);
}
-void BaseTab::OnBim(wxCommandEvent &event) {
- LoadFile("/home/loic/hartwig.pgn");
-}
+void BaseTab::OnBim(wxCommandEvent &event) {}
void BaseTab::OnOpenGame(wxListEvent &event) {
wxLogDebug("Open!");
@@ -39,6 +39,7 @@ void BaseTab::LoadFile(std::string path) {
wxString ext = file.GetExt().Lower();
if (ext == "pgn") {
base = new PGNGameBase(path);
+ SetLabel(file.GetName()+ "(PGN)");
}
if (base != NULL) {
@@ -51,8 +52,12 @@ void BaseTab::LoadFile(std::string path) {
game_list->SetItem(index, 3, base->GetTag("Event"));
game_list->SetItem(index, 4, base->GetTag("Round"));
game_list->SetItem(index, 5, base->GetTag("Result"));
- game_list->SetItem(index, 5, base->GetTag("ECO"));
+ game_list->SetItem(index, 6, base->GetTag("ECO"));
id++;
}
}
+
+ wxCommandEvent event(REFRESH_TAB_TITLE, GetId());
+ event.SetEventObject(this);
+ ProcessEvent(event);
} \ No newline at end of file
diff --git a/src/base_tab/BaseTab.hpp b/src/base_tab/BaseTab.hpp
index 26ee8c1..3283102 100644
--- a/src/base_tab/BaseTab.hpp
+++ b/src/base_tab/BaseTab.hpp
@@ -6,12 +6,13 @@
// Foreign events
wxDECLARE_EVENT(NEW_GAME_EVENT, wxCommandEvent);
+wxDECLARE_EVENT(REFRESH_TAB_TITLE, wxCommandEvent);
class BaseTab : public BasePanelBF, public TabInfos {
GameBase *base;
public:
- BaseTab(wxFrame *parent);
+ BaseTab(wxFrame *parent, std::string base_file);
void ApplyPreferences();
void LoadFile(std::string path);
void OnBim(wxCommandEvent &event);