annotate dw/fltkcomplexbutton.hh @ 2024:f542084fa707

rm spaces
author corvid <corvid@lavabit.com>
date Mon, 16 May 2011 19:13:04 +0000
parents 73336563b6e7
children 5625ee0230ad
rev   line source
1325
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1031
diff changeset
1
1811
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
2 // fltkcomplexbutton.hh contains code from FLTK 1.3's FL/Fl_Button.H
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
3 // that is Copyright 1998-2010 by Bill Spitzak and others.
1325
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1031
diff changeset
4
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1031
diff changeset
5 /*
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1031
diff changeset
6 * This program is free software; you can redistribute it and/or modify
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1031
diff changeset
7 * it under the terms of the GNU General Public License as published by
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1031
diff changeset
8 * the Free Software Foundation; either version 3 of the License, or
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1031
diff changeset
9 * (at your option) any later version.
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1031
diff changeset
10 *
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1031
diff changeset
11 * This program is distributed in the hope that it will be useful,
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1031
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1031
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1031
diff changeset
14 * GNU General Public License for more details.
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1031
diff changeset
15 *
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1031
diff changeset
16 * You should have received a copy of the GNU General Public License
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1031
diff changeset
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23d34e319c36 fix up licensing
corvid <corvid@lavabit.com>
parents: 1031
diff changeset
18 */
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
19
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
20 #ifndef __FLTK_COMPLEX_BUTTON_HH__
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
21 #define __FLTK_COMPLEX_BUTTON_HH__
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
22
1811
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
23 #include <FL/Fl_Group.H>
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
24
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
25 // values for type()
2024
f542084fa707 rm spaces
corvid <corvid@lavabit.com>
parents: 1876
diff changeset
26 #define FL_NORMAL_BUTTON 0 /**< value() will be set to 1 during the press of the button and
1811
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
27 reverts back to 0 when the button is released */
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
28 #define FL_TOGGLE_BUTTON 1 ///< value() toggles between 0 and 1 at every click of the button
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
29 #define FL_RADIO_BUTTON (FL_RESERVED_TYPE+2) /**< is set to 1 at button press, and all other
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
30 buttons in the same group with <tt>type() == FL_RADIO_BUTTON</tt>
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
31 are set to zero.*/
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
32 #define FL_HIDDEN_BUTTON 3 ///< for Forms compatibility
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 extern FL_EXPORT Fl_Shortcut fl_old_shortcut(const char*);
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
35
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
36 namespace dw {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
37 namespace fltk {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
38 namespace ui {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
39
1811
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
40 class FL_EXPORT ComplexButton : public Fl_Group {
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
41
1811
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
42 int shortcut_;
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
43 char value_;
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
44 char oldval;
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
45 uchar down_box_;
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
46
1811
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
47 protected:
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 static Fl_Widget_Tracker *key_release_tracker;
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
50 static void key_release_timeout(void*);
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
51 void simulate_key_action();
2024
f542084fa707 rm spaces
corvid <corvid@lavabit.com>
parents: 1876
diff changeset
52
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
53 virtual void draw();
1811
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
54
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
55 public:
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
56
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
57 virtual int handle(int);
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
58
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
59 ComplexButton(int X, int Y, int W, int H, const char *L = 0);
1876
73336563b6e7 don't let complex button destroy flat view
corvid <corvid@lavabit.com>
parents: 1811
diff changeset
60 ~ComplexButton();
1811
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 int value(int v);
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
63
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
64 /**
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
65 Returns the current value of the button (0 or 1).
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
66 */
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
67 char value() const {return value_;}
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
68
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
69 /**
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
70 Same as \c value(1).
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
71 \see value(int v)
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
72 */
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
73 int set() {return value(1);}
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 /**
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
76 Same as \c value(0).
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
77 \see value(int v)
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 int clear() {return value(0);}
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
80
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
81 void setonly(); // this should only be called on FL_RADIO_BUTTONs
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
82
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
83 /**
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
84 Returns the current shortcut key for the button.
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
85 \retval int
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
86 */
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
87 int shortcut() const {return shortcut_;}
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
88
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
89 /**
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
90 Sets the shortcut key to \c s.
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
91 Setting this overrides the use of '\&' in the label().
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
92 The value is a bitwise OR of a key and a set of shift flags, for example:
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
93 <tt>FL_ALT | 'a'</tt>, or
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
94 <tt>FL_ALT | (FL_F + 10)</tt>, or just
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
95 <tt>'a'</tt>.
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
96 A value of 0 disables the shortcut.
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 The key can be any value returned by Fl::event_key(), but will usually be
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
99 an ASCII letter. Use a lower-case letter unless you require the shift key
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
100 to be held down.
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
101
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
102 The shift flags can be any set of values accepted by Fl::event_state().
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
103 If the bit is on, that shift key must be pushed. Meta, Alt, Ctrl, and
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
104 Shift must be off if they are not in the shift flags (zero for the other
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
105 bits indicates a "don't care" setting).
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
106 \param[in] s bitwise OR of key and shift flags
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
107 */
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
108 void shortcut(int s) {shortcut_ = s;}
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 /**
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
111 Returns the current down box type, which is drawn when value() is non-zero.
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
112 \retval Fl_Boxtype
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
113 */
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
114 Fl_Boxtype down_box() const {return (Fl_Boxtype)down_box_;}
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
115
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
116 /**
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
117 Sets the down box type. The default value of 0 causes FLTK to figure out
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
118 the correct matching down version of box().
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
119 \param[in] b down box type
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
120 */
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
121 void down_box(Fl_Boxtype b) {down_box_ = b;}
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
122
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
123 /// (for backwards compatibility)
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
124 void shortcut(const char *s) {shortcut(fl_old_shortcut(s));}
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
125
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
126 /// (for backwards compatibility)
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
127 Fl_Color down_color() const {return selection_color();}
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
128
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
129 /// (for backwards compatibility)
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
130 void down_color(unsigned c) {selection_color(c);}
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
131 };
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
132
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
133 } // namespace ui
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
134 } // namespace fltk
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
135 } // namespace dw
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
136
1811
630b3ab2f2bd fltkcomplexbutton from Fl_Button
corvid <corvid@lavabit.com>
parents: 1325
diff changeset
137 #endif
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
138
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
139 //
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
140 //