1
//------------------------------------------------------------------------
2
// WINDOW : Unix/FLTK application window
3
//------------------------------------------------------------------------
5
// GL-Friendly Node Builder (C) 2000-2007 Andrew Apted
7
// Based on 'BSP 2.3' by Colin Reed, Lee Killough and others.
9
// This program is free software; you can redistribute it and/or
10
// modify it under the terms of the GNU General Public License
11
// as published by the Free Software Foundation; either version 2
12
// of the License, or (at your option) any later version.
14
// This program is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
// GNU General Public License for more details.
19
//------------------------------------------------------------------------
21
// this includes everything we need
29
Guix_MainWin *guix_win;
32
static void main_win_close_CB(Fl_Widget *w, void *data)
35
guix_win->want_quit = TRUE;
42
// This routine is meant to delay a short time (e.g. 1/5th of a
43
// second) to allow the window manager to move our windows around.
45
// Hopefully such nonsense doesn't happen under Win32.
47
void WindowSmallDelay(void)
50
Fl::wait(0); usleep(100 * 1000);
51
Fl::wait(0); usleep(100 * 1000);
59
// MainWin Constructor
61
Guix_MainWin::Guix_MainWin(const char *title) :
62
Fl_Window(guix_prefs.win_w, guix_prefs.win_h, title)
64
// turn off auto-add-widget mode
67
size_range(MAIN_WINDOW_MIN_W, MAIN_WINDOW_MIN_H);
69
// Set initial position.
71
// Note: this may not work properly. It seems that when my window
72
// manager adds the titlebar/border, it moves the actual window
73
// down and slightly to the right, causing subsequent invokations
74
// to keep going lower and lower.
76
position(guix_prefs.win_x, guix_prefs.win_y);
78
callback((Fl_Callback *) main_win_close_CB);
80
// set a nice darkish gray for the space between main boxes
81
color(MAIN_BG_COLOR, MAIN_BG_COLOR);
87
int hw = (w() - 8*2 - 4) / 2;
94
menu_bar = MenuCreate(0, 0, w(), 28);
97
build_mode = new Guix_BuildMode(8, 4+mh, hw, 176);
100
misc_opts = new Guix_MiscOptions(8+hw+4, 4+mh, hw, 136);
103
factor = new Guix_FactorBox(8+hw+4, 140+mh, hw, 40);
106
files = new Guix_FileBox(8, 184+mh, w()-8*2, 86);
109
builder = new Guix_BuildButton(8, 274+10+mh, hw, 60);
112
progress = new Guix_ProgressBox(8+hw+4, 274+mh, hw, 74);
115
text_box = new Guix_TextBox(0, 352+mh, w(), h() - 352 - mh);
120
// show window (pass some dummy arguments)
122
char *argv[] = { "glBSPX", NULL };
126
// read initial pos, giving 1/5th of a second for the WM to adjust
127
// our window's position (naughty WM...)
130
init_x = x(); init_y = y();
131
init_w = w(); init_h = h();
135
// MainWin Destructor
137
Guix_MainWin::~Guix_MainWin()
143
void Guix_MainWin::WritePrefs()
145
// check if moved or resized
146
if (x() != init_x || y() != init_y)
148
guix_prefs.win_x = x();
149
guix_prefs.win_y = y();
152
if (w() != init_w || h() != init_h)
154
guix_prefs.win_w = w();
155
guix_prefs.win_h = h();
160
void Guix_MainWin::ReadAllInfo()
162
// Note: do build_mode before files
163
build_mode->ReadInfo();
164
misc_opts->ReadInfo();
170
void Guix_MainWin::WriteAllInfo()
172
// Note: do build_mode before files
173
build_mode->WriteInfo();
174
misc_opts->WriteInfo();
180
void Guix_MainWin::LockOut(boolean_g lock_it)
182
build_mode->LockOut(lock_it);
183
misc_opts->LockOut(lock_it);
184
files->LockOut(lock_it);
185
factor->LockOut(lock_it);
186
builder->LockOut(lock_it);
187
text_box->LockOut(lock_it);
189
// change the mouse cursor
190
cursor(lock_it ? FL_CURSOR_WAIT : FL_CURSOR_DEFAULT);