~ubuntu-branches/ubuntu/jaunty/glbsp/jaunty

« back to all changes in this revision

Viewing changes to gui/window.cc

  • Committer: Bazaar Package Importer
  • Author(s): Darren Salt
  • Date: 2008-01-30 13:33:49 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080130133349-kgojg33vyiu8xbvp
Tags: 2.24-1
* New upstream release.
* Bumped the lib soname and the library package name due to one silly
  little binary incompatibility caused by changes in an exported struct.
  (Safe; nothing else currently in the archive has ever used libglbsp2.)
* Removed my patches since they're all applied upstream.
* Updated the list of documentation files.
* Build-time changes:
  - Switched from dh_movefiles to dh_install.
  - Updated my makefile to cope with upstream changes.
  - Corrected for debian-rules-ignores-make-clean-error.
  - Corrected for substvar-source-version-is-deprecated.
  - Link libglbsp, rather than glbsp, with libm and libz.
* Fixed shlibdeps. (Closes: #460387)
* Bumped standards version to 3.7.3 (no other changes).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//------------------------------------------------------------------------
 
2
// WINDOW : Unix/FLTK application window
 
3
//------------------------------------------------------------------------
 
4
//
 
5
//  GL-Friendly Node Builder (C) 2000-2007 Andrew Apted
 
6
//
 
7
//  Based on 'BSP 2.3' by Colin Reed, Lee Killough and others.
 
8
//
 
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.
 
13
//
 
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.
 
18
//
 
19
//------------------------------------------------------------------------
 
20
 
 
21
// this includes everything we need
 
22
#include "local.h"
 
23
 
 
24
#ifndef WIN32
 
25
#include <unistd.h>
 
26
#endif
 
27
 
 
28
 
 
29
Guix_MainWin *guix_win;
 
30
 
 
31
 
 
32
static void main_win_close_CB(Fl_Widget *w, void *data)
 
33
{
 
34
  if (guix_win)
 
35
    guix_win->want_quit = TRUE;
 
36
}
 
37
 
 
38
 
 
39
//
 
40
// WindowSmallDelay
 
41
//
 
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.
 
44
//
 
45
// Hopefully such nonsense doesn't happen under Win32.
 
46
//
 
47
void WindowSmallDelay(void)
 
48
{
 
49
#ifndef WIN32
 
50
  Fl::wait(0);  usleep(100 * 1000);
 
51
  Fl::wait(0);  usleep(100 * 1000);
 
52
#endif
 
53
 
 
54
  Fl::wait(0);
 
55
}
 
56
 
 
57
 
 
58
//
 
59
// MainWin Constructor
 
60
//
 
61
Guix_MainWin::Guix_MainWin(const char *title) :
 
62
    Fl_Window(guix_prefs.win_w, guix_prefs.win_h, title)
 
63
{
 
64
  // turn off auto-add-widget mode
 
65
  end();
 
66
 
 
67
  size_range(MAIN_WINDOW_MIN_W, MAIN_WINDOW_MIN_H);
 
68
 
 
69
  // Set initial position.
 
70
  //
 
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.
 
75
 
 
76
  position(guix_prefs.win_x, guix_prefs.win_y);
 
77
 
 
78
  callback((Fl_Callback *) main_win_close_CB);
 
79
 
 
80
  // set a nice darkish gray for the space between main boxes
 
81
  color(MAIN_BG_COLOR, MAIN_BG_COLOR);
 
82
 
 
83
  want_quit = FALSE;
 
84
 
 
85
 
 
86
  // create contents
 
87
  int hw = (w() - 8*2 - 4) / 2;
 
88
  int mh = 28;
 
89
 
 
90
#ifdef MACOSX
 
91
  mh = 1;
 
92
#endif
 
93
 
 
94
  menu_bar = MenuCreate(0, 0, w(), 28);
 
95
  add(menu_bar);
 
96
 
 
97
  build_mode = new Guix_BuildMode(8, 4+mh, hw, 176);
 
98
  add(build_mode);
 
99
 
 
100
  misc_opts  = new Guix_MiscOptions(8+hw+4, 4+mh, hw, 136);
 
101
  add(misc_opts);
 
102
   
 
103
  factor = new Guix_FactorBox(8+hw+4, 140+mh, hw, 40);
 
104
  add(factor);
 
105
 
 
106
  files = new Guix_FileBox(8, 184+mh, w()-8*2, 86);
 
107
  add(files);
 
108
 
 
109
  builder = new Guix_BuildButton(8, 274+10+mh, hw, 60);
 
110
  add(builder);
 
111
 
 
112
  progress = new Guix_ProgressBox(8+hw+4, 274+mh, hw, 74);
 
113
  add(progress);
 
114
 
 
115
  text_box = new Guix_TextBox(0, 352+mh, w(), h() - 352 - mh);
 
116
  add(text_box);
 
117
  resizable(text_box);
 
118
 
 
119
 
 
120
  // show window (pass some dummy arguments)
 
121
  int argc = 1;
 
122
  char *argv[] = { "glBSPX", NULL };
 
123
  
 
124
  show(argc, argv);
 
125
 
 
126
  // read initial pos, giving 1/5th of a second for the WM to adjust
 
127
  // our window's position (naughty WM...)
 
128
  WindowSmallDelay();
 
129
 
 
130
  init_x = x(); init_y = y();
 
131
  init_w = w(); init_h = h();
 
132
}
 
133
 
 
134
//
 
135
// MainWin Destructor
 
136
//
 
137
Guix_MainWin::~Guix_MainWin()
 
138
{
 
139
  WritePrefs();
 
140
}
 
141
 
 
142
 
 
143
void Guix_MainWin::WritePrefs()
 
144
{
 
145
  // check if moved or resized
 
146
  if (x() != init_x || y() != init_y)
 
147
  {
 
148
    guix_prefs.win_x = x();
 
149
    guix_prefs.win_y = y();
 
150
  }
 
151
 
 
152
  if (w() != init_w || h() != init_h)
 
153
  {
 
154
    guix_prefs.win_w = w();
 
155
    guix_prefs.win_h = h();
 
156
  }
 
157
}
 
158
 
 
159
 
 
160
void Guix_MainWin::ReadAllInfo()
 
161
{
 
162
  // Note: do build_mode before files
 
163
  build_mode->ReadInfo();
 
164
  misc_opts->ReadInfo();
 
165
  files->ReadInfo();
 
166
  factor->ReadInfo();
 
167
}
 
168
 
 
169
 
 
170
void Guix_MainWin::WriteAllInfo()
 
171
{
 
172
  // Note: do build_mode before files
 
173
  build_mode->WriteInfo();
 
174
  misc_opts->WriteInfo();
 
175
  files->WriteInfo();
 
176
  factor->WriteInfo();
 
177
}
 
178
 
 
179
 
 
180
void Guix_MainWin::LockOut(boolean_g lock_it)
 
181
{
 
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);
 
188
 
 
189
  // change the mouse cursor
 
190
  cursor(lock_it ? FL_CURSOR_WAIT : FL_CURSOR_DEFAULT);
 
191
}
 
192