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_t x = 0, uint32_t y = 0, uint32_t w = 0, uint32_t h = 0,
23 Element * parentElement = NULL);
24 Element(uint32_t x, uint32_t y, uint32_t w, uint32_t h,
25 uint8_t fgR = 0xFF, uint8_t fgG = 0xFF, uint8_t fgB = 0xFF, uint8_t fgA = 0xFF,
26 uint8_t bgR = 0x00, uint8_t bgG = 0x00, uint8_t bgB = 0x00, uint8_t bgA = 0xFF,
27 Element * parentElement = NULL);
28 virtual ~Element(); // Destructor cannot be pure virtual...
29 virtual void HandleKey(SDL_Scancode key) = 0; // These are "pure" virtual functions...
30 virtual void HandleMouseMove(uint32_t x, uint32_t y) = 0;
31 virtual void HandleMouseButton(uint32_t x, uint32_t y, bool mouseDown) = 0;
32 virtual void Draw(void) = 0;
33 virtual void Notify(Element *) = 0;
34 bool Inside(uint32_t x, uint32_t 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);
49 void SetVisible(bool);
51 static void SetScreen(SDL_Surface *);
52 static bool ScreenNeedsRefreshing(void);
53 static void ScreenWasRefreshed(void);
61 SDL_Surface * backstore;
62 std::list<SDL_Rect> coverList;
66 static SDL_Surface * screen;
67 static bool needToRefreshScreen;
70 #endif // __ELEMENT_H__