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 };
22 Element(uint32 x = 0, uint32 y = 0, uint32 w = 0, uint32 h = 0,
23 Element * parentElement = NULL);
24 Element(uint32 x, uint32 y, uint32 w, uint32 h,
25 uint8 fgR = 0xFF, uint8 fgG = 0xFF, uint8 fgB = 0xFF, uint8 fgA = 0xFF,
26 uint8 bgR = 0x00, uint8 bgG = 0x00, uint8 bgB = 0x00, uint8 bgA = 0xFF,
27 Element * parentElement = NULL);
28 virtual ~Element(); // Destructor cannot be pure virtual...
29 virtual void HandleKey(SDLKey key) = 0; // These are "pure" virtual functions...
30 virtual void HandleMouseMove(uint32 x, uint32 y) = 0;
31 virtual void HandleMouseButton(uint32 x, uint32 y, bool mouseDown) = 0;
32 virtual void Draw(void) = 0;
33 virtual void Notify(Element *) = 0;
34 bool Inside(uint32 x, uint32 y);
35 //Badly named, though we may code something that does this...
36 // SDL_Rect GetParentCorner(void);
37 SDL_Rect GetScreenCoords(void);
38 SDL_Rect GetExtents(void);
40 //May use this in the future...
41 SDL_Rect GetParentRect(void);
43 void CreateBackstore(void);
44 void RestoreScreenFromBackstore(void);
45 void SaveScreenToBackstore(void);
46 void ResetCoverageList(void);
47 //Need something to prevent this on Elements that don't have mouseover effects...
48 void AdjustCoverageList(SDL_Rect r);
50 static void SetScreen(SDL_Surface *);
51 static bool ScreenNeedsRefreshing(void);
52 static void ScreenWasRefreshed(void);
60 SDL_Surface * backstore;
61 std::list<SDL_Rect> coverList;
64 static SDL_Surface * screen;
65 static bool needToRefreshScreen;
68 #endif // __ELEMENT_H__