summaryrefslogtreecommitdiff
path: root/platgui.h
blob: 0719ef093a3963e65417b48bdc270e5836d1de3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/*

    viDOOM - level editor for DOOM

    Copyright (C) 2000  Ian Cowburn (ianc@noddybox.demon.co.uk)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    -------------------------------------------------------------------------

			 Platform specific GUI routines

    This is the platform specific routines for pop-up menus, dialogs and
    file selectors.  More DOOM graphics orientied GUI is handled by the
    generic GUI (gui.h) that is built on top of gfx.

    As with the platform specific GFX all calls can be differentiated from
    the generic gui by starting with GUI_, rather than Gui.

    Note that all these routines are expected to preserve screen contents.

    $Id$

*/

#ifndef _PLATGUI_H
#define _PLATGUI_H

#include "gfx.h"

/* Type for a picklist, where each entry has an associated grahpic.  If the
   image is NULL then no picture should be shown for that entry.
*/
typedef struct
	{
	char		*text;
	GFX_IMAGE	img;
	int		client_index;	/* Returned by GUI_image_picklist() */
	} PLAT_IMG_PICKLIST;


/* Type for a picklist
*/
typedef struct
	{
	char		*text;
	int		client_index;	/* Returned by GUI_client_picklist() */
	} PLAT_PICKLIST;


/* Types to define a menu
*/
typedef struct
	{
	char		*text;		/* Text to display */
	int		client_index;	/* Value returned by GUI_menu() */
	} PLAT_MENU;


/* Types to define a radio box
*/
typedef struct
	{
	char		*text;		/* Label for this button.  NULL==end */
	int		client_index;	/* Value returned by GUI_radio() */
	} PLAT_RADIO;

/* Types to define a simple dialog
*/
#define PLAT_DIAL_MAXSTRLEN	128

#define PLAT_DIAL_STRING	0
#define PLAT_DIAL_INTEGER	1
#define PLAT_DIAL_DOUBLE	2

typedef struct
	{
	char		*text;		/* Label for item.  NULL==no label */
	int		type;		/* Data type (PLAT_DIAL_xxx) */
	union 				/* Data */
	    {
	    int		i;
	    char	s[PLAT_DIAL_MAXSTRLEN+1];
	    double	d;
	    } data;
	} PLAT_DIALOG;


/* Inform GUI of screen size if required
*/
void	GUI_setscreen(int w,int h);

/* Display a Yes/No option box.  Returns TRUE/FALSE accordingly.
*/
int	GUI_yesno(char *question);


/* Pop-up/display a menu.  Return the client_index of the selected item from the
   menus, or defval for no selection.  The co-ords can obviously be ignored or
   honoured, though honouring is preferable.

   MENU array is terminated by one with a NULL text entry.
*/
int	GUI_menu(char *title, int x, int y, PLAT_MENU menu[], int defval);


/* Allow selection of a filename.  Returns NULL if cancelled, otherwise the
   selected path with must be Releas()'ed later.

   If supported then files ending with filter should only be displayed.  Filter
   should be NULL to show all files.
*/
char	*GUI_fsel(char *title, char *default_path, char *filter);


/* Display a picklist.  The items are described by the array of pointers
   passed in, which terminates with a NULL pointer.  The index to the selected
   item is returned, or -1 if the pickbox was cancelled.
*/
int	GUI_picklist(char *title,char *opts[]);


/* Does a picklist as above, but works on structures cntaining client return
   values, rather than simple array indexes.
*/
int	GUI_client_picklist(char *title,PLAT_PICKLIST opts[],int defval);


/* Display a picklist with associated images.  The items are described by the
   array of structs passed in, which terminates with a NULL pointer in the
   text field.  The client index data in the selected item is returned, or 
   defval if the pickbox was cancelled.

   If this cannot be supported on the platform then the minimum this should
   do is a sideways call to GUI_client_picklist()
*/
int	GUI_image_picklist(char *title,PLAT_IMG_PICKLIST opts[],int defval);


/* Display a radio box.  The items are described by the array of structs
   passed in, which terminates with a NULL pointer in the text field.
   The client index data in the selected item is returned, or defval if the
   radio box was cancelled.

   If one of the entries client index values is the same as current then that
   option will be the one selected when the radio box is displayed.  Otherwise
   the first item will be the selected one.
*/
int	GUI_radio_box(char *title,PLAT_RADIO opts[],int current,int defval);

/* Display a mutli-selection radio box.  The items are described by the array
   of char pointers passed in, which terminates with a NULL pointer.

   The passed in integer pointer points to a value which is used to enable/
   disable the options dependent on the integers bit setting.  The integer
   pointed to is updated on exit of the multi-selection box is not cancelled.

   Note that the bit patterns are matched bit number to opt index. ie.
   	val & 0x0001	corresponds to	opts[0]
   	val & 0x0002	corresponds to	opts[1]
	....
   	val & 0x0010	corresponds to	opts[4]
	....
   	val & 0x0100	corresponds to	opts[8]
	....
   	val & 0x8000	corresponds to	opts[15]

    A maximum of 16 bits should be all that needs supporting currently.

    Returns TRUE if dialog accepted, otherwise FALSE.
*/
int	GUI_multi_box(char *title,char *opts[],int *val);


/* Displays a very simple dialog made up of 'no' fields as defined in pd[].
   Returns TRUE if the dialog is accepted, FALSE otherwise.

   Note that as the values in the PLAT_DIALOG array are not pointing to
   actual client data they need not be preserved on a cancel of the dialog.
*/
int	GUI_dialog(char *title, int no, PLAT_DIALOG pd[]);


#endif


/* END OF FILE */