source: NonGTP/FLTK/include/fltk/forms.h @ 773

Revision 773, 33.1 KB checked in by gumbau, 19 years ago (diff)

FLTK imported to SVN repository to be linked agains the GeoTool? application

RevLine 
[773]1//
2// "$Id: forms.h 3887 2004-11-12 06:50:20Z spitzak $"
3//
4// Forms emulation header file for the Fast Light Tool Kit (FLTK).
5//
6// Copyright 1998-2003 by Bill Spitzak and others.
7//
8// This library is free software; you can redistribute it and/or
9// modify it under the terms of the GNU Library General Public
10// License as published by the Free Software Foundation; either
11// version 2 of the License, or (at your option) any later version.
12//
13// This library is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16// Library General Public License for more details.
17//
18// You should have received a copy of the GNU Library General Public
19// License along with this library; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21// USA.
22//
23// Please report all bugs and problems to "fltk-bugs@fltk.org".
24//
25
26#ifndef __FORMS_H__
27#define __FORMS_H__
28
29#include <fltk/Fl.h>
30#include <fltk/Fl_Group.h>
31#include <fltk/Fl_Window.h>
32#include <fltk/fl_draw.h>
33
34typedef Fl_Widget FL_OBJECT;
35typedef Fl_Window FL_FORM;
36
37////////////////////////////////////////////////////////////////
38// Random constants & symbols defined by forms.h file:
39
40#ifndef NULL
41#define NULL 0
42#endif
43#ifndef FALSE
44#define FALSE 0
45#define TRUE 1
46#endif
47
48#define FL_ON           1
49#define FL_OK           1
50#define FL_VALID        1
51#define FL_PREEMPT      1
52#define FL_AUTO         2
53#define FL_WHEN_NEEDED  FL_AUTO
54#define FL_OFF          0
55#define FL_NONE         0
56#define FL_CANCEL       0
57#define FL_INVALID      0
58#define FL_IGNORE       -1
59#define FL_CLOSE        -2
60
61#define FL_LCOL         FL_BLACK
62#define FL_COL1         FL_GRAY
63#define FL_MCOL         FL_LIGHT1
64#define FL_LEFT_BCOL    FL_LIGHT3 // 53 is better match
65#define FL_TOP_BCOL     FL_LIGHT2 // 51
66#define FL_BOTTOM_BCOL  FL_DARK2  // 40
67#define FL_RIGHT_BCOL   FL_DARK3  // 36
68#define FL_INACTIVE     FL_INACTIVE_COLOR
69#define FL_INACTIVE_COL FL_INACTIVE_COLOR
70#define FL_FREE_COL1    FL_FREE_COLOR
71#define FL_FREE_COL2    ((Fl_Color)(FL_FREE_COLOR+1))
72#define FL_FREE_COL3    ((Fl_Color)(FL_FREE_COLOR+2))
73#define FL_FREE_COL4    ((Fl_Color)(FL_FREE_COLOR+3))
74#define FL_FREE_COL5    ((Fl_Color)(FL_FREE_COLOR+4))
75#define FL_FREE_COL6    ((Fl_Color)(FL_FREE_COLOR+5))
76#define FL_FREE_COL7    ((Fl_Color)(FL_FREE_COLOR+6))
77#define FL_FREE_COL8    ((Fl_Color)(FL_FREE_COLOR+7))
78#define FL_FREE_COL9    ((Fl_Color)(FL_FREE_COLOR+8))
79#define FL_FREE_COL10   ((Fl_Color)(FL_FREE_COLOR+9))
80#define FL_FREE_COL11   ((Fl_Color)(FL_FREE_COLOR+10))
81#define FL_FREE_COL12   ((Fl_Color)(FL_FREE_COLOR+11))
82#define FL_FREE_COL13   ((Fl_Color)(FL_FREE_COLOR+12))
83#define FL_FREE_COL14   ((Fl_Color)(FL_FREE_COLOR+13))
84#define FL_FREE_COL15   ((Fl_Color)(FL_FREE_COLOR+14))
85#define FL_FREE_COL16   ((Fl_Color)(FL_FREE_COLOR+15))
86#define FL_TOMATO       ((Fl_Color)(131))
87#define FL_INDIANRED    ((Fl_Color)(164))
88#define FL_SLATEBLUE    ((Fl_Color)(195))
89#define FL_DARKGOLD     ((Fl_Color)(84))
90#define FL_PALEGREEN    ((Fl_Color)(157))
91#define FL_ORCHID       ((Fl_Color)(203))
92#define FL_DARKCYAN     ((Fl_Color)(189))
93#define FL_DARKTOMATO   ((Fl_Color)(113))
94#define FL_WHEAT        ((Fl_Color)(174))
95
96#define FL_ALIGN_BESIDE FL_ALIGN_INSIDE
97
98#define FL_PUP_TOGGLE   2 // FL_MENU_TOGGLE
99#define FL_PUP_INACTIVE 1 // FL_MENU_INACTIVE
100#define FL_NO_FRAME     FL_NO_BOX
101#define FL_ROUNDED3D_UPBOX      FL_ROUND_UP_BOX
102#define FL_ROUNDED3D_DOWNBOX    FL_ROUND_DOWN_BOX
103#define FL_OVAL3D_UPBOX         FL_ROUND_UP_BOX
104#define FL_OVAL3D_DOWNBOX       FL_ROUND_DOWN_BOX
105
106#define FL_MBUTTON1     1
107#define FL_LEFTMOUSE    1
108#define FL_MBUTTON2     2
109#define FL_MIDDLEMOUSE  2
110#define FL_MBUTTON3     3
111#define FL_RIGHTMOUSE   3
112#define FL_MBUTTON4     4
113#define FL_MBUTTON5     5
114
115#define FL_INVALID_STYLE 255
116#define FL_NORMAL_STYLE 0
117#define FL_BOLD_STYLE   1
118#define FL_ITALIC_STYLE 2
119#define FL_BOLDITALIC_STYLE 3
120#define FL_FIXED_STYLE  4
121#define FL_FIXEDBOLD_STYLE 5
122#define FL_FIXEDITALIC_STYLE 6
123#define FL_FIXEDBOLDITALIC_STYLE 7
124#define FL_TIMES_STYLE  8
125#define FL_TIMESBOLD_STYLE 9
126#define FL_TIMESITALIC_STYLE 10
127#define FL_TIMESBOLDITALIC_STYLE 11
128
129// hacks to change the labeltype() when passed to fl_set_object_lstyle():
130#define FL_SHADOW_STYLE         0x100
131#define FL_ENGRAVED_STYLE       0x200
132#define FL_EMBOSSED_STYLE       0x300
133
134// size values are different from XForms, match older Forms:
135#define FL_TINY_SIZE    8
136#define FL_SMALL_SIZE   11 // 10
137#undef FL_NORMAL_SIZE
138#define FL_NORMAL_SIZE  14 // 12
139#define FL_MEDIUM_SIZE  18 // 14
140#define FL_LARGE_SIZE   24 // 18
141#define FL_HUGE_SIZE    32 // 24
142#define FL_DEFAULT_SIZE FL_SMALL_SIZE
143#define FL_TINY_FONT    FL_TINY_SIZE
144#define FL_SMALL_FONT   FL_SMALL_SIZE
145#define FL_NORMAL_FONT  FL_NORMAL_SIZE
146#define FL_MEDIUM_FONT  FL_MEDIUM_SIZE
147#define FL_LARGE_FONT   FL_LARGE_SIZE
148#define FL_HUGE_FONT    FL_HUGE_SIZE
149#define FL_NORMAL_FONT1 FL_SMALL_FONT
150#define FL_NORMAL_FONT2 FL_NORMAL_FONT
151#define FL_DEFAULT_FONT FL_SMALL_FONT
152
153#define FL_RETURN_END_CHANGED   FL_WHEN_RELEASE
154#define FL_RETURN_CHANGED       FL_WHEN_CHANGED
155#define FL_RETURN_END           FL_WHEN_RELEASE_ALWAYS
156#define FL_RETURN_ALWAYS        (FL_WHEN_CHANGED|FL_WHEN_NOT_CHANGED)
157
158#define FL_BOUND_WIDTH  3
159
160typedef int FL_Coord;
161typedef int FL_COLOR;
162
163////////////////////////////////////////////////////////////////
164// fltk interaction:
165
166#define FL_CMD_OPT void
167extern FL_FORMS_API void fl_initialize(int*, char*[], const char*, FL_CMD_OPT*, int);
168inline void fl_finish() {}
169
170typedef void (*FL_IO_CALLBACK) (int, void*);
171inline void fl_add_io_callback(int fd, short w, FL_IO_CALLBACK cb, void* v) {
172  Fl::add_fd(fd,w,cb,v);}
173inline void fl_remove_io_callback(int fd, short, FL_IO_CALLBACK) {
174  Fl::remove_fd(fd);} // removes all the callbacks!
175
176// type of callback is different and no "id" number is returned:
177inline void fl_add_timeout(long msec, void (*cb)(void*), void* v) {
178  Fl::add_timeout(msec*.001, (Fl_Timeout_Handler)cb, v);}
179inline void fl_remove_timeout(int) {}
180
181// type of callback is different!
182inline void fl_set_idle_callback(void (*cb)()) {Fl::set_idle(cb);}
183
184FL_FORMS_API Fl_Widget* fl_do_forms(void);
185FL_FORMS_API Fl_Widget* fl_check_forms();
186inline Fl_Widget* fl_do_only_forms(void) {return fl_do_forms();}
187inline Fl_Widget* fl_check_only_forms(void) {return fl_check_forms();}
188
189// because of new redraw behavior, these are no-ops:
190inline void fl_freeze_object(Fl_Widget*) {}
191inline void fl_unfreeze_object(Fl_Widget*) {}
192inline void fl_freeze_form(Fl_Window*) {}
193inline void fl_unfreeze_form(Fl_Window*) {}
194inline void fl_freeze_all_forms() {}
195inline void fl_unfreeze_all_forms() {}
196
197inline void fl_set_focus_object(Fl_Window*, Fl_Widget* o) {Fl::focus(o);}
198inline void fl_reset_focus_object(Fl_Widget* o) {Fl::focus(o);}
199#define fl_set_object_focus fl_set_focus_object
200
201// void fl_set_form_atclose(Fl_Window*w,int (*cb)(Fl_Window*,void*),void* v)
202// void fl_set_atclose(int (*cb)(Fl_Window*,void*),void*)
203// fl_set_form_atactivate/atdeactivate not implemented!
204
205////////////////////////////////////////////////////////////////
206// Fl_Widget:
207
208inline void fl_set_object_boxtype(Fl_Widget* o, Fl_Boxtype a) {o->box(a);}
209inline void fl_set_object_lsize(Fl_Widget* o,int s) {o->label_size(s);}
210FL_FORMS_API void fl_set_object_lstyle(Fl_Widget* o,int a);
211inline void fl_set_object_lcol(Fl_Widget* o, unsigned a) {o->label_color((Fl_Color)a);}
212#define fl_set_object_lcolor  fl_set_object_lcol
213inline void fl_set_object_lalign(Fl_Widget* o, Fl_Align a) { o->clear_flag(FL_ALIGN_MASK); o->set_flag(a);}
214#define fl_set_object_align fl_set_object_lalign
215inline void fl_set_object_color(Fl_Widget* o,unsigned a,unsigned b) {o->color((Fl_Color)a); o->selection_color((Fl_Color)b);}
216inline void fl_set_object_label(Fl_Widget* o, const char* a) {o->label(a); o->redraw();}
217inline void fl_set_object_position(Fl_Widget*o,int x,int y) {o->position(x,y);}
218inline void fl_set_object_size(Fl_Widget* o, int w, int h) {o->size(w,h);}
219inline void fl_set_object_geometry(Fl_Widget* o,int x,int y,int w,int h) {o->resize(x,y,w,h);}
220
221inline void fl_get_object_geometry(Fl_Widget* o,int*x,int*y,int*w,int*h) {
222  *x = o->x(); *y = o->y(); *w = o->w(); *h = o->h();}
223inline void fl_get_object_position(Fl_Widget* o,int*x,int*y) {
224  *x = o->x(); *y = o->y();}
225
226typedef void (*Forms_CB)(Fl_Widget*, long);
227inline void fl_set_object_callback(Fl_Widget*o,Forms_CB c,long a) {o->callback(c,a);}
228#define fl_set_call_back      fl_set_object_callback
229inline void fl_call_object_callback(Fl_Widget* o) {o->do_callback();}
230inline void fl_trigger_object(Fl_Widget* o) {o->do_callback();}
231inline void fl_set_object_return(Fl_Widget* o, int v) {
232  o->when(v|FL_WHEN_RELEASE);}
233
234inline void fl_redraw_object(Fl_Widget* o) {o->redraw();}
235inline void fl_show_object(Fl_Widget* o) {o->show();}
236inline void fl_hide_object(Fl_Widget* o) {o->hide();}
237inline void fl_free_object(Fl_Widget* x) {delete x;}
238inline void fl_delete_object(Fl_Widget* o) {((Fl_Group*)(o->parent()))->remove(*o);}
239inline void fl_activate_object(Fl_Widget* o) {o->activate();}
240inline void fl_deactivate_object(Fl_Widget* o) {o->deactivate();}
241
242inline void fl_add_object(Fl_Window* f, Fl_Widget* x) {f->add(x);}
243inline void fl_insert_object(Fl_Widget* o, Fl_Widget* b) {
244    ((Fl_Group*)(b->parent()))->insert(*o,b);}
245
246inline Fl_Window* FL_ObjWin(Fl_Widget* o) {return o->window();}
247
248////////////////////////////////////////////////////////////////
249// things that appered in the demos a lot that I don't emulate, but
250// I did not want to edit out of all the demos...
251
252inline int fl_get_border_width() {return 3;}
253inline void fl_set_border_width(int) {}
254inline void fl_set_object_dblbuffer(Fl_Widget*, int) {}
255inline void fl_set_form_dblbuffer(Fl_Window*, int) {}
256
257////////////////////////////////////////////////////////////////
258// Fl_Window:
259
260inline void fl_free_form(Fl_Window* x) {delete x;}
261inline void fl_redraw_form(Fl_Window* f) {f->redraw();}
262
263inline Fl_Window* fl_bgn_form(Fl_Boxtype b,int w,int h) {
264  Fl_Window* g = new Fl_Window(w,h,0);
265  g->box(b);
266  return g;
267}
268inline void fl_addto_form(Fl_Window* f) {f->begin();}
269inline Fl_Group* fl_bgn_group() {return new Fl_Group(0,0,0,0,0);}
270inline void fl_addto_group(Fl_Widget* o) {((Fl_Group* )o)->begin();}
271FL_FORMS_API void fl_end_group();
272FL_FORMS_API void fl_end_form();
273#define resizebox _ddfdesign_kludge()
274
275inline void fl_scale_form(Fl_Window* f, double x, double y) {
276  f->resizable(f); f->size(int(f->w()*x),int(f->h()*y));}
277inline void fl_set_form_position(Fl_Window* f,int x,int y) {f->position(x,y);}
278inline void fl_set_form_size(Fl_Window* f, int w, int h) {f->size(w,h);}
279inline void fl_set_form_geometry(Fl_Window* f,int x,int y,int w,int h) {
280  f->resize(x,y,w,h);}
281#define fl_set_initial_placement fl_set_form_geometry
282inline void fl_adjust_form_size(Fl_Window*) {}
283
284FL_FORMS_API void fl_show_form(Fl_Window* f,int p,int b,const char* n);
285enum {  // "p" argument values:
286  FL_PLACE_FREE = 0,    // make resizable
287  FL_PLACE_MOUSE = 1,   // mouse centered on form
288  FL_PLACE_CENTER = 2,  // center of the screen
289  FL_PLACE_POSITION = 4,// fixed position, resizable
290  FL_PLACE_SIZE = 8,    // fixed size, normal fltk behavior
291  FL_PLACE_GEOMETRY =16,// fixed size and position
292  FL_PLACE_ASPECT = 32, // keep aspect ratio (ignored)
293  FL_PLACE_FULLSCREEN=64,// fill screen
294  FL_PLACE_HOTSPOT = 128,// enables hotspot
295  FL_PLACE_ICONIC = 256,// iconic (ignored)
296  FL_FREE_SIZE=(1<<14), // force resizable
297  FL_FIX_SIZE =(1<<15)  // force off resizable
298};
299#define FL_PLACE_FREE_CENTER (FL_PLACE_CENTER|FL_FREE_SIZE)
300#define FL_PLACE_CENTERFREE  (FL_PLACE_CENTER|FL_FREE_SIZE)
301enum {  // "b" arguement values:
302  FL_NOBORDER = 0,
303  FL_FULLBORDER,
304  FL_TRANSIENT
305//FL_MODAL = (1<<8)     // not implemented yet in Forms
306};
307inline void fl_set_form_hotspot(Fl_Window* w,int x,int y) {w->hotspot(x,y);}
308inline void fl_set_form_hotobject(Fl_Window* w, Fl_Widget* o) {w->hotspot(o);}
309extern FL_FORMS_API char fl_flip;       // in forms.C
310inline void fl_flip_yorigin() {fl_flip = 1;}
311
312#define fl_prepare_form_window fl_show_form
313inline void fl_show_form_window(Fl_Window*) {}
314
315inline void fl_raise_form(Fl_Window* f) {f->show();}
316
317inline void fl_hide_form(Fl_Window* f) {f->hide();}
318inline void fl_pop_form(Fl_Window* f) {f->show();}
319
320extern FL_FORMS_API char fl_modal_next; // in forms.C
321inline void fl_activate_all_forms() {}
322inline void fl_deactivate_all_forms() {fl_modal_next = 1;}
323inline void fl_deactivate_form(Fl_Window*w) {w->deactivate();}
324inline void fl_activate_form(Fl_Window*w) {w->activate();}
325
326inline void fl_set_form_title(Fl_Window* f, const char* s) {f->label(s);}
327inline void fl_title_form(Fl_Window* f, const char* s) {f->label(s);}
328
329typedef void (*Forms_FormCB)(Fl_Widget*);
330inline void fl_set_form_callback(Fl_Window* f,Forms_FormCB c) {f->callback(c);}
331#define fl_set_form_call_back fl_set_form_callback
332
333inline void fl_init() {}
334inline void fl_set_graphics_mode(int r, int /*d*/) {
335  Fl::visual(r ? FL_RGB : FL_INDEX);
336  // d should add FL_DOUBLE, but that always fails in fltk 2.0
337}
338
339inline int fl_form_is_visible(Fl_Window* f) {return f->visible();}
340
341inline int fl_mouse_button() {return Fl::event_button();}
342#define fl_mousebutton fl_mouse_button
343
344#define fl_free       free
345#define fl_malloc     malloc
346#define fl_calloc     calloc
347#define fl_realloc    realloc
348
349////////////////////////////////////////////////////////////////
350// Drawing functions.  Only usable inside an Fl_Free object?
351
352#if 0
353inline void fl_drw_box(Fl_Boxtype b,int x,int y,int w,int h,Fl_Color bgc,int=3) {
354    b->draw(x,y,w,h,bgc);}
355inline void fl_drw_frame(Fl_Boxtype b,int x,int y,int w,int h,Fl_Color bgc,int=3) {
356    b->draw(x,y,w,h,bgc,FL_FRAME_ONLY);}
357#endif
358
359inline void fl_drw_text(Fl_Align align, int x, int y, int w, int h,
360                  Fl_Color fgcolor, int size, Fl_Font style,
361                  const char* s) {
362  fl_font(style,size);
363  fl_color(fgcolor);
364  fl_draw(s,x,y,w,h,align);
365}
366
367// this does not work except for CENTER...
368inline void fl_drw_text_beside(Fl_Align align, int x, int y, int w, int h,
369                  Fl_Color fgcolor, int size, Fl_Font style,
370                  const char* s) {
371  fl_font(style,size);
372  fl_color(fgcolor);
373  fl_draw(s,x,y,w,h,align);
374}
375
376//inline void fl_set_font_name(Fl_Font n,const char* s) {fl_set_font(n,s);}
377
378inline void fl_mapcolor(Fl_Color c, uchar r, uchar g, uchar b) {
379  fl_set_color(c,fl_rgb(r,g,b));}
380#define fl_set_clipping(x,y,w,h) fl_clip(x,y,w,h)
381#define fl_unset_clipping() fl_pop_clip()
382
383////////////////////////////////////////////////////////////////
384// Forms classes:
385
386inline Fl_Widget* fl_add_new(Fl_Widget* p) {return p;}
387inline Fl_Widget* fl_add_new(uchar t,Fl_Widget* p) {p->type(t); return p;}
388
389#define forms_constructor(type,name) \
390inline type* name(uchar t,int x,int y,int w,int h,const char* l) { \
391 return (type*)(fl_add_new(t, new type(x,y,w,h,l)));}
392#define forms_constructort(type,name) \
393inline type* name(uchar t,int x,int y,int w,int h,const char* l) { \
394 return (type*)(fl_add_new(new type(t,x,y,w,h,l)));}
395#define forms_constructorb(type,name) \
396inline type* name(Fl_Boxtype t,int x,int y,int w,int h,const char* l) { \
397 return (type*)(fl_add_new(new type(t,x,y,w,h,l)));}
398
399#include "Fl_FormsBitmap.h"
400#define FL_NORMAL_BITMAP FL_NO_BOX
401forms_constructorb(Fl_FormsBitmap, fl_add_bitmap)
402inline void fl_set_bitmap_data(Fl_Widget* o, int w, int h, const uchar* b) {
403    ((Fl_FormsBitmap*)o)->set(w,h,b);
404}
405
406#include "Fl_FormsPixmap.h"
407#define FL_NORMAL_PIXMAP FL_NO_BOX
408forms_constructorb(Fl_FormsPixmap, fl_add_pixmap)
409inline void fl_set_pixmap_data(Fl_Widget* o, char*const* b) {
410    ((Fl_FormsPixmap*)o)->set(b);
411}
412//inline void fl_set_pixmap_file(Fl_Widget*, const char*);
413inline void fl_set_pixmap_align(Fl_Widget* o,Fl_Align a,int,int) { o->clear_flag(FL_ALIGN_MASK); o->set_flag(a);}
414//inline void fl_set_pixmap_colorcloseness(int, int, int);
415
416#include <fltk/Fl_Box.h>
417forms_constructorb(Fl_Box, fl_add_box)
418
419#include <fltk/Fl_Browser.h>
420forms_constructor(Fl_Browser, fl_add_browser)
421
422inline void fl_clear_browser(Fl_Widget* o) {
423    ((Fl_Browser*)o)->clear();}
424inline void fl_add_browser_line(Fl_Widget* o, const char* s) {
425    ((Fl_Browser*)o)->add(s);}
426inline void fl_addto_browser(Fl_Widget* o, const char* s) {
427    ((Fl_Browser*)o)->add(s);} /* should also scroll to bottom */
428//inline void fl_addto_browser_chars(Fl_Widget*, const char*)
429//#define fl_append_browser fl_addto_browser_chars
430inline void fl_insert_browser_line(Fl_Widget* o, int n, const char* s) {
431    ((Fl_Browser*)o)->insert(n,s);}
432inline void fl_delete_browser_line(Fl_Widget* o, int n) {
433    ((Fl_Browser*)o)->remove(n);}
434inline void fl_replace_browser_line(Fl_Widget* o, int n, const char* s) {
435    ((Fl_Browser*)o)->replace(n,s);}
436inline char* fl_get_browser_line(Fl_Widget* o, int n) {
437    return (char*)(((Fl_Browser*)o)->text(n));}
438FL_FORMS_API int fl_load_browser(Fl_Widget* o, const char* f);
439inline void fl_select_browser_line(Fl_Widget* o, int n) {
440    ((Fl_Browser*)o)->select(n,1);}
441inline void fl_deselect_browser_line(Fl_Widget* o, int n) {
442    ((Fl_Browser*)o)->select(n,0);}
443inline void fl_deselect_browser(Fl_Widget* o) {
444    ((Fl_Browser*)o)->deselect();}
445inline int fl_isselected_browser_line(Fl_Widget* o, int n) {
446    return ((Fl_Browser*)o)->selected(n);}
447inline int fl_get_browser_topline(Fl_Widget* o) {
448    return ((Fl_Browser*)o)->topline();}
449inline int fl_get_browser(Fl_Widget* o) {
450    return ((Fl_Browser*)o)->value();}
451inline int fl_get_browser_maxline(Fl_Widget* o) {
452    return ((Fl_Browser*)o)->size();}
453//linline int fl_get_browser_screenlines(Fl_Widget*);
454inline void fl_set_browser_topline(Fl_Widget* o, int n) {
455    ((Fl_Browser*)o)->topline(n);}
456inline void fl_set_browser_fontsize(Fl_Widget* o, int s) {
457    ((Fl_Browser*)o)->text_size(s);}
458inline void fl_set_browser_fontstyle(Fl_Widget* o, int s) {
459    ((Fl_Browser*)o)->text_font(fl_fonts+s);}
460inline void fl_set_browser_specialkey(Fl_Widget* o, char c) {
461    ((Fl_Browser*)o)->format_char(c);}
462//inline void fl_set_browser_vscrollbar(Fl_Widget*, int);
463//inline void fl_set_browser_hscrollbar(Fl_Widget*, int);
464//inline void fl_set_browser_leftslider(Fl_Widget*, int);
465//#define fl_set_browser_leftscrollbar fl_set_browser_leftslider
466//inline void fl_set_browser_line_selectable(Fl_Widget*, int, int);
467//inline void fl_get_browser_dimension(Fl_Widget*,int*,int*,int*,int*);
468//inline void fl_set_browser_dblclick_callback(Fl_Widget*,FL_CALLBACKPTR,long);
469//inline void fl_set_browser_xoffset(Fl_Widget*, FL_Coord);
470//inline void fl_set_browser_scrollbarsize(Fl_Widget*, int, int);
471inline void fl_setdisplayed_browser_line(Fl_Widget* o, int n, int i) {
472    ((Fl_Browser*)o)->display(n,i);}
473inline int fl_isdisplayed_browser_line(Fl_Widget* o, int n) {
474    return ((Fl_Browser*)o)->displayed(n);}
475
476#include <fltk/Fl_Button.h>
477
478#define FL_NORMAL_BUTTON        0
479//#define FL_HIDDEN_BUTTON
480#define FL_TOUCH_BUTTON         4
481#define FL_INOUT_BUTTON         5
482#define FL_RETURN_BUTTON        6
483#define FL_HIDDEN_RET_BUTTON    7
484#define FL_PUSH_BUTTON          FL_TOGGLE_BUTTON
485#define FL_MENU_BUTTON          9
486
487FL_FORMS_API Fl_Button* fl_add_button(uchar t,int x,int y,int w,int h,const char* l);
488inline int fl_get_button(Fl_Widget* b) {return ((Fl_Button*)b)->value();}
489inline void fl_set_button(Fl_Widget* b, int v) {((Fl_Button*)b)->value(v);}
490inline int fl_get_button_numb(Fl_Widget*) {return Fl::event_button();}
491inline void fl_set_object_shortcut(Fl_Widget* b, const char* s, int=0) {
492  b->shortcut(fltk::key(s));}
493#define fl_set_button_shortcut fl_set_object_shortcut
494
495#include <fltk/Fl_Light_Button.h>
496forms_constructor(Fl_Light_Button, fl_add_lightbutton)
497
498#include <fltk/Fl_Round_Button.h>
499forms_constructor(Fl_Round_Button, fl_add_roundbutton)
500forms_constructor(Fl_Round_Button, fl_add_round3dbutton)
501
502#include <fltk/Fl_Check_Button.h>
503forms_constructor(Fl_Check_Button, fl_add_checkbutton)
504
505inline Fl_Widget* fl_add_bitmapbutton(int t,int x,int y,int w,int h,const char* l) {Fl_Widget* o = fl_add_button(t,x,y,w,h,l); return o;}
506inline void fl_set_bitmapbutton_data(Fl_Widget* o,int a,int b,uchar* c) {
507  (new Fl_Bitmap(c,a,b))->label(o);}  // does not delete old Fl_Bitmap!
508
509inline Fl_Widget* fl_add_pixmapbutton(int t,int x,int y,int w,int h,const char* l) {Fl_Widget* o = fl_add_button(t,x,y,w,h,l); return o;}
510inline void fl_set_pixmapbutton_data(Fl_Widget* o, const char*const* c) {
511  (new Fl_Pixmap(c))->label(o);}  // does not delete old Fl_Pixmap!
512
513// Fl_Canvas object not yet implemented!
514
515#include "Fl_Chart.h"
516
517forms_constructor(Fl_Chart, fl_add_chart)
518inline void fl_clear_chart(Fl_Widget* o) {
519  ((Fl_Chart*)o)->clear();}
520inline void fl_add_chart_value(Fl_Widget* o,double v,const char* s,uchar c){
521  ((Fl_Chart*)o)->add(v,s,c);}
522inline void fl_insert_chart_value(Fl_Widget* o, int i, double v, const char* s, uchar c) {
523  ((Fl_Chart*)o)->insert(i,v,s,c);}
524inline void fl_replace_chart_value(Fl_Widget* o, int i, double v, const char* s, uchar c) {
525  ((Fl_Chart*)o)->replace(i,v,s,c);}
526inline void fl_set_chart_bounds(Fl_Widget* o, double a, double b) {
527  ((Fl_Chart*)o)->bounds(a,b);}
528inline void fl_set_chart_maxnumb(Fl_Widget* o, int v) {
529  ((Fl_Chart*)o)->maxsize(v);}
530inline void fl_set_chart_autosize(Fl_Widget* o, int v) {
531  ((Fl_Chart*)o)->autosize(v);}
532inline void fl_set_chart_lstyle(Fl_Widget* o, Fl_Font v) {
533  ((Fl_Chart*)o)->text_font(v);}
534inline void fl_set_chart_lsize(Fl_Widget* o, int v) {
535  ((Fl_Chart*)o)->text_size(v);}
536inline void fl_set_chart_lcolor(Fl_Widget* o, unsigned v) {
537  ((Fl_Chart*)o)->text_color((Fl_Color)v);}
538#define fl_set_chart_lcol   fl_set_chart_lcolor
539
540#include <fltk/Fl_Choice.h>
541
542#define FL_NORMAL_CHOICE        0
543#define FL_NORMAL_CHOICE2       0
544#define FL_DROPLIST_CHOICE      0
545
546forms_constructor(Fl_Choice, fl_add_choice)
547inline void fl_clear_choice(Fl_Widget* o) {
548    ((Fl_Choice*)o)->clear();}
549inline void fl_addto_choice(Fl_Widget* o, const char* s) {
550    ((Fl_Choice*)o)->add(s);}
551inline void fl_replace_choice(Fl_Widget* o, int i, const char* s) {
552    ((Fl_Choice*)o)->replace(i-1,s);}
553inline void fl_delete_choice(Fl_Widget* o, int i) {
554    ((Fl_Choice*)o)->remove(i-1);}
555inline void fl_set_choice(Fl_Widget* o, int i) {
556    ((Fl_Choice*)o)->value(i-1);}
557// inline void fl_set_choice_text(Fl_Widget*, const char*);
558inline int fl_get_choice(Fl_Widget* o) {
559    return ((Fl_Choice*)o)->value()+1;}
560// inline const char* fl_get_choice_item_text(Fl_Widget*, int);
561// inline int fl_get_choice_maxitems(Fl_Widget*);
562inline const char* fl_get_choice_text(Fl_Widget* o) {
563    return ((Fl_Choice*)o)->text();}
564inline void fl_set_choice_fontsize(Fl_Widget* o, int x) {
565    ((Fl_Choice*)o)->text_size(x);}
566inline void fl_set_choice_fontstyle(Fl_Widget* o, Fl_Font x) {
567    ((Fl_Choice*)o)->text_font(x);}
568// inline void fl_set_choice_item_mode(Fl_Widget*, int, unsigned);
569// inline void fl_set_choice_item_shortcut(Fl_Widget*, int, const char*);
570
571#include <fltk/Fl_Clock.h>
572forms_constructor(Fl_Clock, fl_add_clock)
573inline void fl_get_clock(Fl_Widget* o, int* h, int* m, int* s) {
574    *h = ((Fl_Clock*)o)->hour();
575    *m = ((Fl_Clock*)o)->minute();
576    *s = ((Fl_Clock*)o)->second();
577}
578
579#include <fltk/Fl_Counter.h>
580forms_constructor(Fl_Counter, fl_add_counter)
581inline void fl_set_counter_value(Fl_Widget* o, double v) {
582    ((Fl_Counter*)o)->value(v);}
583inline void fl_set_counter_bounds(Fl_Widget* o, double a, double b) {
584    ((Fl_Counter*)o)->range(a,b);}
585inline void fl_set_counter_step(Fl_Widget* o, double a, double b) {
586    ((Fl_Counter*)o)->step(a / b);}
587inline void fl_set_counter_precision(Fl_Widget* o, int v) {
588//    ((Fl_Counter*)o)->precision(v);}
589    ((Fl_Counter*)o)->step(1/(10^v));}
590inline void fl_set_counter_return(Fl_Widget* o, int v) {
591    ((Fl_Counter*)o)->when(v|FL_WHEN_RELEASE);}
592inline double fl_get_counter_value(Fl_Widget* o) {
593    return ((Fl_Counter*)o)->value();}
594inline void fl_get_counter_bounds(Fl_Widget* o, float* a, float* b) {
595  *a = float(((Fl_Counter*)o)->minimum());
596  *b = float(((Fl_Counter*)o)->maximum());
597}
598//inline void fl_set_counter_filter(Fl_Widget*,const char* (*)(Fl_Widget*,double,int));
599
600// Cursor stuff cannot be emulated because it uses X stuff
601inline void fl_set_cursor(Fl_Window* w, Fl_Cursor c) {w->cursor(c);}
602#define FL_INVISIBLE_CURSOR FL_CURSOR_NONE
603#define FL_DEFAULT_CURSOR FL_CURSOR_DEFAULT
604
605#include <fltk/Fl_Dial.h>
606
607#define FL_DIAL_COL1 FL_GRAY
608#define FL_DIAL_COL2 37
609
610forms_constructor(Fl_Dial, fl_add_dial)
611inline void fl_set_dial_value(Fl_Widget* o, double v) {
612  ((Fl_Dial*)o)->value(v);}
613inline double fl_get_dial_value(Fl_Widget* o) {
614  return ((Fl_Dial*)o)->value();}
615inline void fl_set_dial_bounds(Fl_Widget* o, double a, double b) {
616  ((Fl_Dial*)o)->range(a, b);}
617inline void fl_get_dial_bounds(Fl_Widget* o, float* a, float* b) {
618  *a = float(((Fl_Dial*)o)->minimum());
619  *b = float(((Fl_Dial*)o)->maximum());
620}
621inline void fl_set_dial_return(Fl_Widget* o, int i) {
622  ((Fl_Dial*)o)->when(i|FL_WHEN_RELEASE);}
623inline void fl_set_dial_angles(Fl_Widget* o, int a, int b) {
624  ((Fl_Dial*)o)->angles(a, b);}
625//inline void fl_set_dial_cross(Fl_Widget* o, int);
626// inline void fl_set_dial_direction(Fl_Widget* o, uchar d) {
627//   ((Fl_Dial*)o)->direction(d);}
628inline void fl_set_dial_step(Fl_Widget* o, double v) {
629  ((Fl_Dial*)o)->step(v);}
630
631// Frames:
632
633inline Fl_Widget* fl_add_frame(Fl_Boxtype i,int x,int y,int w,int h,const char* l) {
634  return fl_add_box(i,x-3,y-3,w+6,h+6,l);}
635
636// labelframe nyi
637inline Fl_Widget* fl_add_labelframe(Fl_Boxtype i,int x,int y,int w,int h,const char* l) {
638  Fl_Widget* o = fl_add_box(i,x-3,y-3,w+6,h+6,l);
639  o->clear_flag(FL_ALIGN_MASK);
640  o->set_flag(FL_ALIGN_TOP | FL_ALIGN_LEFT);
641  return o;
642}
643
644#include "Fl_Free.h"
645inline Fl_Free*
646fl_add_free(int t,double x,double y,double w,double h,const char* l,
647            FL_HANDLEPTR hdl) {
648 return (Fl_Free*)(fl_add_new(
649   new Fl_Free(t,int(x),int(y),int(w),int(h),l,hdl)));
650}
651
652#include <fltk/fl_ask.h>
653#include <fltk/fl_show_colormap.h>
654
655inline int fl_show_question(const char* c, int = 0) {return fl_ask(c);}
656FL_FORMS_API void fl_show_message(const char *,const char *,const char *);
657FL_FORMS_API void fl_show_alert(const char *,const char *,const char *,int=0);
658FL_FORMS_API int fl_show_question(const char *,const char *,const char *);
659inline const char *fl_show_input(const char *l,const char*d=0) {return fl_input(l,d);}
660/*const*/ char *fl_show_simple_input(const char *label, const char *deflt = 0);
661int fl_show_choice(
662    const char *m1,
663    const char *m2,
664    const char *m3,
665    int numb,
666    const char *b0,
667    const char *b1,
668    const char *b2);
669
670inline void fl_set_goodies_font(int a, unsigned b) {
671  fl_message_style->label_font = fl_fonts+a;
672  fl_message_style->label_size = b;
673}
674#define fl_show_messages fl_message
675inline int fl_show_choices(const char* c,int n,const char* b1,const char* b2,
676                           const char* b3, int) {
677  return fl_show_choice(0,c,0,n,b1,b2,b3);
678}
679
680#include <fltk/filename.h>
681#include <fltk/fl_file_chooser.h>
682inline int do_matching(char* a, const char* b) {return filename_match(a,b);}
683
684// Forms-compatable file chooser (implementation in fselect.C):
685FL_FORMS_API char* fl_show_file_selector(const char* message,const char* dir,
686                            const char* pat,const char* fname);
687FL_FORMS_API char*      fl_get_directory();
688FL_FORMS_API char*      fl_get_pattern();
689FL_FORMS_API char*      fl_get_filename();
690
691#include <fltk/Fl_Input.h>
692forms_constructor(Fl_Input, fl_add_input)
693inline void fl_set_input(Fl_Widget* o, const char* v) {
694    ((Fl_Input*)o)->value(v);}
695inline void fl_set_input_return(Fl_Widget* o, int x) {
696    ((Fl_Input*)o)->when(x | FL_WHEN_RELEASE);}
697inline void fl_set_input_color(Fl_Widget* o, unsigned a, unsigned /*b*/) {
698    ((Fl_Input*)o)->text_color((Fl_Color)a);
699//  ((Fl_Input*)o)->cursor_color((Fl_Color)b);
700}
701// inline void fl_set_input_scroll(Fl_Widget*, int);
702inline void fl_set_input_cursorpos(Fl_Widget* o, int x, int /*y*/) {
703  ((Fl_Input*)o)->position(x);}
704// inline void fl_set_input_selected(Fl_Widget*, int);
705// inline void fl_set_input_selected_range(Fl_Widget*, int, int);
706// inline void fl_set_input_maxchars(Fl_Widget*, int);
707// inline void fl_set_input_format(Fl_Widget*, int, int);
708// inline void fl_set_input_hscrollbar(Fl_Widget*, int);
709// inline void fl_set_input_vscrollbar(Fl_Widget*, int);
710// inline void fl_set_input_xoffset(Fl_Widget*, int);
711// inline void fl_set_input_topline(Fl_Widget*, int);
712// inline void fl_set_input_scrollbarsize(Fl_Widget*, int, int);
713// inline int fl_get_input_topline(Fl_Widget*);
714// inline int fl_get_input_screenlines(Fl_Widget*);
715inline int fl_get_input_cursorpos(Fl_Widget* o, int*x, int*y) {
716  *x = ((Fl_Input*)o)->position(); *y = 0; return *x;}
717// inline int fl_get_input_numberoflines(Fl_Widget*);
718// inline void fl_get_input_format(Fl_Widget*, int*, int*);
719inline const char* fl_get_input(Fl_Widget* o) {return ((Fl_Input*)o)->value();}
720
721#include <fltk/Fl_Menu_Button.h>
722
723// types are not implemented, they all act like FL_PUSH_MENU:
724#define FL_TOUCH_MENU           0
725#define FL_PUSH_MENU            1
726#define FL_PULLDOWN_MENU        2
727forms_constructor(Fl_Menu_Button, fl_add_menu)
728
729inline void fl_clear_menu(Fl_Widget* o) {
730    ((Fl_Menu_Button*)o)->clear();}
731inline void fl_set_menu(Fl_Widget* o, const char* s) {
732    ((Fl_Menu_Button*)o)->clear(); ((Fl_Menu_Button*)o)->add(s);}
733inline void fl_addto_menu(Fl_Widget* o, const char* s) {
734    ((Fl_Menu_Button*)o)->add(s);}
735inline void fl_replace_menu_item(Fl_Widget* o, int i, const char* s) {
736    ((Fl_Menu_Button*)o)->replace(i-1,s);}
737inline void fl_delete_menu_item(Fl_Widget* o, int i) {
738    ((Fl_Menu_Button*)o)->remove(i-1);}
739inline void fl_set_menu_item_shortcut(Fl_Widget* o, int i, const char* s) {
740    ((Fl_Menu_Button*)o)->shortcut(i-1,fltk::key(s));}
741// inline void fl_set_menu_item_mode(Fl_Widget* o, int i, long x) {
742//     ((Fl_Menu_Button*)o)->mode(i-1,x);}
743inline void fl_show_menu_symbol(Fl_Widget*, int ) {
744/*    ((Fl_Menu_Button*)o)->show_menu_symbol(i); */}
745// inline void fl_set_menu_popup(Fl_Widget*, int);
746inline int fl_get_menu(Fl_Widget* o) {
747    return ((Fl_Menu_Button*)o)->value()+1;}
748inline const char* fl_get_menu_item_text(Fl_Widget* o, int i) {
749    return ((Fl_Menu_Button*)o)->text(i);}
750inline int fl_get_menu_maxitems(Fl_Widget* o) {
751    return ((Fl_Menu_Button*)o)->size();}
752inline int fl_get_menu_item_mode(Fl_Widget* o, int i) {
753    return ((Fl_Menu_Button*)o)->mode(i);}
754inline const char* fl_get_menu_text(Fl_Widget* o) {
755    return ((Fl_Menu_Button*)o)->text();}
756
757#include "Fl_Positioner.h"
758#define FL_NORMAL_POSITIONER    0
759forms_constructor(Fl_Positioner, fl_add_positioner)
760inline void fl_set_positioner_xvalue(Fl_Widget* o, double v) {
761    ((Fl_Positioner*)o)->xvalue(v);}
762inline double fl_get_positioner_xvalue(Fl_Widget* o) {
763    return ((Fl_Positioner*)o)->xvalue();}
764inline void fl_set_positioner_xbounds(Fl_Widget* o, double a, double b) {
765    ((Fl_Positioner*)o)->xbounds(a,b);}
766inline void fl_get_positioner_xbounds(Fl_Widget* o, float* a, float* b) {
767  *a = float(((Fl_Positioner*)o)->xminimum());
768  *b = float(((Fl_Positioner*)o)->xmaximum());
769}
770inline void fl_set_positioner_yvalue(Fl_Widget* o, double v) {
771    ((Fl_Positioner*)o)->yvalue(v);}
772inline double fl_get_positioner_yvalue(Fl_Widget* o) {
773    return ((Fl_Positioner*)o)->yvalue();}
774inline void fl_set_positioner_ybounds(Fl_Widget* o, double a, double b) {
775    ((Fl_Positioner*)o)->ybounds(a,b);}
776inline void fl_get_positioner_ybounds(Fl_Widget* o, float* a, float* b) {
777  *a = float(((Fl_Positioner*)o)->yminimum());
778  *b = float(((Fl_Positioner*)o)->ymaximum());
779}
780inline void fl_set_positioner_xstep(Fl_Widget* o, double v) {
781    ((Fl_Positioner*)o)->xstep(v);}
782inline void fl_set_positioner_ystep(Fl_Widget* o, double v) {
783    ((Fl_Positioner*)o)->ystep(v);}
784inline void fl_set_positioner_return(Fl_Widget* o, int v) {
785    ((Fl_Positioner*)o)->when(v|FL_WHEN_RELEASE);}
786
787#include <fltk/Fl_Slider.h>
788
789#define FL_HOR_BROWSER_SLIDER FL_HOR_SLIDER
790#define FL_VERT_BROWSER_SLIDER FL_VERT_SLIDER
791
792forms_constructor(Fl_Slider, fl_add_slider)
793#define FL_SLIDER_COL1 FL_GRAY
794inline void fl_set_slider_value(Fl_Widget* o, double v) {
795    ((Fl_Slider*)o)->value(v);}
796inline double fl_get_slider_value(Fl_Widget* o) {
797    return ((Fl_Slider*)o)->value();}
798inline void fl_set_slider_bounds(Fl_Widget* o, double a, double b) {
799    ((Fl_Slider*)o)->range(a, b);}
800inline void fl_get_slider_bounds(Fl_Widget* o, float* a, float* b) {
801  *a = float(((Fl_Slider*)o)->minimum());
802  *b = float(((Fl_Slider*)o)->maximum());
803}
804inline void fl_set_slider_return(Fl_Widget* o, int i) {
805    ((Fl_Slider*)o)->when(i|FL_WHEN_RELEASE);}
806inline void fl_set_slider_step(Fl_Widget* o, double v) {
807    ((Fl_Slider*)o)->step(v);}
808// inline void fl_set_slider_increment(Fl_Widget* o, double v, double);
809inline void fl_set_slider_size(Fl_Widget* o, double v) {
810    ((Fl_Slider*)o)->slider_size(v);}
811
812#include <fltk/Fl_Value_Slider.h>
813forms_constructor(Fl_Value_Slider, fl_add_valslider)
814
815inline void fl_set_slider_precision(Fl_Widget* o, int i) {
816  double v = 1.0;
817  while (i--) v /= 10.0;
818  ((Fl_Value_Slider*)o)->step(v);
819}
820
821// The forms text object was the same as an Fl_Box except it inverted the
822// meaning of FL_ALIGN_INSIDE.  Implementation in forms.C
823class FL_FORMS_API Fl_FormsText : public Fl_Widget {
824protected:
825    void draw();
826public:
827    Fl_FormsText(Fl_Boxtype b, int x, int y, int w, int h, const char* l=0)
828        : Fl_Widget(x,y,w,h,l) {box(b); clear_flag(FL_ALIGN_MASK); set_flag(FL_ALIGN_LEFT);}
829};
830#define FL_NORMAL_TEXT FL_NO_BOX
831forms_constructorb(Fl_FormsText, fl_add_text)
832
833#include "Fl_Timer.h"
834forms_constructort(Fl_Timer, fl_add_timer)
835inline void fl_set_timer(Fl_Widget* o, double v) {((Fl_Timer*)o)->value(v);}
836inline double fl_get_timer(Fl_Widget* o) {return ((Fl_Timer*)o)->value();}
837inline void fl_suspend_timer(Fl_Widget* o) {((Fl_Timer*)o)->suspended(1);}
838inline void fl_resume_timer(Fl_Widget* o) {((Fl_Timer*)o)->suspended(0);}
839inline void fl_set_timer_countup(Fl_Widget* o,char d) {((Fl_Timer*)o)->direction(d);}
840FL_FORMS_API void fl_gettime(long* sec, long* usec);
841
842// Fl_XYPlot nyi
843
844
845// stuff from DDForms:
846
847inline int fl_double_click() {return Fl::event_clicks();}
848inline void fl_draw() {Fl::flush();}
849
850#endif  /* define __FORMS_H__ */
851
852//
853// End of "$Id: forms.h 3887 2004-11-12 06:50:20Z spitzak $".
854//
Note: See TracBrowser for help on using the repository browser.