2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
4 * All source code herein is the property of Volition, Inc. You may not sell
5 * or otherwise commercially exploit the source or things you created based on
10 * $Logfile: /Freespace2/code/Ui/UI.H $
15 * Include file for our user interface.
18 * Revision 1.3 2002/06/09 04:41:15 relnev
19 * added copyright header
21 * Revision 1.2 2002/05/27 00:38:47 relnev
24 * Revision 1.1.1.1 2002/05/03 03:28:12 root
28 * 20 8/16/99 9:45a Jefff
29 * changes to cursor management to allow a 2nd temporary cursor
31 * 19 8/11/99 3:21p Jefff
32 * set_bmaps clarification by daveb
34 * 18 8/11/99 12:18p Jefff
35 * added option to slider2 class to not force slider reset on
38 * 17 8/10/99 6:54p Dave
39 * Mad optimizations. Added paging to the nebula effect.
41 * 16 8/05/99 2:44p Jefff
42 * added disabled callback to UI_BUTTON
44 * 15 6/25/99 11:59a Dave
45 * Multi options screen.
47 * 14 6/22/99 7:03p Dave
48 * New detail options screen.
50 * 13 5/21/99 6:45p Dave
51 * Sped up ui loading a bit. Sped up localization disk access stuff. Multi
52 * start game screen, multi password, and multi pxo-help screen.
54 * 12 5/04/99 5:20p Dave
55 * Fixed up multiplayer join screen and host options screen. Should both
58 * 11 5/03/99 8:33p Dave
59 * New version of multi host options screen.
61 * 10 4/29/99 2:15p Neilk
62 * fixed slider so there is an extra callback for mouse locks
64 * 9 4/16/99 5:22p Neilk
65 * Added UI_SLIDER2 class
67 * 8 2/21/99 6:02p Dave
68 * Fixed standalone WSS packets.
70 * 7 2/11/99 3:08p Dave
71 * PXO refresh button. Very preliminary squad war support.
73 * 6 2/01/99 5:55p Dave
74 * Removed the idea of explicit bitmaps for buttons. Fixed text
75 * highlighting for disabled gadgets.
77 * 5 12/18/98 1:13a Dave
78 * Rough 1024x768 support for Direct3D. Proper detection and usage through
81 * 4 12/02/98 5:47p Dave
82 * Put in interface xstr code. Converted barracks screen to new format.
84 * 3 11/30/98 1:07p Dave
85 * 16 bit conversion, first run.
87 * 2 10/07/98 10:54a Dave
90 * 1 10/07/98 10:51a Dave
92 * 71 5/12/98 11:59p Dave
93 * Put in some more functionality for Parallax Online.
95 * 70 5/11/98 5:29p Hoffoss
96 * Added mouse button mapped to joystick button support.
98 * 69 5/05/98 1:49a Lawrance
99 * Add member function to disable processing for all gadgets in a window
101 * 68 5/03/98 1:55a Lawrance
102 * Add function call that forces button code to skip first callback for
105 * 67 4/17/98 12:22a Dave
106 * Bumped up MAX_TOOLTIPS from 350 to 500 so Freespace will start.
108 * 66 4/14/98 5:07p Dave
109 * Don't load or send invalid pilot pics. Fixed chatbox graphic errors.
110 * Made chatbox display team icons in a team vs. team game. Fixed up pause
111 * and endgame sequencing issues.
113 * 65 4/14/98 4:27p Hoffoss
114 * Changed the way tooltips render as requested.
116 * 64 4/13/98 4:30p Hoffoss
117 * Fixed a bunch of stupid little bugs in options screen. Also changed
118 * forced_draw() to work like it used to.
120 * 63 4/12/98 2:09p Dave
121 * Make main hall door text less stupid. Make sure inputbox focus in the
122 * multi host options screen is managed more intelligently.
124 * 62 4/10/98 5:36p Dave
125 * Put in user notification of illegal values in multi host options
126 * screen. Fixed server respawn ship class problem.
128 * 61 4/10/98 4:51p Hoffoss
129 * Made several changes related to tooltips.
131 * 60 4/09/98 7:14p Hoffoss
132 * Did some cool changes for tooltips.
134 * 59 4/09/98 5:57p Hoffoss
135 * Added custom tooltip handler functionality for callback.
137 * 58 4/09/98 12:12p Mike
138 * Separate versioning for demo and full versions.
141 * 57 3/30/98 6:24p Hoffoss
142 * Added the tooltip (foreign language translation of text) system.
144 * 56 3/23/98 5:48p Hoffoss
145 * Improved listbox handling. Most notibly the scrollbar arrows work now.
147 * 55 3/22/98 10:50p Lawrance
148 * Allow sliders to not have end-buttons.
150 * 54 3/10/98 4:06p Hoffoss
151 * Removed unused variables.
153 * 53 3/09/98 5:55p Dave
154 * Fixed stats to take asteroid hits into account. Polished up UI stuff in
155 * team select. Finished up pilot info popup. Tracked down and fixed
158 * 52 3/02/98 3:54p Lawrance
159 * make button draw function public
161 * 51 2/26/98 4:21p Dave
162 * More robust multiplayer voice.
164 * 50 2/11/98 6:24p Hoffoss
165 * Fixed bug where disabled and hidden buttons give failed sound when
166 * pressed. Shouldn't happen when they are hidden.
168 * 49 2/09/98 10:03a Hoffoss
169 * Made first_time variable public so I can clear the stupid thing in code
170 * that I want it to be cleared in.
172 * 48 1/26/98 6:28p Lawrance
173 * Add ability to for a button press event externally.
175 * 47 1/23/98 5:43p Dave
176 * Finished bringing standalone up to speed. Coded in new host options
179 * 46 1/16/98 7:57p Lawrance
180 * support animating input box cursor
182 * 45 1/15/98 5:10p Allender
183 * ton of interface changes. chatbox in multiplayer now behaves
184 * differently than before. It's always active in any screen that uses
185 * it. Only non-printatble characters will get passed back out from
188 * 44 1/14/98 6:44p Hoffoss
189 * Massive changes to UI code. A lot cleaner and better now. Did all
190 * this to get the new UI_DOT_SLIDER to work properly, which the old code
191 * wasn't flexible enough to handle.
193 * 43 1/02/98 9:11p Lawrance
194 * Add button_hot() function
196 * 42 12/22/97 5:08p Hoffoss
197 * Changed inputbox class to be able to accept only certain keys, changed
198 * pilot screens to utilize this feature. Added to assert with pilot file
201 * 41 12/11/97 8:15p Dave
202 * Put in network options screen. Xed out olf protocol selection screen.
204 * 40 12/10/97 3:14p Dave
205 * Added an overloaded set_mask_bmap(int) function for the UI_WINDOW
207 * 39 12/08/97 6:22p Lawrance
208 * blink cursor on inputbox
210 * 38 12/06/97 4:27p Dave
211 * Another load of interface and multiplayer bug fixes.
213 * 37 11/25/97 3:51p Hoffoss
214 * Changed edit background rect position slightly.
216 * 36 11/19/97 8:32p Hoffoss
217 * Changed UI buttons so they go back to unpressed when they are disabled.
219 * 35 10/29/97 7:25p Hoffoss
220 * Added crude support for UI button double click checking.
222 * 34 10/24/97 10:58p Hoffoss
223 * Made some changes to the UI code to do some things I need it to do.
225 * 33 10/01/97 4:40p Lawrance
226 * allow process() to have key input
228 * 32 9/18/97 10:31p Lawrance
229 * allow listbox to change text
231 * 31 9/09/97 4:32p Dave
232 * Added sel_changed() function to UI_LISTBOX to check is the selection
235 * 30 9/07/97 10:05p Lawrance
238 * 29 8/30/97 12:23p Lawrance
239 * add button function to reset the status of a button
241 * 28 8/29/97 7:33p Lawrance
242 * move cleanup code from destructor to destroy() method
244 * 27 8/24/97 5:25p Lawrance
245 * improve drawing of buttons
247 * 26 8/21/97 12:13p Dave
248 * Made it possible for input box to ignore esc to lose focus.
250 * 25 8/19/97 1:27p Dave
251 * Modified input box to allow character limitation by pixel width.
252 * Changed list box so that you can create an empty box and add items as
255 * 24 8/18/97 5:28p Lawrance
256 * integrating sounds for when mouse goes over an active control
258 * 23 8/17/97 2:42p Lawrance
259 * add code to have selected bitmap for buttons linger for a certain time
261 * 22 8/15/97 8:21p Dave
262 * Modified UI_INPUTBOX so that it is possible to draw it invisibly. That
263 * is, only the text is displayed.
265 * 21 8/14/97 5:23p Dave
266 * Added clear_all_items() to the UI_LISTBOX
268 * 20 6/13/97 5:51p Lawrance
269 * add in support for repeating buttons
271 * 19 6/11/97 1:32p Allender
272 * externed sort_filelist
274 * 18 5/26/97 10:26a Lawrance
275 * get slider control working 100%
277 * 17 5/22/97 5:36p Lawrance
278 * allowing custom art for scrollbars
280 * 16 5/21/97 11:07a Lawrance
281 * integrate masks and custom bitmaps
283 * 15 4/28/97 2:19p Lawrance
284 * added clear_focus() function
286 * 14 4/22/97 10:11a John
287 * Added checkbox lists to listboxes
289 * 13 4/15/97 3:47p Allender
290 * moved type selection of list box items into actual UI code. Made it
291 * behave more like windows listboxes do
293 * 12 1/28/97 4:58p Lawrance
294 * allowing hidden UI components
296 * 11 12/23/96 2:42p Lawrance
297 * allowing keys to select list box items in the mission load screen
299 * 10 12/04/96 3:00p John
300 * Added code to allow adjusting of HUD colors and saved it to the player
303 * 9 12/03/96 3:46p Lawrance
304 * added ability to set contents of input box
306 * 8 12/03/96 11:29a John
307 * Made scroll buttons on listbox scroll once, then delay, then repeat
308 * when the buttons are held down.
310 * 7 12/02/96 2:17p John
311 * Made right button drag UI gadgets around and
312 * Ctrl+Shift+Alt+F12 dumps out where they are.
314 * 6 12/01/96 3:48a Lawrance
315 * added function set_current to UI_LISTBOX
317 * 5 11/29/96 6:08p Lawrance
318 * enabled check-boxes to be set to a specific value outside of the
321 * 4 11/21/96 10:58a John
322 * Started adding code to drag buttons.
324 * 3 11/18/96 4:28p Jasen
325 * making class member process return an int
327 * 2 11/15/96 11:42a John
329 * 1 11/14/96 6:55p John
339 #define UI_KIND_BUTTON 1
340 #define UI_KIND_KEYTRAP 2
341 #define UI_KIND_CHECKBOX 3
342 #define UI_KIND_RADIO 4
343 #define UI_KIND_SCROLLBAR 5
344 #define UI_KIND_LISTBOX 6
345 #define UI_KIND_INPUTBOX 7
346 #define UI_KIND_SLIDER 8
347 #define UI_KIND_ICON 9
348 #define UI_KIND_DOT_SLIDER 10
349 #define UI_KIND_SLIDER2 11
350 #define UI_KIND_DOT_SLIDER_NEW 12
352 #define MAX_KEY_BUFFER 32 // for listboxes
354 #define MAX_BMAPS_PER_GADGET 15
356 #define UI_INPUTBOX_FLAG_INVIS (1 << 0) // don't draw the input box boarders
357 #define UI_INPUTBOX_FLAG_KEYTHRU (1 << 1) // pass all keypresses through to parent
358 #define UI_INPUTBOX_FLAG_ESC_CLR (1 << 2) // allow escape key to clear input box
359 #define UI_INPUTBOX_FLAG_ESC_FOC (1 << 3) // escape loses focus for the input box
360 #define UI_INPUTBOX_FLAG_PASSWD (1 << 4) // display all characters as special "password" characters
361 #define UI_INPUTBOX_FLAG_EAT_USED (1 << 5) // don't return any characters actually used by inputbox
362 #define UI_INPUTBOX_FLAG_LETTER_FIRST (1 << 6) // require input string to begin with a letter.
363 #define UI_INPUTBOX_FLAG_NO_LETTERS (1 << 7) // don't allow [a-z,A-Z] at all, no matter what
364 #define UI_INPUTBOX_FLAG_NO_NUMERALS (1 << 8) // don't allow [0-9] at all, no matter what
365 #define UI_INPUTBOX_FLAG_TEXT_CEN (1 << 9) // always draw text centered in the inputbox
366 #define UI_INPUTBOX_FLAG_NO_BACK (1 << 10) // don't draw a black background rectangle
368 #define UI_GF_MOUSE_CAPTURED (1 << 31) // gadget has all rights to the mouse
380 class UI_DOT_SLIDER_NEW;
384 friend class UI_WINDOW;
385 friend class UI_BUTTON;
386 friend class UI_KEYTRAP;
387 friend class UI_CHECKBOX;
388 friend class UI_RADIO;
389 friend class UI_SCROLLBAR;
390 friend class UI_LISTBOX;
391 friend class UI_INPUTBOX;
393 friend class UI_DOT_SLIDER;
394 friend class UI_DOT_SLIDER_NEW;
401 void (*user_function)(void);
404 int base_drag_x, base_drag_y;
405 int base_start_x, base_start_y;
408 // Data for supporting linking controls to hotspots
409 int linked_to_hotspot;
412 // Data for supporting bitmaps associated with different states of the control
415 // ubyte *bmap_storage[MAX_BMAPS_PER_GADGET];
417 void drag_with_children( int dx, int dy );
418 void start_drag_with_children();
419 void stop_drag_with_children();
426 int is_mouse_on_children();
427 void remove_from_family();
428 void set_parent(UI_GADGET *_parent);
430 UI_GADGET *get_next();
431 UI_GADGET *get_prev();
434 virtual void process(int focus = 0);
435 virtual void destroy();
439 int bmap_ids[MAX_BMAPS_PER_GADGET];
441 UI_GADGET(); // constructor
442 virtual ~UI_GADGET(); // destructor
444 void base_create( UI_WINDOW *wnd, int kind, int x, int y, int w, int h );
449 void set_hotkey(int keycode);
450 void set_callback(void (*user_function)(void));
452 void enable(int n = 1);
453 void capture_mouse();
454 int mouse_captured(UI_GADGET *gadget = NULL);
457 virtual void hide(int n = 1);
458 virtual void unhide();
459 void update_dimensions(int x, int y, int w, int h);
460 void get_dimensions(int *x, int *y, int *w, int *h);
462 void get_mouse_pos(int *x, int *y);
464 void link_hotspot(int num);
466 int bmaps_used() { return uses_bmaps; }
468 // loads nframes bitmaps, starting at index start_frame.
469 // anything < start_frame will not be loaded.
470 // this keeps the loading code from trying to load bitmaps which don't exist
471 // and taking an unnecessary disk hit.
472 int set_bmaps(const char *ani_filename, int nframes = 3, int start_frame = 1); // extracts MAX_BMAPS_PER_GADGET from .ani file
474 void reset(); // zero out m_flags
475 int is_hidden() { return hidden; }
478 // xstrings for a window
479 #define UI_NUM_XSTR_COLORS 2
480 #define UI_XSTR_COLOR_GREEN 0 // shades of green/gray
481 #define UI_XSTR_COLOR_PINK 1 // pinkish hue
482 typedef struct UI_XSTR {
483 const char *xstr; // base string
484 int xstr_id; // xstring id
485 int x, y; // coords of the string
486 int clr; // color to use
487 int font_id; // font id
488 UI_GADGET *assoc; // the associated gadget
491 #define MAX_UI_XSTRS 100
493 // Button terminology:
494 // Up = button is in up state (also called pressed)
495 // Down = button is in down state (also called released)
496 // Just pressed = button has just gone from up to down state
497 // Just released = button has just gone from down to up state
498 // Clicked = a trigger type effect caused by 'just pressed' event or repeat while 'down'
499 // Double clicked = 2 'just pressed' events occuring within a short amount of time
503 #define BF_DOWN (1<<1)
504 #define BF_JUST_PRESSED (1<<2)
505 #define BF_JUST_RELEASED (1<<3)
506 #define BF_CLICKED (1<<4)
507 #define BF_DOUBLE_CLICKED (1<<5)
508 #define BF_HIGHLIGHTED (1<<6) // button is not highlighted (ie mouse is not over)
509 #define BF_JUST_HIGHLIGHTED (1<<7) // button has just been highlighted, true for 1 frame
510 #define BF_IGNORE_FOCUS (1<<8) // button should not use focus to accept space/enter keypresses
511 #define BF_HOTKEY_JUST_PRESSED (1<<9) // button hotkey was just pressed
512 #define BF_REPEATS (1<<10) // if held down, generates repeating presses
513 #define BF_SKIP_FIRST_HIGHLIGHT_CALLBACK (1<<11) // skip first callback for mouse over event
515 class UI_BUTTON : public UI_GADGET
517 friend class UI_SCROLLBAR;
519 friend class UI_DOT_SLIDER;
520 friend class UI_DOT_SLIDER_NEW;
523 int position; // indicates position of button (0 - up, 1 - down by mouse click 2 - down by keypress
524 int next_repeat; // timestamp for next repeat if held down
525 int m_press_linger; // timestamp for hold a pressed state animation
526 int hotkey_if_focus; // hotkey for button that only works if it has focus
527 int force_draw_frame; // frame number to draw next time (override default)
528 int first_callback; // true until first time callback function is called for button highlight
530 // Used to index into bmap_ids[] array to locate right bitmap for button
531 enum { B_NORMAL = 0 };
532 enum { B_HIGHLIGHT = 1 };
533 enum { B_PRESSED = 2 };
534 enum { B_DISABLED = 3 };
535 enum { B_REPEAT_TIME = 100 }; // ms
537 void (*m_just_highlighted_function)(void); // call-back that gets called when button gets highlighted
538 void (*m_disabled_function)(void); // callback that gets called when disabled button gets pressed (sound, popup, etc)
541 virtual void process(int focus = 0);
542 virtual void destroy();
544 int custom_cursor_bmap; // bmap handle of special cursor used on mouseovers
545 int previous_cursor_bmap; // store old cursor
546 void maybe_show_custom_cursor(); // call this in process()
547 void restore_previous_cursor(); // called in frame_reset()
551 void set_hotkey_if_focus(int key);
552 int pressed(); // has it been selected (ie clicked on)
553 int double_clicked(); // button was double clicked on
554 int just_pressed(); // button has just been selected
555 int just_highlighted(); // button has just had mouse go over it
556 int button_down(); // is the button depressed?
557 int button_hilighted(); // is the mouse over this button?
558 void set_button_hilighted(); // force button to be highlighted
559 void press_button(); // force button to get pressed
560 void create(UI_WINDOW *wnd, const char *_text, int _x, int _y, int _w, int _h, int do_repeat=0, int ignore_focus = 0);
561 void set_highlight_action( void (*user_function)(void) );
562 void set_disabled_action( void (*user_function)(void) );
563 void draw_forced(int frame_num);
565 void reset_timestamps();
566 void skip_first_highlight_callback();
567 void repeatable(int yes);
568 void set_custom_cursor_bmap(int bmap_id) { custom_cursor_bmap = bmap_id; }
571 class UI_KEYTRAP : public UI_GADGET
575 virtual void process(int focus = 0);
579 void create(UI_WINDOW *wnd, int hotkey, void (*user_function)(void) );
582 class UI_INPUTBOX : public UI_GADGET
592 int pixel_limit; // base max characters on how wide the string is (-1 to ignore) in pixels
595 // int ignore_escape;
601 int cursor_first_frame;
604 int cursor_current_frame;
605 int cursor_elapsed_time;
607 int validate_input(int chr);
611 virtual void process(int focus = 0);
612 virtual void destroy();
617 void create(UI_WINDOW *wnd, int _x, int _y, int _w, int _textlen, const char *text, int _flags = 0, int pixel_lim = -1, color *clr = NULL);
618 void set_valid_chars(const char *vchars);
619 void set_invalid_chars(const char *ichars);
622 void get_text(char *out);
623 void set_text(const char *in);
627 #define ICON_NOT_HIGHLIGHTED (1<<0) // icon is not highlighted (ie mouse is not over)
628 #define ICON_JUST_HIGHLIGHTED (1<<1) // icon has just been highlighted, true for 1 frame
630 class UI_ICON : public UI_GADGET
634 // Used to index into bmap_ids[] array to locate right bitmap for button
635 enum { ICON_NORMAL = 0 };
636 enum { ICON_HIGHLIGHT = 1 };
637 enum { ICON_SELECTED = 2 };
638 enum { ICON_DISABLED = 3 };
641 virtual void process(int focus = 0);
642 virtual void destroy();
645 void create(UI_WINDOW *wnd, const char *_text, int _x, int _y, int _w, int _h);
648 class UI_CHECKBOX : public UI_GADGET
655 virtual void process(int focus = 0);
656 virtual void destroy();
658 // Used to index into bmap_ids[] array to locate right bitmap for checkbox
659 enum { CBOX_UP_CLEAR = 0 };
660 enum { CBOX_DOWN_CLEAR = 1 };
661 enum { CBOX_UP_MARKED = 2 };
662 enum { CBOX_DOWN_MARKED = 3 };
663 enum { CBOX_DISABLED_CLEAR = 4 };
664 enum { CBOX_DISABLED_MARKED = 5 };
669 void create(UI_WINDOW *wnd, const char *_text, int _x, int _y, int _state );
670 void set_state(int _state);
673 class UI_RADIO : public UI_GADGET
681 virtual void process(int focus = 0);
682 virtual void destroy();
684 // Used to index into bmap_ids[] array to locate right bitmap for radio button
685 enum { RADIO_UP_CLEAR = 0 };
686 enum { RADIO_DOWN_CLEAR = 1 };
687 enum { RADIO_UP_MARKED = 2 };
688 enum { RADIO_DOWN_MARKED = 3 };
689 enum { RADIO_DISABLED_CLEAR = 4 };
690 enum { RADIO_DISABLED_MARKED = 5 };
695 void create(UI_WINDOW *wnd, const char *_text, int _x, int _y, int _state, int _group );
698 class UI_SCROLLBAR : public UI_GADGET
700 friend class UI_LISTBOX;
701 friend class UI_BUTTON;
711 UI_BUTTON down_button;
719 virtual void process(int focus = 0);
721 // Used to index into bmap_ids[] array to locate right bitmap for scrollbar
722 enum { SB_NORMAL = 0 };
723 enum { SB_DISABLED = 1 };
726 void create(UI_WINDOW *wnd, int _x, int _y, int _h,int _start, int _stop, int _position, int _window_size );
729 void hide(int n = 1);
732 void link_hotspot(int up_button_num, int down_button_num);
733 int set_bmaps(const char *up_button_fname, const char *down_button_fname, const char *line_fname);
736 class UI_SLIDER2 : public UI_GADGET
738 friend class UI_BUTTON;
740 int numberItems; // total range
741 int numberPositions; // total positions (height - bitmapbuttonheight)
742 int currentItem; // current item we are on
743 int currentPosition; // current position
747 UI_BUTTON sliderBackground;// invisible button to detect clicks
748 int bitmapSliderControl; // this is the bitmap of the slider button itself
749 void (*upCallback)();
750 void (*downCallback)();
751 void (*captureCallback)(); // this is called when the mouse is released
752 UI_BUTTON *upButton, *downButton;
753 int slider_w, slider_h, slider_half_h; // this is the width and height and half height of the bitmap used for the slider
755 virtual void process(int focus = 0);
757 // Used to index into bmap_ids[] array to locate right bitmap for slider
758 enum { S2_NORMAL = 0 };
759 enum { S2_HIGHLIGHT = 1 };
760 enum { S2_PRESSED = 2 };
761 enum { S2_DISABLED = 3 };
763 // Used for slider mode
764 enum { S2M_ON_ME = 0 };
765 enum { S2M_MOVING = 1 };
766 enum { S2M_DEFAULT = 2 };
770 void create(UI_WINDOW *wnd, int _x, int _y, int _w, int _h, int _numberItems, const char *_bitmapSliderControl,
771 void (*_upCallback)(), void (*_downCallback)(), void (*_captureCallback)());
774 int get_numberItems(); // return number of itmes
775 int get_currentPosition(); // return current position
776 int get_currentItem(); // return current item
777 void set_numberItems(int _numberItems, int reset = 1); // change range. maybe reset back to position 0
778 void set_currentItem(int _currentItem); // force slider to new position manually
779 void force_currentItem(int _currentItem); // force slider to new position manually, _not_ calling any callbacks
787 // general ui commands
788 void hide(int n = 1);
793 // to be phased out eventually in FS2
794 class UI_DOT_SLIDER : public UI_GADGET
796 friend class UI_BUTTON;
800 UI_BUTTON down_button;
801 int first_frame, total_frames;
806 int pos; // 0 thru 10
808 void create(UI_WINDOW *wnd, int _x, int _y, const char *bm, int id, int end_buttons = 1, int num_pos = 10);
810 virtual void process(int focus = 0);
811 virtual void destroy();
814 class UI_DOT_SLIDER_NEW : public UI_GADGET
816 friend class UI_BUTTON;
819 UI_BUTTON down_button;
825 int pos; // 0 thru 10
827 void create(UI_WINDOW *wnd, int _x, int _y, int num_pos, const char *bm_slider, int slider_mask,
828 const char *bm_left = NULL, int left_mask = -1, int left_x = -1, int left_y = -1,
829 const char *bm_right = NULL, int right_mask = -1, int right_x = -1, int right_y = -1,
832 virtual void process(int focus = 0);
835 class UI_LISTBOX : public UI_GADGET
842 int num_items_displayed;
848 int old_current_item;
853 char key_buffer[MAX_KEY_BUFFER];
854 int key_buffer_count;
856 UI_SCROLLBAR scrollbar;
859 virtual void process(int focus = 0);
861 // Used to index into bmap_ids[] array to locate right bitmap for listbox
862 enum { LBOX_NORMAL = 0 };
863 enum { LBOX_DISABLED = 1 };
866 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);
867 int selected(); // selected: Returns >= 0 if an item was selected
868 int current(); // current: Returns which item listbox bar is currently on. This could be -1, if none selected!
869 int toggled(); // toggled: Returns which item was toggled with spacebr or mouse click of check_list is not NULL
870 void set_current(int _index); // sets the current item in the list box
871 void set_first_item(int _index);
872 char *get_string(int _index);
873 void clear_all_items(); // deletes all the items in the list (makes them empty strings)
874 int add_string(char *str);
875 int sel_changed(); // returns > 0 if the selected item has changed
876 void set_new_list(int _numitems, char **_list);
878 int set_bmaps(const char *lbox_fname, const char *b_up_fname, const char *b_down_fname, const char *sb_fname);
879 void link_hotspot(int up_button_num, int down_button_num);
884 #define WIN_SAVE_BG 4
885 #define WIN_DIALOG (4+2+1)
889 friend class UI_GADGET;
890 friend class UI_BUTTON;
891 friend class UI_KEYTRAP;
892 friend class UI_CHECKBOX;
893 friend class UI_RADIO;
894 friend class UI_SCROLLBAR;
895 friend class UI_LISTBOX;
896 friend class UI_INPUTBOX;
898 friend class UI_SLIDER2;
899 friend class UI_DOT_SLIDER;
900 friend class UI_DOT_SLIDER_NEW;
901 friend class UI_ICON;
908 int last_tooltip_hotspot;
909 uint last_tooltip_time;
910 int tt_group; // which tooltip group this window uses, or -1 if none
913 UI_GADGET *first_gadget;
914 UI_GADGET *selected_gadget;
915 UI_GADGET *mouse_captured_gadget;
917 int mask_bmap_id; // bitmap id of the mask bitmap to define hotspots
918 int foreground_bmap_id; // bitmap id of the foreground bitmap to display
919 bitmap *mask_bmap_ptr; // pointer to bitmap of the mask
920 ushort *mask_data; // points to raw mask bitmap data
921 int mask_w, mask_h; // width and height of the mask
923 UI_XSTR *xstrs[MAX_UI_XSTRS]; // strings for drawing in code instead of in artwork
926 int keypress; // filled in each frame
927 int keypress_text; // filled in each frame
928 void capture_mouse(UI_GADGET *gadget = NULL);
929 void release_bitmaps(); // called internally when window destroys gadgets
930 void check_focus_switch_keys();
931 void do_dump_check();
932 void draw_xstrs(); // draw xstrs
933 void draw_one_xstr(UI_XSTR *xstr, int frame);
936 UI_WINDOW(); // constructor
937 ~UI_WINDOW(); // destructor
938 void set_mask_bmap(const char *fname);
939 void set_mask_bmap(int bmap, const char *name);
940 void set_foreground_bmap(const char *fname);
941 void create( int x, int y, int w, int h, int flags );
942 int process( int key_in = -1,int process_mouse = 1);
945 void draw_XSTR_forced(UI_GADGET *owner, int frame);
946 int get_current_hotspot();
948 ushort *get_mask_data(int *w, int *h) { *w = mask_w; *h = mask_h; return mask_data; }
949 void render_tooltip(const char *str);
950 void set_ignore_gadgets(int state);
951 void add_XSTR(const char *string, int xstr_id, int x, int y, UI_GADGET *assoc, int color_type, int font_id = -1);
952 void add_XSTR(UI_XSTR *xstr);
954 const char *(*tooltip_handler)(const char *text);
955 int last_keypress; // filled in each frame
957 int use_hack_to_get_around_stupid_problem_flag;
960 // 2 extremely useful structs
961 typedef struct ui_button_info {
962 const char *filename;
965 UI_BUTTON button; // because we have a class inside this struct, we need the constructor below..
967 ui_button_info(const char *name, int x1, int y1, int xt1, int yt1, int h) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h) {}
983 #define MAX_TOOLTIP_GROUPS 50
984 #define MAX_TOOLTIPS 500
986 extern int Num_tooltip_groups;
987 extern tooltip_group Tooltip_groups[MAX_TOOLTIP_GROUPS];
988 extern tooltip Tooltips[MAX_TOOLTIPS];
991 int ui_getfilelist( int MaxNum, char **list, char *filespec );
992 void ui_sort_filenames( int n, char **list );
995 class UI_SLIDER : public UI_GADGET
1004 UI_BUTTON left_button;
1005 UI_BUTTON right_button;
1012 int marker_x, marker_y, marker_w, marker_h;
1013 int n_positions, pixel_range, increment;
1014 float start, stop, current;
1017 virtual void draw();
1018 virtual void process(int focus = 0);
1020 // Used to index into bmap_ids[] array to locate right bitmap for slider
1021 enum { SLIDER_BAR_NORMAL = 0 };
1022 enum { SLIDER_BAR_DISABLED = 1 };
1023 enum { SLIDER_MARKER_NORMAL = 2 };
1024 enum { SLIDER_MARKER_DISABLED = 3 };
1027 void create(UI_WINDOW *wnd, int _x, int _y, int _w, int _h, float _start, float _stop, float _pos, int n_positions);
1034 void link_hotspot(int up_button_num, int down_button_num);
1035 int set_bmaps(char *left_button_fname, char *right_button_fname, char *bar_fname, char *marker_fname);