istereo2

view libs/goatkit/checkbox.cc @ 9:64e15874f3bd

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 26 Sep 2015 02:56:07 +0300
parents
children 7bd4264bf74a
line source
1 /*
2 GoatKit - a themable/animated widget toolkit for games
3 Copyright (C) 2014 John Tsiombikas <nuclear@member.fsf.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program 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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #include "checkbox.h"
19 #include "boolanm.h"
21 namespace goatkit {
23 struct CheckBoxImpl {
24 BoolAnim checked;
25 };
27 CheckBox::CheckBox()
28 {
29 cbox = new CheckBoxImpl;
30 cbox->checked = false;
31 cbox->checked.set_transition_duration(60);
32 }
34 CheckBox::~CheckBox()
35 {
36 delete cbox;
37 }
39 const char *CheckBox::get_type_name() const
40 {
41 return "checkbox";
42 }
45 void CheckBox::check()
46 {
47 cbox->checked.change(true);
48 }
50 void CheckBox::uncheck()
51 {
52 cbox->checked.change(false);
53 }
55 float CheckBox::get_checked() const
56 {
57 return cbox->checked.get_value();
58 }
60 bool CheckBox::is_checked() const
61 {
62 return cbox->checked.get_state();
63 }
65 void CheckBox::toggle()
66 {
67 if(is_checked()) {
68 uncheck();
69 } else {
70 check();
71 }
72 }
74 void CheckBox::on_click()
75 {
76 toggle();
78 Event ev;
79 ev.type = EV_CHANGE;
80 handle_event(ev);
81 }
83 } // namespace goatkit