2 * $Logfile: /Freespace2/code/Ui/UI.H $
7 * Include file for our user interface.
10 * Revision 1.1 2002/05/03 03:28:12 root
14 * 20 8/16/99 9:45a Jefff
15 * changes to cursor management to allow a 2nd temporary cursor
17 * 19 8/11/99 3:21p Jefff
18 * set_bmaps clarification by daveb
20 * 18 8/11/99 12:18p Jefff
21 * added option to slider2 class to not force slider reset on
24 * 17 8/10/99 6:54p Dave
25 * Mad optimizations. Added paging to the nebula effect.
27 * 16 8/05/99 2:44p Jefff
28 * added disabled callback to UI_BUTTON
30 * 15 6/25/99 11:59a Dave
31 * Multi options screen.
33 * 14 6/22/99 7:03p Dave
34 * New detail options screen.
36 * 13 5/21/99 6:45p Dave
37 * Sped up ui loading a bit. Sped up localization disk access stuff. Multi
38 * start game screen, multi password, and multi pxo-help screen.
40 * 12 5/04/99 5:20p Dave
41 * Fixed up multiplayer join screen and host options screen. Should both
44 * 11 5/03/99 8:33p Dave
45 * New version of multi host options screen.
47 * 10 4/29/99 2:15p Neilk
48 * fixed slider so there is an extra callback for mouse locks
50 * 9 4/16/99 5:22p Neilk
51 * Added UI_SLIDER2 class
53 * 8 2/21/99 6:02p Dave
54 * Fixed standalone WSS packets.
56 * 7 2/11/99 3:08p Dave
57 * PXO refresh button. Very preliminary squad war support.
59 * 6 2/01/99 5:55p Dave
60 * Removed the idea of explicit bitmaps for buttons. Fixed text
61 * highlighting for disabled gadgets.
63 * 5 12/18/98 1:13a Dave
64 * Rough 1024x768 support for Direct3D. Proper detection and usage through
67 * 4 12/02/98 5:47p Dave
68 * Put in interface xstr code. Converted barracks screen to new format.
70 * 3 11/30/98 1:07p Dave
71 * 16 bit conversion, first run.
73 * 2 10/07/98 10:54a Dave
76 * 1 10/07/98 10:51a Dave
78 * 71 5/12/98 11:59p Dave
79 * Put in some more functionality for Parallax Online.
81 * 70 5/11/98 5:29p Hoffoss
82 * Added mouse button mapped to joystick button support.
84 * 69 5/05/98 1:49a Lawrance
85 * Add member function to disable processing for all gadgets in a window
87 * 68 5/03/98 1:55a Lawrance
88 * Add function call that forces button code to skip first callback for
91 * 67 4/17/98 12:22a Dave
92 * Bumped up MAX_TOOLTIPS from 350 to 500 so Freespace will start.
94 * 66 4/14/98 5:07p Dave
95 * Don't load or send invalid pilot pics. Fixed chatbox graphic errors.
96 * Made chatbox display team icons in a team vs. team game. Fixed up pause
97 * and endgame sequencing issues.
99 * 65 4/14/98 4:27p Hoffoss
100 * Changed the way tooltips render as requested.
102 * 64 4/13/98 4:30p Hoffoss
103 * Fixed a bunch of stupid little bugs in options screen. Also changed
104 * forced_draw() to work like it used to.
106 * 63 4/12/98 2:09p Dave
107 * Make main hall door text less stupid. Make sure inputbox focus in the
108 * multi host options screen is managed more intelligently.
110 * 62 4/10/98 5:36p Dave
111 * Put in user notification of illegal values in multi host options
112 * screen. Fixed server respawn ship class problem.
114 * 61 4/10/98 4:51p Hoffoss
115 * Made several changes related to tooltips.
117 * 60 4/09/98 7:14p Hoffoss
118 * Did some cool changes for tooltips.
120 * 59 4/09/98 5:57p Hoffoss
121 * Added custom tooltip handler functionality for callback.
123 * 58 4/09/98 12:12p Mike
124 * Separate versioning for demo and full versions.
127 * 57 3/30/98 6:24p Hoffoss
128 * Added the tooltip (foreign language translation of text) system.
130 * 56 3/23/98 5:48p Hoffoss
131 * Improved listbox handling. Most notibly the scrollbar arrows work now.
133 * 55 3/22/98 10:50p Lawrance
134 * Allow sliders to not have end-buttons.
136 * 54 3/10/98 4:06p Hoffoss
137 * Removed unused variables.
139 * 53 3/09/98 5:55p Dave
140 * Fixed stats to take asteroid hits into account. Polished up UI stuff in
141 * team select. Finished up pilot info popup. Tracked down and fixed
144 * 52 3/02/98 3:54p Lawrance
145 * make button draw function public
147 * 51 2/26/98 4:21p Dave
148 * More robust multiplayer voice.
150 * 50 2/11/98 6:24p Hoffoss
151 * Fixed bug where disabled and hidden buttons give failed sound when
152 * pressed. Shouldn't happen when they are hidden.
154 * 49 2/09/98 10:03a Hoffoss
155 * Made first_time variable public so I can clear the stupid thing in code
156 * that I want it to be cleared in.
158 * 48 1/26/98 6:28p Lawrance
159 * Add ability to for a button press event externally.
161 * 47 1/23/98 5:43p Dave
162 * Finished bringing standalone up to speed. Coded in new host options
165 * 46 1/16/98 7:57p Lawrance
166 * support animating input box cursor
168 * 45 1/15/98 5:10p Allender
169 * ton of interface changes. chatbox in multiplayer now behaves
170 * differently than before. It's always active in any screen that uses
171 * it. Only non-printatble characters will get passed back out from
174 * 44 1/14/98 6:44p Hoffoss
175 * Massive changes to UI code. A lot cleaner and better now. Did all
176 * this to get the new UI_DOT_SLIDER to work properly, which the old code
177 * wasn't flexible enough to handle.
179 * 43 1/02/98 9:11p Lawrance
180 * Add button_hot() function
182 * 42 12/22/97 5:08p Hoffoss
183 * Changed inputbox class to be able to accept only certain keys, changed
184 * pilot screens to utilize this feature. Added to assert with pilot file
187 * 41 12/11/97 8:15p Dave
188 * Put in network options screen. Xed out olf protocol selection screen.
190 * 40 12/10/97 3:14p Dave
191 * Added an overloaded set_mask_bmap(int) function for the UI_WINDOW
193 * 39 12/08/97 6:22p Lawrance
194 * blink cursor on inputbox
196 * 38 12/06/97 4:27p Dave
197 * Another load of interface and multiplayer bug fixes.
199 * 37 11/25/97 3:51p Hoffoss
200 * Changed edit background rect position slightly.
202 * 36 11/19/97 8:32p Hoffoss
203 * Changed UI buttons so they go back to unpressed when they are disabled.
205 * 35 10/29/97 7:25p Hoffoss
206 * Added crude support for UI button double click checking.
208 * 34 10/24/97 10:58p Hoffoss
209 * Made some changes to the UI code to do some things I need it to do.
211 * 33 10/01/97 4:40p Lawrance
212 * allow process() to have key input
214 * 32 9/18/97 10:31p Lawrance
215 * allow listbox to change text
217 * 31 9/09/97 4:32p Dave
218 * Added sel_changed() function to UI_LISTBOX to check is the selection
221 * 30 9/07/97 10:05p Lawrance
224 * 29 8/30/97 12:23p Lawrance
225 * add button function to reset the status of a button
227 * 28 8/29/97 7:33p Lawrance
228 * move cleanup code from destructor to destroy() method
230 * 27 8/24/97 5:25p Lawrance
231 * improve drawing of buttons
233 * 26 8/21/97 12:13p Dave
234 * Made it possible for input box to ignore esc to lose focus.
236 * 25 8/19/97 1:27p Dave
237 * Modified input box to allow character limitation by pixel width.
238 * Changed list box so that you can create an empty box and add items as
241 * 24 8/18/97 5:28p Lawrance
242 * integrating sounds for when mouse goes over an active control
244 * 23 8/17/97 2:42p Lawrance
245 * add code to have selected bitmap for buttons linger for a certain time
247 * 22 8/15/97 8:21p Dave
248 * Modified UI_INPUTBOX so that it is possible to draw it invisibly. That
249 * is, only the text is displayed.
251 * 21 8/14/97 5:23p Dave
252 * Added clear_all_items() to the UI_LISTBOX
254 * 20 6/13/97 5:51p Lawrance
255 * add in support for repeating buttons
257 * 19 6/11/97 1:32p Allender
258 * externed sort_filelist
260 * 18 5/26/97 10:26a Lawrance
261 * get slider control working 100%
263 * 17 5/22/97 5:36p Lawrance
264 * allowing custom art for scrollbars
266 * 16 5/21/97 11:07a Lawrance
267 * integrate masks and custom bitmaps
269 * 15 4/28/97 2:19p Lawrance
270 * added clear_focus() function
272 * 14 4/22/97 10:11a John
273 * Added checkbox lists to listboxes
275 * 13 4/15/97 3:47p Allender
276 * moved type selection of list box items into actual UI code. Made it
277 * behave more like windows listboxes do
279 * 12 1/28/97 4:58p Lawrance
280 * allowing hidden UI components
282 * 11 12/23/96 2:42p Lawrance
283 * allowing keys to select list box items in the mission load screen
285 * 10 12/04/96 3:00p John
286 * Added code to allow adjusting of HUD colors and saved it to the player
289 * 9 12/03/96 3:46p Lawrance
290 * added ability to set contents of input box
292 * 8 12/03/96 11:29a John
293 * Made scroll buttons on listbox scroll once, then delay, then repeat
294 * when the buttons are held down.
296 * 7 12/02/96 2:17p John
297 * Made right button drag UI gadgets around and
298 * Ctrl+Shift+Alt+F12 dumps out where they are.
300 * 6 12/01/96 3:48a Lawrance
301 * added function set_current to UI_LISTBOX
303 * 5 11/29/96 6:08p Lawrance
304 * enabled check-boxes to be set to a specific value outside of the
307 * 4 11/21/96 10:58a John
308 * Started adding code to drag buttons.
310 * 3 11/18/96 4:28p Jasen
311 * making class member process return an int
313 * 2 11/15/96 11:42a John
315 * 1 11/14/96 6:55p John
325 #define UI_KIND_BUTTON 1
326 #define UI_KIND_KEYTRAP 2
327 #define UI_KIND_CHECKBOX 3
328 #define UI_KIND_RADIO 4
329 #define UI_KIND_SCROLLBAR 5
330 #define UI_KIND_LISTBOX 6
331 #define UI_KIND_INPUTBOX 7
332 #define UI_KIND_SLIDER 8
333 #define UI_KIND_ICON 9
334 #define UI_KIND_DOT_SLIDER 10
335 #define UI_KIND_SLIDER2 11
336 #define UI_KIND_DOT_SLIDER_NEW 12
338 #define MAX_KEY_BUFFER 32 // for listboxes
340 #define MAX_BMAPS_PER_GADGET 15
342 #define UI_INPUTBOX_FLAG_INVIS (1 << 0) // don't draw the input box boarders
343 #define UI_INPUTBOX_FLAG_KEYTHRU (1 << 1) // pass all keypresses through to parent
344 #define UI_INPUTBOX_FLAG_ESC_CLR (1 << 2) // allow escape key to clear input box
345 #define UI_INPUTBOX_FLAG_ESC_FOC (1 << 3) // escape loses focus for the input box
346 #define UI_INPUTBOX_FLAG_PASSWD (1 << 4) // display all characters as special "password" characters
347 #define UI_INPUTBOX_FLAG_EAT_USED (1 << 5) // don't return any characters actually used by inputbox
348 #define UI_INPUTBOX_FLAG_LETTER_FIRST (1 << 6) // require input string to begin with a letter.
349 #define UI_INPUTBOX_FLAG_NO_LETTERS (1 << 7) // don't allow [a-z,A-Z] at all, no matter what
350 #define UI_INPUTBOX_FLAG_NO_NUMERALS (1 << 8) // don't allow [0-9] at all, no matter what
351 #define UI_INPUTBOX_FLAG_TEXT_CEN (1 << 9) // always draw text centered in the inputbox
352 #define UI_INPUTBOX_FLAG_NO_BACK (1 << 10) // don't draw a black background rectangle
354 #define UI_GF_MOUSE_CAPTURED (1 << 31) // gadget has all rights to the mouse
366 class UI_DOT_SLIDER_NEW;
370 friend class UI_WINDOW;
371 friend class UI_BUTTON;
372 friend class UI_KEYTRAP;
373 friend class UI_CHECKBOX;
374 friend class UI_RADIO;
375 friend class UI_SCROLLBAR;
376 friend class UI_LISTBOX;
377 friend class UI_INPUTBOX;
379 friend class UI_DOT_SLIDER;
380 friend class UI_DOT_SLIDER_NEW;
388 void (*user_function)(void);
391 int base_drag_x, base_drag_y;
392 int base_start_x, base_start_y;
395 // Data for supporting linking controls to hotspots
396 int linked_to_hotspot;
399 // Data for supporting bitmaps associated with different states of the control
402 // ubyte *bmap_storage[MAX_BMAPS_PER_GADGET];
404 void drag_with_children( int dx, int dy );
405 void start_drag_with_children();
406 void stop_drag_with_children();
413 int is_mouse_on_children();
414 void remove_from_family();
415 void set_parent(UI_GADGET *_parent);
417 UI_GADGET *get_next();
418 UI_GADGET *get_prev();
421 virtual void process(int focus = 0);
422 virtual void destroy();
426 int bmap_ids[MAX_BMAPS_PER_GADGET];
428 UI_GADGET(); // constructor
429 ~UI_GADGET(); // destructor
431 void base_create( UI_WINDOW *wnd, int kind, int x, int y, int w, int h );
436 void set_hotkey(int keycode);
437 void set_callback(void (*user_function)(void));
439 void enable(int n = 1);
440 void capture_mouse();
441 int mouse_captured(UI_GADGET *gadget = NULL);
444 virtual void hide(int n = 1);
445 virtual void unhide();
446 void update_dimensions(int x, int y, int w, int h);
447 void get_dimensions(int *x, int *y, int *w, int *h);
449 void get_mouse_pos(int *x, int *y);
451 void link_hotspot(int num);
453 int bmaps_used() { return uses_bmaps; }
455 // loads nframes bitmaps, starting at index start_frame.
456 // anything < start_frame will not be loaded.
457 // this keeps the loading code from trying to load bitmaps which don't exist
458 // and taking an unnecessary disk hit.
459 int set_bmaps(char *ani_filename, int nframes = 3, int start_frame = 1); // extracts MAX_BMAPS_PER_GADGET from .ani file
461 void reset(); // zero out m_flags
462 int is_hidden() { return hidden; }
465 // xstrings for a window
466 #define UI_NUM_XSTR_COLORS 2
467 #define UI_XSTR_COLOR_GREEN 0 // shades of green/gray
468 #define UI_XSTR_COLOR_PINK 1 // pinkish hue
469 typedef struct UI_XSTR {
470 char *xstr; // base string
471 int xstr_id; // xstring id
472 int x, y; // coords of the string
473 int clr; // color to use
474 int font_id; // font id
475 UI_GADGET *assoc; // the associated gadget
478 #define MAX_UI_XSTRS 100
480 // Button terminology:
481 // Up = button is in up state (also called pressed)
482 // Down = button is in down state (also called released)
483 // Just pressed = button has just gone from up to down state
484 // Just released = button has just gone from down to up state
485 // Clicked = a trigger type effect caused by 'just pressed' event or repeat while 'down'
486 // Double clicked = 2 'just pressed' events occuring within a short amount of time
490 #define BF_DOWN (1<<1)
491 #define BF_JUST_PRESSED (1<<2)
492 #define BF_JUST_RELEASED (1<<3)
493 #define BF_CLICKED (1<<4)
494 #define BF_DOUBLE_CLICKED (1<<5)
495 #define BF_HIGHLIGHTED (1<<6) // button is not highlighted (ie mouse is not over)
496 #define BF_JUST_HIGHLIGHTED (1<<7) // button has just been highlighted, true for 1 frame
497 #define BF_IGNORE_FOCUS (1<<8) // button should not use focus to accept space/enter keypresses
498 #define BF_HOTKEY_JUST_PRESSED (1<<9) // button hotkey was just pressed
499 #define BF_REPEATS (1<<10) // if held down, generates repeating presses
500 #define BF_SKIP_FIRST_HIGHLIGHT_CALLBACK (1<<11) // skip first callback for mouse over event
502 class UI_BUTTON : public UI_GADGET
504 friend class UI_SCROLLBAR;
506 friend class UI_DOT_SLIDER;
507 friend class UI_DOT_SLIDER_NEW;
510 int position; // indicates position of button (0 - up, 1 - down by mouse click 2 - down by keypress
511 int next_repeat; // timestamp for next repeat if held down
512 int m_press_linger; // timestamp for hold a pressed state animation
513 int hotkey_if_focus; // hotkey for button that only works if it has focus
514 int force_draw_frame; // frame number to draw next time (override default)
515 int first_callback; // true until first time callback function is called for button highlight
517 // Used to index into bmap_ids[] array to locate right bitmap for button
518 enum { B_NORMAL = 0 };
519 enum { B_HIGHLIGHT = 1 };
520 enum { B_PRESSED = 2 };
521 enum { B_DISABLED = 3 };
522 enum { B_REPEAT_TIME = 100 }; // ms
524 void (*m_just_highlighted_function)(void); // call-back that gets called when button gets highlighted
525 void (*m_disabled_function)(void); // callback that gets called when disabled button gets pressed (sound, popup, etc)
528 virtual void process(int focus = 0);
529 virtual void destroy();
531 int custom_cursor_bmap; // bmap handle of special cursor used on mouseovers
532 int previous_cursor_bmap; // store old cursor
533 void maybe_show_custom_cursor(); // call this in process()
534 void restore_previous_cursor(); // called in frame_reset()
538 void set_hotkey_if_focus(int key);
539 int pressed(); // has it been selected (ie clicked on)
540 int double_clicked(); // button was double clicked on
541 int just_pressed(); // button has just been selected
542 int just_highlighted(); // button has just had mouse go over it
543 int button_down(); // is the button depressed?
544 int button_hilighted(); // is the mouse over this button?
545 void set_button_hilighted(); // force button to be highlighted
546 void press_button(); // force button to get pressed
547 void create(UI_WINDOW *wnd, char *_text, int _x, int _y, int _w, int _h, int do_repeat=0, int ignore_focus = 0);
548 void set_highlight_action( void (*user_function)(void) );
549 void set_disabled_action( void (*user_function)(void) );
550 void draw_forced(int frame_num);
552 void reset_timestamps();
553 void skip_first_highlight_callback();
554 void repeatable(int yes);
555 void set_custom_cursor_bmap(int bmap_id) { custom_cursor_bmap = bmap_id; };
558 class UI_KEYTRAP : public UI_GADGET
562 virtual void process(int focus = 0);
566 void create(UI_WINDOW *wnd, int hotkey, void (*user_function)(void) );
569 class UI_USERBOX : public UI_GADGET
573 int b1_double_clicked;
575 int b1_drag_x1, b1_drag_y1;
576 int b1_drag_x2, b1_drag_y2;
577 int b1_done_dragging;
580 int mouse_x, mouse_y;
584 class UI_INPUTBOX : public UI_GADGET
594 int pixel_limit; // base max characters on how wide the string is (-1 to ignore) in pixels
603 int cursor_first_frame;
606 int cursor_current_frame;
607 int cursor_elapsed_time;
609 int validate_input(int chr);
613 virtual void process(int focus = 0);
614 virtual void destroy();
619 void create(UI_WINDOW *wnd, int _x, int _y, int _w, int _textlen, char *text, int _flags = 0, int pixel_lim = -1, color *clr = NULL);
620 void set_valid_chars(char *vchars);
621 void set_invalid_chars(char *ichars);
624 void get_text(char *out);
625 void set_text(char *in);
629 #define ICON_NOT_HIGHLIGHTED (1<<0) // icon is not highlighted (ie mouse is not over)
630 #define ICON_JUST_HIGHLIGHTED (1<<1) // icon has just been highlighted, true for 1 frame
632 class UI_ICON : public UI_GADGET
636 // Used to index into bmap_ids[] array to locate right bitmap for button
637 enum { ICON_NORMAL = 0 };
638 enum { ICON_HIGHLIGHT = 1 };
639 enum { ICON_SELECTED = 2 };
640 enum { ICON_DISABLED = 3 };
643 virtual void process(int focus = 0);
644 virtual void destroy();
647 void create(UI_WINDOW *wnd, char *_text, int _x, int _y, int _w, int _h);
650 class UI_CHECKBOX : public UI_GADGET
657 virtual void process(int focus = 0);
658 virtual void destroy();
660 // Used to index into bmap_ids[] array to locate right bitmap for checkbox
661 enum { CBOX_UP_CLEAR = 0 };
662 enum { CBOX_DOWN_CLEAR = 1 };
663 enum { CBOX_UP_MARKED = 2 };
664 enum { CBOX_DOWN_MARKED = 3 };
665 enum { CBOX_DISABLED_CLEAR = 4 };
666 enum { CBOX_DISABLED_MARKED = 5 };
671 void create(UI_WINDOW *wnd, char *_text, int _x, int _y, int _state );
672 void set_state(int _state);
675 class UI_RADIO : public UI_GADGET
683 virtual void process(int focus = 0);
684 virtual void destroy();
686 // Used to index into bmap_ids[] array to locate right bitmap for radio button
687 enum { RADIO_UP_CLEAR = 0 };
688 enum { RADIO_DOWN_CLEAR = 1 };
689 enum { RADIO_UP_MARKED = 2 };
690 enum { RADIO_DOWN_MARKED = 3 };
691 enum { RADIO_DISABLED_CLEAR = 4 };
692 enum { RADIO_DISABLED_MARKED = 5 };
697 void create(UI_WINDOW *wnd, char *_text, int _x, int _y, int _state, int _group );
700 class UI_SCROLLBAR : public UI_GADGET
702 friend class UI_LISTBOX;
703 friend class UI_BUTTON;
713 UI_BUTTON down_button;
721 virtual void process(int focus = 0);
723 // Used to index into bmap_ids[] array to locate right bitmap for scrollbar
724 enum { SB_NORMAL = 0 };
725 enum { SB_DISABLED = 1 };
728 void create(UI_WINDOW *wnd, int _x, int _y, int _h,int _start, int _stop, int _position, int _window_size );
734 void link_hotspot(int up_button_num, int down_button_num);
735 int set_bmaps(char *up_button_fname, char *down_button_fname, char *line_fname);
738 class UI_SLIDER2 : public UI_GADGET
740 friend class UI_BUTTON;
742 int numberItems; // total range
743 int numberPositions; // total positions (height - bitmapbuttonheight)
744 int currentItem; // current item we are on
745 int currentPosition; // current position
749 UI_BUTTON sliderBackground;// invisible button to detect clicks
750 int bitmapSliderControl; // this is the bitmap of the slider button itself
751 void (*upCallback)();
752 void (*downCallback)();
753 void (*captureCallback)(); // this is called when the mouse is released
754 UI_BUTTON *upButton, *downButton;
755 int slider_w, slider_h, slider_half_h; // this is the width and height and half height of the bitmap used for the slider
757 virtual void process(int focus = 0);
759 // Used to index into bmap_ids[] array to locate right bitmap for slider
760 enum { S2_NORMAL = 0 };
761 enum { S2_HIGHLIGHT = 1 };
762 enum { S2_PRESSED = 2 };
763 enum { S2_DISABLED = 3 };
765 // Used for slider mode
766 enum { S2M_ON_ME = 0 };
767 enum { S2M_MOVING = 1 };
768 enum { S2M_DEFAULT = 2 };
772 void create(UI_WINDOW *wnd, int _x, int _y, int _w, int _h, int _numberItems, char *_bitmapSliderControl,
773 void (*_upCallback)(), void (*_downCallback)(), void (*_captureCallback)());
776 int get_numberItems(); // return number of itmes
777 int get_currentPosition(); // return current position
778 int get_currentItem(); // return current item
779 void set_numberItems(int _numberItems, int reset = 1); // change range. maybe reset back to position 0
780 void set_currentItem(int _currentItem); // force slider to new position manually
781 void force_currentItem(int _currentItem); // force slider to new position manually, _not_ calling any callbacks
789 // general ui commands
795 // to be phased out eventually in FS2
796 class UI_DOT_SLIDER : public UI_GADGET
798 friend class UI_BUTTON;
802 UI_BUTTON down_button;
803 int first_frame, total_frames;
808 int pos; // 0 thru 10
810 void create(UI_WINDOW *wnd, int _x, int _y, char *bm, int id, int end_buttons = 1, int num_pos = 10);
812 virtual void process(int focus = 0);
813 virtual void destroy();
816 class UI_DOT_SLIDER_NEW : public UI_GADGET
818 friend class UI_BUTTON;
821 UI_BUTTON down_button;
827 int pos; // 0 thru 10
829 void create(UI_WINDOW *wnd, int _x, int _y, int num_pos, char *bm_slider, int slider_mask,
830 char *bm_left = NULL, int left_mask = -1, int left_x = -1, int left_y = -1,
831 char *bm_right = NULL, int right_mask = -1, int right_x = -1, int right_y = -1,
834 virtual void process(int focus = 0);
837 class UI_LISTBOX : public UI_GADGET
844 int num_items_displayed;
850 int old_current_item;
855 char key_buffer[MAX_KEY_BUFFER];
856 int key_buffer_count;
858 UI_SCROLLBAR scrollbar;
861 virtual void process(int focus = 0);
863 // Used to index into bmap_ids[] array to locate right bitmap for listbox
864 enum { LBOX_NORMAL = 0 };
865 enum { LBOX_DISABLED = 1 };
868 void create(UI_WINDOW *wnd, int _x, int _y, int _w, int _h, int _numitem, char **_list, char *_check_list = NULL, int _max_items = -1);
869 int selected(); // selected: Returns >= 0 if an item was selected
870 int current(); // current: Returns which item listbox bar is currently on. This could be -1, if none selected!
871 int toggled(); // toggled: Returns which item was toggled with spacebr or mouse click of check_list is not NULL
872 void set_current(int _index); // sets the current item in the list box
873 void set_first_item(int _index);
874 char *get_string(int _index);
875 void clear_all_items(); // deletes all the items in the list (makes them empty strings)
876 int add_string(char *str);
877 int sel_changed(); // returns > 0 if the selected item has changed
878 void set_new_list(int _numitems, char **_list);
880 int set_bmaps(char *lbox_fname, char *b_up_fname, char *b_down_fname, char *sb_fname);
881 void link_hotspot(int up_button_num, int down_button_num);
886 #define WIN_SAVE_BG 4
887 #define WIN_DIALOG (4+2+1)
891 friend class UI_GADGET;
892 friend class UI_BUTTON;
893 friend class UI_KEYTRAP;
894 friend class UI_CHECKBOX;
895 friend class UI_RADIO;
896 friend class UI_SCROLLBAR;
897 friend class UI_LISTBOX;
898 friend class UI_INPUTBOX;
900 friend class UI_SLIDER2;
901 friend class UI_DOT_SLIDER;
902 friend class UI_DOT_SLIDER_NEW;
903 friend class UI_ICON;
910 int last_tooltip_hotspot;
911 uint last_tooltip_time;
912 int tt_group; // which tooltip group this window uses, or -1 if none
915 UI_GADGET *first_gadget;
916 UI_GADGET *selected_gadget;
917 UI_GADGET *mouse_captured_gadget;
919 int mask_bmap_id; // bitmap id of the mask bitmap to define hotspots
920 int foreground_bmap_id; // bitmap id of the foreground bitmap to display
921 bitmap *mask_bmap_ptr; // pointer to bitmap of the mask
922 ushort *mask_data; // points to raw mask bitmap data
923 int mask_w, mask_h; // width and height of the mask
925 UI_XSTR *xstrs[MAX_UI_XSTRS]; // strings for drawing in code instead of in artwork
928 int keypress; // filled in each frame
929 void capture_mouse(UI_GADGET *gadget = NULL);
930 void release_bitmaps(); // called internally when window destroys gadgets
931 void check_focus_switch_keys();
932 void do_dump_check();
933 void draw_xstrs(); // draw xstrs
934 void draw_one_xstr(UI_XSTR *xstr, int frame);
937 UI_WINDOW(); // constructor
938 ~UI_WINDOW(); // destructor
939 void set_mask_bmap(char *fname);
940 void set_mask_bmap(int bmap, char *name);
941 void set_foreground_bmap(char *fname);
942 void create( int x, int y, int w, int h, int flags );
943 int process( int key_in = -1,int process_mouse = 1);
946 void draw_XSTR_forced(UI_GADGET *owner, int frame);
947 int get_current_hotspot();
949 ushort *get_mask_data(int *w, int *h) { *w = mask_w; *h = mask_h; return mask_data; }
950 void render_tooltip(char *str);
951 void set_ignore_gadgets(int state);
952 void add_XSTR(char *string, int xstr_id, int x, int y, UI_GADGET *assoc, int color_type, int font_id = -1);
953 void add_XSTR(UI_XSTR *xstr);
955 char *(*tooltip_handler)(char *text);
956 int last_keypress; // filled in each frame
958 int use_hack_to_get_around_stupid_problem_flag;
961 // 2 extremely useful structs
962 typedef struct ui_button_info {
966 UI_BUTTON button; // because we have a class inside this struct, we need the constructor below..
968 ui_button_info(char *name, int x1, int y1, int xt1, int yt1, int h) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h) {}
984 #define MAX_TOOLTIP_GROUPS 50
985 #define MAX_TOOLTIPS 500
987 extern int Num_tooltip_groups;
988 extern tooltip_group Tooltip_groups[MAX_TOOLTIP_GROUPS];
989 extern tooltip Tooltips[MAX_TOOLTIPS];
992 int ui_getfilelist( int MaxNum, char **list, char *filespec );
993 void ui_sort_filenames( int n, char **list );
996 class UI_SLIDER : public UI_GADGET
1005 UI_BUTTON left_button;
1006 UI_BUTTON right_button;
1013 int marker_x, marker_y, marker_w, marker_h;
1014 int n_positions, pixel_range, increment;
1015 float start, stop, current;
1018 virtual void draw();
1019 virtual void process(int focus = 0);
1021 // Used to index into bmap_ids[] array to locate right bitmap for slider
1022 enum { SLIDER_BAR_NORMAL = 0 };
1023 enum { SLIDER_BAR_DISABLED = 1 };
1024 enum { SLIDER_MARKER_NORMAL = 2 };
1025 enum { SLIDER_MARKER_DISABLED = 3 };
1028 void create(UI_WINDOW *wnd, int _x, int _y, int _w, int _h, float _start, float _stop, float _pos, int n_positions);
1035 void link_hotspot(int up_button_num, int down_button_num);
1036 int set_bmaps(char *left_button_fname, char *right_button_fname, char *bar_fname, char *marker_fname);