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/icon.cpp $
15 * C++ class implementation for icon UI element
18 * Revision 1.3 2002/06/09 04:41:29 relnev
19 * added copyright header
21 * Revision 1.2 2002/05/07 03:16:53 theoddone33
22 * The Great Newline Fix
24 * Revision 1.1.1.1 2002/05/03 03:28:11 root
28 * 4 12/02/98 5:47p Dave
29 * Put in interface xstr code. Converted barracks screen to new format.
31 * 3 10/13/98 9:29a Dave
32 * Started neatening up freespace.h. Many variables renamed and
33 * reorganized. Added AlphaColors.[h,cpp]
35 * 2 10/07/98 10:54a Dave
38 * 1 10/07/98 10:51a Dave
40 * 5 2/03/98 4:21p Hoffoss
41 * Made UI controls draw white text when disabled.
43 * 4 1/20/98 10:36a Hoffoss
44 * Fixed optimized warnings.
46 * 3 1/14/98 6:43p Hoffoss
47 * Massive changes to UI code. A lot cleaner and better now. Did all
48 * this to get the new UI_DOT_SLIDER to work properly, which the old code
49 * wasn't flexible enough to handle.
51 * 2 9/07/97 10:05p Lawrance
54 * 1 9/06/97 11:22p Lawrance
61 #include "alphacolors.h"
63 // ---------------------------------------------------------------------------------------
67 void UI_ICON::create(UI_WINDOW *wnd, char *_text, int _x, int _y, int _w, int _h)
74 base_create(wnd, UI_KIND_ICON, _x, _y, _w, _h);
78 void UI_ICON::destroy()
93 if (bmap_ids[ICON_DISABLED] != -1) {
94 gr_set_bitmap(bmap_ids[ICON_DISABLED]);
98 } else if (this->is_mouse_on()) {
100 if (bmap_ids[ICON_SELECTED] != -1) {
101 gr_set_bitmap(bmap_ids[ICON_SELECTED]);
106 if (bmap_ids[ICON_HIGHLIGHT] != -1) {
107 gr_set_bitmap(bmap_ids[ICON_HIGHLIGHT]);
113 if (bmap_ids[ICON_NORMAL] != -1) {
114 gr_set_bitmap(bmap_ids[ICON_NORMAL]);
120 gr_set_font(my_wnd->f_id);
121 gr_set_clip(x, y, w, h);
123 ui_draw_box_out(0, 0, w-1, h-1);
125 gr_set_color_fast(&CDARK_GRAY);
127 gr_set_color_fast(&CBLACK);
130 ui_string_centered(Middle(w), Middle(h), text);
136 // -----------------------------------------------------------------------
139 void UI_ICON::process(int focus)
147 OnMe = is_mouse_on();
150 m_flags |= ICON_NOT_HIGHLIGHTED;
153 if ( m_flags & ICON_NOT_HIGHLIGHTED ) {
154 m_flags |= ICON_JUST_HIGHLIGHTED;
155 // if a callback exists, call it
156 m_flags &= ~ICON_NOT_HIGHLIGHTED;