summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/uimenu.h
blob: 2017fc9ed5bbfbb7ab2f8dc5503bae098626a3a3 (plain) (blame)
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
/***************************************************************************

    uimenu.h

    Internal MAME menus for the user interface.

    Copyright Nicola Salmoria and the MAME Team.
    Visit http://mamedev.org for licensing and usage restrictions.

***************************************************************************/

#pragma once

#ifndef __UIMENU_H__
#define __UIMENU_H__

#include "mamecore.h"


/***************************************************************************
    CONSTANTS
***************************************************************************/

/* flags for menu items */
#define MENU_FLAG_LEFT_ARROW		(1 << 0)
#define MENU_FLAG_RIGHT_ARROW		(1 << 1)
#define MENU_FLAG_INVERT			(1 << 2)
#define MENU_FLAG_MULTILINE			(1 << 3)
#define MENU_FLAG_REDTEXT			(1 << 4)
#define MENU_FLAG_DISABLE			(1 << 5)

/* special menu item for separators */
#define MENU_SEPARATOR_ITEM			"---"

/* flags to pass to ui_menu_process */
#define UI_MENU_PROCESS_NOKEYS		1
#define UI_MENU_PROCESS_LR_REPEAT	2
#define UI_MENU_PROCESS_CUSTOM_ONLY	4

/* options for ui_menu_reset */
enum _ui_menu_reset_options
{
	UI_MENU_RESET_SELECT_FIRST,
	UI_MENU_RESET_REMEMBER_POSITION,
	UI_MENU_RESET_REMEMBER_REF
};
typedef enum _ui_menu_reset_options ui_menu_reset_options;



/***************************************************************************
    TYPE DEFINITIONS
***************************************************************************/

/* forward declarations */
typedef struct _ui_menu ui_menu;


/* menu-related callback functions */
typedef void (*ui_menu_handler_func)(running_machine *machine, ui_menu *menu, void *parameter, void *state);
typedef void (*ui_menu_custom_func)(running_machine *machine, ui_menu *menu, void *state, void *selectedref, float top, float bottom, float x, float y, float x2, float y2);
typedef void (*ui_menu_destroy_state_func)(ui_menu *menu, void *state);


/* menu-related events */
typedef struct _ui_menu_event ui_menu_event;
struct _ui_menu_event
{
	void *			itemref;			/* reference for the selected item */
	int				iptkey;				/* one of the IPT_* values from inptport.h */
	unicode_char	unichar;			/* unicode character if iptkey == IPT_SPECIAL */
};



/***************************************************************************
    FUNCTION PROTOTYPES
***************************************************************************/


/* ----- core system management ----- */

/* initialization */
void ui_menu_init(running_machine *machine);



/* ----- core menu management ----- */

/* allocate a new menu */
ui_menu *ui_menu_alloc(running_machine *machine, ui_menu_handler_func handler, void *parameter);

/* free a menu */
void ui_menu_free(ui_menu *menu);

/* free all items in the menu, and all memory allocated from the memory pool */
void ui_menu_reset(ui_menu *menu, ui_menu_reset_options options);

/* returns TRUE if the menu has any non-default items in it */
int ui_menu_populated(ui_menu *menu);

/* append a new item to the end of the menu */
void ui_menu_item_append(ui_menu *menu, const char *text, const char *subtext, UINT32 flags, void *ref);

/* process a menu, drawing it and returning any interesting events */
const ui_menu_event *ui_menu_process(running_machine *machine, ui_menu *menu, UINT32 flags);

/* configure the menu for custom rendering */
void ui_menu_set_custom_render(ui_menu *menu, ui_menu_custom_func custom, float top, float bottom);

/* allocate permanent memory to represent the menu's state */
void *ui_menu_alloc_state(ui_menu *menu, size_t size, ui_menu_destroy_state_func destroy_state);

/* allocate temporary memory from the menu's memory pool */
void *ui_menu_pool_alloc(ui_menu *menu, size_t size);

/* make a temporary string copy in the menu's memory pool */
const char *ui_menu_pool_strdup(ui_menu *menu, const char *string);

/* retrieves the index of the currently selected menu item */
void *ui_menu_get_selection(ui_menu *menu);

/* changes the index of the currently selected menu item */
void ui_menu_set_selection(ui_menu *menu, void *selected_itemref);



/* ----- menu stack management ----- */

/* reset the menus, clearing everything */
void ui_menu_stack_reset(running_machine *machine);

/* push a new menu onto the stack */
void ui_menu_stack_push(ui_menu *menu);

/* pop a menu from the stack */
void ui_menu_stack_pop(running_machine *machine);



/* ----- UI system interaction ----- */

/* master handler */
UINT32 ui_menu_ui_handler(running_machine *machine, UINT32 state);

/* slider handler */
UINT32 ui_slider_ui_handler(running_machine *machine, UINT32 state);

/* force game select menu */
void ui_menu_force_game_select(running_machine *machine);
int ui_menu_is_force_game_select(void);


#endif	/* __UIMENU_H__ */