1
//------------------------------------------------------------------------
2
// PREFS : Unix/FLTK Preference Window
3
//------------------------------------------------------------------------
5
// GL-Friendly Node Builder (C) 2000-2005 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
25
Guix_PrefWin *guix_pref_win;
28
static void prefs_quit_CB(Fl_Widget *w, void *data)
31
guix_pref_win->want_quit = TRUE;
34
static void prefs_reset_all_CB(Fl_Widget *w, void *data)
39
guix_pref_win->PrefsChanged();
41
guix_win->ReadAllInfo();
45
//------------------------------------------------------------------------
48
// PrefWin Constructor
50
Guix_PrefWin::Guix_PrefWin() : Fl_Window(480, 290, "glBSP Preferences")
52
// cancel the automatic 'begin' in Fl_Group constructor
55
// non-resizable window
56
size_range(w(), h(), w(), h());
58
position(guix_prefs.other_x, guix_prefs.other_y);
62
// allow manual closing of window
63
callback((Fl_Callback *) prefs_quit_CB);
65
// create buttons in top row
67
groups[0] = new Fl_Group(0, 0, w(), 110, "Pop-up dialog options:");
68
groups[0]->box(FL_THIN_UP_BOX);
69
groups[0]->resizable(0);
70
groups[0]->labelfont(FL_HELVETICA | FL_BOLD);
71
groups[0]->labeltype(FL_NORMAL_LABEL);
72
groups[0]->align(FL_ALIGN_INSIDE | FL_ALIGN_LEFT | FL_ALIGN_TOP);
78
overwrite = new Fl_Check_Button(CX, CY, 22, 22,
79
"Warn before overwriting files");
80
overwrite->down_box(FL_DOWN_BOX);
81
overwrite->align(FL_ALIGN_RIGHT);
82
overwrite->value(guix_prefs.overwrite_warn ? 1 : 0);
83
groups[0]->add(overwrite);
87
same_file = new Fl_Check_Button(CX, CY, 22, 22,
88
"Warn if Input and Output files are the same");
89
same_file->down_box(FL_DOWN_BOX);
90
same_file->align(FL_ALIGN_RIGHT);
91
same_file->value(guix_prefs.same_file_warn ? 1 : 0);
92
groups[0]->add(same_file);
96
lack_ext = new Fl_Check_Button(CX, CY, 22, 22,
97
"Warn about missing extensions (otherwise add the default)");
98
lack_ext->down_box(FL_DOWN_BOX);
99
lack_ext->align(FL_ALIGN_RIGHT);
100
lack_ext->value(guix_prefs.lack_ext_warn ? 1 : 0);
101
groups[0]->add(lack_ext);
105
// create reset button
107
groups[1] = new Fl_Group(0, 110, w(), 120);
108
groups[1]->box(FL_THIN_UP_BOX);
109
groups[1]->resizable(0);
112
reset_all = new Fl_Button((w() - 240) / 2, 180, 240, 26,
113
"Reset All To Defaults");
114
reset_all->labelfont(FL_HELVETICA | FL_BOLD);
115
reset_all->callback((Fl_Callback *) prefs_reset_all_CB);
116
groups[1]->add(reset_all);
118
Fl_Box *reset_txt = new Fl_Box(FL_FLAT_BOX, 20, 130, w() - 40, 46,
119
"This button resets all user-changeable options to default "
120
"values, including everything in the main window.");
122
reset_txt->align(FL_ALIGN_LEFT | FL_ALIGN_TOP |
123
FL_ALIGN_INSIDE | FL_ALIGN_WRAP);
124
groups[1]->add(reset_txt);
126
// create quit button
128
groups[2] = new Fl_Group(0, 230, w(), 60);
129
groups[2]->box(FL_THIN_UP_BOX);
130
groups[2]->resizable(0);
133
quit = new Fl_Button(w() - 100, h() - 40, 80, 26, "Close");
134
quit->callback((Fl_Callback *) prefs_quit_CB);
135
groups[2]->add(quit);
141
// read initial pos (same logic as in Guix_MainWin)
144
init_x = x(); init_y = y();
149
// PrefWin Destructor
151
Guix_PrefWin::~Guix_PrefWin()
153
// write new preferences
154
guix_prefs.overwrite_warn = overwrite->value() ? TRUE : FALSE;
155
guix_prefs.same_file_warn = same_file->value() ? TRUE : FALSE;
156
guix_prefs.lack_ext_warn = lack_ext->value() ? TRUE : FALSE;
158
// update window_pos if user moved the window
159
if (x() != init_x || y() != init_y)
161
guix_prefs.other_x = x();
162
guix_prefs.other_y = y();
167
void Guix_PrefWin::PrefsChanged()
169
overwrite->value(guix_prefs.overwrite_warn ? 1 : 0);
172
same_file->value(guix_prefs.same_file_warn ? 1 : 0);
175
lack_ext->value(guix_prefs.lack_ext_warn ? 1 : 0);