]> Shamusworld >> Repos - virtualjaguar/blob - src/gui/element.h
Major refactoring of GUI: Phase I
[virtualjaguar] / src / gui / element.h
1 //
2 // GUI element base class
3 //
4 // by James L. Hammons
5 //
6
7 #ifndef __ELEMENT_H__
8 #define __ELEMENT_H__
9
10 #include "SDL.h"
11 #include "types.h"
12
13 class Element
14 {
15         public:
16                 Element(uint32 x = 0, uint32 y = 0, uint32 w = 0, uint32 h = 0)
17                         { extents.x = x, extents.y = y, extents.w = w, extents.h = h; }
18                 // These are "pure" virtual functions...
19                 virtual void HandleKey(SDLKey key) = 0;
20                 virtual void HandleMouseMove(uint32 x, uint32 y) = 0;
21                 virtual void HandleMouseButton(uint32 x, uint32 y, bool mouseDown) = 0;
22                 virtual void Draw(uint32, uint32) = 0;
23                 virtual void Notify(Element *) = 0;
24 //Needed?               virtual ~Element() = 0;
25 //We're not allocating anything in the base class, so the answer would be NO.
26                 bool Inside(uint32 x, uint32 y);
27
28                 // Class method
29                 static void SetScreenAndPitch(uint32 * s, uint32 p) { screenBuffer = s, pitch = p; }
30
31         protected:
32                 SDL_Rect extents;
33                 uint32 state;
34
35                 // Class variables...
36                 static uint32 * screenBuffer;
37                 static uint32 pitch;
38 };
39
40 #endif  // __ELEMENT_H__