File: widget.h

package info (click to toggle)
fuse-emulator 1.3.2%2Bdfsg1-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 10,456 kB
  • ctags: 9,261
  • sloc: ansic: 83,215; sh: 11,503; perl: 3,806; makefile: 1,000; yacc: 254; lex: 143
file content (270 lines) | stat: -rw-r--r-- 7,247 bytes parent folder | download | duplicates (3)
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
/* widget.h: Simple dialog boxes for all user interfaces.
   Copyright (c) 2001-2004 Matan Ziv-Av, Philip Kendall
   Copyright (c) 2015 Stuart Brady

   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.,
   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

   Author contact information:

   E-mail: philip-fuse@shadowmagic.org.uk

*/

#ifndef FUSE_WIDGET_H
#define FUSE_WIDGET_H

#include "input.h"
#include "ui/scaler/scaler.h"
#include "ui/ui.h"

/* Code called at start and end of emulation */
int widget_init( void );
int widget_end( void );

/* The various widgets which are available */
typedef enum widget_type {

  WIDGET_TYPE_FILESELECTOR,	/* File selector (load) */
  WIDGET_TYPE_FILESELECTOR_SAVE,/* File selector (save) */
  WIDGET_TYPE_GENERAL,		/* General options */
  WIDGET_TYPE_PICTURE,		/* Keyboard picture */
  WIDGET_TYPE_ABOUT,		/* About info */
  WIDGET_TYPE_MENU,		/* General menu */
  WIDGET_TYPE_SELECT,		/* Select machine */
  WIDGET_TYPE_MEDIA,		/* Media options */
  WIDGET_TYPE_SOUND,		/* Sound options */
  WIDGET_TYPE_ERROR,		/* Error report */
  WIDGET_TYPE_RZX,		/* RZX options */
  WIDGET_TYPE_MOVIE,		/* Movie options */
  WIDGET_TYPE_BROWSE,		/* Browse tape */
  WIDGET_TYPE_TEXT,		/* Text entry widget */
  WIDGET_TYPE_DEBUGGER,		/* Debugger widget */
  WIDGET_TYPE_POKEFINDER,	/* Poke finder widget */
  WIDGET_TYPE_POKEMEM,  	/* Poke memory widget */
  WIDGET_TYPE_MEMORYBROWSER,	/* Memory browser widget */
  WIDGET_TYPE_ROM,		/* ROM selector widget */
  WIDGET_TYPE_PERIPHERALS_GENERAL, /* General peripherals options */
  WIDGET_TYPE_PERIPHERALS_DISK, /* Disk peripherals options */
  WIDGET_TYPE_QUERY,		/* Query (yes/no) */
  WIDGET_TYPE_QUERY_SAVE,	/* Query (save/don't save/cancel) */
  WIDGET_TYPE_DISKOPTIONS,	/* Disk options widget */
} widget_type;

/* Activate a widget */
int widget_do( widget_type which, void *data );

/* Finish with widgets for now */
void widget_finish( void );

/* A function to handle keypresses */
typedef void (*widget_keyhandler_fn)( input_key key );

/* The current widget keyhandler */
extern widget_keyhandler_fn widget_keyhandler;

/* Widget-specific bits */

/* Menu widget */

/* A generic callback function */
typedef void (*widget_menu_callback_fn)( int action );

/* A generic menu detail callback function */
typedef const char* (*widget_menu_detail_callback_fn)( void );

/* A general menu */
typedef struct widget_menu_entry {
  const char *text;		/* Menu entry text */
  input_key key;		/* Which key to activate this widget */

  struct widget_menu_entry *submenu;
  widget_menu_callback_fn callback;
  widget_menu_detail_callback_fn detail;

  int action;
  int inactive;

} widget_menu_entry;

/* The main menu as activated with F1 */
extern widget_menu_entry widget_menu[];

/* Get the maximum menu width to use in pixels */
int widget_calculate_menu_width( widget_menu_entry *menu );

/* The name returned from the file selector */
extern char* widget_filesel_name;

/* Select a machine */
int widget_select_machine( void *data );
     
/* The error widget data type */

typedef struct widget_error_t {
  ui_error_level severity;
  const char *message;
} widget_error_t;

typedef struct widget_filesel_data widget_filesel_data;
typedef struct widget_picture_data widget_picture_data;
typedef struct widget_text_t widget_text_t;
typedef struct widget_select_t widget_select_t;
typedef struct widget_roms_info widget_roms_info;

/* File selector (load) */
static inline int widget_do_fileselector( widget_filesel_data *data )
{
  return widget_do( WIDGET_TYPE_FILESELECTOR, data );
}

/* File selector (save) */
static inline int widget_do_fileselector_save( widget_filesel_data *data )
{
  return widget_do( WIDGET_TYPE_FILESELECTOR_SAVE, data );
}

/* General options */
static inline int widget_do_general( void )
{
  return widget_do( WIDGET_TYPE_GENERAL, NULL );
}

/* Keyboard picture */
static inline int widget_do_picture( widget_picture_data *data )
{
  return widget_do( WIDGET_TYPE_PICTURE, data );
}

/* About fuse widget */
static inline int widget_do_about( void )
{
  return widget_do( WIDGET_TYPE_ABOUT, NULL );
}

/* General menu */
static inline int widget_do_menu( widget_menu_entry *data )
{
  return widget_do( WIDGET_TYPE_MENU, data );
}

/* Select machine */
static inline int widget_do_select( widget_select_t *data )
{
  return widget_do( WIDGET_TYPE_SELECT, data );
}

/* Media options */
static inline int widget_do_media( void )
{
  return widget_do( WIDGET_TYPE_MEDIA, NULL );
}

/* Sound options */
static inline int widget_do_sound( void )
{
  return widget_do( WIDGET_TYPE_SOUND, NULL );
}

/* Error report */
static inline int widget_do_error( widget_error_t *data )
{
  return widget_do( WIDGET_TYPE_ERROR, data );
}

/* RZX options */
static inline int widget_do_rzx( void )
{
  return widget_do( WIDGET_TYPE_RZX, NULL );
}

/* Movie options */
static inline int widget_do_movie( void )
{
  return widget_do( WIDGET_TYPE_MOVIE, NULL );
}

/* Browse tape */
static inline int widget_do_browse( void )
{
  return widget_do( WIDGET_TYPE_BROWSE, NULL );
}

/* Text entry widget */
static inline int widget_do_text( widget_text_t *data )
{
  return widget_do( WIDGET_TYPE_TEXT, data );
}

/* Debugger widget */
static inline int widget_do_debugger( void )
{
  return widget_do( WIDGET_TYPE_DEBUGGER, NULL );
}

/* Poke finder widget */
static inline int widget_do_pokefinder( void )
{
  return widget_do( WIDGET_TYPE_POKEFINDER, NULL );
}

/* Poke memory widget */
static inline int widget_do_pokemem( void )
{
  return widget_do( WIDGET_TYPE_POKEMEM, NULL );
}

/* Memory browser widget */
static inline int widget_do_memorybrowser( void )
{
  return widget_do( WIDGET_TYPE_MEMORYBROWSER, NULL );
}

/* ROM selector widget */
static inline int widget_do_rom( widget_roms_info *data )
{
  return widget_do( WIDGET_TYPE_ROM, data );
}

/* General peripherals options */
static inline int widget_do_peripherals_general( void )
{
  return widget_do( WIDGET_TYPE_PERIPHERALS_GENERAL, NULL );
}

/* Disk peripherals options */
static inline int widget_do_peripherals_disk( void )
{
  return widget_do( WIDGET_TYPE_PERIPHERALS_DISK, NULL );
}

/* Query (yes/no) */
static inline int widget_do_query( const char *message )
{
  return widget_do( WIDGET_TYPE_QUERY, (void *)message );
}

/* Query (save/don't save/cancel) */
static inline int widget_do_query_save( const char *message )
{
  return widget_do( WIDGET_TYPE_QUERY_SAVE, (void *)message );
}

/* Disk options widget */
static inline int widget_do_diskoptions( void )
{
  return widget_do( WIDGET_TYPE_DISKOPTIONS, NULL );
}

#endif				/* #ifndef FUSE_WIDGET_H */