Add check target to the CMake build
[centerim5.git] / src / OptionWindow.h
blob7c92468d3df5108d4b92d276524bbb9bc81254f9
1 // Copyright (C) 2011-2015 Petr Pavlu <setup@dagobah.cz>
2 //
3 // This file is part of CenterIM.
4 //
5 // CenterIM is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // CenterIM is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with CenterIM. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef OPTIONWINDOW_H
19 #define OPTIONWINDOW_H
21 #include <cppconsui/Button.h>
22 #include <cppconsui/CheckBox.h>
23 #include <cppconsui/ComboBox.h>
24 #include <cppconsui/InputDialog.h>
25 #include <cppconsui/SplitDialog.h>
27 class OptionWindow : public CppConsUI::SplitDialog {
28 public:
29 OptionWindow();
30 virtual ~OptionWindow() override {}
32 // FreeWindow
33 virtual void onScreenResized() override;
35 protected:
36 class BooleanOption : public CppConsUI::CheckBox {
37 public:
38 BooleanOption(const char *text, const char *config);
39 virtual ~BooleanOption() override;
41 protected:
42 char *pref_;
44 void onToggle(CppConsUI::CheckBox &activator, bool new_state);
46 private:
47 CONSUI_DISABLE_COPY(BooleanOption);
50 class StringOption : public CppConsUI::Button {
51 public:
52 StringOption(const char *text, const char *config);
53 virtual ~StringOption() override;
55 protected:
56 char *pref_;
58 void onActivate(CppConsUI::Button &activator);
59 void responseHandler(CppConsUI::InputDialog &activator,
60 CppConsUI::AbstractDialog::ResponseType response);
62 private:
63 CONSUI_DISABLE_COPY(StringOption);
66 class IntegerOption : public CppConsUI::Button {
67 public:
68 IntegerOption(const char *text, const char *config);
69 IntegerOption(const char *text, const char *config,
70 sigc::slot<const char *, int> unit_fun);
71 virtual ~IntegerOption() override;
73 protected:
74 char *pref_;
75 bool has_unit_;
76 sigc::slot<const char *, int> unit_fun_;
78 void onActivate(CppConsUI::Button &activator);
79 void responseHandler(CppConsUI::InputDialog &activator,
80 CppConsUI::AbstractDialog::ResponseType response);
82 private:
83 CONSUI_DISABLE_COPY(IntegerOption);
86 class ChoiceOption : public CppConsUI::ComboBox {
87 public:
88 ChoiceOption(const char *text, const char *config);
89 virtual ~ChoiceOption() override;
91 void addOption(const char *title, const char *value);
93 protected:
94 char *pref_;
96 void onSelectionChanged(CppConsUI::ComboBox &activator, int new_entry,
97 const char *title, intptr_t data);
99 private:
100 CONSUI_DISABLE_COPY(ChoiceOption);
103 const char *getPercentUnit(int i) const;
104 const char *getMinUnit(int i) const;
105 void reloadKeyBindings(CppConsUI::Button &activator) const;
106 void reloadColorSchemes(CppConsUI::Button &activator) const;
108 private:
109 CONSUI_DISABLE_COPY(OptionWindow);
112 #endif // OPTIONWINDOW_H
114 // vim: set tabstop=2 shiftwidth=2 textwidth=80 expandtab: