]> Shamusworld >> Repos - apple2/blob - src/gui/menu.h
Added missing files. :-P
[apple2] / src / gui / menu.h
1 //
2 // MENU.H
3 //
4 // Graphical User Interface menu support
5 //
6
7 #ifndef __MENU_H__
8 #define __MENU_H__
9
10 #include <string>
11 #include <vector>
12 #include "window.h"
13
14 struct NameAction
15 {
16         std::string name;
17         Element * (* action)(void);
18         SDL_Scancode hotKey;
19
20         NameAction(std::string n, Element * (* a)(void) = NULL, SDL_Scancode k = SDL_SCANCODE_UNKNOWN): name(n),
21                 action(a), hotKey(k) {}
22 };
23
24 class MenuItems
25 {
26         public:
27                 MenuItems();
28                 bool Inside(uint32_t x, uint32_t y);
29
30                 std::string title;
31                 std::vector<NameAction> item;
32                 uint32_t charLength;
33                 SDL_Rect extents;
34                 SDL_Surface * popupBackstore;
35 };
36
37 class Menu: public Element
38 {
39         public:
40                 Menu(uint32_t x = 0, uint32_t y = 0, uint32_t w = 0, uint32_t h = 0,
41                         uint8_t fgcR = 0x00, uint8_t fgcG = 0x00, uint8_t fgcB = 0x7F, uint8_t fgcA = 0xFF,
42                         uint8_t bgcR = 0x3F, uint8_t bgcG = 0x3F, uint8_t bgcB = 0xFF, uint8_t bgcA = 0xFF,
43                         uint8_t fgchR = 0x3F, uint8_t fgchG = 0x3F, uint8_t fgchB = 0xFF, uint8_t fgchA = 0xFF,
44                         uint8_t bgchR = 0x87, uint8_t bgchG = 0x87, uint8_t bgchB = 0xFF, uint8_t bgchA = 0xFF);
45                 ~Menu();
46                 virtual void HandleKey(SDL_Scancode key);
47                 virtual void HandleMouseMove(uint32_t x, uint32_t y);
48                 virtual void HandleMouseButton(uint32_t x, uint32_t y, bool mouseDown);
49                 virtual void Draw(void);
50                 virtual void Notify(Element *);
51                 void Add(MenuItems mi);
52                 void SaveStateVariables(void);
53                 void CheckStateAndRedrawIfNeeded(void);
54
55         protected:
56                 bool activated, clicked;
57                 uint32_t inside, insidePopup;
58                 int menuChosen, menuItemChosen;
59                 uint32_t fgColorHL, bgColorHL;
60
61         private:
62                 std::vector<MenuItems> itemList;
63                 bool activatedSave, clickedSave;
64                 uint32_t insideSave, insidePopupSave;
65                 int menuChosenSave, menuItemChosenSave;
66 };
67
68 #endif  // __MENU_H__