2 // Menu class & supporting structs/classes
13 #include "guimisc.h" // Ick.
20 Window * (* action)(void);
23 NameAction(std::string n, Window * (* a)(void) = NULL, SDLKey k = SDLK_UNKNOWN):
24 name(n), action(a), hotKey(k) {}
30 MenuItems(): charLength(0) {}
31 // Normally, we avoid implementation in a header file but in this case
32 // we can make an exception. ;-)
33 bool Inside(uint32 x, uint32 y)
34 { return (x >= (uint32)extents.x && x < (uint32)(extents.x + extents.w)
35 && y >= (uint32)extents.y && y < (uint32)(extents.y + extents.h) ? true : false); }
38 std::vector<NameAction> item;
43 class Menu: public Element
46 // 1CFF -> 0 001 11 00 111 1 1111
47 // 421F -> 0 100 00 10 000 1 1111
48 Menu(uint32 x = 0, uint32 y = 0, uint32 w = 0, uint32 h = FONT_HEIGHT,
49 uint32 fgc = 0xFF7F0000, uint32 bgc = 0xFFFF3F3F, uint32 fgch = 0xFFFF3F3F,
50 uint32 bgch = 0xFFFF8787);
51 virtual void HandleKey(SDLKey key);
52 virtual void HandleMouseMove(uint32 x, uint32 y);
53 virtual void HandleMouseButton(uint32 x, uint32 y, bool mouseDown);
54 virtual void Draw(uint32 offsetX = 0, uint32 offsetY = 0);
55 virtual void Notify(Element *) {}
56 void Add(MenuItems mi);
59 bool activated, clicked;
60 uint32 inside, insidePopup;
61 uint32 fgColor, bgColor, fgColorHL, bgColorHL;
62 int menuChosen, menuItemChosen;
65 std::vector<MenuItems> itemList;