StarTrekV3_Linux  Version3
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Pages
Menu.h
Go to the documentation of this file.
1 //
2 // ___.--------._____________,------' -----.`----._
3 // \ ` - . _ /\
4 // `.__________ ` - | | __,---"-._
5 // `-----------.______ ,'_/ ________,------'___________`----.___________
6 // `-----.____,' \===========================================/
7 // | :| >--------------.----------.---------------'
8 // / :| _,--' ,--' `--.__.--'
9 // / : |--'______________/_
10 // ,---,' : \__________________`--.
11 // `__________ |/|
12 // `------._ |\|
13 // `--._________,-'
14 //
15 //
16 //
17 // Credits go to Paramount pictures for the star - trek concept and universe.
18 
19 
20 // Copyright (C) 2015 - 2016 E.J.M. Martens
21 //
22 // This program is free software; you can redistribute it and/or
23 // modify it under the terms of the GNU General Public License
24 // as published by the Free Software Foundation; either version 2
25 // of the License, or (at your option) any later version.
26 //
27 // This program is distributed in the hope that it will be useful,
28 // but WITHOUT ANY WARRANTY; without even the implied warranty of
29 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 // GNU General Public License for more details.
31 //
32 // You should have received a copy of the GNU General Public License
33 // along with this program; if not, write to the Free Software
34 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
35 
36 
37 #ifndef _MENU
38 #define _MENU
39 
40 #include <allegro5/allegro.h>
41 #include <allegro5/allegro_font.h>
42 #include <allegro5/allegro_ttf.h>
43 
44 #include <string>
45 #include <vector>
46 
47 using namespace std;
48 
49 class TMenu;
50 
51 
57 class TMenuItem
58 {
59  friend class TMenu;
60  private:
61  int m_nX, m_nY;
62  // Callback function
63  void (* m_pCallBack)();
64  // Parent Menu
65  TMenu * m_pParent;
66  // draw position
67  int m_nWidth, m_nHeight;
68  string m_strCaption;
69  bool m_blHighlight;
70 
71  protected:
72 
73 
74  public:
91  TMenuItem (int a_nX, int a_nY, int a_nWidth, int a_nHeight, TMenu * a_pParent,void (* a_pCallBack)());
97  void ProcessMouseEvent(ALLEGRO_MOUSE_EVENT * mouse_event);
98 
104  void Draw(ALLEGRO_FONT * a_pFont);
105 };
106 
107 
108 
114 class TMenu
115 {
116  friend class TMenuItem;
117  private:
118  ALLEGRO_COLOR m_ColorInner;
119  ALLEGRO_COLOR m_ColorOuter;
120  ALLEGRO_COLOR m_ColorHighlight;
121  int m_nIndex;
122  vector <TMenuItem> m_vMenuItems;
123  protected:
124 
125  public:
126  TMenu();
127  ~TMenu();
128  void ClearItems();
129  void AddMenuItem(string a_strCaption, void (* a_pCallBack)());
130  void DeleteLast();
131  void ProcessMouseEvent(ALLEGRO_MOUSE_EVENT * mouse_event);
132  void Draw(ALLEGRO_FONT * a_pFont);
133  int Count();
134 
135 };
136 
137 
138 
139 #endif
void ProcessMouseEvent(ALLEGRO_MOUSE_EVENT *mouse_event)
Mouse event handler for menu item.
Definition: Menu.cpp:37
friend class TMenu
Definition: Menu.h:59
Definition: Menu.h:57
void Draw(ALLEGRO_FONT *a_pFont)
Definition: Menu.cpp:149
void ProcessMouseEvent(ALLEGRO_MOUSE_EVENT *mouse_event)
Definition: Menu.cpp:136
Definition: Menu.h:114
friend class TMenuItem
Definition: Menu.h:116
void Draw(ALLEGRO_FONT *a_pFont)
Draw this menu item.
Definition: Menu.cpp:63