1 /*
2 Copyright (C) 1997-2001 Id Software, Inc.
3 
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 
13 See the GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 
19 */
20 #ifndef __QMENU_H__
21 #define __QMENU_H__
22 
23 #define MAXMENUITEMS	64
24 
25 #define MTYPE_SLIDER		0
26 #define MTYPE_LIST			1
27 #define MTYPE_ACTION		2
28 #define MTYPE_SPINCONTROL	3
29 #define MTYPE_SEPARATOR  	4
30 #define MTYPE_FIELD			5
31 
32 #define	K_TAB			9
33 #define	K_ENTER			13
34 #define	K_ESCAPE		27
35 #define	K_SPACE			32
36 
37 // normal keys should be passed as lowercased ascii
38 
39 #define	K_BACKSPACE		127
40 #define	K_UPARROW		128
41 #define	K_DOWNARROW		129
42 #define	K_LEFTARROW		130
43 #define	K_RIGHTARROW	131
44 
45 #define QMF_LEFT_JUSTIFY	0x00000001
46 #define QMF_GRAYED			0x00000002
47 #define QMF_NUMBERSONLY		0x00000004
48 #define QMF_DISABLED		0x00000008
49 
50 
51 //MENU_FONT_SIZE * 2
52 #define RCOLUMN_OFFSET  24
53 #define LCOLUMN_OFFSET -24
54 
55 #define SLIDER_RANGE 10
56 //
57 
58 typedef struct _tag_menuframework
59 {
60 	int x, y;
61 	int	cursor;
62 
63 	int	nitems;
64 	int nslots;
65 	void *items[64];
66 
67 	const char *statusbar;
68 
69 	void (*cursordraw)( struct _tag_menuframework *m );
70 
71 } menuframework_s;
72 
73 typedef struct
74 {
75 	int type;
76 	const char *name;
77 	int x, y;
78 	menuframework_s *parent;
79 	int cursor_offset;
80 	int	localdata[4];
81 	unsigned flags;
82 
83 	const char *statusbar;
84 
85 	void (*callback)( void *self );
86 	void (*statusbarfunc)( void *self );
87 	void (*ownerdraw)( void *self );
88 	void (*cursordraw)( void *self );
89 } menucommon_s;
90 
91 typedef struct
92 {
93 	menucommon_s generic;
94 
95 	char		buffer[80];
96 	int			cursor;
97 	int			length;
98 	int			visible_length;
99 	int			visible_offset;
100 } menufield_s;
101 
102 typedef struct
103 {
104 	menucommon_s generic;
105 
106 	float minvalue;
107 	float maxvalue;
108 	float curvalue;
109 
110 	float range;
111 } menuslider_s;
112 
113 typedef struct
114 {
115 	menucommon_s generic;
116 
117 	int curvalue;
118 
119 	const char **itemnames;
120 } menulist_s;
121 
122 typedef struct
123 {
124 	menucommon_s generic;
125 } menuaction_s;
126 
127 typedef struct
128 {
129 	menucommon_s generic;
130 } menuseparator_s;
131 
132 typedef struct
133 {
134 	float x;
135 	float y;
136 	float avg;
137 } menuscale_t;
138 
139 qboolean Field_Key( menufield_s *field, int key );
140 
141 void	Menu_AddItem( menuframework_s *menu, void *item );
142 void	Menu_AdjustCursor( menuframework_s *menu, int dir );
143 void	Menu_Center( menuframework_s *menu );
144 void	Menu_Draw( menuframework_s *menu );
145 void	*Menu_ItemAtCursor( menuframework_s *m );
146 qboolean Menu_SelectItem( menuframework_s *s );
147 qboolean Menu_MouseSelectItem( menucommon_s *item );
148 void	Menu_SetStatusBar( menuframework_s *s, const char *string );
149 void	Menu_SlideItem( menuframework_s *s, int dir );
150 int		Menu_TallySlots( menuframework_s *menu );
151 
152 void	 Menu_DrawString( int, int, const char *, int );
153 void	 Menu_DrawStringDark( int, int, const char *, int );
154 void	 Menu_DrawStringR2L( int, int, const char *, int );
155 void	 Menu_DrawStringR2LDark( int, int, const char *, int );
156 
157 void refreshCursorLink (void);
158 
159 cursor_t cursor;
160 
161 menuscale_t menuScale;
162 
163 #endif
164