comparison dw/fltkcomplexbutton.hh @ 2035:5625ee0230ad

clean out fltkcomplexbutton a bit
author corvid <corvid@lavabit.com>
date Wed, 18 May 2011 16:19:58 +0000
parents f542084fa707
children 6a8f4de33240
comparison
equal deleted inserted replaced
2034:7cad4651d972 2035:5625ee0230ad
20 #ifndef __FLTK_COMPLEX_BUTTON_HH__ 20 #ifndef __FLTK_COMPLEX_BUTTON_HH__
21 #define __FLTK_COMPLEX_BUTTON_HH__ 21 #define __FLTK_COMPLEX_BUTTON_HH__
22 22
23 #include <FL/Fl_Group.H> 23 #include <FL/Fl_Group.H>
24 24
25 // values for type()
26 #define FL_NORMAL_BUTTON 0 /**< value() will be set to 1 during the press of the button and
27 reverts back to 0 when the button is released */
28 #define FL_TOGGLE_BUTTON 1 ///< value() toggles between 0 and 1 at every click of the button
29 #define FL_RADIO_BUTTON (FL_RESERVED_TYPE+2) /**< is set to 1 at button press, and all other
30 buttons in the same group with <tt>type() == FL_RADIO_BUTTON</tt>
31 are set to zero.*/
32 #define FL_HIDDEN_BUTTON 3 ///< for Forms compatibility
33
34 extern FL_EXPORT Fl_Shortcut fl_old_shortcut(const char*); 25 extern FL_EXPORT Fl_Shortcut fl_old_shortcut(const char*);
35 26
36 namespace dw { 27 namespace dw {
37 namespace fltk { 28 namespace fltk {
38 namespace ui { 29 namespace ui {
43 char value_; 34 char value_;
44 char oldval; 35 char oldval;
45 uchar down_box_; 36 uchar down_box_;
46 37
47 protected: 38 protected:
48
49 static Fl_Widget_Tracker *key_release_tracker;
50 static void key_release_timeout(void*);
51 void simulate_key_action();
52
53 virtual void draw(); 39 virtual void draw();
54 40
55 public: 41 public:
56
57 virtual int handle(int); 42 virtual int handle(int);
58 43
59 ComplexButton(int X, int Y, int W, int H, const char *L = 0); 44 ComplexButton(int X, int Y, int W, int H, const char *L = 0);
60 ~ComplexButton(); 45 ~ComplexButton();
61 46
63 48
64 /** 49 /**
65 Returns the current value of the button (0 or 1). 50 Returns the current value of the button (0 or 1).
66 */ 51 */
67 char value() const {return value_;} 52 char value() const {return value_;}
68
69 /**
70 Same as \c value(1).
71 \see value(int v)
72 */
73 int set() {return value(1);}
74
75 /**
76 Same as \c value(0).
77 \see value(int v)
78 */
79 int clear() {return value(0);}
80
81 void setonly(); // this should only be called on FL_RADIO_BUTTONs
82
83 /**
84 Returns the current shortcut key for the button.
85 \retval int
86 */
87 int shortcut() const {return shortcut_;}
88
89 /**
90 Sets the shortcut key to \c s.
91 Setting this overrides the use of '\&' in the label().
92 The value is a bitwise OR of a key and a set of shift flags, for example:
93 <tt>FL_ALT | 'a'</tt>, or
94 <tt>FL_ALT | (FL_F + 10)</tt>, or just
95 <tt>'a'</tt>.
96 A value of 0 disables the shortcut.
97
98 The key can be any value returned by Fl::event_key(), but will usually be
99 an ASCII letter. Use a lower-case letter unless you require the shift key
100 to be held down.
101
102 The shift flags can be any set of values accepted by Fl::event_state().
103 If the bit is on, that shift key must be pushed. Meta, Alt, Ctrl, and
104 Shift must be off if they are not in the shift flags (zero for the other
105 bits indicates a "don't care" setting).
106 \param[in] s bitwise OR of key and shift flags
107 */
108 void shortcut(int s) {shortcut_ = s;}
109 53
110 /** 54 /**
111 Returns the current down box type, which is drawn when value() is non-zero. 55 Returns the current down box type, which is drawn when value() is non-zero.
112 \retval Fl_Boxtype 56 \retval Fl_Boxtype
113 */ 57 */
119 \param[in] b down box type 63 \param[in] b down box type
120 */ 64 */
121 void down_box(Fl_Boxtype b) {down_box_ = b;} 65 void down_box(Fl_Boxtype b) {down_box_ = b;}
122 66
123 /// (for backwards compatibility) 67 /// (for backwards compatibility)
124 void shortcut(const char *s) {shortcut(fl_old_shortcut(s));}
125
126 /// (for backwards compatibility)
127 Fl_Color down_color() const {return selection_color();}
128
129 /// (for backwards compatibility)
130 void down_color(unsigned c) {selection_color(c);} 68 void down_color(unsigned c) {selection_color(c);}
131 }; 69 };
132 70
133 } // namespace ui 71 } // namespace ui
134 } // namespace fltk 72 } // namespace fltk