4 // Graphical User Interface base class
5 // All GUI elements are derived from this base class.
11 // These are various GUI messages that can be sent to the SDL event handler
13 enum { WINDOW_CLOSE, MENU_ITEM_CHOSEN, SCREEN_REFRESH_NEEDED };
21 Element(uint32 x = 0, uint32 y = 0, uint32 w = 0, uint32 h = 0,
22 Element * parentElement = NULL);
23 Element(uint32 x, uint32 y, uint32 w, uint32 h,
24 uint8 fgR = 0xFF, uint8 fgG = 0xFF, uint8 fgB = 0xFF, uint8 fgA = 0xFF,
25 uint8 bgR = 0x00, uint8 bgG = 0x00, uint8 bgB = 0x00, uint8 bgA = 0xFF,
26 Element * parentElement = NULL);
27 virtual ~Element(); // Destructor cannot be pure virtual...
28 virtual void HandleKey(SDLKey key) = 0; // These are "pure" virtual functions...
29 virtual void HandleMouseMove(uint32 x, uint32 y) = 0;
30 virtual void HandleMouseButton(uint32 x, uint32 y, bool mouseDown) = 0;
31 virtual void Draw(void) = 0;
32 virtual void Notify(Element *) = 0;
33 bool Inside(uint32 x, uint32 y);
34 //Badly named, though we may code something that does this...
35 // SDL_Rect GetParentCorner(void);
36 SDL_Rect GetScreenCoords(void);
38 //May use this in the future...
39 SDL_Rect GetParentRect(void);
41 void CreateBackstore(void);
42 void RestoreScreenFromBackstore(void);
44 static void SetScreen(SDL_Surface *);
45 static bool ScreenNeedsRefreshing(void);
46 static void ScreenWasRefreshed(void);
54 SDL_Surface * backstore;
57 static SDL_Surface * screen;
58 static bool needToRefreshScreen;
61 #endif // __ELEMENT_H__