Labyrinth
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
window.hpp
1 //////////////////////////////
2 //
3 // File: lxs/windowing/window.hpp
4 // Author: Maciej Kaminski
5 // E-mail: maciej.a.kaminski@gmail.com
6 // Website: maciejkaminski.pl
7 //
8 // File creation date: Oct 24 2012
9 // This file is part of Project Labyrinth
10 // This file is going to be released under terms of GNU GPL in near future
11 //
12 //////////////////////////////
13 
14 #ifndef __LXS_WINDOW__
15 #define __LXS_WINDOW__
16 #include "lxs/coregraphics/renderable.hpp"
17 #include <vector>
18 #include<boost/shared_ptr.hpp>
19 namespace LxS
20 {
21  namespace Game
22  {
23  class GameObject;
24  class Character;
25  }
26  namespace CoreGraphics
27  {
28  class Renderable;
29  class R3DCamera;
30  }
31  namespace Windowing
32  {
33  //! window - or rather any kind of GUI object (very generic window)
35  {
36  friend class ContainerWindow;
37  private:
38  //! in cm
39  float width;//cm
40  //! in cm
41  float height;//cm
42  //! in cm from left
43  float x;//from left
44  //! in cm from bottom
45  float y;//from bottom
46  //! parent window
47  Window * parent;
48  public:
49  //using LxS::Renderable::Rendermode
50  //!recursive GetParent;
51  Window * GetRoot() ;
52  //!Return parent window
53  Window * GetParent() {return parent;}
54  //! attach child
55  virtual void AttachChild(Window * child){}
56  //! detach particular child
57  virtual void DetachChild(Window * child){}
58  //! replace child. new is emplaced at position right before old one
59  virtual void ReplaceChild(Window * old_child, Window * new_child){}
60  //! for autosave routine or else
61  virtual void SaveFile(){}//autosave or else
62  protected:
63  //! \brief replace reference to this in parent window for a new window
64  //! does not delete this from main memory - only swaps pointer in parent window
65  void ReplaceSelf(Window * replacement)
66  { GetParent()->ReplaceChild(this,replacement);}
67  public:
68  //! default constructor
69  Window();
70  virtual ~Window();
71  //! return position x (from bottom left corner)
72  float GetX() {return x;}
73  //! return position y (from bottom left corner)
74  float GetY() {return y;}
75  //! return height of the window
76  float GetWidth() {return width;}
77  //! return width of the window
78  float GetHeight() {return height;}
79  //! set position x (from bottom left corner)
80  virtual float SetX (float f);
81 
82  //! set position y (from bottom left corner)
83  virtual float SetY (float f);
84  //! set width of the window
85  virtual float SetWidth(float f);
86  //! set height of the window
87  virtual float SetHeight(float f);
88  //! set width and height of the window
89  virtual void SetWH(float w, float h);
90  //! set position - both coords (from bottom left corner)
91  virtual void SetYX(float y, float x);
92 
93  //! axis-numbering: 0-1, left analog X-Y; 2-3, right analog
94  //! 4-7 - nothing; 8 d-pad up; 9 dpad right; 10 dpad down; 11 dpad left
95  //! 12 - l2, 13-r2, 14- l1, 15 - r1
96  //! 16 - triangle, 17 - circle, 18 - cross, 19 - square; 20 - nothing
97  virtual void JoystickAxes(int Axis, const float *direction) {}
98  //! set pointer to parent window
99  virtual void SetParent(Window * _parent){parent=_parent;}
100  //! maximize
101  virtual void Maximize();
102  //! rearrange after movement
103  virtual void MovementHandler() {}
104  //! rearrange after resizing
105  virtual void ResizeHandler() {}
106  //! rendering routine of a window
107  virtual void Render(Renderable::Rendermode mode);
108  //! some windows are animated
109  virtual void Animate(float dt);
110  //! load resources, prepare to display
111  virtual void Initialize();
112  //! free resources to save some space
113  virtual void UnloadResources();
114  //! window was pressed and released; coordinates from left-bottom corner
115  //! of the window
116  virtual void Released(float x, float y);
117  //! window was clicked; coordinates from left-bottom corner
118  //! of the window
119  virtual void Clicked(float x, float y);
120  //! object within window is dragged; coordinates from left-bottom corner
121  //! of the window
122  virtual void Dragged(float x, float y);
123  //! as degrees given current camera angle!
124  virtual void DraggedAngle(float x, float y);
125  //! menu button - on android phone (no such button on iphone)
126  virtual void MenuButtonPressed() {}
127  //! back button - on android phone (no such button on iphone)
128  virtual void BackButtonPressed() {}
129  unsigned long GetTexelsCount();
130  unsigned long GetFacesCount();
131  //! rearrange
132  virtual void Refresh(){}
133  //! window appears
134  virtual void OnFocus(){Refresh();}
135  };
136  }
137 }
138 #endif