Add help menu and about dialog

This commit is contained in:
Loic Guegan 2023-02-01 21:15:11 +01:00
parent e0babeaf88
commit a575fea2bc
7 changed files with 376 additions and 36 deletions

View file

@ -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();
}

View file

@ -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);

View file

@ -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@"

View file

@ -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 );

View file

@ -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:
@ -91,6 +93,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
///////////////////////////////////////////////////////////////////////////////