File: window.cc

package info (click to toggle)
glbsp 2.24-8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,220 kB
  • sloc: cpp: 10,762; ansic: 6,953; makefile: 121; sh: 14
file content (171 lines) | stat: -rw-r--r-- 3,820 bytes parent folder | download | duplicates (5)
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
//------------------------------------------------------------------------
//  WINDOW : Main application window
//------------------------------------------------------------------------
//
//  GL-Node Viewer (C) 2004-2007 Andrew Apted
//
//  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 "defs.h"

#ifndef WIN32
#include <unistd.h>
#endif


Guix_MainWin *guix_win;


#define WINDOW_MIN_W  480
#define WINDOW_MIN_H  440

#define WINDOW_NORM_W  620
#define WINDOW_NORM_H  460


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_Double_Window(WINDOW_NORM_W, WINDOW_NORM_H, title)
{
  // turn off auto-add-widget mode
  end();

  size_range(WINDOW_MIN_W, 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()-200, 28);
  add(menu_bar);

  grid = new W_Grid(0, mh, w()-200, h()-mh);
  add(grid);
  resizable(grid);

  info = new W_Info(w()-200, mh*0, 200, h()-mh*0);
  add(info);

#if 0
  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);
#endif

  // show window (pass some dummy arguments)
  int argc = 1;
  char *argv[] = { "nodeview", 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();
  }
}