OChess v0.0.2
Programmer's Manual
EditorPrefs.hpp
1#include "ochess.hpp"
2#include <wx/combobox.h>
3#include <wx/dir.h>
4#include <wx/filename.h>
5#include <wx/preferences.h>
6#include <wx/spinctrl.h>
7#include <wx/stdpaths.h>
8#ifdef __APPLE__
9#include <wx/bmpbndl.h>
10#endif
16
17public:
18 EditorPrefsPanel(wxWindow *parent) : PrefsEditor(parent) {
19
20 // Bind(wxEVT_SPINCTRL, &BoardPrefsPanel::OnConfChange, this, wxID_ANY);
21 }
22 void OnConfChange(wxCommandEvent &event) {
23 UNUSED(event);
24 }
25
26 virtual bool TransferDataToWindow() {
27 CONFIG_OPEN(config);
28 row_size->SetValue(config->Read("editor/row_size", 50));
29 col_size->SetValue(config->Read("editor/col_size", 100));
30 show_move_icons->SetValue(config->Read("editor/show_move_icons", true));
31 color_margin->SetColour(wxColour(config->Read("editor/color_margin", "#F3F3F3")));
32 color_scrollbar->SetColour(wxColour(config->Read("editor/color_scrollbar", "#838383")));
33 color_scrollbarbg->SetColour(wxColour(config->Read("editor/color_scrollbarbg", "#FFFFFF")));
34 color_commentbg->SetColour(wxColour(config->Read("editor/color_commentbg", "#ffffcc")));
35 CONFIG_CLOSE(config);
36 return true;
37 }
38
39 void ApplyPreferences() {
40 CONFIG_OPEN(config);
41 config->Write("editor/row_size", row_size->GetValue());
42 config->Write("editor/col_size", col_size->GetValue());
43 config->Write("editor/show_move_icons", show_move_icons->GetValue());
44 config->Write("editor/color_margin", color_margin->GetColour().GetAsString());
45 config->Write("editor/color_scrollbar", color_scrollbar->GetColour().GetAsString());
46 config->Write("editor/color_scrollbarbg", color_scrollbarbg->GetColour().GetAsString());
47 config->Write("editor/color_commentbg", color_commentbg->GetColour().GetAsString());
48 CONFIG_CLOSE(config);
49 }
50
51 virtual bool TransferDataFromWindow() {
52 ApplyPreferences();
53 MAINWIN->ApplyPreferences();
54 return (true);
55 }
56};
57
62class EditorPrefs : public wxPreferencesPage {
63public:
64 virtual wxString GetName() const { return "Editor"; }
65 virtual wxBitmap GetLargeIcon() {
66 return wxArtProvider::GetBitmap(wxART_HELP, wxART_TOOLBAR);
67 }
68 #ifdef __APPLE__
69 virtual wxBitmapBundle GetIcon() {
70 return wxBitmapBundle::FromBitmap(LoadPNG("ui_text_alt"));
71 }
72 #endif
73 virtual wxWindow *CreateWindow(wxWindow *parent) {
74 return new EditorPrefsPanel(parent);
75 }
76};
Configuration page for the EditorCanvas.
Definition: EditorPrefs.hpp:15
Interface for wxWidgets to load EditorPrefsPanel into the preference window.
Definition: EditorPrefs.hpp:62
Class PrefsEditor.
Definition: gui.h:199
wxBitmap LoadPNG(std::string icon, wxSize size)
Load an icon from embedded binary resources and rescale it to a specified size.
Definition: binres.cpp:7