1 /*
2  *  This file is part of the XForms library package.
3  *
4  *  XForms is free software; you can redistribute it and/or modify it
5  *  under the terms of the GNU Lesser General Public License as
6  *  published by the Free Software Foundation; either version 2.1, or
7  *  (at your option) any later version.
8  *
9  *  XForms is distributed in the hope that it will be useful, but
10  *  WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the GNU
12  *  Lesser General Public License for more details.
13  *
14  *  You should have received a copy of the GNU Lesser General Public License
15  *  along with XForms.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 /********************** crop here for forms.h **********************/
19 
20 /**
21  * \file button.h
22  *
23  * All Buttons: regular button, light button and round button
24  *
25  */
26 
27 #ifndef FL_BUTTON_H
28 #define FL_BUTTON_H
29 
30 
31 typedef enum {
32     FL_NORMAL_BUTTON,
33     FL_PUSH_BUTTON,
34     FL_RADIO_BUTTON,
35     FL_HIDDEN_BUTTON,
36     FL_TOUCH_BUTTON,
37     FL_INOUT_BUTTON,
38     FL_RETURN_BUTTON,
39     FL_HIDDEN_RET_BUTTON,
40     FL_MENU_BUTTON
41 } FL_BUTTON_TYPE;
42 
43 #define FL_TOGGLE_BUTTON    FL_PUSH_BUTTON
44 
45 typedef struct {
46     Pixmap         pixmap,
47                    mask;
48     unsigned int   bits_w,
49                    bits_h;
50     int            val;             /* state of button (on/off) */
51     int            mousebut;        /* mouse button that caused the push     */
52     int            timdel;          /* time since last touch (TOUCH buttons) */
53     int            event;           /* what event triggers redraw            */
54     int            is_pushed;       /* set while drawn as pushed down        */
55     int            react_to[ 5 ];   /* mouse buttons button reacts to        */
56     long           cspecl;          /* reserved for class specfic stuff      */
57     void         * cspecv;          /* misc. things                          */
58     char         * filename;
59     Pixmap         focus_pixmap,
60                    focus_mask;
61     char         * focus_filename;
62 } FL_BUTTON_SPEC;
63 
64 #define FL_BUTTON_STRUCT FL_BUTTON_SPEC
65 
66 typedef void ( * FL_DrawButton )( FL_OBJECT * );
67 typedef void ( * FL_CleanupButton )( FL_BUTTON_STRUCT * );
68 
69 #define FL_DRAWBUTTON      FL_DrawButton
70 #define FL_CLEANUPBUTTON   FL_CleanupButton
71 
72 /* normal button default */
73 
74 #define FL_BUTTON_BOXTYPE           FL_UP_BOX
75 #define FL_BUTTON_COL1              FL_COL1
76 #define FL_BUTTON_COL2              FL_COL1
77 #define FL_BUTTON_LCOL              FL_LCOL
78 #define FL_BUTTON_ALIGN             FL_ALIGN_CENTER
79 #define FL_BUTTON_MCOL1             FL_MCOL
80 #define FL_BUTTON_MCOL2             FL_MCOL
81 #define FL_BUTTON_BW                FL_BOUND_WIDTH
82 
83 /* light button defaults */
84 
85 #define FL_LIGHTBUTTON_BOXTYPE      FL_UP_BOX
86 #define FL_LIGHTBUTTON_COL1         FL_COL1
87 #define FL_LIGHTBUTTON_COL2         FL_YELLOW
88 #define FL_LIGHTBUTTON_LCOL         FL_LCOL
89 #define FL_LIGHTBUTTON_ALIGN        ( FL_ALIGN_CENTER | FL_ALIGN_INSIDE )
90 #define FL_LIGHTBUTTON_TOPCOL       FL_COL1
91 #define FL_LIGHTBUTTON_MCOL         FL_MCOL
92 #define FL_LIGHTBUTTON_MINSIZE      ( ( FL_Coord ) 12 )
93 
94 /* round button defaults */
95 
96 #define FL_ROUNDBUTTON_BOXTYPE      FL_NO_BOX
97 #define FL_ROUNDBUTTON_COL1         FL_MCOL
98 #define FL_ROUNDBUTTON_COL2         FL_YELLOW
99 #define FL_ROUNDBUTTON_LCOL         FL_LCOL
100 #define FL_ROUNDBUTTON_ALIGN        FL_ALIGN_CENTER
101 #define FL_ROUNDBUTTON_TOPCOL       FL_COL1
102 #define FL_ROUNDBUTTON_MCOL         FL_MCOL
103 
104 /* round3d button defaults */
105 
106 #define FL_ROUND3DBUTTON_BOXTYPE    FL_NO_BOX
107 #define FL_ROUND3DBUTTON_COL1       FL_COL1
108 #define FL_ROUND3DBUTTON_COL2       FL_BLACK
109 #define FL_ROUND3DBUTTON_LCOL       FL_LCOL
110 #define FL_ROUND3DBUTTON_ALIGN      FL_ALIGN_CENTER
111 #define FL_ROUND3DBUTTON_TOPCOL     FL_COL1
112 #define FL_ROUND3DBUTTON_MCOL       FL_MCOL
113 
114 /* check button defaults */
115 
116 #define FL_CHECKBUTTON_BOXTYPE      FL_NO_BOX
117 #define FL_CHECKBUTTON_COL1         FL_COL1
118 #define FL_CHECKBUTTON_COL2         FL_YELLOW
119 #define FL_CHECKBUTTON_LCOL         FL_LCOL
120 #define FL_CHECKBUTTON_ALIGN        FL_ALIGN_CENTER
121 
122 #define FL_CHECKBUTTON_TOPCOL       FL_COL1
123 #define FL_CHECKBUTTON_MCOL         FL_MCOL
124 
125 /* bitmap button defaults */
126 
127 #define FL_BITMAPBUTTON_BOXTYPE     FL_UP_BOX
128 #define FL_BITMAPBUTTON_COL1        FL_COL1         /* bitmap background  */
129 #define FL_BITMAPBUTTON_COL2        FL_BLUE         /* "focus" color       */
130 #define FL_BITMAPBUTTON_LCOL        FL_LCOL         /* bitmap foreground   */
131 #define FL_BITMAPBUTTON_ALIGN       FL_ALIGN_BOTTOM
132 
133 /* bitmap button defaults */
134 
135 #define FL_PIXMAPBUTTON_BOXTYPE     FL_UP_BOX
136 #define FL_PIXMAPBUTTON_COL1        FL_BUTTON_COL1
137 #define FL_PIXMAPBUTTON_COL2        FL_BUTTON_COL2
138 #define FL_PIXMAPBUTTON_LCOL        FL_BUTTON_LCOL
139 #define FL_PIXMAPBUTTON_MCOL1       FL_BUTTON_MCOL1
140 #define FL_PIXMAPBUTTON_MCOL2       FL_BUTTON_MCOL2
141 #define FL_PIXMAPBUTTON_ALIGN       FL_ALIGN_BOTTOM
142 
143 /***** Routines *****/
144 
145 FL_EXPORT FL_OBJECT * fl_create_button( int          type,
146                                         FL_Coord     x,
147                                         FL_Coord     y,
148                                         FL_Coord     w,
149                                         FL_Coord     h,
150                                         const char * label );
151 
152 FL_EXPORT FL_OBJECT * fl_create_roundbutton( int          type,
153                                              FL_Coord     x,
154                                              FL_Coord     y,
155                                              FL_Coord     w,
156                                              FL_Coord     h,
157                                              const char * label );
158 
159 FL_EXPORT FL_OBJECT * fl_create_round3dbutton( int        type,
160                                                FL_Coord   x,
161                                                FL_Coord   y,
162                                                FL_Coord   w,
163                                                FL_Coord   h,
164                                                const char * label );
165 
166 FL_EXPORT FL_OBJECT * fl_create_lightbutton( int          type,
167                                              FL_Coord     x,
168                                              FL_Coord     y,
169                                              FL_Coord     w,
170                                              FL_Coord     h,
171                                              const char * label );
172 
173 FL_EXPORT FL_OBJECT * fl_create_checkbutton( int          type,
174                                              FL_Coord     x,
175                                              FL_Coord     y,
176                                              FL_Coord     w,
177                                              FL_Coord     h,
178                                              const char * label );
179 
180 FL_EXPORT FL_OBJECT * fl_create_bitmapbutton( int          type,
181                                               FL_Coord     x,
182                                               FL_Coord     y,
183                                               FL_Coord     w,
184                                               FL_Coord     h,
185                                               const char * label );
186 
187 FL_EXPORT FL_OBJECT * fl_create_pixmapbutton( int          type,
188                                               FL_Coord     x,
189                                               FL_Coord     y,
190                                               FL_Coord     w,
191                                               FL_Coord     h,
192                                               const char * label );
193 
194 FL_EXPORT FL_OBJECT * fl_create_scrollbutton( int          type,
195                                               FL_Coord     x,
196                                               FL_Coord     y,
197                                               FL_Coord     w,
198                                               FL_Coord     h,
199                                               const char * label );
200 
201 FL_EXPORT FL_OBJECT * fl_create_labelbutton( int           type,
202                                              FL_Coord      x,
203                                              FL_Coord      y,
204                                              FL_Coord      w,
205                                              FL_Coord      h,
206                                              const char * label );
207 
208 FL_EXPORT FL_OBJECT *fl_add_roundbutton( int          type,
209                                          FL_Coord     x,
210                                          FL_Coord     y,
211                                          FL_Coord     w,
212                                          FL_Coord     h,
213                                          const char * label );
214 
215 FL_EXPORT FL_OBJECT * fl_add_round3dbutton( int          type,
216                                             FL_Coord     x,
217                                             FL_Coord     y,
218                                             FL_Coord     w,
219                                             FL_Coord     h,
220                                             const char * label );
221 
222 FL_EXPORT FL_OBJECT * fl_add_lightbutton( int         type,
223                                           FL_Coord    x,
224                                           FL_Coord    y,
225                                           FL_Coord    w,
226                                           FL_Coord    h,
227                                           const char * label );
228 
229 FL_EXPORT FL_OBJECT * fl_add_checkbutton( int          type,
230                                           FL_Coord     x,
231                                           FL_Coord     y,
232                                           FL_Coord     w,
233                                           FL_Coord     h,
234                                           const char * label );
235 
236 FL_EXPORT FL_OBJECT * fl_add_button( int          type,
237                                      FL_Coord     x,
238                                      FL_Coord     y,
239                                      FL_Coord     w,
240                                      FL_Coord     h,
241                                      const char * label );
242 
243 FL_EXPORT FL_OBJECT * fl_add_bitmapbutton( int          type,
244                                            FL_Coord     x,
245                                            FL_Coord     y,
246                                            FL_Coord     w,
247                                            FL_Coord     h,
248                                            const char * label );
249 
250 FL_EXPORT FL_OBJECT * fl_add_scrollbutton( int          type,
251                                            FL_Coord     x,
252                                            FL_Coord     y,
253                                            FL_Coord     w,
254                                            FL_Coord     h,
255                                            const char * label );
256 
257 FL_EXPORT FL_OBJECT * fl_add_labelbutton( int          type,
258                                           FL_Coord     x,
259                                           FL_Coord     y,
260                                           FL_Coord     w,
261                                           FL_Coord     h,
262                                           const char * label );
263 
264 #define fl_set_bitmapbutton_file  fl_set_bitmap_file
265 
266 FL_EXPORT void fl_set_bitmapbutton_data( FL_OBJECT     * ob,
267                                          int             w,
268                                          int             h,
269                                          unsigned char * bits );
270 
271 #define fl_set_bitmapbutton_datafile  fl_set_bitmapbutton_file
272 
273 FL_EXPORT FL_OBJECT * fl_add_pixmapbutton( int          type,
274                                            FL_Coord     x,
275                                            FL_Coord     y,
276                                            FL_Coord     w,
277                                            FL_Coord     h,
278                                            const char * label );
279 
280 #define fl_set_pixmapbutton_data       fl_set_pixmap_data
281 #define fl_set_pixmapbutton_file       fl_set_pixmap_file
282 #define fl_set_pixmapbutton_pixmap     fl_set_pixmap_pixmap
283 #define fl_get_pixmapbutton_pixmap     fl_get_pixmap_pixmap
284 #define fl_set_pixmapbutton_align      fl_set_pixmap_align
285 #define fl_free_pixmapbutton_pixmap    fl_free_pixmap_pixmap
286 #define fl_set_pixmapbutton_datafile   fl_set_pixmapbutton_file
287 #define fl_set_pixmapbutton_show_focus fl_set_pixmapbutton_focus_outline
288 
289 
290 FL_EXPORT void fl_set_pixmapbutton_focus_outline( FL_OBJECT * ob,
291                                                   int         yes );
292 
293 FL_EXPORT void fl_set_pixmapbutton_focus_data( FL_OBJECT  * ob,
294                                                char      ** bits );
295 
296 FL_EXPORT void fl_set_pixmapbutton_focus_file( FL_OBJECT  * ob,
297                                                const char * fname );
298 
299 FL_EXPORT void fl_set_pixmapbutton_focus_pixmap( FL_OBJECT * ob,
300                                                  Pixmap      id,
301                                                  Pixmap      mask );
302 
303 FL_EXPORT int fl_get_button( FL_OBJECT * ob );
304 
305 FL_EXPORT void fl_set_button( FL_OBJECT * ob,
306                               int         pushed );
307 
308 FL_EXPORT int fl_get_button_numb( FL_OBJECT * ob );
309 
310 #define fl_set_button_shortcut  fl_set_object_shortcut
311 
312 FL_EXPORT FL_OBJECT * fl_create_generic_button( int          objclass,
313                                                 int          type,
314                                                 FL_Coord     x,
315                                                 FL_Coord     y,
316                                                 FL_Coord     w,
317                                                 FL_Coord     h,
318                                                 const char * label );
319 
320 FL_EXPORT void fl_add_button_class( int              bclass,
321                                     FL_DrawButton    drawit,
322                                     FL_CleanupButton cleanup );
323 
324 FL_EXPORT void fl_set_button_mouse_buttons( FL_OBJECT    * ob,
325                                             unsigned int   buttons );
326 
327 FL_EXPORT void fl_get_button_mouse_buttons( FL_OBJECT    * ob,
328                                             unsigned int * buttons );
329 
330 #endif /* ! defined FL_BUTTON_H */
331