1
//------------------------------------------------------------------------
2
// MENU : Menu handling
3
//------------------------------------------------------------------------
5
// GL-Node Viewer (C) 2004-2007 Andrew Apted
7
// This program is free software; you can redistribute it and/or
8
// modify it under the terms of the GNU General Public License
9
// as published by the Free Software Foundation; either version 2
10
// of the License, or (at your option) any later version.
12
// This program is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
// GNU General Public License for more details.
17
//------------------------------------------------------------------------
19
// this includes everything we need
23
static bool menu_want_to_quit;
27
static void menu_quit_CB(Fl_Widget *w, void *data)
29
menu_want_to_quit = true;
35
static void menu_do_exit(Fl_Widget *w, void * data)
37
guix_win->want_quit = true;
42
//------------------------------------------------------------------------
44
static void menu_do_prefs(Fl_Widget *w, void * data)
49
//------------------------------------------------------------------------
51
static const char *about_Info =
52
"By Andrew Apted (C) 2004-2007";
55
static void menu_do_about(Fl_Widget *w, void * data)
58
menu_want_to_quit = false;
60
Fl_Window *ab_win = new Fl_Window(600, 340, "About " PROG_NAME);
64
ab_win->size_range(ab_win->w(), ab_win->h(), ab_win->w(), ab_win->h());
65
ab_win->position(guix_prefs.manual_x, guix_prefs.manual_y);
66
ab_win->callback((Fl_Callback *) menu_quit_CB);
68
// add the about image
69
Fl_Group *group = new Fl_Group(0, 0, 230, ab_win->h());
70
group->box(FL_FLAT_BOX);
71
group->color(FL_BLACK, FL_BLACK);
74
Fl_Box *box = new Fl_Box(20, 90, ABOUT_IMG_W+2, ABOUT_IMG_H+2);
75
box->image(about_image);
80
box = new Fl_Box(240, 5, 350, 50, "glBSPX " GLBSP_VER);
85
box = new Fl_Box(240, 60, 350, 270, about_Info);
86
box->align(FL_ALIGN_INSIDE | FL_ALIGN_LEFT | FL_ALIGN_TOP);
90
// finally add an "OK" button
91
Fl_Button *button = new Fl_Button(ab_win->w()-10-60, ab_win->h()-10-30,
93
button->callback((Fl_Callback *) menu_quit_CB);
99
// capture initial size
101
int init_x = ab_win->x();
102
int init_y = ab_win->y();
104
// run the GUI until the user closes
105
while (! menu_want_to_quit)
108
// check if the user moved/resized the window
109
if (ab_win->x() != init_x || ab_win->y() != init_y)
111
guix_prefs.manual_x = ab_win->x();
112
guix_prefs.manual_y = ab_win->y();
115
// this deletes all the child widgets too...
121
//------------------------------------------------------------------------
123
static void menu_do_manual(Fl_Widget *w, void * data)
128
//------------------------------------------------------------------------
130
static void menu_do_license(Fl_Widget *w, void * data)
135
//------------------------------------------------------------------------
137
static void menu_do_save_log(Fl_Widget *w, void * data)
142
//------------------------------------------------------------------------
145
#define FCAL (Fl_Callback *)
147
static Fl_Menu_Item menu_items[] =
149
{ "&File", 0, 0, 0, FL_SUBMENU },
150
{ "&Preferences...", 0, FCAL menu_do_prefs },
151
{ "&Save Log...", 0, FCAL menu_do_save_log },
153
{ "E&xit", FL_ALT + 'q', FCAL menu_do_exit },
157
{ "&Help", 0, 0, 0, FL_SUBMENU },
158
{ "&About...", 0, FCAL menu_do_about },
159
{ "&License...", 0, FCAL menu_do_license },
160
{ "&Manual...", FL_F+1, FCAL menu_do_manual },
171
Fl_Sys_Menu_Bar * MenuCreate(int x, int y, int w, int h)
173
Fl_Sys_Menu_Bar *bar = new Fl_Sys_Menu_Bar(x, y, w, h);
174
bar->menu(menu_items);
178
Fl_Menu_Bar * MenuCreate(int x, int y, int w, int h)
180
Fl_Menu_Bar *bar = new Fl_Menu_Bar(x, y, w, h);
181
bar->menu(menu_items);