1 | /****************************************************************************
|
---|
2 |
|
---|
3 | GLUI User Interface Toolkit
|
---|
4 | ---------------------------
|
---|
5 |
|
---|
6 | glui.h - Main header for GLUI User Interface Toolkit
|
---|
7 |
|
---|
8 |
|
---|
9 | --------------------------------------------------
|
---|
10 |
|
---|
11 | Copyright (c) 1998 Paul Rademacher
|
---|
12 |
|
---|
13 | This program is freely distributable without licensing fees and is
|
---|
14 | provided without guarantee or warrantee expressed or implied. This
|
---|
15 | program is -not- in the public domain.
|
---|
16 |
|
---|
17 | *****************************************************************************/
|
---|
18 |
|
---|
19 |
|
---|
20 | #ifndef _GLUI_H_
|
---|
21 | #define _GLUI_H_
|
---|
22 |
|
---|
23 | #include "glut.h"
|
---|
24 | #include <stdlib.h>
|
---|
25 | #include <stdio.h>
|
---|
26 | #include <string.h>
|
---|
27 | #include <sys/types.h>
|
---|
28 | #include <time.h>
|
---|
29 |
|
---|
30 | #define GLUI_VERSION 2.01f /********** Current version **********/
|
---|
31 |
|
---|
32 | class Arcball;
|
---|
33 |
|
---|
34 | /********** Do some basic defines *******/
|
---|
35 | #ifndef false
|
---|
36 | #define true 1
|
---|
37 | #define false 0
|
---|
38 | #endif
|
---|
39 |
|
---|
40 | #ifndef Byte
|
---|
41 | #define Byte unsigned char
|
---|
42 | #endif
|
---|
43 |
|
---|
44 | #ifndef _RGBC_
|
---|
45 | class RGBc {
|
---|
46 | public:
|
---|
47 | Byte r, g, b;
|
---|
48 |
|
---|
49 | void set(Byte r,Byte g,Byte b) {this->r=r;this->g=g;this->b=b;};
|
---|
50 |
|
---|
51 | RGBc( void ) {};
|
---|
52 | RGBc( Byte r, Byte g, Byte b ) { set( r, g, b ); };
|
---|
53 | };
|
---|
54 | #define _RGBC_
|
---|
55 | #endif
|
---|
56 |
|
---|
57 | /********** List of GLUT callbacks ********/
|
---|
58 |
|
---|
59 | enum GLUI_Glut_CB_Types {
|
---|
60 | GLUI_GLUT_RESHAPE,
|
---|
61 | GLUI_GLUT_KEYBOARD,
|
---|
62 | GLUI_GLUT_DISPLAY,
|
---|
63 | GLUI_GLUT_MOUSE,
|
---|
64 | GLUI_GLUT_MOTION,
|
---|
65 | GLUI_GLUT_SPECIAL,
|
---|
66 | GLUI_GLUT_PASSIVE_MOTION,
|
---|
67 | GLUI_GLUT_ENTRY,
|
---|
68 | GLUI_GLUT_VISIBILITY
|
---|
69 | };
|
---|
70 |
|
---|
71 | /********** List of control types **********/
|
---|
72 | enum GLUI_Control_Types {
|
---|
73 | GLUI_CONTROL_CHECKBOX =1,
|
---|
74 | GLUI_CONTROL_BUTTON,
|
---|
75 | GLUI_CONTROL_RADIOBUTTON,
|
---|
76 | GLUI_CONTROL_RADIOGROUP,
|
---|
77 | GLUI_CONTROL_SLIDER,
|
---|
78 | GLUI_CONTROL_STATICTEXT,
|
---|
79 | GLUI_CONTROL_EDITTEXT,
|
---|
80 | GLUI_CONTROL_BITMAP,
|
---|
81 | GLUI_CONTROL_PANEL,
|
---|
82 | GLUI_CONTROL_SPINNER,
|
---|
83 | GLUI_CONTROL_SEPARATOR,
|
---|
84 | GLUI_CONTROL_COLUMN,
|
---|
85 | GLUI_CONTROL_LISTBOX,
|
---|
86 | GLUI_CONTROL_MOUSE_INTERACTION,
|
---|
87 | GLUI_CONTROL_ROTATION,
|
---|
88 | GLUI_CONTROL_TRANSLATION,
|
---|
89 | GLUI_CONTROL_ROLLOUT,
|
---|
90 | GLUI_CONTROL_HSLIDER
|
---|
91 | };
|
---|
92 |
|
---|
93 |
|
---|
94 | /********* Constants for window placement **********/
|
---|
95 | #define GLUI_XOFF 6
|
---|
96 | #define GLUI_YOFF 6
|
---|
97 | #define GLUI_ITEMSPACING 3
|
---|
98 | #define GLUI_CHECKBOX_SIZE 13
|
---|
99 | #define GLUI_RADIOBUTTON_SIZE 13
|
---|
100 | #define GLUI_BUTTON_SIZE 20
|
---|
101 | #define GLUI_STATICTEXT_SIZE 13
|
---|
102 | #define GLUI_SEPARATOR_HEIGHT 8
|
---|
103 | #define GLUI_DEFAULT_CONTROL_WIDTH 100
|
---|
104 | #define GLUI_DEFAULT_CONTROL_HEIGHT 13
|
---|
105 | #define GLUI_EDITTEXT_BOXINNERMARGINX 3
|
---|
106 | #define GLUI_EDITTEXT_HEIGHT 20
|
---|
107 | #define GLUI_EDITTEXT_WIDTH 130
|
---|
108 | #define GLUI_EDITTEXT_MIN_INT_WIDTH 35
|
---|
109 | #define GLUI_EDITTEXT_MIN_TEXT_WIDTH 50
|
---|
110 | #define GLUI_PANEL_NAME_DROP 8
|
---|
111 | #define GLUI_PANEL_EMBOSS_TOP 4
|
---|
112 | /* #define GLUI_ROTATION_WIDTH 60*/
|
---|
113 | /* #define GLUI_ROTATION_HEIGHT 78 */
|
---|
114 | #define GLUI_ROTATION_WIDTH 50
|
---|
115 | #define GLUI_ROTATION_HEIGHT (GLUI_ROTATION_WIDTH+18)
|
---|
116 | #define GLUI_MOUSE_INTERACTION_WIDTH 50
|
---|
117 | #define GLUI_MOUSE_INTERACTION_HEIGHT (GLUI_MOUSE_INTERACTION_WIDTH)+18
|
---|
118 | #define GLUI_HSLIDER_HEIGHT 16
|
---|
119 | #define GLUI_HSLIDER_WIDTH 130
|
---|
120 |
|
---|
121 |
|
---|
122 | /** Different panel control types **/
|
---|
123 | #define GLUI_PANEL_NONE 0
|
---|
124 | #define GLUI_PANEL_EMBOSSED 1
|
---|
125 | #define GLUI_PANEL_RAISED 2
|
---|
126 |
|
---|
127 |
|
---|
128 | /** Max # of els in control's float_array **/
|
---|
129 | #define GLUI_DEF_MAX_ARRAY 30
|
---|
130 |
|
---|
131 | /********* The control's 'active' behavior *********/
|
---|
132 | #define GLUI_CONTROL_ACTIVE_MOUSEDOWN 1
|
---|
133 | #define GLUI_CONTROL_ACTIVE_PERMANENT 2
|
---|
134 |
|
---|
135 |
|
---|
136 | /********* Control alignment types **********/
|
---|
137 | #define GLUI_ALIGN_CENTER 1
|
---|
138 | #define GLUI_ALIGN_RIGHT 2
|
---|
139 | #define GLUI_ALIGN_LEFT 3
|
---|
140 |
|
---|
141 |
|
---|
142 | /********** Limit types - how to limit spinner values *********/
|
---|
143 | #define GLUI_LIMIT_NONE 0
|
---|
144 | #define GLUI_LIMIT_CLAMP 1
|
---|
145 | #define GLUI_LIMIT_WRAP 2
|
---|
146 |
|
---|
147 |
|
---|
148 | /********** Translation control types ********************/
|
---|
149 |
|
---|
150 | #define GLUI_TRANSLATION_XY 0
|
---|
151 | #define GLUI_TRANSLATION_Z 1
|
---|
152 | #define GLUI_TRANSLATION_X 2
|
---|
153 | #define GLUI_TRANSLATION_Y 3
|
---|
154 |
|
---|
155 | #define GLUI_TRANSLATION_LOCK_NONE 0
|
---|
156 | #define GLUI_TRANSLATION_LOCK_X 1
|
---|
157 | #define GLUI_TRANSLATION_LOCK_Y 2
|
---|
158 |
|
---|
159 | /********** How was a control activated? *****************/
|
---|
160 | #define GLUI_ACTIVATE_MOUSE 1
|
---|
161 | #define GLUI_ACTIVATE_TAB 2
|
---|
162 |
|
---|
163 |
|
---|
164 | /********** What type of live variable does a control have? **********/
|
---|
165 | #define GLUI_LIVE_NONE 0
|
---|
166 | #define GLUI_LIVE_INT 1
|
---|
167 | #define GLUI_LIVE_FLOAT 2
|
---|
168 | #define GLUI_LIVE_TEXT 3
|
---|
169 | #define GLUI_LIVE_DOUBLE 4
|
---|
170 | #define GLUI_LIVE_FLOAT_ARRAY 5
|
---|
171 |
|
---|
172 |
|
---|
173 | /********** Translation codes **********/
|
---|
174 |
|
---|
175 | enum TranslationCodes {
|
---|
176 | GLUI_TRANSLATION_MOUSE_NONE=0,
|
---|
177 | GLUI_TRANSLATION_MOUSE_UP,
|
---|
178 | GLUI_TRANSLATION_MOUSE_DOWN,
|
---|
179 | GLUI_TRANSLATION_MOUSE_LEFT,
|
---|
180 | GLUI_TRANSLATION_MOUSE_RIGHT,
|
---|
181 | GLUI_TRANSLATION_MOUSE_UP_LEFT,
|
---|
182 | GLUI_TRANSLATION_MOUSE_UP_RIGHT,
|
---|
183 | GLUI_TRANSLATION_MOUSE_DOWN_LEFT,
|
---|
184 | GLUI_TRANSLATION_MOUSE_DOWN_RIGHT
|
---|
185 | };
|
---|
186 |
|
---|
187 | /************ A string type for us to use **********/
|
---|
188 | /* typedef char GLUI_String[300]; */
|
---|
189 | class GLUI_String
|
---|
190 | {
|
---|
191 | public:
|
---|
192 | char string[300];
|
---|
193 |
|
---|
194 | char &operator[]( int i ) {
|
---|
195 | return string[i];
|
---|
196 | }
|
---|
197 |
|
---|
198 | operator char*() { return (char*) &string[0]; };
|
---|
199 | /* operator void*() { return (void*) &string[0]; }; */
|
---|
200 |
|
---|
201 | GLUI_String( void ) {
|
---|
202 | string[0] = '\0';
|
---|
203 | }
|
---|
204 |
|
---|
205 | GLUI_String( char *text ) {
|
---|
206 | strcpy( string, text );
|
---|
207 | }
|
---|
208 | };
|
---|
209 |
|
---|
210 |
|
---|
211 | /********* Pre-declare the various classes *********/
|
---|
212 | class GLUI;
|
---|
213 | class GLUI_Control;
|
---|
214 | class GLUI_Listbox;
|
---|
215 | class GLUI_Rotation;
|
---|
216 | class GLUI_Translation;
|
---|
217 | class GLUI_Mouse_Interaction;
|
---|
218 | class GLUI_Checkbox;
|
---|
219 | class GLUI_HSlider;
|
---|
220 | class GLUI_Button;
|
---|
221 | class GLUI_StaticText;
|
---|
222 | class GLUI_Bitmap;
|
---|
223 | class GLUI_EditText;
|
---|
224 | class GLUI_Node;
|
---|
225 | class GLUI_Main;
|
---|
226 | class GLUI_Panel;
|
---|
227 | class GLUI_Spinner;
|
---|
228 | class GLUI_RadioButton;
|
---|
229 | class GLUI_RadioGroup;
|
---|
230 | class GLUI_Separator;
|
---|
231 | class GLUI_Column;
|
---|
232 | class GLUI_Master;
|
---|
233 | class GLUI_Glut_Window;
|
---|
234 | class GLUI_Rollout;
|
---|
235 |
|
---|
236 |
|
---|
237 |
|
---|
238 | /*** Flags for GLUI class constructor ***/
|
---|
239 | #define GLUI_SUBWINDOW ((long)(1<< 1))
|
---|
240 | #define GLUI_SUBWINDOW_TOP ((long)(1<< 2))
|
---|
241 | #define GLUI_SUBWINDOW_BOTTOM ((long)(1<< 3))
|
---|
242 | #define GLUI_SUBWINDOW_LEFT ((long)(1<< 4))
|
---|
243 | #define GLUI_SUBWINDOW_RIGHT ((long)(1<< 5))
|
---|
244 |
|
---|
245 | /*** Codes for different type of edittext boxes and spinners ***/
|
---|
246 | #define GLUI_EDITTEXT_TEXT 1
|
---|
247 | #define GLUI_EDITTEXT_INT 2
|
---|
248 | #define GLUI_EDITTEXT_FLOAT 3
|
---|
249 | #define GLUI_SPINNER_INT GLUI_EDITTEXT_INT
|
---|
250 | #define GLUI_SPINNER_FLOAT GLUI_EDITTEXT_FLOAT
|
---|
251 | #define GLUI_HSLIDER_INT GLUI_EDITTEXT_INT
|
---|
252 | #define GLUI_HSLIDER_FLOAT GLUI_EDITTEXT_FLOAT
|
---|
253 |
|
---|
254 |
|
---|
255 |
|
---|
256 | /*** Definition of callbacks ***/
|
---|
257 | typedef void (*GLUI_Update_CB) (int id);
|
---|
258 | typedef void (*Int1_CB) (int);
|
---|
259 | typedef void (*Int2_CB) (int, int);
|
---|
260 | typedef void (*Int3_CB) (int, int, int);
|
---|
261 | typedef void (*Int4_CB) (int, int, int, int);
|
---|
262 |
|
---|
263 |
|
---|
264 |
|
---|
265 | /************************************************************/
|
---|
266 | /* */
|
---|
267 | /* Base class, for hierarchical relationships */
|
---|
268 | /* */
|
---|
269 | /************************************************************/
|
---|
270 |
|
---|
271 | class GLUI_Node {
|
---|
272 | protected:
|
---|
273 | GLUI_Node *parent_node;
|
---|
274 | GLUI_Node *child_head;
|
---|
275 | GLUI_Node *child_tail;
|
---|
276 | GLUI_Node *next_sibling;
|
---|
277 | GLUI_Node *prev_sibling;
|
---|
278 |
|
---|
279 | public:
|
---|
280 | GLUI_Node *first_sibling( void );
|
---|
281 | GLUI_Node *last_sibling( void );
|
---|
282 | GLUI_Node *prev( void );
|
---|
283 | GLUI_Node *next( void );
|
---|
284 | GLUI_Node *first_child( void ) { return child_head; };
|
---|
285 | GLUI_Node *last_child( void ) { return child_tail; };
|
---|
286 | GLUI_Node *parent(void) { return parent_node; };
|
---|
287 |
|
---|
288 | void link_this_to_parent_last( GLUI_Node *parent );
|
---|
289 | void link_this_to_parent_first( GLUI_Node *parent );
|
---|
290 | void link_this_to_sibling_next( GLUI_Node *sibling );
|
---|
291 | void link_this_to_sibling_prev( GLUI_Node *sibling );
|
---|
292 | void unlink( void );
|
---|
293 |
|
---|
294 | void dump( FILE *out, char *name ) {
|
---|
295 | fprintf( out, "GLUI_node: %s\n", name );
|
---|
296 | fprintf( out, " parent: %p child_head: %p child_tail: %p\n",
|
---|
297 | parent_node, child_head, child_tail );
|
---|
298 | fprintf( out, " next: %p prev: %p\n", next_sibling, prev_sibling );
|
---|
299 | }
|
---|
300 |
|
---|
301 | GLUI_Node( void ) {
|
---|
302 | parent_node= child_head = child_tail = next_sibling = prev_sibling = NULL;
|
---|
303 | };
|
---|
304 |
|
---|
305 | friend GLUI_Rollout;
|
---|
306 | friend GLUI_Main;
|
---|
307 | };
|
---|
308 |
|
---|
309 |
|
---|
310 |
|
---|
311 | /************************************************************/
|
---|
312 | /* */
|
---|
313 | /* Standard Bitmap stuff */
|
---|
314 | /* */
|
---|
315 | /************************************************************/
|
---|
316 |
|
---|
317 | enum GLUI_StdBitmaps_Codes {
|
---|
318 | GLUI_STDBITMAP_CHECKBOX_OFF=0,
|
---|
319 | GLUI_STDBITMAP_CHECKBOX_ON,
|
---|
320 | GLUI_STDBITMAP_RADIOBUTTON_OFF,
|
---|
321 | GLUI_STDBITMAP_RADIOBUTTON_ON,
|
---|
322 | GLUI_STDBITMAP_UP_ARROW,
|
---|
323 | GLUI_STDBITMAP_DOWN_ARROW,
|
---|
324 | GLUI_STDBITMAP_LEFT_ARROW,
|
---|
325 | GLUI_STDBITMAP_RIGHT_ARROW,
|
---|
326 | GLUI_STDBITMAP_TROUGH,
|
---|
327 | GLUI_STDBITMAP_SPINNER_UP_OFF,
|
---|
328 | GLUI_STDBITMAP_SPINNER_UP_ON,
|
---|
329 | GLUI_STDBITMAP_SPINNER_DOWN_OFF,
|
---|
330 | GLUI_STDBITMAP_SPINNER_DOWN_ON,
|
---|
331 |
|
---|
332 | GLUI_STDBITMAP_CHECKBOX_OFF_DIS, /*** Disactivated control bitmaps ***/
|
---|
333 | GLUI_STDBITMAP_CHECKBOX_ON_DIS,
|
---|
334 | GLUI_STDBITMAP_RADIOBUTTON_OFF_DIS,
|
---|
335 | GLUI_STDBITMAP_RADIOBUTTON_ON_DIS,
|
---|
336 | GLUI_STDBITMAP_SPINNER_UP_DIS,
|
---|
337 | GLUI_STDBITMAP_SPINNER_DOWN_DIS,
|
---|
338 | GLUI_STDBITMAP_LISTBOX_UP,
|
---|
339 | GLUI_STDBITMAP_LISTBOX_DOWN,
|
---|
340 | GLUI_STDBITMAP_LISTBOX_UP_DIS,
|
---|
341 | /***
|
---|
342 | GLUI_STDBITMAP_SLIDER_TAB,
|
---|
343 | ***/
|
---|
344 | GLUI_STDBITMAP_NUM_ITEMS
|
---|
345 | };
|
---|
346 |
|
---|
347 |
|
---|
348 | /************ Image Bitmap arrays **********/
|
---|
349 | extern int glui_img_checkbox_0[];
|
---|
350 | extern int glui_img_checkbox_1[];
|
---|
351 | extern int glui_img_radiobutton_0[];
|
---|
352 | extern int glui_img_radiobutton_1[];
|
---|
353 | extern int glui_img_uparrow[];
|
---|
354 | extern int glui_img_downarrow[];
|
---|
355 | extern int glui_img_leftarrow[];
|
---|
356 | extern int glui_img_rightarrow[];
|
---|
357 | extern int glui_img_trough[];
|
---|
358 | extern int glui_img_spinup_0[];
|
---|
359 | extern int glui_img_spinup_1[];
|
---|
360 | extern int glui_img_spindown_0[];
|
---|
361 | extern int glui_img_spindown_1[];
|
---|
362 | extern int glui_img_checkbox_0_dis[];
|
---|
363 | extern int glui_img_checkbox_1_dis[];
|
---|
364 | extern int glui_img_radiobutton_0_dis[];
|
---|
365 | extern int glui_img_radiobutton_1_dis[];
|
---|
366 | extern int glui_img_spinup_dis[];
|
---|
367 | extern int glui_img_spindown_dis[];
|
---|
368 | extern int glui_img_listbox_up[];
|
---|
369 | extern int glui_img_listbox_down[];
|
---|
370 | extern int glui_img_listbox_up_dis[];
|
---|
371 |
|
---|
372 | extern int *bitmap_arrays[];
|
---|
373 |
|
---|
374 |
|
---|
375 |
|
---|
376 | /************************************************************/
|
---|
377 | /* */
|
---|
378 | /* Class GLUI_Bitmap */
|
---|
379 | /* */
|
---|
380 | /************************************************************/
|
---|
381 | class GLUI_Bitmap
|
---|
382 | {
|
---|
383 | public:
|
---|
384 | unsigned char *pixels;
|
---|
385 | int w, h;
|
---|
386 |
|
---|
387 | void load_from_array( int *array );
|
---|
388 |
|
---|
389 | GLUI_Bitmap( void ) {
|
---|
390 | pixels = NULL;
|
---|
391 | w = 0;
|
---|
392 | h = 0;
|
---|
393 | }
|
---|
394 | };
|
---|
395 |
|
---|
396 |
|
---|
397 |
|
---|
398 |
|
---|
399 | /************************************************************/
|
---|
400 | /* */
|
---|
401 | /* Class GLUI_StdBitmap */
|
---|
402 | /* */
|
---|
403 | /************************************************************/
|
---|
404 | class GLUI_StdBitmaps
|
---|
405 | {
|
---|
406 | public:
|
---|
407 | GLUI_Bitmap bitmaps[ GLUI_STDBITMAP_NUM_ITEMS ];
|
---|
408 |
|
---|
409 | void draw( int bitmap_num, int x, int y );
|
---|
410 |
|
---|
411 | GLUI_StdBitmaps( void ) {
|
---|
412 | int i;
|
---|
413 |
|
---|
414 | for( i=0; i<GLUI_STDBITMAP_NUM_ITEMS; i++ ) {
|
---|
415 | bitmaps[i].load_from_array( bitmap_arrays[i] );
|
---|
416 | }
|
---|
417 | }
|
---|
418 | };
|
---|
419 |
|
---|
420 |
|
---|
421 |
|
---|
422 |
|
---|
423 | /************************************************************/
|
---|
424 | /* */
|
---|
425 | /* Master GLUI Class */
|
---|
426 | /* */
|
---|
427 | /************************************************************/
|
---|
428 | class GLUI_Master_Object {
|
---|
429 | private:
|
---|
430 | GLUI_Node glut_windows;
|
---|
431 | void (*glut_idle_CB)(void);
|
---|
432 |
|
---|
433 | void add_cb_to_glut_window(int window,int cb_type,void *cb);
|
---|
434 |
|
---|
435 | public:
|
---|
436 | GLUI_Node gluis;
|
---|
437 | GLUI_Control *active_control, *curr_left_button_glut_menu;
|
---|
438 | GLUI *active_control_glui;
|
---|
439 | int glui_id_counter;
|
---|
440 |
|
---|
441 | GLUI_Glut_Window *find_glut_window( int window_id );
|
---|
442 |
|
---|
443 | void set_glutIdleFunc(void (*f)(void));
|
---|
444 |
|
---|
445 | /**************
|
---|
446 | void (*glut_keyboard_CB)(unsigned char, int, int);
|
---|
447 | void (*glut_reshape_CB)(int, int);
|
---|
448 | void (*glut_special_CB)(int, int, int);
|
---|
449 | void (*glut_mouse_CB)(int,int,int,int);
|
---|
450 |
|
---|
451 | void (*glut_passive_motion_CB)(int,int);
|
---|
452 | void (*glut_visibility_CB)(int);
|
---|
453 | void (*glut_motion_CB)(int,int);
|
---|
454 | void (*glut_display_CB)(void);
|
---|
455 | void (*glut_entry_CB)(int);
|
---|
456 | **********/
|
---|
457 |
|
---|
458 | void set_left_button_glut_menu_control( GLUI_Control *control );
|
---|
459 |
|
---|
460 |
|
---|
461 | /********** GLUT callthroughs **********/
|
---|
462 | /* These are the glut callbacks that we do not handle */
|
---|
463 |
|
---|
464 | void set_glutReshapeFunc(void (*f)(int width, int height));
|
---|
465 | void set_glutKeyboardFunc(void (*f)(unsigned char key, int x, int y));
|
---|
466 | void set_glutSpecialFunc(void (*f)(int key, int x, int y));
|
---|
467 | void set_glutMouseFunc(void (*f)(int, int, int, int ));
|
---|
468 |
|
---|
469 | void set_glutDisplayFunc(void (*f)(void)) {glutDisplayFunc(f);};
|
---|
470 | void set_glutTimerFunc(unsigned int millis, void (*f)(int value), int value)
|
---|
471 | { ::glutTimerFunc(millis,f,value);};
|
---|
472 | void set_glutOverlayDisplayFunc(void(*f)(void)){glutOverlayDisplayFunc(f);};
|
---|
473 | void set_glutSpaceballMotionFunc(Int3_CB f) {glutSpaceballMotionFunc(f);};
|
---|
474 | void set_glutSpaceballRotateFunc(Int3_CB f) {glutSpaceballRotateFunc(f);};
|
---|
475 | void set_glutSpaceballButtonFunc(Int2_CB f) {glutSpaceballButtonFunc(f);};
|
---|
476 | void set_glutTabletMotionFunc(Int2_CB f) {glutTabletMotionFunc(f);};
|
---|
477 | void set_glutTabletButtonFunc(Int4_CB f) {glutTabletButtonFunc(f);};
|
---|
478 | /* void set_glutWindowStatusFunc(Int1_CB f) {glutWindowStatusFunc(f);}; */
|
---|
479 | void set_glutMenuStatusFunc(Int3_CB f) {glutMenuStatusFunc(f);};
|
---|
480 | void set_glutMenuStateFunc(Int1_CB f) {glutMenuStateFunc(f);};
|
---|
481 | void set_glutButtonBoxFunc(Int2_CB f) {glutButtonBoxFunc(f);};
|
---|
482 | void set_glutDialsFunc(Int2_CB f) {glutDialsFunc(f);};
|
---|
483 |
|
---|
484 |
|
---|
485 | GLUI *create_glui( char *name, long flags=0, int x=-1, int y=-1 );
|
---|
486 | GLUI *create_glui_subwindow( int parent_window, long flags=0 );
|
---|
487 | GLUI *find_glui_by_window_id( int window_id );
|
---|
488 | void get_viewport_area( int *x, int *y, int *w, int *h );
|
---|
489 | void auto_set_viewport( void );
|
---|
490 | void close_all( void );
|
---|
491 | void sync_live_all( void );
|
---|
492 |
|
---|
493 | void reshape( void );
|
---|
494 |
|
---|
495 | float get_version( void ) { return GLUI_VERSION; };
|
---|
496 |
|
---|
497 | friend void glui_idle_func(void);
|
---|
498 |
|
---|
499 | GLUI_Master_Object( void ) {
|
---|
500 | glut_idle_CB = NULL;
|
---|
501 | glui_id_counter = 1;
|
---|
502 | }
|
---|
503 | };
|
---|
504 |
|
---|
505 | extern GLUI_Master_Object GLUI_Master;
|
---|
506 |
|
---|
507 |
|
---|
508 |
|
---|
509 | /************************************************************/
|
---|
510 | /* */
|
---|
511 | /* Class for managing a GLUT window */
|
---|
512 | /* */
|
---|
513 | /************************************************************/
|
---|
514 |
|
---|
515 | class GLUI_Glut_Window : public GLUI_Node {
|
---|
516 | public:
|
---|
517 | int glut_window_id;
|
---|
518 |
|
---|
519 | /*********** Pointers to GLUT callthrough functions *****/
|
---|
520 | void (*glut_keyboard_CB)(unsigned char, int, int);
|
---|
521 | void (*glut_special_CB)(int, int, int);
|
---|
522 | void (*glut_reshape_CB)(int, int);
|
---|
523 | void (*glut_passive_motion_CB)(int,int);
|
---|
524 | void (*glut_mouse_CB)(int,int,int,int);
|
---|
525 | void (*glut_visibility_CB)(int);
|
---|
526 | void (*glut_motion_CB)(int,int);
|
---|
527 | void (*glut_display_CB)(void);
|
---|
528 | void (*glut_entry_CB)(int);
|
---|
529 |
|
---|
530 | GLUI_Glut_Window( void ) {
|
---|
531 | glut_display_CB = NULL;
|
---|
532 | glut_reshape_CB = NULL;
|
---|
533 | glut_keyboard_CB = NULL;
|
---|
534 | glut_special_CB = NULL;
|
---|
535 | glut_mouse_CB = NULL;
|
---|
536 | glut_motion_CB = NULL;
|
---|
537 | glut_passive_motion_CB = NULL;
|
---|
538 | glut_entry_CB = NULL;
|
---|
539 | glut_visibility_CB = NULL;
|
---|
540 | glut_window_id = 0;
|
---|
541 | };
|
---|
542 | };
|
---|
543 |
|
---|
544 |
|
---|
545 |
|
---|
546 | /************************************************************/
|
---|
547 | /* */
|
---|
548 | /* Main GLUI class (not user-level) */
|
---|
549 | /* */
|
---|
550 | /************************************************************/
|
---|
551 |
|
---|
552 | class GLUI_Main : public GLUI_Node {
|
---|
553 | protected:
|
---|
554 | /*** Variables ***/
|
---|
555 | int main_gfx_window_id;
|
---|
556 | int mouse_button_down;
|
---|
557 | int glut_window_id;
|
---|
558 | int top_level_glut_window_id;
|
---|
559 | GLUI_Control *active_control;
|
---|
560 | GLUI_Control *mouse_over_control;
|
---|
561 | GLUI_Panel *main_panel;
|
---|
562 | int curr_cursor;
|
---|
563 | int w, h;
|
---|
564 | long flags;
|
---|
565 | int closing;
|
---|
566 | int parent_window;
|
---|
567 | int glui_id;
|
---|
568 |
|
---|
569 | /********** Friend classes *************/
|
---|
570 |
|
---|
571 | friend GLUI_Control;
|
---|
572 | friend GLUI_Rotation;
|
---|
573 | friend GLUI_Translation;
|
---|
574 | friend GLUI;
|
---|
575 | friend GLUI_Master_Object;
|
---|
576 |
|
---|
577 |
|
---|
578 | /********** Misc functions *************/
|
---|
579 |
|
---|
580 | GLUI_Control *find_control( int x, int y );
|
---|
581 | GLUI_Control *find_next_control( GLUI_Control *control );
|
---|
582 | GLUI_Control *find_next_control_rec( GLUI_Control *control );
|
---|
583 | GLUI_Control *find_next_control_( GLUI_Control *control );
|
---|
584 | GLUI_Control *find_prev_control( GLUI_Control *control );
|
---|
585 | void create_standalone_window( char *name, int x=-1, int y=-1 );
|
---|
586 | void create_subwindow( int parent,int window_alignment );
|
---|
587 | void setup_default_glut_callbacks( void );
|
---|
588 |
|
---|
589 | void mouse(int button, int state, int x, int y);
|
---|
590 | void keyboard(unsigned char key, int x, int y);
|
---|
591 | void special(int key, int x, int y);
|
---|
592 | void passive_motion(int x, int y);
|
---|
593 | void reshape( int w, int h );
|
---|
594 | void visibility(int state);
|
---|
595 | void motion(int x, int y);
|
---|
596 | void entry(int state);
|
---|
597 | void display( void );
|
---|
598 | void idle(void);
|
---|
599 |
|
---|
600 | void (*glut_mouse_CB)(int, int, int, int);
|
---|
601 | void (*glut_keyboard_CB)(unsigned char, int, int);
|
---|
602 | void (*glut_special_CB)(int, int, int);
|
---|
603 | void (*glut_reshape_CB)(int, int);
|
---|
604 |
|
---|
605 |
|
---|
606 | /*********** Friend functions and classes **********/
|
---|
607 |
|
---|
608 | friend void glui_mouse_func(int button, int state, int x, int y);
|
---|
609 | friend void glui_keyboard_func(unsigned char key, int x, int y);
|
---|
610 | friend void glui_special_func(int key, int x, int y);
|
---|
611 | friend void glui_passive_motion_func(int x, int y);
|
---|
612 | friend void glui_reshape_func( int w, int h );
|
---|
613 | friend void glui_visibility_func(int state);
|
---|
614 | friend void glui_motion_func(int x, int y);
|
---|
615 | friend void glui_entry_func(int state);
|
---|
616 | friend void glui_display_func( void );
|
---|
617 | friend void glui_idle_func(void);
|
---|
618 |
|
---|
619 | friend void glui_parent_window_reshape_func( int w, int h );
|
---|
620 | friend void glui_parent_window_keyboard_func( unsigned char, int, int );
|
---|
621 | friend void glui_parent_window_special_func( int, int, int );
|
---|
622 | friend void glui_parent_window_mouse_func( int, int, int, int );
|
---|
623 |
|
---|
624 |
|
---|
625 | /*********** Controls ************/
|
---|
626 | GLUI_Control *controls;
|
---|
627 | int num_controls;
|
---|
628 |
|
---|
629 | int add_control( GLUI_Node *parent, GLUI_Control *control );
|
---|
630 |
|
---|
631 |
|
---|
632 | /********** Constructors and Destructors ***********/
|
---|
633 |
|
---|
634 | GLUI_Main( void );
|
---|
635 |
|
---|
636 | public:
|
---|
637 | GLUI_StdBitmaps std_bitmaps;
|
---|
638 | GLUI_String window_name;
|
---|
639 | RGBc bkgd_color;
|
---|
640 | float bkgd_color_f[3];
|
---|
641 |
|
---|
642 | void *font;
|
---|
643 | int curr_modifiers;
|
---|
644 |
|
---|
645 | void adjust_glut_xy( int &x, int &y ) { y = h-y; x = x; };
|
---|
646 | void activate_control( GLUI_Control *control, int how );
|
---|
647 | void align_controls( GLUI_Control *control );
|
---|
648 | void restore_draw_buffer( int buffer_state );
|
---|
649 | void disactivate_current_control( void );
|
---|
650 | void draw_raised_box( int x, int y, int w, int h );
|
---|
651 | void draw_lowered_box( int x, int y, int w, int h );
|
---|
652 | int set_front_draw_buffer( void );
|
---|
653 | void post_update_main_gfx( void );
|
---|
654 | void pack_controls( void );
|
---|
655 | void close_internal( void );
|
---|
656 | void check_subwindow_position( void );
|
---|
657 | void set_ortho_projection( void );
|
---|
658 | void set_viewport( void );
|
---|
659 | void refresh( void );
|
---|
660 | };
|
---|
661 |
|
---|
662 |
|
---|
663 |
|
---|
664 |
|
---|
665 |
|
---|
666 |
|
---|
667 | /************************************************************/
|
---|
668 | /* */
|
---|
669 | /* GLUI_Control: base class for all controls */
|
---|
670 | /* */
|
---|
671 | /************************************************************/
|
---|
672 |
|
---|
673 | class GLUI_Control : public GLUI_Node {
|
---|
674 | public:
|
---|
675 |
|
---|
676 | int w, h; /* dimensions of control */
|
---|
677 | int x_abs, y_abs;
|
---|
678 | int x_off, y_off_top, y_off_bot; /* INNER margins, by which
|
---|
679 | child controls are indented */
|
---|
680 | int contain_x, contain_y;
|
---|
681 | int contain_w, contain_h;
|
---|
682 | /* if this is a container control (e.g.,
|
---|
683 | radiogroup or panel) this indicated dimensions
|
---|
684 | of inner area in which controls reside */
|
---|
685 | int active, active_type, can_activate;
|
---|
686 | int spacebar_mouse_click;
|
---|
687 | long user_id, type;
|
---|
688 | int is_container; /* Is this a container class (e.g., panel) */
|
---|
689 | int alignment;
|
---|
690 | GLUI_Update_CB callback;
|
---|
691 | void *ptr_val; /* A pointer value */
|
---|
692 | float float_val; /* A float value */
|
---|
693 | int enabled; /* Is this control grayed out? */
|
---|
694 | int int_val; /* An integer value */
|
---|
695 | float float_array_val[GLUI_DEF_MAX_ARRAY];
|
---|
696 | int state;
|
---|
697 | GLUI_String name; /* The name of this control */
|
---|
698 | GLUI_String text;
|
---|
699 | GLUI *glui;
|
---|
700 | void *font;
|
---|
701 | int live_type, live_inited;
|
---|
702 | int last_live_int; /* last value that live var known to have */
|
---|
703 | float last_live_float;
|
---|
704 | GLUI_String last_live_text;
|
---|
705 | float last_live_float_array[GLUI_DEF_MAX_ARRAY];
|
---|
706 | int float_array_size;
|
---|
707 |
|
---|
708 | int collapsible, is_open;
|
---|
709 | GLUI_Node collapsed_node;
|
---|
710 | int hidden; /* Collapsed controls (and children) are hidden */
|
---|
711 |
|
---|
712 | /*** Get/Set values ***/
|
---|
713 |
|
---|
714 | virtual void set_name( char *string );
|
---|
715 | virtual void set_int_val( int new_int ) { int_val = new_int; output_live(true); };
|
---|
716 | virtual void set_float_val( float new_float ) { float_val = new_float; output_live(true); };
|
---|
717 | virtual void set_ptr_val( void *new_ptr ) { ptr_val = new_ptr; output_live(true); };
|
---|
718 | virtual void set_float_array_val( float *array_ptr );
|
---|
719 |
|
---|
720 | virtual float get_float_val( void ) { return float_val; };
|
---|
721 | virtual int get_int_val( void ) { return int_val; };
|
---|
722 | virtual void get_float_array_val( float *array_ptr );
|
---|
723 |
|
---|
724 | virtual int mouse_down_handler( int local_x, int local_y )
|
---|
725 | { local_x = local_y = local_x + local_y; return false; };
|
---|
726 | virtual int mouse_up_handler( int local_x, int local_y, int inside )
|
---|
727 | { local_x = local_y = inside = local_x+local_y+inside; return false; };
|
---|
728 | virtual int mouse_held_down_handler( int local_x, int local_y, int inside)
|
---|
729 | { local_x = local_y = inside = local_x+local_y+inside; return false; };
|
---|
730 | virtual int key_handler( unsigned char key, int modifiers )
|
---|
731 | { key = key; modifiers = modifiers; return false; };
|
---|
732 | virtual int special_handler( int key,int modifiers )
|
---|
733 | { key = modifiers = key+modifiers; return false; };
|
---|
734 |
|
---|
735 | virtual void update_size( void ) { };
|
---|
736 | virtual void idle( void ) { };
|
---|
737 | virtual int mouse_over( int state, int x, int y )
|
---|
738 | { state = x = y = state+x+y; return false; };
|
---|
739 |
|
---|
740 | virtual void enable( void );
|
---|
741 | virtual void disable( void );
|
---|
742 | virtual void activate( int how ) { how = how; active = true; };
|
---|
743 | virtual void disactivate( void ) { active = false; };
|
---|
744 |
|
---|
745 | void hide_internal( int recurse );
|
---|
746 | void unhide_internal( int recurse );
|
---|
747 |
|
---|
748 | int can_draw( void ) { return (glui != NULL && hidden == false); };
|
---|
749 |
|
---|
750 | virtual void align( void );
|
---|
751 | void pack( int x, int y ); /* Recalculate positions and offsets */
|
---|
752 | void pack_old( int x, int y );
|
---|
753 | void draw_recursive( int x, int y );
|
---|
754 | int set_to_glut_window( void );
|
---|
755 | void restore_window( int orig );
|
---|
756 | void translate_and_draw_front( void );
|
---|
757 | void translate_to_origin( void )
|
---|
758 | {glTranslatef((float)x_abs+.5,(float)y_abs+.5,0.0);};
|
---|
759 | virtual void draw( int x, int y )=0;
|
---|
760 | void set_font( void *new_font );
|
---|
761 | void *get_font( void );
|
---|
762 | int string_width( char *text );
|
---|
763 | int char_width( char c );
|
---|
764 |
|
---|
765 | void draw_name( int x, int y );
|
---|
766 | void draw_box_inwards_outline( int x_min, int x_max,
|
---|
767 | int y_min, int y_max );
|
---|
768 | void draw_box( int x_min, int x_max, int y_min, int y_max,
|
---|
769 | float r, float g, float b );
|
---|
770 | void draw_bkgd_box( int x_min, int x_max, int y_min, int y_max );
|
---|
771 | void draw_emboss_box( int x_min, int x_max,int y_min,int y_max);
|
---|
772 | void draw_string( char *text );
|
---|
773 | void draw_char( char c );
|
---|
774 | void draw_active_box( int x_min, int x_max, int y_min, int y_max );
|
---|
775 | void set_to_bkgd_color( void );
|
---|
776 |
|
---|
777 | void set_w( int new_w );
|
---|
778 | void set_h( int new_w );
|
---|
779 | void set_alignment( int new_align );
|
---|
780 | void sync_live( int recurse, int draw ); /* Reads live variable */
|
---|
781 | void init_live( void );
|
---|
782 | void output_live( int update_main_gfx ); /** Writes live variable **/
|
---|
783 | virtual void set_text( char *t ) { t = t; };
|
---|
784 | void execute_callback( void );
|
---|
785 | void get_this_column_dims( int *col_x, int *col_y,
|
---|
786 | int *col_w, int *col_h,
|
---|
787 | int *col_x_off, int *col_y_off );
|
---|
788 | virtual int needs_idle( void );
|
---|
789 |
|
---|
790 | GLUI_Control(void) {
|
---|
791 | x_off = GLUI_XOFF;
|
---|
792 | y_off_top = GLUI_YOFF;
|
---|
793 | y_off_bot = GLUI_YOFF;
|
---|
794 | x_abs = GLUI_XOFF;
|
---|
795 | y_abs = GLUI_YOFF;
|
---|
796 | state = 0;
|
---|
797 | active = false;
|
---|
798 | enabled = true;
|
---|
799 | int_val = 0;
|
---|
800 | last_live_int = 0;
|
---|
801 | float_array_size = 0;
|
---|
802 | sprintf( (char*)name, "Control: %p", this );
|
---|
803 | float_val = 0.0;
|
---|
804 | last_live_float = 0.0;
|
---|
805 | ptr_val = NULL;
|
---|
806 | glui = NULL;
|
---|
807 | w = GLUI_DEFAULT_CONTROL_WIDTH;
|
---|
808 | h = GLUI_DEFAULT_CONTROL_HEIGHT;
|
---|
809 | font = NULL;
|
---|
810 | active_type = GLUI_CONTROL_ACTIVE_MOUSEDOWN;
|
---|
811 | alignment = GLUI_ALIGN_LEFT;
|
---|
812 | is_container = false;
|
---|
813 | can_activate = true; /* By default, you can activate a control */
|
---|
814 | spacebar_mouse_click = true; /* Does spacebar simulate a mouse click? */
|
---|
815 | live_type = GLUI_LIVE_NONE;
|
---|
816 | strcpy( (char*)text, "" );
|
---|
817 | strcpy( (char*)last_live_text, "" );
|
---|
818 | live_inited = false;
|
---|
819 | collapsible = false;
|
---|
820 | is_open = true;
|
---|
821 | hidden = false;
|
---|
822 |
|
---|
823 | int i;
|
---|
824 | for( i=0; i<GLUI_DEF_MAX_ARRAY; i++ )
|
---|
825 | float_array_val[i] = last_live_float_array[i] = 0.0;
|
---|
826 | };
|
---|
827 |
|
---|
828 | ~GLUI_Control();
|
---|
829 | };
|
---|
830 |
|
---|
831 |
|
---|
832 |
|
---|
833 |
|
---|
834 | /************************************************************/
|
---|
835 | /* */
|
---|
836 | /* Button class (container) */
|
---|
837 | /* */
|
---|
838 | /************************************************************/
|
---|
839 |
|
---|
840 | class GLUI_Button : public GLUI_Control
|
---|
841 | {
|
---|
842 | public:
|
---|
843 | int currently_inside;
|
---|
844 |
|
---|
845 | int mouse_down_handler( int local_x, int local_y );
|
---|
846 | int mouse_up_handler( int local_x, int local_y, int same );
|
---|
847 | int mouse_held_down_handler( int local_x, int local_y, int inside );
|
---|
848 | int key_handler( unsigned char key,int modifiers );
|
---|
849 |
|
---|
850 | void draw( int x, int y );
|
---|
851 | void draw_pressed( void );
|
---|
852 | void draw_unpressed( void );
|
---|
853 | void draw_text( int sunken );
|
---|
854 |
|
---|
855 | void update_size( void );
|
---|
856 |
|
---|
857 | GLUI_Button( void ) {
|
---|
858 | sprintf( name, "Button: %p", this );
|
---|
859 | type = GLUI_CONTROL_BUTTON;
|
---|
860 | h = GLUI_BUTTON_SIZE;
|
---|
861 | w = 100;
|
---|
862 | alignment = GLUI_ALIGN_CENTER;
|
---|
863 | can_activate = true;
|
---|
864 | };
|
---|
865 | };
|
---|
866 |
|
---|
867 |
|
---|
868 |
|
---|
869 | /************************************************************/
|
---|
870 | /* */
|
---|
871 | /* Checkbox class (container) */
|
---|
872 | /* */
|
---|
873 | /************************************************************/
|
---|
874 |
|
---|
875 | class GLUI_Checkbox : public GLUI_Control
|
---|
876 | {
|
---|
877 | public:
|
---|
878 | int orig_value, currently_inside;
|
---|
879 | int text_x_offset;
|
---|
880 |
|
---|
881 | int mouse_down_handler( int local_x, int local_y );
|
---|
882 | int mouse_up_handler( int local_x, int local_y, int inside );
|
---|
883 | int mouse_held_down_handler( int local_x, int local_y, int inside );
|
---|
884 | int key_handler( unsigned char key,int modifiers );
|
---|
885 |
|
---|
886 | void update_size( void );
|
---|
887 |
|
---|
888 | void draw( int x, int y );
|
---|
889 |
|
---|
890 | void draw_active_area( void );
|
---|
891 | void draw_checked( void );
|
---|
892 | void draw_unchecked( void );
|
---|
893 | void draw_X( void );
|
---|
894 | void draw_empty_box( void );
|
---|
895 | void set_int_val( int new_val );
|
---|
896 |
|
---|
897 | GLUI_Checkbox( void ) {
|
---|
898 | sprintf( name, "Checkbox: %p", this );
|
---|
899 | type = GLUI_CONTROL_CHECKBOX;
|
---|
900 | w = 100;
|
---|
901 | h = GLUI_CHECKBOX_SIZE;
|
---|
902 | orig_value = -1;
|
---|
903 | text_x_offset = 18;
|
---|
904 | can_activate = true;
|
---|
905 | live_type = GLUI_LIVE_INT; /* This control has an 'int' live var */
|
---|
906 | };
|
---|
907 | };
|
---|
908 |
|
---|
909 |
|
---|
910 | /************************************************************/
|
---|
911 | /* */
|
---|
912 | /* Column class */
|
---|
913 | /* */
|
---|
914 | /************************************************************/
|
---|
915 |
|
---|
916 | class GLUI_Column : public GLUI_Control
|
---|
917 | {
|
---|
918 | public:
|
---|
919 | void draw( int x, int y );
|
---|
920 |
|
---|
921 | GLUI_Column( void ) {
|
---|
922 | type = GLUI_CONTROL_COLUMN;
|
---|
923 | w = 0;
|
---|
924 | h = 0;
|
---|
925 | int_val = 0;
|
---|
926 | can_activate = false;
|
---|
927 | };
|
---|
928 | };
|
---|
929 |
|
---|
930 |
|
---|
931 |
|
---|
932 | /************************************************************/
|
---|
933 | /* */
|
---|
934 | /* Panel class (container) */
|
---|
935 | /* */
|
---|
936 | /************************************************************/
|
---|
937 |
|
---|
938 | class GLUI_Panel : public GLUI_Control
|
---|
939 | {
|
---|
940 | public:
|
---|
941 | void draw( int x, int y );
|
---|
942 | void set_name( char *text );
|
---|
943 | void set_type( int new_type );
|
---|
944 |
|
---|
945 | void update_size( void );
|
---|
946 |
|
---|
947 | GLUI_Panel( void ) {
|
---|
948 | type = GLUI_CONTROL_PANEL;
|
---|
949 | w = 300;
|
---|
950 | h = GLUI_DEFAULT_CONTROL_HEIGHT + 7;
|
---|
951 | int_val = GLUI_PANEL_EMBOSSED;
|
---|
952 | alignment = GLUI_ALIGN_CENTER;
|
---|
953 | is_container = true;
|
---|
954 | can_activate = false;
|
---|
955 | strcpy( name, "" );
|
---|
956 | };
|
---|
957 | };
|
---|
958 |
|
---|
959 |
|
---|
960 | /************************************************************/
|
---|
961 | /* */
|
---|
962 | /* Panel class (container) */
|
---|
963 | /* */
|
---|
964 | /************************************************************/
|
---|
965 |
|
---|
966 | class GLUI_Rollout : public GLUI_Panel
|
---|
967 | {
|
---|
968 | /* private: */
|
---|
969 | /* GLUI_Panel panel; */
|
---|
970 | public:
|
---|
971 | int currently_inside, initially_inside;
|
---|
972 | GLUI_Button button;
|
---|
973 |
|
---|
974 | void draw( int x, int y );
|
---|
975 | void draw_pressed( void );
|
---|
976 | void draw_unpressed( void );
|
---|
977 | int mouse_down_handler( int local_x, int local_y );
|
---|
978 | int mouse_up_handler( int local_x, int local_y, int inside );
|
---|
979 | int mouse_held_down_handler( int local_x, int local_y, int inside );
|
---|
980 |
|
---|
981 | void open( void );
|
---|
982 | void close( void );
|
---|
983 |
|
---|
984 | /* void set_name( char *text ) { panel.set_name( text ); }; */
|
---|
985 | void update_size( void );
|
---|
986 |
|
---|
987 | GLUI_Rollout( void ) {
|
---|
988 | currently_inside = false;
|
---|
989 | initially_inside = false;
|
---|
990 | can_activate = true;
|
---|
991 | is_container = true;
|
---|
992 | type = GLUI_CONTROL_ROLLOUT;
|
---|
993 | h = GLUI_DEFAULT_CONTROL_HEIGHT + 7;
|
---|
994 | w = GLUI_DEFAULT_CONTROL_WIDTH;
|
---|
995 | y_off_top = 21;
|
---|
996 | collapsible = true;
|
---|
997 | strcpy( name, "" );
|
---|
998 | };
|
---|
999 | };
|
---|
1000 |
|
---|
1001 |
|
---|
1002 | /************************************************************/
|
---|
1003 | /* */
|
---|
1004 | /* User-Level GLUI class */
|
---|
1005 | /* */
|
---|
1006 | /************************************************************/
|
---|
1007 |
|
---|
1008 | class GLUI : public GLUI_Main {
|
---|
1009 | private:
|
---|
1010 | public:
|
---|
1011 | void add_column( int draw_bar = true );
|
---|
1012 | void add_column_to_panel( GLUI_Panel *panel, int draw_bar = true );
|
---|
1013 |
|
---|
1014 | void add_separator( void );
|
---|
1015 | void add_separator_to_panel( GLUI_Panel *panel );
|
---|
1016 |
|
---|
1017 | GLUI_RadioGroup
|
---|
1018 | *add_radiogroup( int *live_var=NULL,
|
---|
1019 | int user_id=-1,GLUI_Update_CB callback=NULL);
|
---|
1020 |
|
---|
1021 | GLUI_RadioGroup
|
---|
1022 | *add_radiogroup_to_panel( GLUI_Panel *panel,
|
---|
1023 | int *live_var=NULL,
|
---|
1024 | int user_id=-1, GLUI_Update_CB callback=NULL );
|
---|
1025 | GLUI_RadioButton
|
---|
1026 | *add_radiobutton_to_group( GLUI_RadioGroup *group,
|
---|
1027 | char *name );
|
---|
1028 |
|
---|
1029 | GLUI_Listbox *add_listbox( char *name, int *live_var=NULL,
|
---|
1030 | int id=-1, GLUI_Update_CB callback=NULL );
|
---|
1031 | GLUI_Listbox *add_listbox_to_panel( GLUI_Panel *panel,
|
---|
1032 | char *name, int *live_var=NULL,
|
---|
1033 | int id=-1, GLUI_Update_CB callback=NULL);
|
---|
1034 |
|
---|
1035 | GLUI_Rotation *add_rotation( char *name, float *live_var=NULL,
|
---|
1036 | int id=-1, GLUI_Update_CB callback=NULL );
|
---|
1037 | GLUI_Rotation *add_rotation_to_panel( GLUI_Panel *panel,
|
---|
1038 | char *name, float *live_var=NULL,
|
---|
1039 | int id=-1, GLUI_Update_CB callback=NULL);
|
---|
1040 |
|
---|
1041 | GLUI_Translation *add_translation( char *name,
|
---|
1042 | int trans_type, float *live_var=NULL,
|
---|
1043 | int id=-1, GLUI_Update_CB callback=NULL );
|
---|
1044 | GLUI_Translation *add_translation_to_panel(
|
---|
1045 | GLUI_Panel *panel, char *name,
|
---|
1046 | int trans_type, float *live_var=NULL,
|
---|
1047 | int id=-1, GLUI_Update_CB callback=NULL);
|
---|
1048 |
|
---|
1049 | GLUI_Checkbox *add_checkbox( char *name,
|
---|
1050 | int *live_var=NULL,
|
---|
1051 | int id=-1, GLUI_Update_CB callback=NULL);
|
---|
1052 | GLUI_Checkbox *add_checkbox_to_panel( GLUI_Panel *panel, char *name,
|
---|
1053 | int *live_var=NULL, int id=-1,
|
---|
1054 | GLUI_Update_CB callback=NULL);
|
---|
1055 |
|
---|
1056 | GLUI_Button *add_button( char *name, int id=-1,
|
---|
1057 | GLUI_Update_CB callback=NULL);
|
---|
1058 | GLUI_Button *add_button_to_panel( GLUI_Panel *panel, char *name,
|
---|
1059 | int id=-1, GLUI_Update_CB callback=NULL );
|
---|
1060 |
|
---|
1061 | GLUI_StaticText *add_statictext( char *name );
|
---|
1062 | GLUI_StaticText *add_statictext_to_panel( GLUI_Panel *panel, char *name );
|
---|
1063 |
|
---|
1064 | GLUI_EditText *add_edittext( char *name,
|
---|
1065 | int data_type=GLUI_EDITTEXT_TEXT,
|
---|
1066 | void *live_var=NULL,
|
---|
1067 | int id=-1, GLUI_Update_CB callback=NULL );
|
---|
1068 | GLUI_EditText *add_edittext_to_panel( GLUI_Panel *panel,
|
---|
1069 | char *name,
|
---|
1070 | int data_type=GLUI_EDITTEXT_TEXT,
|
---|
1071 | void *live_var=NULL, int id=-1,
|
---|
1072 | GLUI_Update_CB callback=NULL );
|
---|
1073 |
|
---|
1074 | GLUI_Spinner *add_spinner( char *name,
|
---|
1075 | int data_type=GLUI_SPINNER_INT,
|
---|
1076 | void *live_var=NULL,
|
---|
1077 | int id=-1, GLUI_Update_CB callback=NULL );
|
---|
1078 | GLUI_Spinner *add_spinner_to_panel( GLUI_Panel *panel,
|
---|
1079 | char *name,
|
---|
1080 | int data_type=GLUI_SPINNER_INT,
|
---|
1081 | void *live_var=NULL,
|
---|
1082 | int id=-1,
|
---|
1083 | GLUI_Update_CB callback=NULL );
|
---|
1084 |
|
---|
1085 | GLUI_HSlider *add_slider(int resizable=false,
|
---|
1086 | int data_type=GLUI_HSLIDER_INT,
|
---|
1087 | void *live_var=NULL,
|
---|
1088 | int id=-1, GLUI_Update_CB callback=NULL );
|
---|
1089 | GLUI_HSlider *add_slider_to_panel( GLUI_Panel *panel,
|
---|
1090 | int resizable=false,
|
---|
1091 | int data_type=GLUI_HSLIDER_INT,
|
---|
1092 | void *live_var=NULL,
|
---|
1093 | int id=-1,
|
---|
1094 | GLUI_Update_CB callback=NULL );
|
---|
1095 |
|
---|
1096 | GLUI_Panel *add_panel( char *name, int type=GLUI_PANEL_EMBOSSED );
|
---|
1097 | GLUI_Panel *add_panel_to_panel( GLUI_Panel *panel, char *name,
|
---|
1098 | int type=GLUI_PANEL_EMBOSSED );
|
---|
1099 |
|
---|
1100 | GLUI_Rollout *add_rollout( char *name, int open=true );
|
---|
1101 | GLUI_Rollout *add_rollout_to_panel( GLUI_Panel *panel, char *name, int open=true );
|
---|
1102 |
|
---|
1103 | void set_main_gfx_window( int window_id );
|
---|
1104 | int get_glut_window_id( void ) { return glut_window_id; };
|
---|
1105 |
|
---|
1106 | void enable( void ) { main_panel->enable(); };
|
---|
1107 | void disable( void );
|
---|
1108 |
|
---|
1109 | void sync_live( void );
|
---|
1110 |
|
---|
1111 | void close( void );
|
---|
1112 |
|
---|
1113 | void show( void );
|
---|
1114 | void hide( void );
|
---|
1115 |
|
---|
1116 | /***** GLUT callback setup functions *****/
|
---|
1117 | /*
|
---|
1118 | void set_glutDisplayFunc(void (*f)(void));
|
---|
1119 | void set_glutReshapeFunc(void (*f)(int width, int height));
|
---|
1120 | void set_glutKeyboardFunc(void (*f)(unsigned char key, int x, int y));
|
---|
1121 | void set_glutSpecialFunc(void (*f)(int key, int x, int y));
|
---|
1122 | void set_glutMouseFunc(void (*f)(int button, int state, int x, int y));
|
---|
1123 | void set_glutMotionFunc(void (*f)(int x, int y));
|
---|
1124 | void set_glutPassiveMotionFunc(void (*f)(int x, int y));
|
---|
1125 | void set_glutEntryFunc(void (*f)(int state));
|
---|
1126 | void set_glutVisibilityFunc(void (*f)(int state));
|
---|
1127 | void set_glutInit( int *argcp, char **argv );
|
---|
1128 | void set_glutInitWindowSize(int width, int height);
|
---|
1129 | void set_glutInitWindowPosition(int x, int y);
|
---|
1130 | void set_glutInitDisplayMode(unsigned int mode);
|
---|
1131 | int set_glutCreateWindow(char *name);
|
---|
1132 | */
|
---|
1133 |
|
---|
1134 | /***** Constructors and desctructors *****/
|
---|
1135 |
|
---|
1136 | int init( char *name, long flags, int x, int y, int parent_window );
|
---|
1137 | };
|
---|
1138 |
|
---|
1139 |
|
---|
1140 |
|
---|
1141 |
|
---|
1142 | /************************************************************/
|
---|
1143 | /* */
|
---|
1144 | /* EditText class */
|
---|
1145 | /* */
|
---|
1146 | /************************************************************/
|
---|
1147 |
|
---|
1148 | class GLUI_EditText : public GLUI_Control
|
---|
1149 | {
|
---|
1150 | public:
|
---|
1151 | int has_limits;
|
---|
1152 | int data_type;
|
---|
1153 | GLUI_String orig_text;
|
---|
1154 | int insertion_pt;
|
---|
1155 | int title_x_offset;
|
---|
1156 | int text_x_offset;
|
---|
1157 | int substring_start; /*substring that gets displayed in box*/
|
---|
1158 | int substring_end;
|
---|
1159 | int sel_start, sel_end; /* current selection */
|
---|
1160 | int num_periods;
|
---|
1161 | int last_insertion_pt;
|
---|
1162 | float float_low, float_high;
|
---|
1163 | int int_low, int_high;
|
---|
1164 | GLUI_Spinner *spinner;
|
---|
1165 | int debug;
|
---|
1166 | int draw_text_only;
|
---|
1167 |
|
---|
1168 |
|
---|
1169 | int mouse_down_handler( int local_x, int local_y );
|
---|
1170 | int mouse_up_handler( int local_x, int local_y, int same );
|
---|
1171 | int mouse_held_down_handler( int local_x, int local_y, int inside );
|
---|
1172 | int key_handler( unsigned char key,int modifiers );
|
---|
1173 | int special_handler( int key,int modifiers );
|
---|
1174 |
|
---|
1175 | void activate( int how );
|
---|
1176 | void disactivate( void );
|
---|
1177 |
|
---|
1178 | void draw( int x, int y );
|
---|
1179 |
|
---|
1180 | int mouse_over( int state, int x, int y );
|
---|
1181 |
|
---|
1182 | int find_word_break( int start, int direction );
|
---|
1183 | int substring_width( int start, int end );
|
---|
1184 | void clear_substring( int start, int end );
|
---|
1185 | int find_insertion_pt( int x, int y );
|
---|
1186 | int update_substring_bounds( void );
|
---|
1187 | void update_and_draw_text( void );
|
---|
1188 | void draw_text( int x, int y );
|
---|
1189 | void draw_insertion_pt( void );
|
---|
1190 | void set_numeric_text( void );
|
---|
1191 | void update_x_offsets( void );
|
---|
1192 | void update_size( void );
|
---|
1193 |
|
---|
1194 | void set_float_limits( float low,float high,int limit_type=GLUI_LIMIT_CLAMP);
|
---|
1195 | void set_int_limits( int low, int high, int limit_type=GLUI_LIMIT_CLAMP );
|
---|
1196 | void set_float_val( float new_val );
|
---|
1197 | void set_int_val( int new_val );
|
---|
1198 | void set_text( char *text );
|
---|
1199 | char *get_text( void ) { return text; };
|
---|
1200 |
|
---|
1201 | void dump( FILE *out, char *text );
|
---|
1202 |
|
---|
1203 | GLUI_EditText( void ) {
|
---|
1204 | type = GLUI_CONTROL_EDITTEXT;
|
---|
1205 | h = GLUI_EDITTEXT_HEIGHT;
|
---|
1206 | w = GLUI_EDITTEXT_WIDTH;
|
---|
1207 | title_x_offset = 0;
|
---|
1208 | text_x_offset = 55;
|
---|
1209 | insertion_pt = -1;
|
---|
1210 | last_insertion_pt = -1;
|
---|
1211 | name[0] = '\0';
|
---|
1212 | substring_start = 0;
|
---|
1213 | data_type = GLUI_EDITTEXT_TEXT;
|
---|
1214 | substring_end = 2;
|
---|
1215 | num_periods = 0;
|
---|
1216 | has_limits = GLUI_LIMIT_NONE;
|
---|
1217 | sel_start = 0;
|
---|
1218 | sel_end = 0;
|
---|
1219 | active_type = GLUI_CONTROL_ACTIVE_PERMANENT;
|
---|
1220 | can_activate = true;
|
---|
1221 | spacebar_mouse_click = false;
|
---|
1222 | spinner = NULL;
|
---|
1223 | debug = false;
|
---|
1224 | draw_text_only = false;
|
---|
1225 | };
|
---|
1226 | };
|
---|
1227 |
|
---|
1228 |
|
---|
1229 |
|
---|
1230 |
|
---|
1231 | /************************************************************/
|
---|
1232 | /* */
|
---|
1233 | /* RadioGroup class (container) */
|
---|
1234 | /* */
|
---|
1235 | /************************************************************/
|
---|
1236 |
|
---|
1237 | class GLUI_RadioGroup : public GLUI_Control
|
---|
1238 | {
|
---|
1239 | public:
|
---|
1240 | int num_buttons;
|
---|
1241 |
|
---|
1242 | void draw( int x, int y );
|
---|
1243 | void set_name( char *text );
|
---|
1244 | void set_int_val( int int_val );
|
---|
1245 | void set_selected( int int_val );
|
---|
1246 |
|
---|
1247 | void draw_group( int translate );
|
---|
1248 |
|
---|
1249 | GLUI_RadioGroup( void ) {
|
---|
1250 | type = GLUI_CONTROL_RADIOGROUP;
|
---|
1251 | x_off = 0;
|
---|
1252 | y_off_top = 0;
|
---|
1253 | y_off_bot = 0;
|
---|
1254 | is_container = true;
|
---|
1255 | w = 300;
|
---|
1256 | h = 300;
|
---|
1257 | num_buttons = 0;
|
---|
1258 | name[0] = '\0';
|
---|
1259 | can_activate = false;
|
---|
1260 | live_type = GLUI_LIVE_INT;
|
---|
1261 | };
|
---|
1262 | };
|
---|
1263 |
|
---|
1264 |
|
---|
1265 |
|
---|
1266 | /************************************************************/
|
---|
1267 | /* */
|
---|
1268 | /* RadioButton class (container) */
|
---|
1269 | /* */
|
---|
1270 | /************************************************************/
|
---|
1271 |
|
---|
1272 | class GLUI_RadioButton : public GLUI_Control
|
---|
1273 | {
|
---|
1274 | public:
|
---|
1275 | int orig_value, currently_inside;
|
---|
1276 | int text_x_offset;
|
---|
1277 |
|
---|
1278 | int mouse_down_handler( int local_x, int local_y );
|
---|
1279 | int mouse_up_handler( int local_x, int local_y, int inside );
|
---|
1280 | int mouse_held_down_handler( int local_x, int local_y, int inside );
|
---|
1281 |
|
---|
1282 | void draw( int x, int y );
|
---|
1283 | void update_size( void );
|
---|
1284 |
|
---|
1285 | void draw_active_area( void );
|
---|
1286 | void draw_checked( void );
|
---|
1287 | void draw_unchecked( void );
|
---|
1288 | void draw_O( void );
|
---|
1289 |
|
---|
1290 | GLUI_RadioGroup *group;
|
---|
1291 |
|
---|
1292 | GLUI_RadioButton( void ) {
|
---|
1293 | sprintf( name, "RadioButton: %p", this );
|
---|
1294 | type = GLUI_CONTROL_RADIOBUTTON;
|
---|
1295 | h = GLUI_RADIOBUTTON_SIZE;
|
---|
1296 | group = NULL;
|
---|
1297 | orig_value = -1;
|
---|
1298 | text_x_offset = 18;
|
---|
1299 | can_activate = true;
|
---|
1300 | };
|
---|
1301 | };
|
---|
1302 |
|
---|
1303 |
|
---|
1304 | /************************************************************/
|
---|
1305 | /* */
|
---|
1306 | /* Separator class (container) */
|
---|
1307 | /* */
|
---|
1308 | /************************************************************/
|
---|
1309 |
|
---|
1310 | class GLUI_Separator : public GLUI_Control
|
---|
1311 | {
|
---|
1312 | public:
|
---|
1313 | void draw( int x, int y );
|
---|
1314 |
|
---|
1315 | GLUI_Separator( void ) {
|
---|
1316 | type = GLUI_CONTROL_SEPARATOR;
|
---|
1317 | w = 100;
|
---|
1318 | h = GLUI_SEPARATOR_HEIGHT;
|
---|
1319 | can_activate = false;
|
---|
1320 | };
|
---|
1321 | };
|
---|
1322 |
|
---|
1323 |
|
---|
1324 | #define GLUI_SPINNER_ARROW_WIDTH 12
|
---|
1325 | #define GLUI_SPINNER_ARROW_HEIGHT 8
|
---|
1326 | #define GLUI_SPINNER_ARROW_Y 2
|
---|
1327 |
|
---|
1328 | #define GLUI_SPINNER_STATE_NONE 0
|
---|
1329 | #define GLUI_SPINNER_STATE_UP 1
|
---|
1330 | #define GLUI_SPINNER_STATE_DOWN 2
|
---|
1331 | #define GLUI_SPINNER_STATE_BOTH 3
|
---|
1332 |
|
---|
1333 | #define GLUI_SPINNER_DEFAULT_GROWTH_EXP 1.05f
|
---|
1334 |
|
---|
1335 |
|
---|
1336 | /************************************************************/
|
---|
1337 | /* */
|
---|
1338 | /* Spinner class (container) */
|
---|
1339 | /* */
|
---|
1340 | /************************************************************/
|
---|
1341 |
|
---|
1342 | class GLUI_Spinner : public GLUI_Control
|
---|
1343 | {
|
---|
1344 | public:
|
---|
1345 | int currently_inside;
|
---|
1346 | int state;
|
---|
1347 | float growth, growth_exp;
|
---|
1348 | int last_x, last_y;
|
---|
1349 | int data_type;
|
---|
1350 | int callback_count;
|
---|
1351 | int last_int_val;
|
---|
1352 | float last_float_val;
|
---|
1353 | int first_callback;
|
---|
1354 | float user_speed;
|
---|
1355 |
|
---|
1356 | GLUI_EditText *edittext;
|
---|
1357 |
|
---|
1358 | int mouse_down_handler( int local_x, int local_y );
|
---|
1359 | int mouse_up_handler( int local_x, int local_y, int same );
|
---|
1360 | int mouse_held_down_handler( int local_x, int local_y, int inside );
|
---|
1361 | int key_handler( unsigned char key,int modifiers );
|
---|
1362 | int special_handler( int key,int modifiers );
|
---|
1363 |
|
---|
1364 | void draw( int x, int y );
|
---|
1365 | void draw_pressed( void );
|
---|
1366 | void draw_unpressed( void );
|
---|
1367 | void draw_text( int sunken );
|
---|
1368 |
|
---|
1369 | void update_size( void );
|
---|
1370 |
|
---|
1371 | void set_float_limits( float low,float high,int limit_type=GLUI_LIMIT_CLAMP);
|
---|
1372 | void set_int_limits( int low, int high,int limit_type=GLUI_LIMIT_CLAMP);
|
---|
1373 | int find_arrow( int local_x, int local_y );
|
---|
1374 | void do_drag( int x, int y );
|
---|
1375 | void do_callbacks( void );
|
---|
1376 | void draw_arrows( void );
|
---|
1377 | void do_click( void );
|
---|
1378 | void idle( void );
|
---|
1379 | int needs_idle( void );
|
---|
1380 |
|
---|
1381 | char *get_text( void );
|
---|
1382 |
|
---|
1383 | void set_float_val( float new_val );
|
---|
1384 | void set_int_val( int new_val );
|
---|
1385 | float get_float_val( void );
|
---|
1386 | int get_int_val( void );
|
---|
1387 | void increase_growth( void );
|
---|
1388 | void reset_growth( void );
|
---|
1389 |
|
---|
1390 | void set_speed( float speed ) { user_speed = speed; };
|
---|
1391 |
|
---|
1392 | GLUI_Spinner( void ) {
|
---|
1393 | sprintf( name, "Spinner: %p", this );
|
---|
1394 | type = GLUI_CONTROL_SPINNER;
|
---|
1395 | h = GLUI_EDITTEXT_HEIGHT;
|
---|
1396 | w = GLUI_EDITTEXT_WIDTH;
|
---|
1397 | x_off = 0;
|
---|
1398 | y_off_top = 0;
|
---|
1399 | y_off_bot = 0;
|
---|
1400 | can_activate = true;
|
---|
1401 | state = GLUI_SPINNER_STATE_NONE;
|
---|
1402 | edittext = NULL;
|
---|
1403 | growth_exp = GLUI_SPINNER_DEFAULT_GROWTH_EXP;
|
---|
1404 | callback_count = 0;
|
---|
1405 | first_callback = true;
|
---|
1406 | user_speed = 1.0;
|
---|
1407 | };
|
---|
1408 | };
|
---|
1409 |
|
---|
1410 | #define GLUI_HSLIDER_ARROW_WIDTH 16
|
---|
1411 | #define GLUI_HSLIDER_ARROW_HEIGHT 16
|
---|
1412 |
|
---|
1413 | #define GLUI_HSLIDER_STATE_NONE 0
|
---|
1414 | #define GLUI_HSLIDER_STATE_UP 1
|
---|
1415 | #define GLUI_HSLIDER_STATE_DOWN 2
|
---|
1416 | #define GLUI_HSLIDER_STATE_BUTTON 3
|
---|
1417 | #define GLUI_HSLIDER_STATE_TROUGH_RIGHT 4
|
---|
1418 | #define GLUI_HSLIDER_STATE_TROUGH_LEFT 5
|
---|
1419 | #define GLUI_HSLIDER_STATE_BUTTON_LEFT 6
|
---|
1420 | #define GLUI_HSLIDER_STATE_BUTTON_RIGHT 7
|
---|
1421 |
|
---|
1422 | #define GLUI_HSLIDER_DEFAULT_GROWTH_EXP 1.05f
|
---|
1423 |
|
---|
1424 |
|
---|
1425 | /************************************************************/
|
---|
1426 | /* */
|
---|
1427 | /* HSlider class (container) */
|
---|
1428 | /* */
|
---|
1429 | /************************************************************/
|
---|
1430 |
|
---|
1431 | class GLUI_HSlider : public GLUI_Control
|
---|
1432 | {
|
---|
1433 | public:
|
---|
1434 | int state;
|
---|
1435 | int button_is_resizable;
|
---|
1436 | float button_left_edge;
|
---|
1437 | float button_right_edge;
|
---|
1438 | int bounce_target;
|
---|
1439 | int new_button_center;
|
---|
1440 | int old_button_center;
|
---|
1441 | int data_type;
|
---|
1442 | int callback_count;
|
---|
1443 | int last_int_val;
|
---|
1444 | float last_float_val;
|
---|
1445 | int first_callback;
|
---|
1446 | int bneeds_idle;
|
---|
1447 | int int_low, int_high;
|
---|
1448 | float float_low, float_high;
|
---|
1449 | clock_t last_click_time;
|
---|
1450 |
|
---|
1451 | int needs_idle();
|
---|
1452 | void idle();
|
---|
1453 | int mouse_over( int state, int x, int y );
|
---|
1454 | int mouse_down_handler( int local_x, int local_y );
|
---|
1455 | int mouse_up_handler( int local_x, int local_y, int same );
|
---|
1456 | int mouse_held_down_handler( int local_x, int local_y, int inside );
|
---|
1457 | int key_handler( unsigned char key,int modifiers );
|
---|
1458 | int special_handler( int key,int modifiers );
|
---|
1459 |
|
---|
1460 | void draw( int x, int y );
|
---|
1461 |
|
---|
1462 | void update_size( void );
|
---|
1463 |
|
---|
1464 | void set_float_limits( float low, float high );
|
---|
1465 | void set_int_limits( int low, int high );
|
---|
1466 | int locate_click( int local_x, int local_y );
|
---|
1467 | void do_callbacks( void );
|
---|
1468 | void reconcile_edge( void );
|
---|
1469 | void do_click( void );
|
---|
1470 |
|
---|
1471 | void set_slider_val( float lval );
|
---|
1472 | void set_slider_val( float lval, float hval );
|
---|
1473 | void set_slider_val( int lval, int hval );
|
---|
1474 | float get_slider_val();
|
---|
1475 | int sync_slider();
|
---|
1476 | float find_val( float pct );
|
---|
1477 |
|
---|
1478 | private:
|
---|
1479 | int redge_to_pixel(float val);
|
---|
1480 | int ledge_to_pixel(float val);
|
---|
1481 | void move_button_pixels(int nval, int &oval);
|
---|
1482 | void move_val(float dx);
|
---|
1483 | float pixel_to_redge(int val);
|
---|
1484 | float pixel_to_ledge(int val);
|
---|
1485 | void update_slider_val();
|
---|
1486 |
|
---|
1487 | public:
|
---|
1488 | GLUI_HSlider( void ) {
|
---|
1489 | sprintf( name, "HSlider: %p", this );
|
---|
1490 | type = GLUI_CONTROL_HSLIDER;
|
---|
1491 | h = GLUI_HSLIDER_HEIGHT;
|
---|
1492 | w = GLUI_HSLIDER_WIDTH;
|
---|
1493 | button_is_resizable = false;
|
---|
1494 | button_left_edge = GLUI_HSLIDER_ARROW_WIDTH;
|
---|
1495 | button_right_edge = GLUI_HSLIDER_ARROW_WIDTH + 10;
|
---|
1496 | int_low = 0;
|
---|
1497 | int_high = w - 2*GLUI_HSLIDER_ARROW_WIDTH - 4;
|
---|
1498 | float_low = (float) int_low;
|
---|
1499 | float_high = (float) int_high;
|
---|
1500 | x_off = 0;
|
---|
1501 | y_off_top = 0;
|
---|
1502 | y_off_bot = 0;
|
---|
1503 | can_activate = true;
|
---|
1504 | state = GLUI_HSLIDER_STATE_NONE;
|
---|
1505 | callback_count = 0;
|
---|
1506 | first_callback = true;
|
---|
1507 | bneeds_idle = 0;
|
---|
1508 | last_click_time = clock();
|
---|
1509 | };
|
---|
1510 | };
|
---|
1511 |
|
---|
1512 | /************************************************************/
|
---|
1513 |
|
---|
1514 | /* */
|
---|
1515 | /* StaticText class */
|
---|
1516 | /* */
|
---|
1517 | /************************************************************/
|
---|
1518 |
|
---|
1519 | class GLUI_StaticText : public GLUI_Control
|
---|
1520 | {
|
---|
1521 | public:
|
---|
1522 | void set_text( char *text );
|
---|
1523 | void draw( int x, int y );
|
---|
1524 | void draw_text( void );
|
---|
1525 | void update_size( void );
|
---|
1526 | void erase_text( void );
|
---|
1527 |
|
---|
1528 | GLUI_StaticText( void ) {
|
---|
1529 | type = GLUI_CONTROL_STATICTEXT;
|
---|
1530 | h = GLUI_STATICTEXT_SIZE;
|
---|
1531 | name[0] = '\0';
|
---|
1532 | can_activate = false;
|
---|
1533 | };
|
---|
1534 | };
|
---|
1535 |
|
---|
1536 |
|
---|
1537 |
|
---|
1538 | /************************************************************/
|
---|
1539 | /* */
|
---|
1540 | /* Listbox class */
|
---|
1541 | /* */
|
---|
1542 | /************************************************************/
|
---|
1543 |
|
---|
1544 | class GLUI_Listbox_Item : public GLUI_Node
|
---|
1545 | {
|
---|
1546 | public:
|
---|
1547 | GLUI_String text;
|
---|
1548 | int id;
|
---|
1549 | };
|
---|
1550 |
|
---|
1551 | class GLUI_Listbox : public GLUI_Control
|
---|
1552 | {
|
---|
1553 | public:
|
---|
1554 | GLUI_String curr_text;
|
---|
1555 | GLUI_Listbox_Item items_list;
|
---|
1556 | int depressed;
|
---|
1557 |
|
---|
1558 | int orig_value, currently_inside;
|
---|
1559 | int text_x_offset, title_x_offset;
|
---|
1560 | int glut_menu_id;
|
---|
1561 |
|
---|
1562 | int mouse_down_handler( int local_x, int local_y );
|
---|
1563 | int mouse_up_handler( int local_x, int local_y, int inside );
|
---|
1564 | int mouse_held_down_handler( int local_x, int local_y, int inside );
|
---|
1565 | int key_handler( unsigned char key,int modifiers );
|
---|
1566 | int special_handler( int key,int modifiers );
|
---|
1567 |
|
---|
1568 | void update_size( void );
|
---|
1569 | void draw( int x, int y );
|
---|
1570 | int mouse_over( int state, int x, int y );
|
---|
1571 |
|
---|
1572 | void draw_active_area( void );
|
---|
1573 | void set_int_val( int new_val );
|
---|
1574 | void dump( FILE *output );
|
---|
1575 |
|
---|
1576 | int add_item( int id, char *text );
|
---|
1577 | int delete_item( char *text );
|
---|
1578 | int delete_item( int id );
|
---|
1579 | int sort_items( void );
|
---|
1580 |
|
---|
1581 | int do_selection( int item );
|
---|
1582 |
|
---|
1583 | void increase_width( void );
|
---|
1584 |
|
---|
1585 | GLUI_Listbox_Item *get_item_ptr( char *text );
|
---|
1586 | GLUI_Listbox_Item *get_item_ptr( int id );
|
---|
1587 |
|
---|
1588 |
|
---|
1589 | GLUI_Listbox( void ) {
|
---|
1590 | sprintf( name, "Listbox: %p", this );
|
---|
1591 | type = GLUI_CONTROL_LISTBOX;
|
---|
1592 | w = GLUI_EDITTEXT_WIDTH;
|
---|
1593 | h = GLUI_EDITTEXT_HEIGHT;
|
---|
1594 | orig_value = -1;
|
---|
1595 | title_x_offset = 0;
|
---|
1596 | text_x_offset = 55;
|
---|
1597 | can_activate = true;
|
---|
1598 | curr_text[0] = '\0';
|
---|
1599 | live_type = GLUI_LIVE_INT; /* This has an integer live var */
|
---|
1600 | depressed = false;
|
---|
1601 | glut_menu_id = -1;
|
---|
1602 | };
|
---|
1603 |
|
---|
1604 | ~GLUI_Listbox();
|
---|
1605 | };
|
---|
1606 |
|
---|
1607 |
|
---|
1608 | /************************************************************/
|
---|
1609 | /* */
|
---|
1610 | /* Mouse_Interaction class */
|
---|
1611 | /* */
|
---|
1612 | /************************************************************/
|
---|
1613 |
|
---|
1614 | class GLUI_Mouse_Interaction : public GLUI_Control
|
---|
1615 | {
|
---|
1616 | public:
|
---|
1617 | /*int get_main_area_size( void ) { return MIN( h-18, */
|
---|
1618 | int draw_active_area_only;
|
---|
1619 |
|
---|
1620 | int mouse_down_handler( int local_x, int local_y );
|
---|
1621 | int mouse_up_handler( int local_x, int local_y, int inside );
|
---|
1622 | int mouse_held_down_handler( int local_x, int local_y, int inside );
|
---|
1623 | int special_handler( int key, int modifiers );
|
---|
1624 | void update_size( void );
|
---|
1625 | void draw( int x, int y );
|
---|
1626 | void draw_active_area( void );
|
---|
1627 |
|
---|
1628 | /*** The following methods (starting with "iaction_") need to
|
---|
1629 | be overloaded ***/
|
---|
1630 | virtual int iaction_mouse_down_handler( int local_x, int local_y ) = 0;
|
---|
1631 | virtual int iaction_mouse_up_handler( int local_x, int local_y, int inside )=0;
|
---|
1632 | virtual int iaction_mouse_held_down_handler( int local_x, int local_y, int inside )=0;
|
---|
1633 | virtual int iaction_special_handler( int key, int modifiers )=0;
|
---|
1634 | virtual void iaction_draw_active_area_persp( void )=0;
|
---|
1635 | virtual void iaction_draw_active_area_ortho( void )=0;
|
---|
1636 | virtual void iaction_dump( FILE *output )=0;
|
---|
1637 | virtual void iaction_init( void ) = 0;
|
---|
1638 |
|
---|
1639 | GLUI_Mouse_Interaction( void ) {
|
---|
1640 | sprintf( name, "Mouse_Interaction: %p", this );
|
---|
1641 | type = GLUI_CONTROL_MOUSE_INTERACTION;
|
---|
1642 | w = GLUI_MOUSE_INTERACTION_WIDTH;
|
---|
1643 | h = GLUI_MOUSE_INTERACTION_HEIGHT;
|
---|
1644 | can_activate = true;
|
---|
1645 | live_type = GLUI_LIVE_NONE;
|
---|
1646 | alignment = GLUI_ALIGN_CENTER;
|
---|
1647 | draw_active_area_only = false;
|
---|
1648 | };
|
---|
1649 | };
|
---|
1650 |
|
---|
1651 |
|
---|
1652 | /************************************************************/
|
---|
1653 | /* */
|
---|
1654 | /* Rotation class */
|
---|
1655 | /* */
|
---|
1656 | /************************************************************/
|
---|
1657 |
|
---|
1658 | class GLUI_Rotation : public GLUI_Mouse_Interaction
|
---|
1659 | {
|
---|
1660 | public:
|
---|
1661 | Arcball *ball;
|
---|
1662 | GLUquadricObj *quadObj;
|
---|
1663 | int can_spin, spinning;
|
---|
1664 | float damping;
|
---|
1665 |
|
---|
1666 | int iaction_mouse_down_handler( int local_x, int local_y );
|
---|
1667 | int iaction_mouse_up_handler( int local_x, int local_y, int inside );
|
---|
1668 | int iaction_mouse_held_down_handler( int local_x, int local_y, int inside );
|
---|
1669 | int iaction_special_handler( int key, int modifiers );
|
---|
1670 | void iaction_init( void ) { init_ball(); };
|
---|
1671 | void iaction_draw_active_area_persp( void );
|
---|
1672 | void iaction_draw_active_area_ortho( void );
|
---|
1673 | void iaction_dump( FILE *output );
|
---|
1674 |
|
---|
1675 | /* void update_size( void ); */
|
---|
1676 | /* void draw( int x, int y ); */
|
---|
1677 | /* int mouse_over( int state, int x, int y ); */
|
---|
1678 |
|
---|
1679 | void setup_texture( void );
|
---|
1680 | void setup_lights( void );
|
---|
1681 | void draw_ball( float radius );
|
---|
1682 |
|
---|
1683 | void init_ball( void );
|
---|
1684 |
|
---|
1685 | void reset( void );
|
---|
1686 |
|
---|
1687 | int needs_idle( void );
|
---|
1688 | void idle( void );
|
---|
1689 |
|
---|
1690 | void copy_float_array_to_ball( void );
|
---|
1691 | void copy_ball_to_float_array( void );
|
---|
1692 |
|
---|
1693 | void set_spin( float damp_factor );
|
---|
1694 |
|
---|
1695 | GLUI_Rotation(void);
|
---|
1696 | };
|
---|
1697 |
|
---|
1698 |
|
---|
1699 |
|
---|
1700 | /************************************************************/
|
---|
1701 | /* */
|
---|
1702 | /* Translation class */
|
---|
1703 | /* */
|
---|
1704 | /************************************************************/
|
---|
1705 |
|
---|
1706 | class GLUI_Translation : public GLUI_Mouse_Interaction
|
---|
1707 | {
|
---|
1708 | public:
|
---|
1709 | int trans_type; /* Is this an XY or a Z controller? */
|
---|
1710 | int down_x, down_y;
|
---|
1711 | float scale_factor;
|
---|
1712 | GLUquadricObj *quadObj;
|
---|
1713 | int trans_mouse_code;
|
---|
1714 | float orig_x, orig_y, orig_z;
|
---|
1715 | int locked;
|
---|
1716 |
|
---|
1717 | int iaction_mouse_down_handler( int local_x, int local_y );
|
---|
1718 | int iaction_mouse_up_handler( int local_x, int local_y, int inside );
|
---|
1719 | int iaction_mouse_held_down_handler( int local_x, int local_y, int inside );
|
---|
1720 | int iaction_special_handler( int key, int modifiers );
|
---|
1721 | void iaction_init( void ) { };
|
---|
1722 | void iaction_draw_active_area_persp( void );
|
---|
1723 | void iaction_draw_active_area_ortho( void );
|
---|
1724 | void iaction_dump( FILE *output );
|
---|
1725 |
|
---|
1726 | void set_speed( float s ) { scale_factor = s; };
|
---|
1727 |
|
---|
1728 | void setup_texture( void );
|
---|
1729 | void setup_lights( void );
|
---|
1730 | void draw_2d_arrow( int radius, int filled, int orientation );
|
---|
1731 | void draw_2d_x_arrows( int radius );
|
---|
1732 | void draw_2d_y_arrows( int radius );
|
---|
1733 | void draw_2d_z_arrows( int radius );
|
---|
1734 | void draw_2d_xy_arrows( int radius );
|
---|
1735 |
|
---|
1736 | int get_mouse_code( int x, int y );
|
---|
1737 |
|
---|
1738 | /* Float array is either a single float (for single-axis controls),
|
---|
1739 | or two floats for X and Y (if an XY controller) */
|
---|
1740 |
|
---|
1741 | float get_z( void ) { return float_array_val[0]; }
|
---|
1742 | float get_x( void ) { return float_array_val[0]; }
|
---|
1743 | float get_y( void ) {
|
---|
1744 | if ( trans_type == GLUI_TRANSLATION_XY ) return float_array_val[1];
|
---|
1745 | else return float_array_val[0];
|
---|
1746 | }
|
---|
1747 |
|
---|
1748 | void set_z( float val );
|
---|
1749 | void set_x( float val );
|
---|
1750 | void set_y( float val );
|
---|
1751 | void set_one_val( float val, int index );
|
---|
1752 |
|
---|
1753 | GLUI_Translation( void ) {
|
---|
1754 | locked = GLUI_TRANSLATION_LOCK_NONE;
|
---|
1755 | sprintf( name, "Translation: %p", this );
|
---|
1756 | type = GLUI_CONTROL_TRANSLATION;
|
---|
1757 | w = GLUI_MOUSE_INTERACTION_WIDTH;
|
---|
1758 | h = GLUI_MOUSE_INTERACTION_HEIGHT;
|
---|
1759 | can_activate = true;
|
---|
1760 | live_type = GLUI_LIVE_FLOAT_ARRAY;
|
---|
1761 | float_array_size = 0;
|
---|
1762 | alignment = GLUI_ALIGN_CENTER;
|
---|
1763 | trans_type = GLUI_TRANSLATION_XY;
|
---|
1764 | scale_factor = 1.0;
|
---|
1765 | quadObj = NULL;
|
---|
1766 | trans_mouse_code = GLUI_TRANSLATION_MOUSE_NONE;
|
---|
1767 | };
|
---|
1768 | };
|
---|
1769 |
|
---|
1770 |
|
---|
1771 |
|
---|
1772 |
|
---|
1773 | /********** Misc functions *********************/
|
---|
1774 | int _glutBitmapWidthString( void *font, char *s );
|
---|
1775 | void _glutBitmapString( void *font, char *s );
|
---|
1776 |
|
---|
1777 |
|
---|
1778 |
|
---|
1779 | /********** Our own callbacks for glut *********/
|
---|
1780 | /* These are the callbacks that we pass to glut. They take
|
---|
1781 | some action if necessary, then (possibly) call the user-level
|
---|
1782 | glut callbacks.
|
---|
1783 | */
|
---|
1784 |
|
---|
1785 | void glui_display_func( void );
|
---|
1786 | void glui_reshape_func( int w, int h );
|
---|
1787 | void glui_keyboard_func(unsigned char key, int x, int y);
|
---|
1788 | void glui_special_func(int key, int x, int y);
|
---|
1789 | void glui_mouse_func(int button, int state, int x, int y);
|
---|
1790 | void glui_motion_func(int x, int y);
|
---|
1791 | void glui_passive_motion_func(int x, int y);
|
---|
1792 | void glui_entry_func(int state);
|
---|
1793 | void glui_visibility_func(int state);
|
---|
1794 | void glui_idle_func(void);
|
---|
1795 |
|
---|
1796 | void glui_parent_window_reshape_func( int w, int h );
|
---|
1797 | void glui_parent_window_keyboard_func(unsigned char key, int x, int y);
|
---|
1798 | void glui_parent_window_mouse_func(int, int, int, int );
|
---|
1799 | void glui_parent_window_special_func(int key, int x, int y);
|
---|
1800 |
|
---|
1801 |
|
---|
1802 |
|
---|
1803 | #endif
|
---|