]> Shamusworld >> Repos - apple2/blob - src/gui/button.h
4b4f1316a758d4cf2d2a6031fd990fe8a32f7509
[apple2] / src / gui / button.h
1 //
2 // BUTTON.H
3 //
4 // Graphical User Interface button class
5 //
6
7 #ifndef __BUTTON_H__
8 #define __BUTTON_H__
9
10 #include <string>
11 //#include <list>
12 #include "element.h"
13
14 //Apparently this approach doesn't work for inheritance... D'oh!
15 //class Element;                                                                        // Forward declaration
16
17 class Button: public Element
18 {
19         public:
20                 Button(uint32_t x = 0, uint32_t y = 0, uint32_t w = 0, uint32_t h = 0, Element * parent = NULL);
21                 Button(uint32_t x, uint32_t y, uint32_t w, uint32_t h, SDL_Surface * upImg, Element * parent = NULL);
22                 Button(uint32_t x, uint32_t y, SDL_Surface * bU, SDL_Surface * bH = NULL, SDL_Surface * bD = NULL, Element * parent = NULL);
23                 Button(uint32_t x, uint32_t y, uint32_t w, uint32_t h, std::string s, Element * parent = NULL);
24                 Button(uint32_t x, uint32_t y, std::string s, Element * parent = NULL);
25                 ~Button();
26                 virtual void HandleKey(SDL_Scancode key);
27                 virtual void HandleMouseMove(uint32_t x, uint32_t y);
28                 virtual void HandleMouseButton(uint32_t x, uint32_t y, bool mouseDown);
29                 virtual void Draw(void);
30                 virtual void Notify(Element *);
31                 bool ButtonClicked(void);
32                 void SaveStateVariables(void);
33                 void CheckStateAndRedrawIfNeeded(void);
34                 void SetText(std::string s);
35
36         protected:
37                 bool activated, clicked, inside;
38                 SDL_Surface * buttonUp, * buttonDown, * buttonHover;
39                 uint32_t fgColorHL;
40                 uint32_t bgColorHL;
41
42         private:
43                 bool surfacesAreLocal;
44                 bool activatedSave, clickedSave, insideSave;
45 };
46
47 #endif  // __BUTTON_H__