source: NonGTP/glut/FLTK/include/FL/menubar.h @ 814

Revision 814, 2.1 KB checked in by gumbau, 18 years ago (diff)

Glut initial import used by Geometry modules

Line 
1// This is an additional header file for "DDForms", which was our internal
2// enhancement of Forms.  This defines the precursor of the Fl_Menu class.
3//
4// Unfortunately it defined the callbacks as taking a long rather
5// than a void* argument, requiring some dubious casts to emulate it:
6
7#include "Fl_Menu_Bar.h"
8
9struct FL_API MenuEntry {
10  const char *text;     /*initial character indicates "type", 0 = end of menu*/
11  ulong bind;   /* key binding in forms format (#x, etc) */
12  void (*cb)(Fl_Widget *,long); /* callback */
13  long data;            /* value for callback */
14  int flags;            /* see below for flags */
15  uchar labeltype;
16  uchar labelfont;
17  uchar labelsize;
18  uchar labelcolor;
19};
20
21#define CHECKED FL_MENU_CHECK
22#define UNCHECKED FL_MENU_BOX
23#define DISABLED FL_MENU_INACTIVE
24
25/* Turn a box into a menu bar: */
26inline void MenuBar(Fl_Widget *o,MenuEntry *m) {
27    Fl_Menu_Bar *mb = new Fl_Menu_Bar(o->x(),o->y(),o->w(),o->h());
28    mb->menu((Fl_Menu_Item*)m);
29    mb->box(0);
30    Fl_Group *g = (Fl_Group *)(o->parent());
31    int i = g->find(*o);
32    g->insert(*mb, i<g->children()-1 ? g->child(i+1) : 0);
33}
34
35/* advance to the Nth item in menu, skipping submenus: */
36inline MenuEntry *MenuGetEntry(MenuEntry *m,int i) {
37    return (MenuEntry*)(((Fl_Menu_Item*)m)->next(i));
38}
39
40/* Init the shortcuts for a widget with a popup menu: */
41inline void MenuSetShortcuts(Fl_Widget *, MenuEntry *) {}
42
43inline void MenuAdd(
44    MenuEntry m[],
45    int, /* number of entries in menutable, ignored here */
46    const char *text,
47    const char *bind,
48    void (*cb)(Fl_Widget *,long),
49    long data,
50    int flags) {
51    ((Fl_Menu_Item*)m)->add(text,bind,(Fl_Callback*)cb,(void *)data,flags);
52}
53
54inline MenuEntry *MenuPopup(Fl_Widget *o,const char *title,MenuEntry *m,
55                            int x, int y) {
56    const Fl_Menu_Item* v = ((Fl_Menu_Item*)m)->popup(x,y,title);
57    if (v && v->callback_) v->do_callback(o);
58    return (MenuEntry *)v;
59}
60
61inline MenuEntry *MenuHandleShortcut(Fl_Widget *o,MenuEntry *m,char) {
62    const Fl_Menu_Item* v = ((Fl_Menu_Item*)m)->test_shortcut();
63    if (v && v->callback_) v->do_callback(o);
64    return (MenuEntry *)v;
65}
Note: See TracBrowser for help on using the repository browser.