2 * $Logfile: /Freespace2/code/Ui/UI.H $
7 * Include file for our user interface.
10 * Revision 1.2 2002/05/27 00:38:47 relnev
13 * Revision 1.1.1.1 2002/05/03 03:28:12 root
17 * 20 8/16/99 9:45a Jefff
18 * changes to cursor management to allow a 2nd temporary cursor
20 * 19 8/11/99 3:21p Jefff
21 * set_bmaps clarification by daveb
23 * 18 8/11/99 12:18p Jefff
24 * added option to slider2 class to not force slider reset on
27 * 17 8/10/99 6:54p Dave
28 * Mad optimizations. Added paging to the nebula effect.
30 * 16 8/05/99 2:44p Jefff
31 * added disabled callback to UI_BUTTON
33 * 15 6/25/99 11:59a Dave
34 * Multi options screen.
36 * 14 6/22/99 7:03p Dave
37 * New detail options screen.
39 * 13 5/21/99 6:45p Dave
40 * Sped up ui loading a bit. Sped up localization disk access stuff. Multi
41 * start game screen, multi password, and multi pxo-help screen.
43 * 12 5/04/99 5:20p Dave
44 * Fixed up multiplayer join screen and host options screen. Should both
47 * 11 5/03/99 8:33p Dave
48 * New version of multi host options screen.
50 * 10 4/29/99 2:15p Neilk
51 * fixed slider so there is an extra callback for mouse locks
53 * 9 4/16/99 5:22p Neilk
54 * Added UI_SLIDER2 class
56 * 8 2/21/99 6:02p Dave
57 * Fixed standalone WSS packets.
59 * 7 2/11/99 3:08p Dave
60 * PXO refresh button. Very preliminary squad war support.
62 * 6 2/01/99 5:55p Dave
63 * Removed the idea of explicit bitmaps for buttons. Fixed text
64 * highlighting for disabled gadgets.
66 * 5 12/18/98 1:13a Dave
67 * Rough 1024x768 support for Direct3D. Proper detection and usage through
70 * 4 12/02/98 5:47p Dave
71 * Put in interface xstr code. Converted barracks screen to new format.
73 * 3 11/30/98 1:07p Dave
74 * 16 bit conversion, first run.
76 * 2 10/07/98 10:54a Dave
79 * 1 10/07/98 10:51a Dave
81 * 71 5/12/98 11:59p Dave
82 * Put in some more functionality for Parallax Online.
84 * 70 5/11/98 5:29p Hoffoss
85 * Added mouse button mapped to joystick button support.
87 * 69 5/05/98 1:49a Lawrance
88 * Add member function to disable processing for all gadgets in a window
90 * 68 5/03/98 1:55a Lawrance
91 * Add function call that forces button code to skip first callback for
94 * 67 4/17/98 12:22a Dave
95 * Bumped up MAX_TOOLTIPS from 350 to 500 so Freespace will start.
97 * 66 4/14/98 5:07p Dave
98 * Don't load or send invalid pilot pics. Fixed chatbox graphic errors.
99 * Made chatbox display team icons in a team vs. team game. Fixed up pause
100 * and endgame sequencing issues.
102 * 65 4/14/98 4:27p Hoffoss
103 * Changed the way tooltips render as requested.
105 * 64 4/13/98 4:30p Hoffoss
106 * Fixed a bunch of stupid little bugs in options screen. Also changed
107 * forced_draw() to work like it used to.
109 * 63 4/12/98 2:09p Dave
110 * Make main hall door text less stupid. Make sure inputbox focus in the
111 * multi host options screen is managed more intelligently.
113 * 62 4/10/98 5:36p Dave
114 * Put in user notification of illegal values in multi host options
115 * screen. Fixed server respawn ship class problem.
117 * 61 4/10/98 4:51p Hoffoss
118 * Made several changes related to tooltips.
120 * 60 4/09/98 7:14p Hoffoss
121 * Did some cool changes for tooltips.
123 * 59 4/09/98 5:57p Hoffoss
124 * Added custom tooltip handler functionality for callback.
126 * 58 4/09/98 12:12p Mike
127 * Separate versioning for demo and full versions.
130 * 57 3/30/98 6:24p Hoffoss
131 * Added the tooltip (foreign language translation of text) system.
133 * 56 3/23/98 5:48p Hoffoss
134 * Improved listbox handling. Most notibly the scrollbar arrows work now.
136 * 55 3/22/98 10:50p Lawrance
137 * Allow sliders to not have end-buttons.
139 * 54 3/10/98 4:06p Hoffoss
140 * Removed unused variables.
142 * 53 3/09/98 5:55p Dave
143 * Fixed stats to take asteroid hits into account. Polished up UI stuff in
144 * team select. Finished up pilot info popup. Tracked down and fixed
147 * 52 3/02/98 3:54p Lawrance
148 * make button draw function public
150 * 51 2/26/98 4:21p Dave
151 * More robust multiplayer voice.
153 * 50 2/11/98 6:24p Hoffoss
154 * Fixed bug where disabled and hidden buttons give failed sound when
155 * pressed. Shouldn't happen when they are hidden.
157 * 49 2/09/98 10:03a Hoffoss
158 * Made first_time variable public so I can clear the stupid thing in code
159 * that I want it to be cleared in.
161 * 48 1/26/98 6:28p Lawrance
162 * Add ability to for a button press event externally.
164 * 47 1/23/98 5:43p Dave
165 * Finished bringing standalone up to speed. Coded in new host options
168 * 46 1/16/98 7:57p Lawrance
169 * support animating input box cursor
171 * 45 1/15/98 5:10p Allender
172 * ton of interface changes. chatbox in multiplayer now behaves
173 * differently than before. It's always active in any screen that uses
174 * it. Only non-printatble characters will get passed back out from
177 * 44 1/14/98 6:44p Hoffoss
178 * Massive changes to UI code. A lot cleaner and better now. Did all
179 * this to get the new UI_DOT_SLIDER to work properly, which the old code
180 * wasn't flexible enough to handle.
182 * 43 1/02/98 9:11p Lawrance
183 * Add button_hot() function
185 * 42 12/22/97 5:08p Hoffoss
186 * Changed inputbox class to be able to accept only certain keys, changed
187 * pilot screens to utilize this feature. Added to assert with pilot file
190 * 41 12/11/97 8:15p Dave
191 * Put in network options screen. Xed out olf protocol selection screen.
193 * 40 12/10/97 3:14p Dave
194 * Added an overloaded set_mask_bmap(int) function for the UI_WINDOW
196 * 39 12/08/97 6:22p Lawrance
197 * blink cursor on inputbox
199 * 38 12/06/97 4:27p Dave
200 * Another load of interface and multiplayer bug fixes.
202 * 37 11/25/97 3:51p Hoffoss
203 * Changed edit background rect position slightly.
205 * 36 11/19/97 8:32p Hoffoss
206 * Changed UI buttons so they go back to unpressed when they are disabled.
208 * 35 10/29/97 7:25p Hoffoss
209 * Added crude support for UI button double click checking.
211 * 34 10/24/97 10:58p Hoffoss
212 * Made some changes to the UI code to do some things I need it to do.
214 * 33 10/01/97 4:40p Lawrance
215 * allow process() to have key input
217 * 32 9/18/97 10:31p Lawrance
218 * allow listbox to change text
220 * 31 9/09/97 4:32p Dave
221 * Added sel_changed() function to UI_LISTBOX to check is the selection
224 * 30 9/07/97 10:05p Lawrance
227 * 29 8/30/97 12:23p Lawrance
228 * add button function to reset the status of a button
230 * 28 8/29/97 7:33p Lawrance
231 * move cleanup code from destructor to destroy() method
233 * 27 8/24/97 5:25p Lawrance
234 * improve drawing of buttons
236 * 26 8/21/97 12:13p Dave
237 * Made it possible for input box to ignore esc to lose focus.
239 * 25 8/19/97 1:27p Dave
240 * Modified input box to allow character limitation by pixel width.
241 * Changed list box so that you can create an empty box and add items as
244 * 24 8/18/97 5:28p Lawrance
245 * integrating sounds for when mouse goes over an active control
247 * 23 8/17/97 2:42p Lawrance
248 * add code to have selected bitmap for buttons linger for a certain time
250 * 22 8/15/97 8:21p Dave
251 * Modified UI_INPUTBOX so that it is possible to draw it invisibly. That
252 * is, only the text is displayed.
254 * 21 8/14/97 5:23p Dave
255 * Added clear_all_items() to the UI_LISTBOX
257 * 20 6/13/97 5:51p Lawrance
258 * add in support for repeating buttons
260 * 19 6/11/97 1:32p Allender
261 * externed sort_filelist
263 * 18 5/26/97 10:26a Lawrance
264 * get slider control working 100%
266 * 17 5/22/97 5:36p Lawrance
267 * allowing custom art for scrollbars
269 * 16 5/21/97 11:07a Lawrance
270 * integrate masks and custom bitmaps
272 * 15 4/28/97 2:19p Lawrance
273 * added clear_focus() function
275 * 14 4/22/97 10:11a John
276 * Added checkbox lists to listboxes
278 * 13 4/15/97 3:47p Allender
279 * moved type selection of list box items into actual UI code. Made it
280 * behave more like windows listboxes do
282 * 12 1/28/97 4:58p Lawrance
283 * allowing hidden UI components
285 * 11 12/23/96 2:42p Lawrance
286 * allowing keys to select list box items in the mission load screen
288 * 10 12/04/96 3:00p John
289 * Added code to allow adjusting of HUD colors and saved it to the player
292 * 9 12/03/96 3:46p Lawrance
293 * added ability to set contents of input box
295 * 8 12/03/96 11:29a John
296 * Made scroll buttons on listbox scroll once, then delay, then repeat
297 * when the buttons are held down.
299 * 7 12/02/96 2:17p John
300 * Made right button drag UI gadgets around and
301 * Ctrl+Shift+Alt+F12 dumps out where they are.
303 * 6 12/01/96 3:48a Lawrance
304 * added function set_current to UI_LISTBOX
306 * 5 11/29/96 6:08p Lawrance
307 * enabled check-boxes to be set to a specific value outside of the
310 * 4 11/21/96 10:58a John
311 * Started adding code to drag buttons.
313 * 3 11/18/96 4:28p Jasen
314 * making class member process return an int
316 * 2 11/15/96 11:42a John
318 * 1 11/14/96 6:55p John
328 #define UI_KIND_BUTTON 1
329 #define UI_KIND_KEYTRAP 2
330 #define UI_KIND_CHECKBOX 3
331 #define UI_KIND_RADIO 4
332 #define UI_KIND_SCROLLBAR 5
333 #define UI_KIND_LISTBOX 6
334 #define UI_KIND_INPUTBOX 7
335 #define UI_KIND_SLIDER 8
336 #define UI_KIND_ICON 9
337 #define UI_KIND_DOT_SLIDER 10
338 #define UI_KIND_SLIDER2 11
339 #define UI_KIND_DOT_SLIDER_NEW 12
341 #define MAX_KEY_BUFFER 32 // for listboxes
343 #define MAX_BMAPS_PER_GADGET 15
345 #define UI_INPUTBOX_FLAG_INVIS (1 << 0) // don't draw the input box boarders
346 #define UI_INPUTBOX_FLAG_KEYTHRU (1 << 1) // pass all keypresses through to parent
347 #define UI_INPUTBOX_FLAG_ESC_CLR (1 << 2) // allow escape key to clear input box
348 #define UI_INPUTBOX_FLAG_ESC_FOC (1 << 3) // escape loses focus for the input box
349 #define UI_INPUTBOX_FLAG_PASSWD (1 << 4) // display all characters as special "password" characters
350 #define UI_INPUTBOX_FLAG_EAT_USED (1 << 5) // don't return any characters actually used by inputbox
351 #define UI_INPUTBOX_FLAG_LETTER_FIRST (1 << 6) // require input string to begin with a letter.
352 #define UI_INPUTBOX_FLAG_NO_LETTERS (1 << 7) // don't allow [a-z,A-Z] at all, no matter what
353 #define UI_INPUTBOX_FLAG_NO_NUMERALS (1 << 8) // don't allow [0-9] at all, no matter what
354 #define UI_INPUTBOX_FLAG_TEXT_CEN (1 << 9) // always draw text centered in the inputbox
355 #define UI_INPUTBOX_FLAG_NO_BACK (1 << 10) // don't draw a black background rectangle
357 #define UI_GF_MOUSE_CAPTURED (1 << 31) // gadget has all rights to the mouse
369 class UI_DOT_SLIDER_NEW;
373 friend class UI_WINDOW;
374 friend class UI_BUTTON;
375 friend class UI_KEYTRAP;
376 friend class UI_CHECKBOX;
377 friend class UI_RADIO;
378 friend class UI_SCROLLBAR;
379 friend class UI_LISTBOX;
380 friend class UI_INPUTBOX;
382 friend class UI_DOT_SLIDER;
383 friend class UI_DOT_SLIDER_NEW;
391 void (*user_function)(void);
394 int base_drag_x, base_drag_y;
395 int base_start_x, base_start_y;
398 // Data for supporting linking controls to hotspots
399 int linked_to_hotspot;
402 // Data for supporting bitmaps associated with different states of the control
405 // ubyte *bmap_storage[MAX_BMAPS_PER_GADGET];
407 void drag_with_children( int dx, int dy );
408 void start_drag_with_children();
409 void stop_drag_with_children();
416 int is_mouse_on_children();
417 void remove_from_family();
418 void set_parent(UI_GADGET *_parent);
420 UI_GADGET *get_next();
421 UI_GADGET *get_prev();
424 virtual void process(int focus = 0);
425 virtual void destroy();
429 int bmap_ids[MAX_BMAPS_PER_GADGET];
431 UI_GADGET(); // constructor
432 virtual ~UI_GADGET(); // destructor
434 void base_create( UI_WINDOW *wnd, int kind, int x, int y, int w, int h );
439 void set_hotkey(int keycode);
440 void set_callback(void (*user_function)(void));
442 void enable(int n = 1);
443 void capture_mouse();
444 int mouse_captured(UI_GADGET *gadget = NULL);
447 virtual void hide(int n = 1);
448 virtual void unhide();
449 void update_dimensions(int x, int y, int w, int h);
450 void get_dimensions(int *x, int *y, int *w, int *h);
452 void get_mouse_pos(int *x, int *y);
454 void link_hotspot(int num);
456 int bmaps_used() { return uses_bmaps; }
458 // loads nframes bitmaps, starting at index start_frame.
459 // anything < start_frame will not be loaded.
460 // this keeps the loading code from trying to load bitmaps which don't exist
461 // and taking an unnecessary disk hit.
462 int set_bmaps(char *ani_filename, int nframes = 3, int start_frame = 1); // extracts MAX_BMAPS_PER_GADGET from .ani file
464 void reset(); // zero out m_flags
465 int is_hidden() { return hidden; }
468 // xstrings for a window
469 #define UI_NUM_XSTR_COLORS 2
470 #define UI_XSTR_COLOR_GREEN 0 // shades of green/gray
471 #define UI_XSTR_COLOR_PINK 1 // pinkish hue
472 typedef struct UI_XSTR {
473 char *xstr; // base string
474 int xstr_id; // xstring id
475 int x, y; // coords of the string
476 int clr; // color to use
477 int font_id; // font id
478 UI_GADGET *assoc; // the associated gadget
481 #define MAX_UI_XSTRS 100
483 // Button terminology:
484 // Up = button is in up state (also called pressed)
485 // Down = button is in down state (also called released)
486 // Just pressed = button has just gone from up to down state
487 // Just released = button has just gone from down to up state
488 // Clicked = a trigger type effect caused by 'just pressed' event or repeat while 'down'
489 // Double clicked = 2 'just pressed' events occuring within a short amount of time
493 #define BF_DOWN (1<<1)
494 #define BF_JUST_PRESSED (1<<2)
495 #define BF_JUST_RELEASED (1<<3)
496 #define BF_CLICKED (1<<4)
497 #define BF_DOUBLE_CLICKED (1<<5)
498 #define BF_HIGHLIGHTED (1<<6) // button is not highlighted (ie mouse is not over)
499 #define BF_JUST_HIGHLIGHTED (1<<7) // button has just been highlighted, true for 1 frame
500 #define BF_IGNORE_FOCUS (1<<8) // button should not use focus to accept space/enter keypresses
501 #define BF_HOTKEY_JUST_PRESSED (1<<9) // button hotkey was just pressed
502 #define BF_REPEATS (1<<10) // if held down, generates repeating presses
503 #define BF_SKIP_FIRST_HIGHLIGHT_CALLBACK (1<<11) // skip first callback for mouse over event
505 class UI_BUTTON : public UI_GADGET
507 friend class UI_SCROLLBAR;
509 friend class UI_DOT_SLIDER;
510 friend class UI_DOT_SLIDER_NEW;
513 int position; // indicates position of button (0 - up, 1 - down by mouse click 2 - down by keypress
514 int next_repeat; // timestamp for next repeat if held down
515 int m_press_linger; // timestamp for hold a pressed state animation
516 int hotkey_if_focus; // hotkey for button that only works if it has focus
517 int force_draw_frame; // frame number to draw next time (override default)
518 int first_callback; // true until first time callback function is called for button highlight
520 // Used to index into bmap_ids[] array to locate right bitmap for button
521 enum { B_NORMAL = 0 };
522 enum { B_HIGHLIGHT = 1 };
523 enum { B_PRESSED = 2 };
524 enum { B_DISABLED = 3 };
525 enum { B_REPEAT_TIME = 100 }; // ms
527 void (*m_just_highlighted_function)(void); // call-back that gets called when button gets highlighted
528 void (*m_disabled_function)(void); // callback that gets called when disabled button gets pressed (sound, popup, etc)
531 virtual void process(int focus = 0);
532 virtual void destroy();
534 int custom_cursor_bmap; // bmap handle of special cursor used on mouseovers
535 int previous_cursor_bmap; // store old cursor
536 void maybe_show_custom_cursor(); // call this in process()
537 void restore_previous_cursor(); // called in frame_reset()
541 void set_hotkey_if_focus(int key);
542 int pressed(); // has it been selected (ie clicked on)
543 int double_clicked(); // button was double clicked on
544 int just_pressed(); // button has just been selected
545 int just_highlighted(); // button has just had mouse go over it
546 int button_down(); // is the button depressed?
547 int button_hilighted(); // is the mouse over this button?
548 void set_button_hilighted(); // force button to be highlighted
549 void press_button(); // force button to get pressed
550 void create(UI_WINDOW *wnd, char *_text, int _x, int _y, int _w, int _h, int do_repeat=0, int ignore_focus = 0);
551 void set_highlight_action( void (*user_function)(void) );
552 void set_disabled_action( void (*user_function)(void) );
553 void draw_forced(int frame_num);
555 void reset_timestamps();
556 void skip_first_highlight_callback();
557 void repeatable(int yes);
558 void set_custom_cursor_bmap(int bmap_id) { custom_cursor_bmap = bmap_id; };
561 class UI_KEYTRAP : public UI_GADGET
565 virtual void process(int focus = 0);
569 void create(UI_WINDOW *wnd, int hotkey, void (*user_function)(void) );
572 class UI_USERBOX : public UI_GADGET
576 int b1_double_clicked;
578 int b1_drag_x1, b1_drag_y1;
579 int b1_drag_x2, b1_drag_y2;
580 int b1_done_dragging;
583 int mouse_x, mouse_y;
587 class UI_INPUTBOX : public UI_GADGET
597 int pixel_limit; // base max characters on how wide the string is (-1 to ignore) in pixels
606 int cursor_first_frame;
609 int cursor_current_frame;
610 int cursor_elapsed_time;
612 int validate_input(int chr);
616 virtual void process(int focus = 0);
617 virtual void destroy();
622 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);
623 void set_valid_chars(char *vchars);
624 void set_invalid_chars(char *ichars);
627 void get_text(char *out);
628 void set_text(char *in);
632 #define ICON_NOT_HIGHLIGHTED (1<<0) // icon is not highlighted (ie mouse is not over)
633 #define ICON_JUST_HIGHLIGHTED (1<<1) // icon has just been highlighted, true for 1 frame
635 class UI_ICON : public UI_GADGET
639 // Used to index into bmap_ids[] array to locate right bitmap for button
640 enum { ICON_NORMAL = 0 };
641 enum { ICON_HIGHLIGHT = 1 };
642 enum { ICON_SELECTED = 2 };
643 enum { ICON_DISABLED = 3 };
646 virtual void process(int focus = 0);
647 virtual void destroy();
650 void create(UI_WINDOW *wnd, char *_text, int _x, int _y, int _w, int _h);
653 class UI_CHECKBOX : public UI_GADGET
660 virtual void process(int focus = 0);
661 virtual void destroy();
663 // Used to index into bmap_ids[] array to locate right bitmap for checkbox
664 enum { CBOX_UP_CLEAR = 0 };
665 enum { CBOX_DOWN_CLEAR = 1 };
666 enum { CBOX_UP_MARKED = 2 };
667 enum { CBOX_DOWN_MARKED = 3 };
668 enum { CBOX_DISABLED_CLEAR = 4 };
669 enum { CBOX_DISABLED_MARKED = 5 };
674 void create(UI_WINDOW *wnd, char *_text, int _x, int _y, int _state );
675 void set_state(int _state);
678 class UI_RADIO : public UI_GADGET
686 virtual void process(int focus = 0);
687 virtual void destroy();
689 // Used to index into bmap_ids[] array to locate right bitmap for radio button
690 enum { RADIO_UP_CLEAR = 0 };
691 enum { RADIO_DOWN_CLEAR = 1 };
692 enum { RADIO_UP_MARKED = 2 };
693 enum { RADIO_DOWN_MARKED = 3 };
694 enum { RADIO_DISABLED_CLEAR = 4 };
695 enum { RADIO_DISABLED_MARKED = 5 };
700 void create(UI_WINDOW *wnd, char *_text, int _x, int _y, int _state, int _group );
703 class UI_SCROLLBAR : public UI_GADGET
705 friend class UI_LISTBOX;
706 friend class UI_BUTTON;
716 UI_BUTTON down_button;
724 virtual void process(int focus = 0);
726 // Used to index into bmap_ids[] array to locate right bitmap for scrollbar
727 enum { SB_NORMAL = 0 };
728 enum { SB_DISABLED = 1 };
731 void create(UI_WINDOW *wnd, int _x, int _y, int _h,int _start, int _stop, int _position, int _window_size );
737 void link_hotspot(int up_button_num, int down_button_num);
738 int set_bmaps(char *up_button_fname, char *down_button_fname, char *line_fname);
741 class UI_SLIDER2 : public UI_GADGET
743 friend class UI_BUTTON;
745 int numberItems; // total range
746 int numberPositions; // total positions (height - bitmapbuttonheight)
747 int currentItem; // current item we are on
748 int currentPosition; // current position
752 UI_BUTTON sliderBackground;// invisible button to detect clicks
753 int bitmapSliderControl; // this is the bitmap of the slider button itself
754 void (*upCallback)();
755 void (*downCallback)();
756 void (*captureCallback)(); // this is called when the mouse is released
757 UI_BUTTON *upButton, *downButton;
758 int slider_w, slider_h, slider_half_h; // this is the width and height and half height of the bitmap used for the slider
760 virtual void process(int focus = 0);
762 // Used to index into bmap_ids[] array to locate right bitmap for slider
763 enum { S2_NORMAL = 0 };
764 enum { S2_HIGHLIGHT = 1 };
765 enum { S2_PRESSED = 2 };
766 enum { S2_DISABLED = 3 };
768 // Used for slider mode
769 enum { S2M_ON_ME = 0 };
770 enum { S2M_MOVING = 1 };
771 enum { S2M_DEFAULT = 2 };
775 void create(UI_WINDOW *wnd, int _x, int _y, int _w, int _h, int _numberItems, char *_bitmapSliderControl,
776 void (*_upCallback)(), void (*_downCallback)(), void (*_captureCallback)());
779 int get_numberItems(); // return number of itmes
780 int get_currentPosition(); // return current position
781 int get_currentItem(); // return current item
782 void set_numberItems(int _numberItems, int reset = 1); // change range. maybe reset back to position 0
783 void set_currentItem(int _currentItem); // force slider to new position manually
784 void force_currentItem(int _currentItem); // force slider to new position manually, _not_ calling any callbacks
792 // general ui commands
798 // to be phased out eventually in FS2
799 class UI_DOT_SLIDER : public UI_GADGET
801 friend class UI_BUTTON;
805 UI_BUTTON down_button;
806 int first_frame, total_frames;
811 int pos; // 0 thru 10
813 void create(UI_WINDOW *wnd, int _x, int _y, char *bm, int id, int end_buttons = 1, int num_pos = 10);
815 virtual void process(int focus = 0);
816 virtual void destroy();
819 class UI_DOT_SLIDER_NEW : public UI_GADGET
821 friend class UI_BUTTON;
824 UI_BUTTON down_button;
830 int pos; // 0 thru 10
832 void create(UI_WINDOW *wnd, int _x, int _y, int num_pos, char *bm_slider, int slider_mask,
833 char *bm_left = NULL, int left_mask = -1, int left_x = -1, int left_y = -1,
834 char *bm_right = NULL, int right_mask = -1, int right_x = -1, int right_y = -1,
837 virtual void process(int focus = 0);
840 class UI_LISTBOX : public UI_GADGET
847 int num_items_displayed;
853 int old_current_item;
858 char key_buffer[MAX_KEY_BUFFER];
859 int key_buffer_count;
861 UI_SCROLLBAR scrollbar;
864 virtual void process(int focus = 0);
866 // Used to index into bmap_ids[] array to locate right bitmap for listbox
867 enum { LBOX_NORMAL = 0 };
868 enum { LBOX_DISABLED = 1 };
871 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);
872 int selected(); // selected: Returns >= 0 if an item was selected
873 int current(); // current: Returns which item listbox bar is currently on. This could be -1, if none selected!
874 int toggled(); // toggled: Returns which item was toggled with spacebr or mouse click of check_list is not NULL
875 void set_current(int _index); // sets the current item in the list box
876 void set_first_item(int _index);
877 char *get_string(int _index);
878 void clear_all_items(); // deletes all the items in the list (makes them empty strings)
879 int add_string(char *str);
880 int sel_changed(); // returns > 0 if the selected item has changed
881 void set_new_list(int _numitems, char **_list);
883 int set_bmaps(char *lbox_fname, char *b_up_fname, char *b_down_fname, char *sb_fname);
884 void link_hotspot(int up_button_num, int down_button_num);
889 #define WIN_SAVE_BG 4
890 #define WIN_DIALOG (4+2+1)
894 friend class UI_GADGET;
895 friend class UI_BUTTON;
896 friend class UI_KEYTRAP;
897 friend class UI_CHECKBOX;
898 friend class UI_RADIO;
899 friend class UI_SCROLLBAR;
900 friend class UI_LISTBOX;
901 friend class UI_INPUTBOX;
903 friend class UI_SLIDER2;
904 friend class UI_DOT_SLIDER;
905 friend class UI_DOT_SLIDER_NEW;
906 friend class UI_ICON;
913 int last_tooltip_hotspot;
914 uint last_tooltip_time;
915 int tt_group; // which tooltip group this window uses, or -1 if none
918 UI_GADGET *first_gadget;
919 UI_GADGET *selected_gadget;
920 UI_GADGET *mouse_captured_gadget;
922 int mask_bmap_id; // bitmap id of the mask bitmap to define hotspots
923 int foreground_bmap_id; // bitmap id of the foreground bitmap to display
924 bitmap *mask_bmap_ptr; // pointer to bitmap of the mask
925 ushort *mask_data; // points to raw mask bitmap data
926 int mask_w, mask_h; // width and height of the mask
928 UI_XSTR *xstrs[MAX_UI_XSTRS]; // strings for drawing in code instead of in artwork
931 int keypress; // filled in each frame
932 void capture_mouse(UI_GADGET *gadget = NULL);
933 void release_bitmaps(); // called internally when window destroys gadgets
934 void check_focus_switch_keys();
935 void do_dump_check();
936 void draw_xstrs(); // draw xstrs
937 void draw_one_xstr(UI_XSTR *xstr, int frame);
940 UI_WINDOW(); // constructor
941 ~UI_WINDOW(); // destructor
942 void set_mask_bmap(char *fname);
943 void set_mask_bmap(int bmap, char *name);
944 void set_foreground_bmap(char *fname);
945 void create( int x, int y, int w, int h, int flags );
946 int process( int key_in = -1,int process_mouse = 1);
949 void draw_XSTR_forced(UI_GADGET *owner, int frame);
950 int get_current_hotspot();
952 ushort *get_mask_data(int *w, int *h) { *w = mask_w; *h = mask_h; return mask_data; }
953 void render_tooltip(char *str);
954 void set_ignore_gadgets(int state);
955 void add_XSTR(char *string, int xstr_id, int x, int y, UI_GADGET *assoc, int color_type, int font_id = -1);
956 void add_XSTR(UI_XSTR *xstr);
958 char *(*tooltip_handler)(char *text);
959 int last_keypress; // filled in each frame
961 int use_hack_to_get_around_stupid_problem_flag;
964 // 2 extremely useful structs
965 typedef struct ui_button_info {
969 UI_BUTTON button; // because we have a class inside this struct, we need the constructor below..
971 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) {}
987 #define MAX_TOOLTIP_GROUPS 50
988 #define MAX_TOOLTIPS 500
990 extern int Num_tooltip_groups;
991 extern tooltip_group Tooltip_groups[MAX_TOOLTIP_GROUPS];
992 extern tooltip Tooltips[MAX_TOOLTIPS];
995 int ui_getfilelist( int MaxNum, char **list, char *filespec );
996 void ui_sort_filenames( int n, char **list );
999 class UI_SLIDER : public UI_GADGET
1008 UI_BUTTON left_button;
1009 UI_BUTTON right_button;
1016 int marker_x, marker_y, marker_w, marker_h;
1017 int n_positions, pixel_range, increment;
1018 float start, stop, current;
1021 virtual void draw();
1022 virtual void process(int focus = 0);
1024 // Used to index into bmap_ids[] array to locate right bitmap for slider
1025 enum { SLIDER_BAR_NORMAL = 0 };
1026 enum { SLIDER_BAR_DISABLED = 1 };
1027 enum { SLIDER_MARKER_NORMAL = 2 };
1028 enum { SLIDER_MARKER_DISABLED = 3 };
1031 void create(UI_WINDOW *wnd, int _x, int _y, int _w, int _h, float _start, float _stop, float _pos, int n_positions);
1038 void link_hotspot(int up_button_num, int down_button_num);
1039 int set_bmaps(char *left_button_fname, char *right_button_fname, char *bar_fname, char *marker_fname);