2012-01-17 14:46:06 -06:00
|
|
|
#ifndef WINDOW_H
|
|
|
|
#define WINDOW_H
|
2012-01-08 11:39:03 -06:00
|
|
|
|
|
|
|
#include <vector>
|
2012-01-17 14:46:06 -06:00
|
|
|
#include "interface/Point.h"
|
2012-01-14 12:51:24 -06:00
|
|
|
#include "Engine.h"
|
2012-01-08 11:39:03 -06:00
|
|
|
|
2012-01-14 12:51:24 -06:00
|
|
|
namespace ui
|
2012-01-08 11:39:03 -06:00
|
|
|
{
|
2012-01-17 14:46:06 -06:00
|
|
|
|
|
|
|
enum ChromeStyle
|
|
|
|
{
|
|
|
|
None, Title, Resizable
|
|
|
|
};
|
|
|
|
//class State;
|
2012-01-14 12:51:24 -06:00
|
|
|
class Engine;
|
|
|
|
class Component;
|
2012-01-17 14:46:06 -06:00
|
|
|
|
2012-01-14 12:51:24 -06:00
|
|
|
/* class State
|
2012-01-17 14:46:06 -06:00
|
|
|
*
|
2012-01-14 12:51:24 -06:00
|
|
|
* A UI state. Contains all components.
|
|
|
|
*/
|
2012-01-17 14:46:06 -06:00
|
|
|
class Window
|
2012-01-14 12:51:24 -06:00
|
|
|
{
|
|
|
|
public:
|
2012-01-21 16:48:37 -06:00
|
|
|
Point Position;
|
|
|
|
Point Size;
|
|
|
|
|
2012-01-17 14:46:06 -06:00
|
|
|
Window(Point _position, Point _size);
|
|
|
|
virtual ~Window();
|
2012-01-14 12:51:24 -06:00
|
|
|
|
|
|
|
bool AllowExclusiveDrawing; //false will not call draw on objects outside of bounds
|
|
|
|
|
|
|
|
// Add Component to state
|
|
|
|
void AddComponent(Component* c);
|
2012-01-17 14:46:06 -06:00
|
|
|
|
2012-01-14 12:51:24 -06:00
|
|
|
// Get the number of components this state has.
|
|
|
|
unsigned GetComponentCount();
|
2012-01-17 14:46:06 -06:00
|
|
|
|
2012-01-14 12:51:24 -06:00
|
|
|
// Get component by index. (See GetComponentCount())
|
|
|
|
Component* GetComponent(unsigned idx);
|
2012-01-17 14:46:06 -06:00
|
|
|
|
2012-01-14 12:51:24 -06:00
|
|
|
// Remove a component from state. NOTE: This DOES NOT free component from memory.
|
|
|
|
void RemoveComponent(Component* c);
|
2012-01-17 14:46:06 -06:00
|
|
|
|
2012-01-14 12:51:24 -06:00
|
|
|
// Remove a component from state. NOTE: This WILL free component from memory.
|
|
|
|
void RemoveComponent(unsigned idx);
|
2012-01-17 14:46:06 -06:00
|
|
|
|
2012-07-18 14:34:58 -05:00
|
|
|
virtual void ToolTip(Component * sender, ui::Point mousePosition, std::string toolTip) {}
|
|
|
|
|
2012-01-17 14:46:06 -06:00
|
|
|
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);
|
2012-01-29 18:40:28 -06:00
|
|
|
virtual void DoKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
|
|
|
|
virtual void DoKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
|
2012-01-14 12:51:24 -06:00
|
|
|
|
2012-04-09 06:40:30 -05:00
|
|
|
//Sets halt and destroy, this causes the Windows to stop sending events and remove itself.
|
|
|
|
void SelfDestruct();
|
|
|
|
|
2012-01-14 12:51:24 -06:00
|
|
|
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) {}
|
2012-01-29 18:40:28 -06:00
|
|
|
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt) {}
|
|
|
|
virtual void OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt) {}
|
2012-01-14 12:51:24 -06:00
|
|
|
std::vector<Component*> Components;
|
|
|
|
Component* focusedComponent_;
|
2012-01-17 14:46:06 -06:00
|
|
|
ChromeStyle chrome;
|
|
|
|
|
2012-04-09 06:40:30 -05:00
|
|
|
//These controls allow a component to call the destruction of the Window inside an event (called by the Window)
|
|
|
|
void finalise();
|
|
|
|
bool halt;
|
|
|
|
bool destruct;
|
2012-05-13 11:43:41 -05:00
|
|
|
#ifdef DEBUG
|
|
|
|
bool debugMode;
|
|
|
|
#endif
|
2012-04-09 06:40:30 -05:00
|
|
|
|
2012-01-14 12:51:24 -06:00
|
|
|
};
|
|
|
|
|
2012-01-17 14:46:06 -06:00
|
|
|
|
|
|
|
/*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);
|
|
|
|
};*/
|
2012-01-14 12:51:24 -06:00
|
|
|
}
|
2012-01-17 14:46:06 -06:00
|
|
|
#endif // WINDOW_H
|