Starshatter_Open
Open source Starshatter engine
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Menu.h
Go to the documentation of this file.
1
/* Project nGenEx
2
Destroyer Studios LLC
3
Copyright © 1997-2004. All Rights Reserved.
4
5
SUBSYSTEM: nGenEx.lib
6
FILE: Menu.h
7
AUTHOR: John DiCamillo
8
9
10
OVERVIEW
11
========
12
Simple menu hierarchy class
13
*/
14
15
#ifndef Menu_h
16
#define Menu_h
17
18
#include "
Types.h
"
19
#include "
List.h
"
20
#include "
Text.h
"
21
22
// +-------------------------------------------------------------------+
23
24
class
Menu
;
25
class
MenuItem
;
26
class
MenuHistory
;
27
28
// +-------------------------------------------------------------------+
29
30
class
Menu
31
{
32
public
:
33
static
const
char
*
TYPENAME
() {
return
"Menu"
; }
34
35
Menu
() { }
36
Menu
(
Text
t) :
title
(t) { }
37
virtual
~Menu
() {
items
.
destroy
(); }
38
39
virtual
Text
GetTitle
()
const
{
return
title
; }
40
virtual
void
SetTitle
(
Text
t) {
title
= t; }
41
virtual
Menu
*
GetParent
()
const
{
return
parent
; }
42
virtual
void
SetParent
(
Menu
* p) {
parent
= p; }
43
44
virtual
void
AddItem
(
Text
label, DWORD value=0,
bool
enabled=
true
);
45
virtual
void
AddItem
(
MenuItem
* item);
46
virtual
void
AddMenu
(
Text
label,
Menu
* menu, DWORD value=0);
47
virtual
MenuItem
*
GetItem
(
int
index);
48
virtual
void
SetItem
(
int
index,
MenuItem
* item);
49
virtual
int
NumItems
()
const
;
50
virtual
void
ClearItems
();
51
52
ListIter<MenuItem>
GetItems
() {
return
items
; }
53
54
protected
:
55
Text
title
;
56
List<MenuItem>
items
;
57
Menu
*
parent
;
58
59
friend
class
MenuItem
;
60
};
61
62
// +-------------------------------------------------------------------+
63
64
class
MenuItem
65
{
66
public
:
67
static
const
char
*
TYPENAME
() {
return
"MenuItem"
; }
68
69
MenuItem
(
Text
label, DWORD value=0,
bool
enabled
=
true
);
70
virtual
~MenuItem
();
71
72
virtual
Text
GetText
()
const
{
return
text
; }
73
virtual
void
SetText
(
Text
t) {
text
= t; }
74
75
virtual
DWORD
GetData
()
const
{
return
data
; }
76
virtual
void
SetData
(DWORD d) {
data
= d; }
77
78
virtual
int
GetEnabled
()
const
{
return
enabled
; }
79
virtual
void
SetEnabled
(
int
e) {
enabled
= e; }
80
81
virtual
int
GetSelected
()
const
{
return
selected
; }
82
virtual
void
SetSelected
(
int
s) {
selected
= s; }
83
84
virtual
Menu
*
GetMenu
()
const
{
return
menu
; }
85
virtual
void
SetMenu
(
Menu
* m) {
menu
= m; }
86
87
virtual
Menu
*
GetSubmenu
()
const
{
return
submenu
; }
88
virtual
void
SetSubmenu
(
Menu
* s) {
submenu
= s; }
89
90
protected
:
91
Text
text
;
92
DWORD
data
;
93
int
enabled
;
94
int
selected
;
95
96
Menu
*
menu
;
97
Menu
*
submenu
;
98
99
friend
class
Menu
;
100
};
101
102
// +-------------------------------------------------------------------+
103
104
class
MenuHistory
105
{
106
public
:
107
static
const
char
*
TYPENAME
() {
return
"MenuHistory"
; }
108
109
MenuHistory
() { }
110
virtual
~MenuHistory
() { history.
clear
(); }
111
112
virtual
Menu
*
GetCurrent
();
113
virtual
Menu
*
GetLevel
(
int
n);
114
virtual
Menu
*
Find
(
const
char
* title);
115
virtual
void
Pop
();
116
virtual
void
Push
(
Menu
* menu);
117
virtual
void
Clear
();
118
119
private
:
120
List<Menu>
history;
121
};
122
123
#endif Menu_h
124
nGenEx
Menu.h
Generated on Tue Jun 5 2012 20:46:24 for Starshatter_Open by
1.8.1