aboutsummaryrefslogtreecommitdiff
path: root/src/game_tab/GameTab.cpp
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2022-02-23 18:11:55 +0100
committerLoic Guegan <manzerbredes@mailbox.org>2022-02-23 18:11:55 +0100
commitce941c146aea7925bded6b9d2a0d0559d3156ad3 (patch)
tree4c52e02600e3fd127bfb28b3e974d45541ec9e4e /src/game_tab/GameTab.cpp
Create repository
Diffstat (limited to 'src/game_tab/GameTab.cpp')
-rw-r--r--src/game_tab/GameTab.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/game_tab/GameTab.cpp b/src/game_tab/GameTab.cpp
new file mode 100644
index 0000000..3e32b4e
--- /dev/null
+++ b/src/game_tab/GameTab.cpp
@@ -0,0 +1,52 @@
+#include "GameTab.hpp"
+#include <wx/clipbrd.h>
+
+wxDEFINE_EVENT(GAME_CHANGE, wxCommandEvent);
+
+GameTab::GameTab(wxFrame *parent, Game *game)
+ : wxPanel(parent), game(game), TabInfos(TabInfos::GAME) {
+ // Splitter
+ wxSplitterWindow *splitter = new wxSplitterWindow(this, wxID_ANY);
+ splitter->SetMinimumPaneSize(100);
+
+ // Panels
+ board_panel = new BoardPanel((wxFrame *)splitter, game);
+ editor_panel = new EditorPanel((wxFrame *)splitter, game);
+ splitter->SplitVertically(board_panel, editor_panel);
+
+ // Setup splitter
+ wxBoxSizer *topSizer = new wxBoxSizer(wxHORIZONTAL);
+ topSizer->Add(splitter, 1, wxEXPAND);
+ SetSizerAndFit(topSizer);
+
+ // Refresh panels
+ wxCommandEvent event(REFRESH_TAB_TITLE, GetId());
+ event.SetEventObject(this);
+ OnRefreshTabTitle(event);
+ board_panel->Notify();
+ editor_panel->Notify();
+
+ Bind(REFRESH_TAB_TITLE, &GameTab::OnRefreshTabTitle, this, wxID_ANY);
+ Bind(GAME_CHANGE, &GameTab::OnGameChange, this, wxID_ANY);
+}
+
+void GameTab::OnGameChange(wxCommandEvent &event) {
+ board_panel->Notify();
+ editor_panel->Notify();
+}
+
+void GameTab::OnRefreshTabTitle(wxCommandEvent &event) {
+ std::string white = game->GetTag("White");
+ std::string black = game->GetTag("Black");
+ if (white.size() == 0 && black.size() == 0) {
+ SetLabel("New Game");
+ } else {
+ SetLabel(white + "-" + black);
+ }
+ event.SetEventObject(this);
+ event.Skip();
+}
+
+void GameTab::ApplyPreferences() {
+ board_panel->ApplyPreferences();
+}