annotate dw/fltkcomplexbutton.cc @ 2021:e63f6fc75427

Convert tabs into spaces
author Jorge Arellano Cid <jcid@dillo.org>
date Mon, 16 May 2011 13:57:30 -0400
parents 06fb15f69228
children b4c1aa2d99dc
rev   line source
1811
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
1 // fltkcomplexbutton.cc contains code from FLTK 1.3's src/Fl_Button.cxx
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
2 // that is Copyright 1998-2010 by Bill Spitzak and others.
1325
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1274
diff changeset
3
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1274
diff changeset
4 /*
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1274
diff changeset
5 * This program is free software; you can redistribute it and/or modify
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1274
diff changeset
6 * it under the terms of the GNU General Public License as published by
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1274
diff changeset
7 * the Free Software Foundation; either version 3 of the License, or
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1274
diff changeset
8 * (at your option) any later version.
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1274
diff changeset
9 *
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1274
diff changeset
10 * This program is distributed in the hope that it will be useful,
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1274
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1274
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1274
diff changeset
13 * GNU General Public License for more details.
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1274
diff changeset
14 *
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1274
diff changeset
15 * You should have received a copy of the GNU General Public License
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1274
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1274
diff changeset
17 */
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
18
1811
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
19 #include <FL/Fl.H>
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
20 #include <FL/Fl_Button.H>
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
21 #include <FL/Fl_Group.H>
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
22 #include <FL/Fl_Window.H>
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
23
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
24 #include "fltkcomplexbutton.hh"
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
25
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
26 using namespace dw::fltk::ui;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
27
1811
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
28 /**
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
29 Sets the current value of the button.
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
30 A non-zero value sets the button to 1 (ON), and zero sets it to 0 (OFF).
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
31 \param[in] v button value.
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
32 \see set(), clear()
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
33 */
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
34 int ComplexButton::value(int v) {
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
35 v = v ? 1 : 0;
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
36 oldval = v;
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
37 clear_changed();
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
38 if (value_ != v) {
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
39 value_ = v;
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
40 if (box()) redraw();
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
41 else redraw_label();
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
42 return 1;
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
43 } else {
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
44 return 0;
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
45 }
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
46 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
47
1811
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
48 /**
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
49 Turns on this button and turns off all other radio buttons in the group
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
50 (calling \c value(1) or \c set() does not do this).
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
51 */
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
52 void ComplexButton::setonly() { // set this radio button on, turn others off
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
53 value(1);
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
54 Fl_Group* g = parent();
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
55 Fl_Widget*const* a = g->array();
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
56 for (int i = g->children(); i--;) {
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
57 Fl_Widget* o = *a++;
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
58 if (o != this && o->type()==FL_RADIO_BUTTON) ((Fl_Button*)o)->value(0);
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
59 }
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
60 }
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
61
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
62 void ComplexButton::draw() {
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
63 if (type() == FL_HIDDEN_BUTTON) return;
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
64 Fl_Color col = value() ? selection_color() : color();
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
65 draw_box(value() ? (down_box()?down_box():fl_down(box())) : box(), col);
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
66 draw_backdrop();
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
67 if (labeltype() == FL_NORMAL_LABEL && value()) {
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
68 Fl_Color c = labelcolor();
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
69 labelcolor(fl_contrast(c, col));
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
70 draw_label();
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
71 labelcolor(c);
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
72 } else draw_label();
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
73 if (Fl::focus() == this) draw_focus();
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
74
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
75 // ComplexButton is a Group; draw its children
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
76 for (int i = children () - 1; i >= 0; i--)
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
77 draw_child (*child (i));
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
78 }
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
79
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
80 int ComplexButton::handle(int event) {
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
81 int newval;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
82 switch (event) {
1811
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
83 case FL_ENTER: /* FALLTHROUGH */
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
84 case FL_LEAVE:
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
85 // if ((value_?selection_color():color())==FL_GRAY) redraw();
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
86 return 1;
1811
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
87 case FL_PUSH:
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
88 if (Fl::visible_focus() && handle(FL_FOCUS)) Fl::focus(this);
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
89 case FL_DRAG:
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
90 if (Fl::event_inside(this)) {
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
91 if (type() == FL_RADIO_BUTTON) newval = 1;
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
92 else newval = !oldval;
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
93 } else
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
94 {
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
95 clear_changed();
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
96 newval = oldval;
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
97 }
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
98 if (newval != value_) {
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
99 value_ = newval;
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
100 set_changed();
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
101 redraw();
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
102 if (when() & FL_WHEN_CHANGED) do_callback();
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
103 }
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
104 return 1;
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
105 case FL_RELEASE:
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
106 if (value_ == oldval) {
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
107 if (when() & FL_WHEN_NOT_CHANGED) do_callback();
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
108 return 1;
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
109 }
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
110 set_changed();
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
111 if (type() == FL_RADIO_BUTTON) setonly();
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
112 else if (type() == FL_TOGGLE_BUTTON) oldval = value_;
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
113 else {
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
114 value(oldval);
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
115 set_changed();
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
116 if (when() & FL_WHEN_CHANGED) {
2021
e63f6fc75427 Convert tabs into spaces
Jorge Arellano Cid <jcid@dillo.org>
parents: 1902
diff changeset
117 Fl_Widget_Tracker wp(this);
1811
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
118 do_callback();
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
119 if (wp.deleted()) return 1;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
120 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
121 }
1811
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
122 if (when() & FL_WHEN_RELEASE) do_callback();
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
123 return 1;
1811
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
124 case FL_SHORTCUT:
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
125 if (!(shortcut() ?
2021
e63f6fc75427 Convert tabs into spaces
Jorge Arellano Cid <jcid@dillo.org>
parents: 1902
diff changeset
126 Fl::test_shortcut(shortcut()) : test_shortcut())) return 0;
1811
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
127 if (Fl::visible_focus() && handle(FL_FOCUS)) Fl::focus(this);
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
128 goto triggered_by_keyboard;
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
129 case FL_FOCUS : /* FALLTHROUGH */
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
130 case FL_UNFOCUS :
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
131 if (Fl::visible_focus()) {
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
132 if (box() == FL_NO_BOX) {
2021
e63f6fc75427 Convert tabs into spaces
Jorge Arellano Cid <jcid@dillo.org>
parents: 1902
diff changeset
133 // Widgets with the FL_NO_BOX boxtype need a parent to
e63f6fc75427 Convert tabs into spaces
Jorge Arellano Cid <jcid@dillo.org>
parents: 1902
diff changeset
134 // redraw, since it is responsible for redrawing the
e63f6fc75427 Convert tabs into spaces
Jorge Arellano Cid <jcid@dillo.org>
parents: 1902
diff changeset
135 // background...
e63f6fc75427 Convert tabs into spaces
Jorge Arellano Cid <jcid@dillo.org>
parents: 1902
diff changeset
136 int X = x() > 0 ? x() - 1 : 0;
e63f6fc75427 Convert tabs into spaces
Jorge Arellano Cid <jcid@dillo.org>
parents: 1902
diff changeset
137 int Y = y() > 0 ? y() - 1 : 0;
e63f6fc75427 Convert tabs into spaces
Jorge Arellano Cid <jcid@dillo.org>
parents: 1902
diff changeset
138 if (window()) window()->damage(FL_DAMAGE_ALL, X, Y, w() + 2, h() + 2);
1811
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
139 } else redraw();
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
140 return 1;
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
141 } else return 0;
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
142 case FL_KEYBOARD :
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
143 if (Fl::focus() == this && Fl::event_key() == ' ' &&
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
144 !(Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT | FL_META))) {
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
145 set_changed();
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
146 triggered_by_keyboard:
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
147 Fl_Widget_Tracker wp(this);
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
148 if (type() == FL_RADIO_BUTTON && !value_) {
2021
e63f6fc75427 Convert tabs into spaces
Jorge Arellano Cid <jcid@dillo.org>
parents: 1902
diff changeset
149 setonly();
e63f6fc75427 Convert tabs into spaces
Jorge Arellano Cid <jcid@dillo.org>
parents: 1902
diff changeset
150 if (when() & FL_WHEN_CHANGED) do_callback();
1811
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
151 } else if (type() == FL_TOGGLE_BUTTON) {
2021
e63f6fc75427 Convert tabs into spaces
Jorge Arellano Cid <jcid@dillo.org>
parents: 1902
diff changeset
152 value(!value());
e63f6fc75427 Convert tabs into spaces
Jorge Arellano Cid <jcid@dillo.org>
parents: 1902
diff changeset
153 if (when() & FL_WHEN_CHANGED) do_callback();
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
154 }
1811
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
155 if (wp.deleted()) return 1;
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
156 if (when() & FL_WHEN_RELEASE) do_callback();
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
157 return 1;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
158 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
159 default:
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
160 return 0;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
161 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
162 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
163
1811
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
164 /**
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
165 The constructor creates the button using the given position, size and label.
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
166 \param[in] X, Y, W, H position and size of the widget
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
167 \param[in] L widget label, default is no label
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
168 */
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
169 ComplexButton::ComplexButton(int X, int Y, int W, int H, const char *L)
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
170 : Fl_Group(X,Y,W,H,L) {
1875
d7dc24f8cdfb prevent new Fl_Widgets from automatically being added to a Fl_Group
corvid <corvid@lavabit.com>
parents: 1811
diff changeset
171 Fl_Group::current(0);
1811
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
172 box(FL_UP_BOX);
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
173 down_box(FL_NO_BOX);
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
174 value_ = oldval = 0;
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
175 shortcut_ = 0;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
176 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
177
1876
73336563b6e7 don't let complex button destroy flat view
corvid <corvid@lavabit.com>
parents: 1875
diff changeset
178 ComplexButton::~ComplexButton() {
73336563b6e7 don't let complex button destroy flat view
corvid <corvid@lavabit.com>
parents: 1875
diff changeset
179 /*
73336563b6e7 don't let complex button destroy flat view
corvid <corvid@lavabit.com>
parents: 1875
diff changeset
180 * The Fl_Group destructor clear()s the children, but layout expects
73336563b6e7 don't let complex button destroy flat view
corvid <corvid@lavabit.com>
parents: 1875
diff changeset
181 * the flat view to be around until it deletes if.
73336563b6e7 don't let complex button destroy flat view
corvid <corvid@lavabit.com>
parents: 1875
diff changeset
182 */
73336563b6e7 don't let complex button destroy flat view
corvid <corvid@lavabit.com>
parents: 1875
diff changeset
183 remove(0);
73336563b6e7 don't let complex button destroy flat view
corvid <corvid@lavabit.com>
parents: 1875
diff changeset
184 }