1 /***************************************************************************
2                           menuitem.h  -  description
3                              -------------------
4     begin                : Tue Feb 29 2000
5     copyright            : (C) 2000 by Michael Speck
6     email                :
7  ***************************************************************************/
8 
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17 
18 #ifndef MENUITEM_H
19 #define MENUITEM_H
20 
21 
22 /**
23   *@author Michael Speck
24   */
25 
26 #include "sdl.h"
27 class Menu;
28 
29 //manager return values
30 #define MR_NONE		0
31 #define MR_CONTINUE	1
32 //entry types
33 #define ET_SEPARATOR	0
34 #define ET_SUBMENU		1
35 #define ET_SWITCHGRP    2
36 #define ET_RANGE		3
37 #define ET_ACTION		4
38 #define ET_KEY			5
39 #define ET_STRING		6
40 class MenuItem {
41 public:
42     MenuItem();  //Separator
43     MenuItem(char *name); //Separator
44     MenuItem(char *name, int *p, char *cap1, char *cap2); //switch
45     MenuItem(char *name, int *p, char **caps, int num); //switch group
46     MenuItem(char *name, int *p, int min, int max, int step = 1); //range
47     MenuItem(char *name, int *p, char *keys); //key
48     MenuItem(char *name, int a_id); //action
49     MenuItem(char *name, Menu* m); //submenu
50     MenuItem(char *name, char *p, int max); //string
51     ~MenuItem();
52     void SetXY(int x, int y);
53     void SetBackgnd(SDL_Surface *backgnd);
54     void SetSubmenu(Menu *m);
55     void SetFont(SFnt *fnt, SFnt *enlgt_fnt);
56     void ComputeStr();
57     void Enlight(int t);
58     int  Type();
59     int KeyEvent(int code);
60     void SetKey(int code);
61     void Update();
62     void SetChanged(int c);
63     void Hide();
64     void Refresh();
65     void ComputeSize();
66     void Compute();
67     Menu* Submenu();
68     int ActionId();
69     void ClearAlpha();
70     int Pos();
71     void StrUpdate();
72     void EditStr(int code, int unicode);
73     void SetRestrKeys(char *rk);
74     void NoBackgnd();
75     int OnItem(int mx, int my);
76     int ButtonEvent(SDL_MouseButtonEvent button);
77     void SetString(char *s, int rep);
78     void SetRange(int ll, int ul, int st, int rep);
79     int Used();
80     void SetUsed(int u);
81 private:
82     SDL_Surface	*backgnd;
83     SFnt    *font;
84     SFnt    *enlgt_font;
85     char    name[32];
86     char    string[64];
87     char    **sw_cap;
88     int     sw_cap_num;
89     int	    type;
90     int	    *pos;
91     int	    min;
92     int	    max;
93     int	    action;
94     Menu    *submenu;
95     char    *restr_keys;
96     int	    x;
97     int	    y;
98     int	    dx;
99     int     dy;
100     int	    dw;
101     int	    dh;
102     char    enlighted;
103     int     alpha;
104     char    changed;
105     int     step;
106     int     used;
107 };
108 
109 #endif
110