1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
|
//------------------------------------------------------------------------
// WINDOW : Unix/FLTK application window
//------------------------------------------------------------------------
//
// GL-Friendly Node Builder (C) 2000-2007 Andrew Apted
//
// Based on 'BSP 2.3' by Colin Reed, Lee Killough and others.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//------------------------------------------------------------------------
// this includes everything we need
#include "local.h"
#ifndef WIN32
#include <unistd.h>
#endif
Guix_MainWin *guix_win;
static void main_win_close_CB(Fl_Widget *w, void *data)
{
if (guix_win)
guix_win->want_quit = TRUE;
}
//
// WindowSmallDelay
//
// This routine is meant to delay a short time (e.g. 1/5th of a
// second) to allow the window manager to move our windows around.
//
// Hopefully such nonsense doesn't happen under Win32.
//
void WindowSmallDelay(void)
{
#ifndef WIN32
Fl::wait(0); usleep(100 * 1000);
Fl::wait(0); usleep(100 * 1000);
#endif
Fl::wait(0);
}
//
// MainWin Constructor
//
Guix_MainWin::Guix_MainWin(const char *title) :
Fl_Window(guix_prefs.win_w, guix_prefs.win_h, title)
{
// turn off auto-add-widget mode
end();
size_range(MAIN_WINDOW_MIN_W, MAIN_WINDOW_MIN_H);
// Set initial position.
//
// Note: this may not work properly. It seems that when my window
// manager adds the titlebar/border, it moves the actual window
// down and slightly to the right, causing subsequent invokations
// to keep going lower and lower.
position(guix_prefs.win_x, guix_prefs.win_y);
callback((Fl_Callback *) main_win_close_CB);
// set a nice darkish gray for the space between main boxes
color(MAIN_BG_COLOR, MAIN_BG_COLOR);
want_quit = FALSE;
// create contents
int hw = (w() - 8*2 - 4) / 2;
int mh = 28;
#ifdef MACOSX
mh = 1;
#endif
menu_bar = MenuCreate(0, 0, w(), 28);
add(menu_bar);
build_mode = new Guix_BuildMode(8, 4+mh, hw, 176);
add(build_mode);
misc_opts = new Guix_MiscOptions(8+hw+4, 4+mh, hw, 136);
add(misc_opts);
factor = new Guix_FactorBox(8+hw+4, 140+mh, hw, 40);
add(factor);
files = new Guix_FileBox(8, 184+mh, w()-8*2, 86);
add(files);
builder = new Guix_BuildButton(8, 274+10+mh, hw, 60);
add(builder);
progress = new Guix_ProgressBox(8+hw+4, 274+mh, hw, 74);
add(progress);
text_box = new Guix_TextBox(0, 352+mh, w(), h() - 352 - mh);
add(text_box);
resizable(text_box);
// show window (pass some dummy arguments)
int argc = 1;
char *argv[] = { "glBSPX", NULL };
show(argc, argv);
// read initial pos, giving 1/5th of a second for the WM to adjust
// our window's position (naughty WM...)
WindowSmallDelay();
init_x = x(); init_y = y();
init_w = w(); init_h = h();
}
//
// MainWin Destructor
//
Guix_MainWin::~Guix_MainWin()
{
WritePrefs();
}
void Guix_MainWin::WritePrefs()
{
// check if moved or resized
if (x() != init_x || y() != init_y)
{
guix_prefs.win_x = x();
guix_prefs.win_y = y();
}
if (w() != init_w || h() != init_h)
{
guix_prefs.win_w = w();
guix_prefs.win_h = h();
}
}
void Guix_MainWin::ReadAllInfo()
{
// Note: do build_mode before files
build_mode->ReadInfo();
misc_opts->ReadInfo();
files->ReadInfo();
factor->ReadInfo();
}
void Guix_MainWin::WriteAllInfo()
{
// Note: do build_mode before files
build_mode->WriteInfo();
misc_opts->WriteInfo();
files->WriteInfo();
factor->WriteInfo();
}
void Guix_MainWin::LockOut(boolean_g lock_it)
{
build_mode->LockOut(lock_it);
misc_opts->LockOut(lock_it);
files->LockOut(lock_it);
factor->LockOut(lock_it);
builder->LockOut(lock_it);
text_box->LockOut(lock_it);
// change the mouse cursor
cursor(lock_it ? FL_CURSOR_WAIT : FL_CURSOR_DEFAULT);
}
|