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 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320
|
//------------------------------------------------------------------------
// Options : Unix/FLTK Option boxes
//------------------------------------------------------------------------
//
// 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"
#define BM_BUTTONTYPE FL_ROUND_DOWN_BOX
#define BM_BUTTONSIZE 30
static void build_mode_radio_CB(Fl_Widget *w, void *data)
{
boolean_g old_gwa = guix_info.gwa_mode;
guix_win->build_mode->WriteInfo();
// communicate with output file widget, for GWA mode
if (old_gwa != guix_info.gwa_mode)
{
guix_win->files->GWA_Changed();
}
guix_win->misc_opts->GWA_Changed();
}
//
// BuildMode Constructor
//
Guix_BuildMode::Guix_BuildMode(int x, int y, int w, int h) :
Fl_Group(x, y, w, h, "Build Mode")
{
// cancel the automatic 'begin' in Fl_Group constructor
end();
box(FL_THIN_UP_BOX);
resizable(0); // no resizing the kiddies, please
labelfont(FL_HELVETICA | FL_BOLD);
labeltype(FL_NORMAL_LABEL);
align(FL_ALIGN_INSIDE | FL_ALIGN_LEFT | FL_ALIGN_TOP);
// create the children
int CX = x+12;
int CY = y+16;
gwa = new Fl_Check_Button(CX, CY,
BM_BUTTONSIZE, BM_BUTTONSIZE, "GWA Mode");
gwa->down_box(BM_BUTTONTYPE);
gwa->type(FL_RADIO_BUTTON);
gwa->align(FL_ALIGN_RIGHT);
gwa->callback((Fl_Callback *) build_mode_radio_CB);
add(gwa);
CY += 24;
maybe_normal = new Fl_Check_Button(CX, CY,
BM_BUTTONSIZE, BM_BUTTONSIZE, "GL, Normal if missing");
maybe_normal->down_box(BM_BUTTONTYPE);
maybe_normal->type(FL_RADIO_BUTTON);
maybe_normal->align(FL_ALIGN_RIGHT);
maybe_normal->callback((Fl_Callback *) build_mode_radio_CB);
add(maybe_normal);
CY += 24;
both = new Fl_Check_Button(CX, CY,
BM_BUTTONSIZE, BM_BUTTONSIZE, "GL and Normal nodes");
both->down_box(BM_BUTTONTYPE);
both->type(FL_RADIO_BUTTON);
both->align(FL_ALIGN_RIGHT);
both->callback((Fl_Callback *) build_mode_radio_CB);
add(both);
CY += 24;
gl_only = new Fl_Check_Button(CX, CY,
BM_BUTTONSIZE, BM_BUTTONSIZE, "GL nodes only");
gl_only->down_box(BM_BUTTONTYPE);
gl_only->type(FL_RADIO_BUTTON);
gl_only->align(FL_ALIGN_RIGHT);
gl_only->callback((Fl_Callback *) build_mode_radio_CB);
add(gl_only);
CY += 24;
ReadInfo();
}
//
// BuildMode Destructor
//
Guix_BuildMode::~Guix_BuildMode()
{
WriteInfo();
}
void Guix_BuildMode::ReadInfo()
{
if (guix_info.gwa_mode)
gwa->setonly();
else if (guix_info.no_normal)
gl_only->setonly();
else if (guix_info.force_normal)
both->setonly();
else
maybe_normal->setonly();
// redraw them all (just to be safe)
gwa->redraw();
gl_only->redraw();
both->redraw();
maybe_normal->redraw();
}
void Guix_BuildMode::WriteInfo()
{
// default: everything false
guix_info.gwa_mode = FALSE;
guix_info.no_normal = FALSE;
guix_info.force_normal = FALSE;
if (gwa->value())
{
guix_info.gwa_mode = TRUE;
}
else if (gl_only->value())
{
guix_info.no_normal = TRUE;
}
else if (both->value())
{
guix_info.force_normal = TRUE;
}
}
void Guix_BuildMode::LockOut(boolean_g lock_it)
{
if (lock_it)
{
gwa->set_output();
maybe_normal->set_output();
both->set_output();
gl_only->set_output();
}
else
{
gwa->clear_output();
maybe_normal->clear_output();
both->clear_output();
gl_only->clear_output();
}
}
//------------------------------------------------------------------------
static void misc_opts_check_CB(Fl_Widget *w, void *data)
{
guix_win->misc_opts->WriteInfo();
}
//
// MiscOptions Constructor
//
Guix_MiscOptions::Guix_MiscOptions(int x, int y, int w, int h) :
Fl_Group(x, y, w, h, "Misc Options")
{
// cancel the automatic 'begin' in Fl_Group constructor
end();
box(FL_THIN_UP_BOX);
resizable(0); // no resizing the kiddies, please
labelfont(FL_HELVETICA | FL_BOLD);
labeltype(FL_NORMAL_LABEL);
align(FL_ALIGN_INSIDE | FL_ALIGN_LEFT | FL_ALIGN_TOP);
// create children
int CX = x+12;
int CY = y+20;
warnings = new Fl_Check_Button(CX, CY, 22, 22, "Extra Warnings");
warnings->down_box(FL_DOWN_BOX);
warnings->align(FL_ALIGN_RIGHT);
warnings->callback((Fl_Callback *) misc_opts_check_CB);
add(warnings);
CY += 24;
no_reject = new Fl_Check_Button(CX, CY, 22, 22, "Don't clobber REJECT");
no_reject->down_box(FL_DOWN_BOX);
no_reject->align(FL_ALIGN_RIGHT);
no_reject->callback((Fl_Callback *) misc_opts_check_CB);
add(no_reject);
CY += 24;
pack_sides = new Fl_Check_Button(CX, CY, 22, 22, "Pack Sidedefs");
pack_sides->down_box(FL_DOWN_BOX);
pack_sides->align(FL_ALIGN_RIGHT);
pack_sides->callback((Fl_Callback *) misc_opts_check_CB);
add(pack_sides);
CY += 24;
choose_fresh = new Fl_Check_Button(CX, CY, 22, 22, "Fresh Partition Lines");
choose_fresh->down_box(FL_DOWN_BOX);
choose_fresh->align(FL_ALIGN_RIGHT);
choose_fresh->callback((Fl_Callback *) misc_opts_check_CB);
add(choose_fresh);
CY += 24;
ReadInfo();
}
//
// MiscOptions Destructor
//
Guix_MiscOptions::~Guix_MiscOptions()
{
WriteInfo();
}
void Guix_MiscOptions::ReadInfo()
{
choose_fresh->value(guix_info.fast ? 0 : 1); // API change
choose_fresh->redraw();
warnings->value(guix_info.mini_warnings ? 1 : 0);
warnings->redraw();
no_reject->value(guix_info.no_reject ? 1 : 0);
no_reject->redraw();
pack_sides->value(guix_info.pack_sides ? 1 : 0);
pack_sides->redraw();
GWA_Changed();
}
void Guix_MiscOptions::WriteInfo()
{
guix_info.fast = choose_fresh->value() ? FALSE : TRUE; // API change
guix_info.no_reject = no_reject->value() ? TRUE : FALSE;
guix_info.mini_warnings = warnings->value() ? TRUE : FALSE;
guix_info.pack_sides = pack_sides->value() ? TRUE : FALSE;
}
void Guix_MiscOptions::GWA_Changed()
{
if (guix_info.gwa_mode)
{
no_reject->deactivate();
pack_sides->deactivate();
}
else
{
no_reject->activate();
pack_sides->activate();
}
if (guix_info.force_normal)
choose_fresh->deactivate();
else
choose_fresh->activate();
}
void Guix_MiscOptions::LockOut(boolean_g lock_it)
{
if (lock_it)
{
choose_fresh->set_output();
warnings->set_output();
no_reject->set_output();
pack_sides->set_output();
}
else
{
choose_fresh->clear_output();
warnings->clear_output();
no_reject->clear_output();
pack_sides->clear_output();
}
}
|