Resolve "Toggle Free Look with Hotkey"
[ryzomcore.git] / ryzom / client / src / interfaces_manager / control.h
blob0772e4c777f5352b88ae3b72b756de4f134a7f94
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef CL_CONTROL_H
20 #define CL_CONTROL_H
23 /////////////
24 // Include //
25 /////////////
26 // Misc
27 #include "nel/misc/types_nl.h"
28 // Std
29 #include <list>
32 ///////////
33 // Using //
34 ///////////
35 //using std::list;
38 /**
39 * basis class for all controls in interface.
40 * \author Guillaume PUZIN
41 * \author Nevrax France
42 * \date 2001
44 class CControl
46 private:
47 /// Initialize the control (1 function called for all constructors -> easier).
48 void init(uint id, float x, float y, float x_pixel, float y_pixel, float w, float h, float w_pixel, float h_pixel);
50 public:
51 enum THotSpot
53 HS_TL = 0,
54 HS_TM,
55 HS_TR,
56 HS_ML,
57 HS_MM,
58 HS_MR,
59 HS_BL,
60 HS_BM,
61 HS_BR
64 enum TMode
66 Mode_0_1 = 0,
67 Mode_Pixel
70 protected:
71 typedef std::list<CControl *> TListControl;
72 TListControl _Children;
74 // Id of the control.
75 uint _Id;
77 /// Position of the Control (between 0-1).
78 float _X;
79 float _Y;
80 /// Position of the Control (in Pixel).
81 float _X_Pixel;
82 float _Y_Pixel;
83 /// Display Position of the Control (between 0-1).
84 float _X_Display;
85 float _Y_Display;
86 /// The control position is relative to this Reference.
87 float _X_Ref;
88 float _Y_Ref;
89 /// Delta to add to the position because of the Hot Spot.
90 float _X_HotSpot;
91 float _Y_HotSpot;
93 /// Width and Height (between 0-1).
94 float _W;
95 float _H;
96 /// Width and Height (in pixel).
97 float _W_Pixel;
98 float _H_Pixel;
99 /// Display Width and Height of the Control (between 0-1).
100 float _W_Display;
101 float _H_Display;
102 /// Reference Size (the OSD size).
103 float _W_Ref;
104 float _H_Ref;
106 /// Do the control have to be displayed. true -> yes.
107 bool _Show;
108 /// How to display the control in relation to the position of the control.
109 THotSpot _HotSpot;
110 /// Useful for the Parent to know what reference position to give to the control.
111 THotSpot _Origin;
112 /// Pointer on the Parent.
113 CControl *_Parent;
115 /// Calculate the Display X, Y, Width, Height.
116 virtual void calculateDisplay();
117 /// Calculate the display position of the control in relation to the position of the control (Hot Spot).
118 virtual void calculateHS();
119 /// Function to calculate where to display a child.
120 void calculateOrigin(float &x, float &y, THotSpot origin);
122 public:
123 /// Constructor
124 CControl(uint id = 0);
125 CControl(uint id, float x, float y, float x_pixel, float y_pixel, float w, float h, float w_pixel, float h_pixel);
126 virtual ~CControl(){}
128 /// get the display values of the control
129 void getDisplayValues( float &x, float &y, float &h, float &w) const;
131 /// get the size of the control
132 void getSize( float &w, float &h, float &wPixel, float &hPixel) const;
134 /// get the position of the control
135 void getPosition( float &x, float &y, float &xPixel, float &yPixel) const;
137 /// set the size of the control
138 void setSize( float w, float h, float wPixel, float hPixel);
140 /// set the position of the control
141 void setPosition( float x, float y, float xPixel, float yPixel);
144 /// Display the control.
145 virtual void display() = 0;
147 /// Manage the click for the control.
148 virtual void click(float x, float y, bool &taken);
150 /// Manage the right click for the control.
151 virtual void clickRight(float x, float y, bool &taken);
153 /// The window size has changed -> resize the control.
154 virtual void resize(uint32 width, uint32 height);
156 /// Set some references for the display.
157 virtual void ref(float x, float y, float w, float h);
159 /// Hide or show the control. false -> hide, true -> show.
160 virtual void show(bool show);
162 /// Change the Hot Spot.
163 virtual void hotSpot(THotSpot hs);
165 /// Set Origin.
166 virtual void origin(THotSpot o) {_Origin = o;}
168 /// Set the parent of the control.
169 virtual void parent(CControl *p) {_Parent = p;}
171 /// Return the show of the control.
172 bool show();
174 /// Return the Hot Spot.
175 THotSpot hotSpot();
177 /// Get Origin.
178 THotSpot origin() {return _Origin;}
180 /// Get the parent of the control
181 CControl *parent() {return _Parent;}
183 /// Add a child to the control.
184 void addChild(CControl *ctrl);
187 * called when the mouse has moved
188 * \param the x coordinate of the mouse
189 * \param the y coordinate of the mouse
191 virtual void mouseMove( float x, float y);
194 * Get the Id of the control.
195 * \return uint : control Id.
197 inline uint id() const {return _Id;}
201 #endif // CL_CONTROL_H
203 /* End of control.h */