diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-01-17 20:46:06 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-01-17 20:46:06 (GMT) |
| commit | 4a60b97c700c2f1843b7e99313554cb89fb5da4e (patch) | |
| tree | 3b33ef6f74a4e8a4ff5968a81b9c4c429ccaa7c6 /src/interface/Window.h | |
| parent | 6273089bf486bf46ad325d72c7290ebb272bd3d8 (diff) | |
| download | powder-4a60b97c700c2f1843b7e99313554cb89fb5da4e.zip powder-4a60b97c700c2f1843b7e99313554cb89fb5da4e.tar.gz | |
Some minor changes
Diffstat (limited to 'src/interface/Window.h')
| -rw-r--r-- | src/interface/Window.h | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/src/interface/Window.h b/src/interface/Window.h new file mode 100644 index 0000000..581b91f --- /dev/null +++ b/src/interface/Window.h @@ -0,0 +1,103 @@ +#ifndef WINDOW_H +#define WINDOW_H + +#include <vector> +#include "interface/Point.h" +#include "Engine.h" + +namespace ui +{ + +enum ChromeStyle +{ + None, Title, Resizable +}; +//class State; + class Engine; + class Component; + + /* class State + * + * A UI state. Contains all components. + */ + class Window + { + public: + Window(Point _position, Point _size); + virtual ~Window(); + + bool AllowExclusiveDrawing; //false will not call draw on objects outside of bounds + + // Add Component to state + void AddComponent(Component* c); + + // Get the number of components this state has. + unsigned GetComponentCount(); + + // Get component by index. (See GetComponentCount()) + Component* GetComponent(unsigned idx); + + // Remove a component from state. NOTE: This DOES NOT free component from memory. + void RemoveComponent(Component* c); + + // Remove a component from state. NOTE: This WILL free component from memory. + void RemoveComponent(unsigned idx); + + virtual void DoInitialized(); + virtual void DoExit(); + virtual void DoTick(float dt); + virtual void DoDraw(); + + virtual void DoMouseMove(int x, int y, int dx, int dy); + virtual void DoMouseDown(int x, int y, unsigned button); + virtual void DoMouseUp(int x, int y, unsigned button); + virtual void DoMouseWheel(int x, int y, int d); + virtual void DoKeyPress(int key, bool shift, bool ctrl, bool alt); + virtual void DoKeyRelease(int key, bool shift, bool ctrl, bool alt); + + bool IsFocused(const Component* c) const; + void FocusComponent(Component* c); + + void* UserData; + + protected: + virtual void OnInitialized() {} + virtual void OnExit() {} + virtual void OnTick(float dt) {} + virtual void OnDraw() {} + + virtual void OnMouseMove(int x, int y, int dx, int dy) {} + virtual void OnMouseDown(int x, int y, unsigned button) {} + virtual void OnMouseUp(int x, int y, unsigned button) {} + virtual void OnMouseWheel(int x, int y, int d) {} + virtual void OnKeyPress(int key, bool shift, bool ctrl, bool alt) {} + virtual void OnKeyRelease(int key, bool shift, bool ctrl, bool alt) {} + std::vector<Component*> Components; + Component* focusedComponent_; + + Point Position; + Point Size; + ChromeStyle chrome; + + }; + + +/*class Window : public State +{ +private: + ChromeStyle chrome; +public: + Window(Point _position, Point _size); + Point Position; + Point Size; + + virtual void DoTick(float dt); + virtual void DoDraw(); + + virtual void DoMouseMove(int x, int y, int dx, int dy); + virtual void DoMouseDown(int x, int y, unsigned button); + virtual void DoMouseUp(int x, int y, unsigned button); + virtual void DoMouseWheel(int x, int y, int d); +};*/ +} +#endif // WINDOW_H |
