X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fgui%2Fmenu.h;fp=src%2Fgui%2Fmenu.h;h=9847418d13c2952102f51934ee15d495502a8598;hb=f9098d0570ae6462781e8189518085cb1c8c00ef;hp=0000000000000000000000000000000000000000;hpb=836c7fa1f3e2dc3ec9849cac2584d4544bf2fba4;p=virtualjaguar diff --git a/src/gui/menu.h b/src/gui/menu.h new file mode 100644 index 0000000..9847418 --- /dev/null +++ b/src/gui/menu.h @@ -0,0 +1,68 @@ +// +// Menu class & supporting structs/classes +// +// by James L. Hammons +// + +#ifndef __MENU_H__ +#define __MENU_H__ + +#include +#include +#include "element.h" +#include "guimisc.h" // Ick. + +class Window; + +struct NameAction +{ + std::string name; + Window * (* action)(void); + SDLKey hotKey; + + NameAction(std::string n, Window * (* a)(void) = NULL, SDLKey k = SDLK_UNKNOWN): + name(n), action(a), hotKey(k) {} +}; + +class MenuItems +{ + public: + MenuItems(): charLength(0) {} + // Normally, we avoid implementation in a header file but in this case + // we can make an exception. ;-) + bool Inside(uint32 x, uint32 y) + { return (x >= (uint32)extents.x && x < (uint32)(extents.x + extents.w) + && y >= (uint32)extents.y && y < (uint32)(extents.y + extents.h) ? true : false); } + + std::string title; + std::vector item; + uint32 charLength; + SDL_Rect extents; +}; + +class Menu: public Element +{ + public: +// 1CFF -> 0 001 11 00 111 1 1111 +// 421F -> 0 100 00 10 000 1 1111 + Menu(uint32 x = 0, uint32 y = 0, uint32 w = 0, uint32 h = FONT_HEIGHT, + uint32 fgc = 0xFF7F0000, uint32 bgc = 0xFFFF3F3F, uint32 fgch = 0xFFFF3F3F, + uint32 bgch = 0xFFFF8787); + virtual void HandleKey(SDLKey key); + virtual void HandleMouseMove(uint32 x, uint32 y); + virtual void HandleMouseButton(uint32 x, uint32 y, bool mouseDown); + virtual void Draw(uint32 offsetX = 0, uint32 offsetY = 0); + virtual void Notify(Element *) {} + void Add(MenuItems mi); + + protected: + bool activated, clicked; + uint32 inside, insidePopup; + uint32 fgColor, bgColor, fgColorHL, bgColorHL; + int menuChosen, menuItemChosen; + + private: + std::vector itemList; +}; + +#endif // __MENU_H__