1 // Copyright (C) 2011-2015 Petr Pavlu <setup@dagobah.cz>
3 // This file is part of CenterIM.
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.
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
{
30 virtual ~OptionWindow() override
{}
33 virtual void onScreenResized() override
;
36 class BooleanOption
: public CppConsUI::CheckBox
{
38 BooleanOption(const char *text
, const char *config
);
39 virtual ~BooleanOption() override
;
44 void onToggle(CppConsUI::CheckBox
&activator
, bool new_state
);
47 CONSUI_DISABLE_COPY(BooleanOption
);
50 class StringOption
: public CppConsUI::Button
{
52 StringOption(const char *text
, const char *config
);
53 virtual ~StringOption() override
;
58 void onActivate(CppConsUI::Button
&activator
);
59 void responseHandler(CppConsUI::InputDialog
&activator
,
60 CppConsUI::AbstractDialog::ResponseType response
);
63 CONSUI_DISABLE_COPY(StringOption
);
66 class IntegerOption
: public CppConsUI::Button
{
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
;
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
);
83 CONSUI_DISABLE_COPY(IntegerOption
);
86 class ChoiceOption
: public CppConsUI::ComboBox
{
88 ChoiceOption(const char *text
, const char *config
);
89 virtual ~ChoiceOption() override
;
91 void addOption(const char *title
, const char *value
);
96 void onSelectionChanged(CppConsUI::ComboBox
&activator
, int new_entry
,
97 const char *title
, intptr_t data
);
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;
109 CONSUI_DISABLE_COPY(OptionWindow
);
112 #endif // OPTIONWINDOW_H
114 // vim: set tabstop=2 shiftwidth=2 textwidth=80 expandtab: