File: menu.h

package info (click to toggle)
lbreakout2 2.5.2-2.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 6,040 kB
  • ctags: 2,374
  • sloc: ansic: 20,911; sh: 2,891; makefile: 374
file content (115 lines) | stat: -rw-r--r-- 4,640 bytes parent folder | download | duplicates (7)
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
/***************************************************************************
                          menu.h  -  description
                             -------------------
    begin                : Thu Sep 20 2001
    copyright            : (C) 2001 by Michael Speck
    email                : kulkanie@gmx.net
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef __MENU_H
#define __MENU_H

/*
====================================================================
Menu
====================================================================
*/
enum { MENU_LAYOUT_CENTERED = 0 };
typedef struct _Menu {
    char    *name;              /* name of menu -- duplicated */
    int     layout;
    int     x, y, w, h;         /* layout */
    List    *items;             /* list of menu items */
    Item    *cur_item;          /* currently highlighted item */
    struct _Menu   *parent;     /* parent menu */
    StkFont    *font, *hfont, *cfont; /* if not set the default fonts are used */
} Menu;

/*
====================================================================
Create menu and center it in x,y,w,h by menu_adjust() later.
====================================================================
*/
Menu *menu_create( char *name, int layout, int x, int y, int w, int h, int border, int add_to_list );
/*
====================================================================
Delete menu and all submenus starting with root menu
====================================================================
*/
void menu_delete( void *menu );
/*
====================================================================
Add item to menu. Add item::menu to children list if
ITEM_LINK.
====================================================================
*/
void menu_add( Menu *menu, Item *item );
/*
====================================================================
Adjust position and size of all entries according to layout.
====================================================================
*/
void menu_adjust( Menu *menu );
/*
====================================================================
Select menu: clear current item and set extern variable cur_menu
====================================================================
*/
void menu_select( Menu *menu );
/*
====================================================================
Show/hide all items
====================================================================
*/
void menu_hide( Menu *menu );
void menu_show( Menu *menu );
/*
====================================================================
modify items according to event (if any) and return action id.
====================================================================
*/
int menu_handle_event( Menu *menu, SDL_Event *event );
/*
====================================================================
Update alpha of items
====================================================================
*/
void menu_update( Menu *menu, int ms );
/*
====================================================================
Select/unselect item: update menu::cur_item und item::highlight
====================================================================
*/
void menu_unselect_cur_item( Menu *menu );
void menu_select_item( Menu *menu, Item *item );
/*
====================================================================
Go one valid menu item up or down.
====================================================================
*/
void menu_up( Menu *menu );
void menu_down( Menu *menu );
/*
====================================================================
Set fonts of menu and items.
====================================================================
*/
void menu_set_fonts( 
    Menu *menu, StkFont *cfont, StkFont *font, StkFont *hfont );
/*
====================================================================
Set background of menu and items.
====================================================================
*/
void menu_set_bkgnd( Menu *menu, SDL_Surface *bkgnd );

#endif