aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2023-02-01 21:15:11 +0100
committerLoic Guegan <manzerbredes@mailbox.org>2023-02-01 21:15:11 +0100
commita575fea2bc094831996c47a6a84497b964a90e02 (patch)
tree59ff4add7dac624fbdf3cb7ad1688c706c0d3284 /src
parente0babeaf88b2a434b10ffb65824440b1adfaa151 (diff)
Add help menu and about dialog
Diffstat (limited to 'src')
-rw-r--r--src/MainWindow.cpp53
-rw-r--r--src/MainWindow.hpp1
-rw-r--r--src/config.h.in2
-rw-r--r--src/gui.cpp37
-rw-r--r--src/gui.h32
5 files changed, 120 insertions, 5 deletions
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index 3a67975..c11e25b 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -43,6 +43,8 @@ MainWindow::MainWindow()
wxCommandEvent dummy(REFRESH_ENGINE_LIST, GetId());
OnRefreshEngineList(dummy);
+ menu_help->Append(8, "About", "OChess Informations");
+
Bind(wxEVT_AUINOTEBOOK_PAGE_CHANGED, &MainWindow::OnPageChange, this,
wxID_ANY);
Bind(REFRESH_TAB_TITLE, &MainWindow::OnRefreshTabTitle, this, wxID_ANY);
@@ -171,6 +173,8 @@ void MainWindow::OnMenuItemClick(wxCommandEvent &event) {
}
} else if (id == 7) { // Create new engine
NewEngine();
+ } else if (id == 8) { // Create new engine
+ ShowAbout();
}
}
@@ -278,3 +282,52 @@ TabInfos* MainWindow::NewGame(std::shared_ptr<Game> game) {
this->AddPage(gt,gt);
return(gt);
}
+
+void MainWindow::ShowAbout(){
+ DialogAbout *dialog=new DialogAbout(this);
+ wxRichTextCtrl *t=dialog->info_richtext;
+
+ // Populate info:
+ wxFont font(wxFontInfo(12));
+ t->SetFont(font);
+ t->BeginAlignment(wxTEXT_ALIGNMENT_CENTRE);
+ t->BeginBold();
+ t->BeginFontSize(20);
+ t->WriteText(wxT("OChess"));
+ t->EndFontSize();
+ t->Newline();
+ t->EndBold();
+ t->WriteText(wxT("An open source software for chess games analysis and database management."));
+ t->Newline();
+ t->Newline();
+ t->BeginFontSize(8);
+ t->WriteText(wxT("OChess version "+std::string(OCHESS_VERSION)));
+ t->Newline();
+ t->WriteText(wxT("OChess is delivered under GPLv3 license"));
+ t->Newline();
+ t->WriteText(wxT("Built on "+std::string(BUILD_TIME)));
+ t->EndFontSize();
+ t->Newline();
+ t->Newline();
+ t->WriteText("Repository:");
+ t->Newline();
+ t->BeginURL("https://gitlab.com/manzerbredes/ochess");
+ t->BeginUnderline();
+ t->WriteText(wxT("https://gitlab.com/manzerbredes/ochess"));
+ t->EndUnderline();
+ t->EndURL();
+ t->Newline();
+ t->Newline();
+ t->BeginFontSize(10);
+ t->WriteText("For any questions/discussion please join the IRC chat at ");
+ t->BeginURL("irc://irc.libera.chat/ochess");
+ t->BeginUnderline();
+ t->WriteText(wxT("irc://irc.libera.chat/ochess"));
+ t->EndUnderline();
+ t->EndURL();
+ t->EndFontSize();
+ t->Newline();
+ t->EndAlignment();
+
+ dialog->Show();
+} \ No newline at end of file
diff --git a/src/MainWindow.hpp b/src/MainWindow.hpp
index b8025aa..8c541dd 100644
--- a/src/MainWindow.hpp
+++ b/src/MainWindow.hpp
@@ -31,6 +31,7 @@ class MainWindow : public MainFrame {
void OnAuiNotebookPageCheck(wxAuiNotebookEvent& event);
void OnCloseTabLinkedTo(wxCommandEvent &event);
void AddPage(wxWindow* window, TabInfos* infos);
+ void ShowAbout();
public:
MainWindow();
TabInfos* NewGame(std::shared_ptr<Game> game);
diff --git a/src/config.h.in b/src/config.h.in
index b00a11d..4c4ac80 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -3,3 +3,5 @@
#define OCHESS_MINOR "@PROJECT_VERSION_MINOR@"
#define OCHESS_PATCH "@PROJECT_VERSION_PATCH@"
#define OCHESS_TWEAK "@PROJECT_VERSION_TWEAK@"
+
+#define BUILD_TIME "@BUILD_TIME@"
diff --git a/src/gui.cpp b/src/gui.cpp
index b3d564b..d427211 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -26,6 +26,9 @@ MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, co
menu_engine = new wxMenu();
menu_bar->Append( menu_engine, wxT("Engine") );
+ menu_help = new wxMenu();
+ menu_bar->Append( menu_help, wxT("Help") );
+
this->SetMenuBar( menu_bar );
status_bar = this->CreateStatusBar( 1, wxSTB_SIZEGRIP, wxID_ANY );
@@ -47,6 +50,40 @@ MainFrame::~MainFrame()
{
}
+DialogAbout::DialogAbout( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
+{
+ this->SetSizeHints( wxDefaultSize, wxDefaultSize );
+
+ wxBoxSizer* main_sizer;
+ main_sizer = new wxBoxSizer( wxVERTICAL );
+
+ m_notebook3 = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
+ info_panel = new wxPanel( m_notebook3, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
+ wxBoxSizer* info_sizer;
+ info_sizer = new wxBoxSizer( wxVERTICAL );
+
+ info_richtext = new wxRichTextCtrl( info_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY|wxVSCROLL|wxHSCROLL|wxNO_BORDER|wxWANTS_CHARS );
+ info_sizer->Add( info_richtext, 1, wxEXPAND | wxALL, 5 );
+
+
+ info_panel->SetSizer( info_sizer );
+ info_panel->Layout();
+ info_sizer->Fit( info_panel );
+ m_notebook3->AddPage( info_panel, wxT("Info"), false );
+
+ main_sizer->Add( m_notebook3, 1, wxEXPAND | wxALL, 5 );
+
+
+ this->SetSizer( main_sizer );
+ this->Layout();
+
+ this->Centre( wxBOTH );
+}
+
+DialogAbout::~DialogAbout()
+{
+}
+
DialogLiveEngine::DialogLiveEngine( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
diff --git a/src/gui.h b/src/gui.h
index 0b1aef6..576b4b2 100644
--- a/src/gui.h
+++ b/src/gui.h
@@ -19,24 +19,25 @@
#include <wx/aui/auibook.h>
#include <wx/sizer.h>
#include <wx/frame.h>
-#include <wx/stattext.h>
-#include <wx/button.h>
+#include <wx/richtext/richtextctrl.h>
+#include <wx/panel.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
+#include <wx/notebook.h>
+#include <wx/dialog.h>
+#include <wx/stattext.h>
+#include <wx/button.h>
#include <wx/spinctrl.h>
#include <wx/listctrl.h>
-#include <wx/dialog.h>
#include <wx/listbox.h>
#include <wx/textctrl.h>
#include <wx/statline.h>
#include <wx/propgrid/propgrid.h>
#include <wx/propgrid/advprops.h>
-#include <wx/panel.h>
#include <wx/clrpicker.h>
#include <wx/checkbox.h>
#include <wx/splitter.h>
-#include <wx/notebook.h>
#include <wx/toolbar.h>
#include <wx/bmpbuttn.h>
#include <wx/combobox.h>
@@ -80,6 +81,7 @@ class MainFrame : public wxFrame
wxMenu* menu_game;
wxMenu* menu_db;
wxMenu* menu_engine;
+ wxMenu* menu_help;
wxStatusBar* status_bar;
public:
@@ -92,6 +94,26 @@ class MainFrame : public wxFrame
};
///////////////////////////////////////////////////////////////////////////////
+/// Class DialogAbout
+///////////////////////////////////////////////////////////////////////////////
+class DialogAbout : public wxDialog
+{
+ private:
+
+ protected:
+ wxNotebook* m_notebook3;
+ wxPanel* info_panel;
+
+ public:
+ wxRichTextCtrl* info_richtext;
+
+ DialogAbout( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 600,400 ), long style = wxDEFAULT_DIALOG_STYLE );
+
+ ~DialogAbout();
+
+};
+
+///////////////////////////////////////////////////////////////////////////////
/// Class DialogLiveEngine
///////////////////////////////////////////////////////////////////////////////
class DialogLiveEngine : public wxDialog