source: NonGTP/FLTK/include/FL/forms.H @ 773

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

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

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