16 #ifdef PU_NOT_USING_GLUT
30 Webster's Dictionary (for American English) permits
31 Color or Colour as acceptable spellings - but
32 The Oxford English Dictionary (for English) only
35 Hence, the logical thing to do is to use 'colour',
36 which *ought* to be acceptable on both sides of
39 However, as a concession to the illogical:
42 #define setColorScheme setColourScheme
43 #define setColor setColour
44 #define getColor getColour
45 #define puColor puColour
46 #define puSetColor puSetColour
47 #define puSetDefaultColorScheme puSetDefaultColourScheme
48 #define puGetDefaultColorScheme puGetDefaultColourScheme
51 typedef void *puFont ;
53 #ifdef PU_NOT_USING_GLUT
54 #define PU_LEFT_BUTTON 0
55 #define PU_LEFT_BUTTON 0
56 #define PU_MIDDLE_BUTTON 1
57 #define PU_RIGHT_BUTTON 2
61 #define PUFONT_8_BY_13 ((void*)3)
62 #define PUFONT_9_BY_15 ((void*)2)
63 #define PUFONT_TIMES_ROMAN_10 ((void*)4)
64 #define PUFONT_TIMES_ROMAN_24 ((void*)5)
65 #define PUFONT_HELVETICA_10 ((void*)6)
66 #define PUFONT_HELVETICA_12 ((void*)7)
67 #define PUFONT_HELVETICA_18 ((void*)8)
71 #define PUFONT_8_BY_13 GLUT_BITMAP_8_BY_13
72 #define PUFONT_9_BY_15 GLUT_BITMAP_9_BY_15
73 #define PUFONT_TIMES_ROMAN_10 GLUT_BITMAP_TIMES_ROMAN_10
74 #define PUFONT_TIMES_ROMAN_24 GLUT_BITMAP_TIMES_ROMAN_24
75 #define PUFONT_HELVETICA_10 GLUT_BITMAP_HELVETICA_10
76 #define PUFONT_HELVETICA_12 GLUT_BITMAP_HELVETICA_12
77 #define PUFONT_HELVETICA_18 GLUT_BITMAP_HELVETICA_18
79 #define PU_LEFT_BUTTON GLUT_LEFT_BUTTON
80 #define PU_MIDDLE_BUTTON GLUT_MIDDLE_BUTTON
81 #define PU_RIGHT_BUTTON GLUT_RIGHT_BUTTON
82 #define PU_DOWN GLUT_DOWN
84 #endif // PU_NOT_USING_GLUT
86 #define PU_UP_AND_DOWN 254
88 #define PU_CONTINUAL PU_DRAG
90 #define PU_KEY_GLUT_SPECIAL_OFFSET 256
92 #ifdef PU_NOT_USING_GLUT
93 #define PU_KEY_F1 (1 + PU_KEY_GLUT_SPECIAL_OFFSET)
94 #define PU_KEY_F2 (2 + PU_KEY_GLUT_SPECIAL_OFFSET)
95 #define PU_KEY_F3 (3 + PU_KEY_GLUT_SPECIAL_OFFSET)
96 #define PU_KEY_F4 (4 + PU_KEY_GLUT_SPECIAL_OFFSET)
97 #define PU_KEY_F5 (5 + PU_KEY_GLUT_SPECIAL_OFFSET)
98 #define PU_KEY_F6 (6 + PU_KEY_GLUT_SPECIAL_OFFSET)
99 #define PU_KEY_F7 (7 + PU_KEY_GLUT_SPECIAL_OFFSET)
100 #define PU_KEY_F8 (8 + PU_KEY_GLUT_SPECIAL_OFFSET)
101 #define PU_KEY_F9 (9 + PU_KEY_GLUT_SPECIAL_OFFSET)
102 #define PU_KEY_F10 (10 + PU_KEY_GLUT_SPECIAL_OFFSET)
103 #define PU_KEY_F11 (11 + PU_KEY_GLUT_SPECIAL_OFFSET)
104 #define PU_KEY_F12 (12 + PU_KEY_GLUT_SPECIAL_OFFSET)
105 #define PU_KEY_LEFT (100 + PU_KEY_GLUT_SPECIAL_OFFSET)
106 #define PU_KEY_UP (101 + PU_KEY_GLUT_SPECIAL_OFFSET)
107 #define PU_KEY_RIGHT (102 + PU_KEY_GLUT_SPECIAL_OFFSET)
108 #define PU_KEY_DOWN (103 + PU_KEY_GLUT_SPECIAL_OFFSET)
109 #define PU_KEY_PAGE_UP (104 + PU_KEY_GLUT_SPECIAL_OFFSET)
110 #define PU_KEY_PAGE_DOWN (105 + PU_KEY_GLUT_SPECIAL_OFFSET)
111 #define PU_KEY_HOME (106 + PU_KEY_GLUT_SPECIAL_OFFSET)
112 #define PU_KEY_END (107 + PU_KEY_GLUT_SPECIAL_OFFSET)
113 #define PU_KEY_INSERT (108 + PU_KEY_GLUT_SPECIAL_OFFSET)
116 #define PU_KEY_F1 (GLUT_KEY_F1 + PU_KEY_GLUT_SPECIAL_OFFSET)
117 #define PU_KEY_F2 (GLUT_KEY_F2 + PU_KEY_GLUT_SPECIAL_OFFSET)
118 #define PU_KEY_F3 (GLUT_KEY_F3 + PU_KEY_GLUT_SPECIAL_OFFSET)
119 #define PU_KEY_F4 (GLUT_KEY_F4 + PU_KEY_GLUT_SPECIAL_OFFSET)
120 #define PU_KEY_F5 (GLUT_KEY_F5 + PU_KEY_GLUT_SPECIAL_OFFSET)
121 #define PU_KEY_F6 (GLUT_KEY_F6 + PU_KEY_GLUT_SPECIAL_OFFSET)
122 #define PU_KEY_F7 (GLUT_KEY_F7 + PU_KEY_GLUT_SPECIAL_OFFSET)
123 #define PU_KEY_F8 (GLUT_KEY_F8 + PU_KEY_GLUT_SPECIAL_OFFSET)
124 #define PU_KEY_F9 (GLUT_KEY_F9 + PU_KEY_GLUT_SPECIAL_OFFSET)
125 #define PU_KEY_F10 (GLUT_KEY_F10 + PU_KEY_GLUT_SPECIAL_OFFSET)
126 #define PU_KEY_F11 (GLUT_KEY_F11 + PU_KEY_GLUT_SPECIAL_OFFSET)
127 #define PU_KEY_F12 (GLUT_KEY_F12 + PU_KEY_GLUT_SPECIAL_OFFSET)
128 #define PU_KEY_LEFT (GLUT_KEY_LEFT + PU_KEY_GLUT_SPECIAL_OFFSET)
129 #define PU_KEY_UP (GLUT_KEY_UP + PU_KEY_GLUT_SPECIAL_OFFSET)
130 #define PU_KEY_RIGHT (GLUT_KEY_RIGHT + PU_KEY_GLUT_SPECIAL_OFFSET)
131 #define PU_KEY_DOWN (GLUT_KEY_DOWN + PU_KEY_GLUT_SPECIAL_OFFSET)
132 #define PU_KEY_PAGE_UP (GLUT_KEY_PAGE_UP + PU_KEY_GLUT_SPECIAL_OFFSET)
133 #define PU_KEY_PAGE_DOWN (GLUT_KEY_PAGE_DOWN + PU_KEY_GLUT_SPECIAL_OFFSET)
134 #define PU_KEY_HOME (GLUT_KEY_HOME + PU_KEY_GLUT_SPECIAL_OFFSET)
135 #define PU_KEY_END (GLUT_KEY_END + PU_KEY_GLUT_SPECIAL_OFFSET)
136 #define PU_KEY_INSERT (GLUT_KEY_INSERT + PU_KEY_GLUT_SPECIAL_OFFSET)
137 #endif // PU_NOT_USING_GLUT
139 #define PUPLACE_DEFAULT PUPLACE_RIGHT
140 #define PUPLACE_ABOVE 0
141 #define PUPLACE_BELOW 1
142 #define PUPLACE_LEFT 2
143 #define PUPLACE_RIGHT 3
145 #define PUCOL_FOREGROUND 0
146 #define PUCOL_BACKGROUND 1
147 #define PUCOL_HIGHLIGHT 2
148 #define PUCOL_LABEL 3
149 #define PUCOL_LEGEND 4
152 #define PUSLIDER_CLICK 0
153 #define PUSLIDER_ALWAYS 1
154 #define PUSLIDER_DELTA 2
156 /* These styles may be negated to get 'highlighted' graphics */
158 #define PUSTYLE_DEFAULT PUSTYLE_SHADED
159 #define PUSTYLE_NONE 0
160 #define PUSTYLE_PLAIN 1
161 #define PUSTYLE_BEVELLED 2
162 #define PUSTYLE_BOXED 3
163 #define PUSTYLE_DROPSHADOW 4
164 #define PUSTYLE_SPECIAL_UNDERLINED 5
165 #define PUSTYLE_SMALL_BEVELLED 6
166 #define PUSTYLE_RADIO 7
167 #define PUSTYLE_SHADED 8
168 #define PUSTYLE_SMALL_SHADED 9
169 #define PUSTYLE_MAX 10
171 /* These are the gaps that we try to leave around text objects */
177 #define PUSTR_MAX_HEIGHT ( 25 + PUSTR_TGAP + PUSTR_BGAP )
179 #define PU_RADIO_BUTTON_SIZE 16
181 extern int puRefresh ;
183 #define PUCLASS_VALUE 0x00000001
184 #define PUCLASS_OBJECT 0x00000002
185 #define PUCLASS_INTERFACE 0x00000004
186 #define PUCLASS_FRAME 0x00000008
187 #define PUCLASS_TEXT 0x00000010
188 #define PUCLASS_BUTTON 0x00000020
189 #define PUCLASS_ONESHOT 0x00000040
190 #define PUCLASS_POPUP 0x00000080
191 #define PUCLASS_POPUPMENU 0x00000100
192 #define PUCLASS_MENUBAR 0x00000200
193 #define PUCLASS_INPUT 0x00000400
194 #define PUCLASS_BUTTONBOX 0x00000800
195 #define PUCLASS_SLIDER 0x00001000
196 #define PUCLASS_DIALOGBOX 0x00002000
198 /* This function is not required for GLUT programs */
199 void puSetWindowSize ( int width, int height ) ;
201 int puGetWindowHeight () ;
202 int puGetWindowWidth () ;
218 typedef float puColour [ 4 ] ; /* RGBA */
225 void draw ( int dx, int dy, int style, puColour colour[], int am_default ) ;
226 void extend ( puBox *bx ) ;
228 void empty ( void ) { min[0]=min[1]=1000000 ; max[0]=max[1]=-1000000 ; }
229 int isEmpty ( void ) { return min[0]>max[0] || min[1]>max[1] ; }
232 #define PUSTRING_MAX 80
234 /* If you change - or add to these, be sure to change _puDefaultColourTable */
236 extern puColour _puDefaultColourTable[] ;
239 inline void puSetColour ( puColour dst, puColour src )
241 dst[0] = src[0] ; dst[1] = src[1] ; dst[2] = src[2] ; dst[3] = src[3] ;
244 inline void puSetColour ( puColour c, float r, float g, float b, float a = 1.0f )
246 c [ 0 ] = r ; c [ 1 ] = g ; c [ 2 ] = b ; c [ 3 ] = a ;
250 void puInit ( void ) ;
251 void puDisplay ( void ) ;
252 int puMouse ( int button, int updown, int x, int y ) ;
253 int puMouse ( int x, int y ) ;
254 int puKeyboard ( int key, int updown ) ;
255 void puHideCursor ( void ) ;
256 void puShowCursor ( void ) ;
257 int puCursorIsHidden ( void ) ;
259 void puDrawString ( puFont fnt, char *str, int x, int y ) ;
260 int puGetStringWidth ( puFont fnt, char *str ) ;
261 int puGetStringHeight ( puFont fnt = NULL ) ;
262 int puGetStringDescender ( puFont fnt = NULL ) ;
270 char string [ PUSTRING_MAX ] ;
272 puValue () { type = PUCLASS_VALUE ; clrValue () ; }
274 virtual ~puValue () ;
276 int getType ( void ) { return type ; }
277 char *getTypeString ( void ) ;
278 void clrValue ( void ) { setValue ( "" ) ; }
280 void setValue ( puValue *pv )
282 integer = pv -> integer ;
283 floater = pv -> floater ;
284 strcpy ( string, pv -> string ) ;
288 void setValue ( int i ) { integer = i ; floater = (float) i ; sprintf ( string, "%d", i ) ; puRefresh = TRUE ; }
289 void setValue ( float f ) { integer = (int) f ; floater = f ; sprintf ( string, "%g", f ) ; puRefresh = TRUE ; }
290 void setValue ( char *s ) {
291 if ( s == NULL || s[0] == '\0' )
300 floater = (float)atof(s) ;
302 if ( string != s ) strcpy ( string, s ) ;
307 void getValue ( int *i ) { *i = integer ; }
308 void getValue ( float *f ) { *f = floater ; }
309 void getValue ( char **s ) { *s = string ; }
310 void getValue ( char *s ) { strcpy ( s, string ) ; }
312 int getValue ( void ) { return integer ; }
315 typedef void (*puCallback)(class puObject *) ;
317 void puSetDefaultStyle ( int style ) ;
318 int puGetDefaultStyle ( void ) ;
319 void puSetDefaultFonts ( puFont legendFont, puFont labelFont ) ;
320 void puGetDefaultFonts ( puFont *legendFont, puFont *labelFont ) ;
321 void puSetDefaultColourScheme ( float r, float g, float b, float a = 1.0 ) ;
322 void puGetDefaultColourScheme ( float *r, float *g, float *b, float *a = NULL );
324 class puObject : public puValue
327 puValue default_value ;
329 puBox bbox ; /* Bounding box of entire Object */
330 puBox abox ; /* Active (clickable) area */
331 puColour colour [ PUCOL_MAX ] ;
332 puInterface *parent ;
334 int active_mouse_edge ; /* is it PU_UP or PU_DOWN (or both) that activates this? */
341 char *label ; puFont labelFont ; int labelPlace ;
342 char *legend ; puFont legendFont ;
347 virtual void draw_label ( int dx, int dy ) ;
348 virtual int isHit ( int x, int y ) { return isVisible() && isActive() &&
353 virtual void doHit ( int button, int updown, int x, int y ) ;
356 puObject ( int minx, int miny, int maxx, int maxy ) ;
362 puBox *getBBox ( void ) { return & bbox ; }
363 puBox *getABox ( void ) { return & abox ; }
365 void setPosition ( int x, int y )
367 if ( abox.isEmpty() )
369 abox.max[0] = abox.min[0] = x ;
370 abox.max[1] = abox.min[1] = y ;
374 abox.max[0] += x - abox.min[0] ;
375 abox.max[1] += y - abox.min[1] ;
379 recalc_bbox() ; puRefresh = TRUE ;
382 void setSize ( int w, int h )
384 abox.max[0] = abox.min[0] + w ;
385 abox.max[1] = abox.min[1] + h ;
386 recalc_bbox() ; puRefresh = TRUE ;
389 void getPosition ( int *x, int *y )
391 if ( abox . isEmpty () )
398 if ( x ) *x = abox.min[0] ;
399 if ( y ) *y = abox.min[1] ;
403 void getSize ( int *w, int *h )
405 if ( abox . isEmpty () )
412 if ( w ) *w = abox.max[0] - abox.min[0] ;
413 if ( h ) *h = abox.max[1] - abox.min[1] ;
417 virtual void recalc_bbox ( void ) ;
418 virtual int checkHit ( int button, int updown, int x, int y ) ;
419 virtual int checkKey ( int key , int updown ) ;
420 virtual void draw ( int dx, int dy ) = 0 ;
422 puInterface *getParent ( void ) { return parent ; }
423 puObject *getNextObject ( void ) { return next ; }
424 puObject *getPrevObject ( void ) { return prev ; }
426 void setCallback ( puCallback c ) { cb = c ; }
427 puCallback getCallback ( void ) { return cb ; }
428 void invokeCallback ( void ) { if ( cb ) (*cb)(this) ; }
430 void makeReturnDefault ( int def ) { am_default = def ; }
431 int isReturnDefault ( void ) { return am_default ; }
433 void setActiveDirn ( int e ) { active_mouse_edge = e ; }
434 int getActiveDirn ( void ) { return active_mouse_edge ; }
436 void setLegend ( char *l ) { legend = l ; recalc_bbox() ; puRefresh = TRUE ; }
437 char *getLegend ( void ) { return legend ; }
439 void setLegendFont ( puFont f ) { legendFont = f ; recalc_bbox() ; puRefresh = TRUE ; }
440 puFont getLegendFont ( void ) { return legendFont ; }
442 void setLabel ( char *l ) { label = l ; recalc_bbox() ; puRefresh = TRUE ; }
443 char *getLabel ( void ) { return label ; }
445 void setLabelFont ( puFont f ) { labelFont = f ; recalc_bbox() ; puRefresh = TRUE ; }
446 puFont getLabelFont ( void ) { return labelFont ; }
448 void setLabelPlace ( int lp ) { labelPlace = lp ; recalc_bbox() ; puRefresh = TRUE ; }
449 int getLabelPlace ( void ) { return labelPlace ; }
451 void activate ( void ) { if ( ! active ) { active = TRUE ; puRefresh = TRUE ; } }
452 void greyOut ( void ) { if ( active ) { active = FALSE ; puRefresh = TRUE ; } }
453 int isActive ( void ) { return active ; }
455 void highlight ( void ) { if ( ! highlighted ) { highlighted = TRUE ; puRefresh = TRUE ; } }
456 void lowlight ( void ) { if ( highlighted ) { highlighted = FALSE ; puRefresh = TRUE ; } }
457 int isHighlighted( void ){ return highlighted ; }
459 void reveal ( void ) { if ( ! visible ) { visible = TRUE ; puRefresh = TRUE ; } }
460 void hide ( void ) { if ( visible ) { visible = FALSE ; puRefresh = TRUE ; } }
461 int isVisible ( void ) { return visible ; }
463 void setStyle ( int which )
470 int getStyle ( void ) { return style ; }
472 void setColourScheme ( float r, float g, float b, float a = 1.0f ) ;
474 void setColour ( int which, float r, float g, float b, float a = 1.0f )
476 puSetColour ( colour [ which ], r, g, b, a ) ;
480 void getColour ( int which, float *r, float *g, float *b, float *a = NULL )
482 if ( r ) *r = colour[which][0] ;
483 if ( g ) *g = colour[which][1] ;
484 if ( b ) *b = colour[which][2] ;
485 if ( a ) *a = colour[which][3] ;
488 void setUserData ( void *data ) { user_data = data ; }
489 void *getUserData ( void ) { return user_data ; }
491 void defaultValue ( void ) { setValue ( & default_value ) ; }
493 void setDefaultValue ( int i ) { default_value . setValue ( i ) ; }
494 void setDefaultValue ( float f ) { default_value . setValue ( f ) ; }
495 void setDefaultValue ( char *s ) { default_value . setValue ( s ) ; }
497 void getDefaultValue ( int *i ) { default_value . getValue ( i ) ; }
498 void getDefaultValue ( float *f ) { default_value . getValue ( f ) ; }
499 void getDefaultValue ( char **s ) { default_value . getValue ( s ) ; }
500 int getDefaultValue ( void ) { return default_value . getValue () ; }
504 The 'live' interface stack is used for clicking and rendering.
507 void puPushLiveInterface ( puInterface *in ) ;
508 void puPopLiveInterface ( void ) ;
509 int puNoLiveInterface ( void ) ;
510 puInterface *puGetBaseLiveInterface ( void ) ;
511 puInterface *puGetUltimateLiveInterface ( void ) ;
514 The regular interface stack is used for adding widgets
517 void puPushInterface ( puInterface *in ) ;
518 void puPopInterface ( void ) ;
519 int puNoInterface ( void ) ;
520 puInterface *puGetCurrInterface ( void ) ;
522 class puInterface : public puObject
528 void doHit ( int button, int updown, int x, int y ) ;
532 puInterface ( int x, int y ) : puObject ( x, y, x, y )
534 type |= PUCLASS_INTERFACE ;
537 puPushInterface ( this ) ;
538 puPushLiveInterface ( this ) ;
543 void recalc_bbox ( void ) ;
544 virtual void add ( puObject *new_object ) ;
545 virtual void remove ( puObject *old_object ) ;
547 void draw ( int dx, int dy ) ;
548 int checkHit ( int button, int updown, int x, int y ) ;
549 int checkKey ( int key , int updown ) ;
551 puObject *getFirstChild ( void ) { return dlist ; }
552 int getNumChildren ( void ) { return num_children ; }
554 virtual void close ( void )
556 if ( puGetCurrInterface () != this )
557 fprintf ( stderr, "PUI: puInterface::close() is mismatched!\n" ) ;
563 class puFrame : public puObject
566 virtual int isHit ( int /* x */, int /* y */ ) { return FALSE ; }
568 void draw ( int dx, int dy ) ;
569 puFrame ( int minx, int miny, int maxx, int maxy ) :
570 puObject ( minx, miny, maxx, maxy )
572 type |= PUCLASS_FRAME ;
577 class puText : public puObject
580 virtual int isHit ( int /* x */, int /* y */ ) { return FALSE ; }
582 void draw ( int dx, int dy ) ;
583 puText ( int x, int y ) : puObject ( x, y, x, y )
585 type |= PUCLASS_TEXT ;
590 class puButton : public puObject
594 void doHit ( int button, int updown, int x, int y ) ;
595 void draw ( int dx, int dy ) ;
596 puButton ( int minx, int miny, char *l ) :
597 puObject ( minx, miny,
598 minx + puGetStringWidth ( NULL, l ) + PUSTR_LGAP + PUSTR_RGAP,
599 miny + puGetStringHeight () + puGetStringDescender () + PUSTR_TGAP + PUSTR_BGAP )
601 type |= PUCLASS_BUTTON ;
605 puButton ( int minx, int miny, int maxx, int maxy ) :
606 puObject ( minx, miny, maxx, maxy )
608 type |= PUCLASS_BUTTON ;
613 class puSlider : public puObject
617 float last_cb_value ;
620 float slider_fraction ;
622 void doHit ( int button, int updown, int x, int y ) ;
623 void draw ( int dx, int dy ) ;
624 puSlider ( int minx, int miny, int sz, int vertical = FALSE ) :
625 puObject ( minx, miny, vertical ?
626 ( minx + puGetStringWidth ( NULL, "W" ) +
627 PUSTR_LGAP + PUSTR_RGAP ) :
631 ( miny + puGetStringHeight () +
632 puGetStringDescender () +
633 PUSTR_TGAP + PUSTR_BGAP )
636 type |= PUCLASS_SLIDER ;
637 slider_fraction = 0.1f ;
638 getValue ( & last_cb_value ) ;
641 cb_mode = PUSLIDER_ALWAYS ;
644 void setCBMode ( int m ) { cb_mode = m ; }
645 float getCBMode ( void ) { return (float)cb_mode ; }
647 int isVertical ( void ) { return vert ; }
649 void setDelta ( float f ) { cb_delta = (f<=0.0f) ? 0.1f : (f>=1.0f) ? 0.9f : f ; }
650 float getDelta ( void ) { return cb_delta ; }
652 void setSliderFraction ( float f ) { slider_fraction = (f<=0.0f) ? 0.1f : (f>=1.0f) ? 0.9f : f ; }
653 float getSliderFraction ( void ) { return slider_fraction ; }
658 class puOneShot : public puButton
662 void doHit ( int button, int updown, int x, int y ) ;
664 puOneShot ( int minx, int miny, char *l ) : puButton ( minx, miny, l )
666 type |= PUCLASS_ONESHOT ;
669 puOneShot ( int minx, int miny, int maxx, int maxy ) :
670 puButton ( minx, miny, maxx, maxy )
672 type |= PUCLASS_ONESHOT ;
678 class puPopup : public puInterface
682 puPopup ( int x, int y ) : puInterface ( x, y )
684 type |= PUCLASS_POPUP ;
689 class puPopupMenu : public puPopup
693 puPopupMenu ( int x, int y ) : puPopup ( x, y )
695 type |= PUCLASS_POPUPMENU ;
698 puObject *add_item ( char *str, puCallback cb ) ;
699 int checkHit ( int button, int updown, int x, int y ) ;
700 int checkKey ( int key , int updown ) ;
701 void close ( void ) ;
704 class puMenuBar : public puInterface
708 puMenuBar ( int h = -1 ) :
710 puInterface ( 0, h < 0 ? puGetWindowHeight() -
711 ( puGetStringHeight() + PUSTR_TGAP + PUSTR_BGAP ) : h )
713 type |= PUCLASS_MENUBAR ;
716 void add_submenu ( char *str, char *items[], puCallback cb[] ) ;
717 void close ( void ) ;
721 class puInput : public puObject
724 int cursor_position ;
725 int select_start_position ;
726 int select_end_position ;
728 void normalize_cursors ( void ) ;
731 void draw ( int dx, int dy ) ;
732 void doHit ( int button, int updown, int x, int y ) ;
733 int checkKey ( int key, int updown ) ;
735 int isAcceptingInput ( void ) { return accepting ; }
736 void rejectInput ( void ) { accepting = FALSE ; }
737 void acceptInput ( void ) { accepting = TRUE ;
738 cursor_position = strlen ( string ) ;
739 select_start_position = select_end_position = -1 ; }
741 int getCursor ( void ) { return cursor_position ; }
742 void setCursor ( int c ) { cursor_position = c ; }
744 void setSelectRegion ( int s, int e )
746 select_start_position = s ;
747 select_end_position = e ;
750 void getSelectRegion ( int *s, int *e )
752 if ( s ) *s = select_start_position ;
753 if ( e ) *e = select_end_position ;
756 puInput ( int minx, int miny, int maxx, int maxy ) :
757 puObject ( minx, miny, maxx, maxy )
759 type |= PUCLASS_INPUT ;
763 cursor_position = 0 ;
764 select_start_position = -1 ;
765 select_end_position = -1 ;
767 setColourScheme ( 0.8f, 0.7f, 0.7f ) ; /* Yeukky Pink */
772 class puButtonBox : public puObject
777 char **button_labels ;
781 puButtonBox ( int minx, int miny, int maxx, int maxy,
782 char **labels, int one_button ) ;
784 int isOneButton ( void ) { return one_only ; }
786 int checkKey ( int key , int updown ) ;
787 int checkHit ( int button, int updown, int x, int y ) ;
788 void draw ( int dx, int dy ) ;
793 class puDialogBox : public puPopup
798 puDialogBox ( int x, int y ) : puPopup ( x, y )
800 type |= PUCLASS_DIALOGBOX ;