aboutsummaryrefslogtreecommitdiff
path: root/src/preferences/EditorPrefs.hpp
blob: 69585198370d237f6123b41390ccd0683c474eed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "ochess.hpp"
#include <wx/combobox.h>
#include <wx/dir.h>
#include <wx/filename.h>
#include <wx/preferences.h>
#include <wx/spinctrl.h>
#include <wx/stdpaths.h>

class EditorPrefsPanel : public PrefsEditor {

public:
  EditorPrefsPanel(wxWindow *parent) : PrefsEditor(parent) {
   
   // Bind(wxEVT_SPINCTRL, &BoardPrefsPanel::OnConfChange, this, wxID_ANY);
  }
  void OnConfChange(wxCommandEvent &event) {
    UNUSED(event);
  }

  virtual bool TransferDataToWindow() {
    CONFIG_OPEN(config);
    row_size->SetValue(config->Read("editor/row_size", 50));
    col_size->SetValue(config->Read("editor/col_size", 100));
    show_move_icons->SetValue(config->Read("editor/show_move_icons", true));
    color_margin->SetColour(wxColour(config->Read("editor/color_margin", "#F3F3F3")));
    color_scrollbar->SetColour(wxColour(config->Read("editor/color_scrollbar", "#838383")));
    color_scrollbarbg->SetColour(wxColour(config->Read("editor/color_scrollbarbg", "#FFFFFF")));
    color_commentbg->SetColour(wxColour(config->Read("editor/color_commentbg", "#ffffcc")));
    CONFIG_CLOSE(config);
    return true;
  }

  void ApplyPreferences() {
    CONFIG_OPEN(config);
    config->Write("editor/row_size", row_size->GetValue());
    config->Write("editor/col_size", col_size->GetValue());
    config->Write("editor/show_move_icons", show_move_icons->GetValue());
    config->Write("editor/color_margin", color_margin->GetColour().GetAsString());
    config->Write("editor/color_scrollbar", color_scrollbar->GetColour().GetAsString());
    config->Write("editor/color_scrollbarbg", color_scrollbarbg->GetColour().GetAsString());
    config->Write("editor/color_commentbg", color_commentbg->GetColour().GetAsString());
    CONFIG_CLOSE(config);
  }

  virtual bool TransferDataFromWindow() {
    ApplyPreferences();
    MAINWIN->ApplyPreferences();
    return (true);
  }
};

class EditorPrefs : public wxPreferencesPage {
public:
  virtual wxString GetName() const { return "Editor"; }
  virtual wxBitmap GetLargeIcon() {
    return wxArtProvider::GetBitmap(wxART_HELP, wxART_TOOLBAR);
  }
  virtual wxWindow *CreateWindow(wxWindow *parent) {
    return new EditorPrefsPanel(parent);
  }
};