1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
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.
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/>.
27 #include "nel/misc/types_nl.h"
39 * basis class for all controls in interface.
40 * \author Guillaume PUZIN
41 * \author Nevrax France
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
);
71 typedef std::list
<CControl
*> TListControl
;
72 TListControl _Children
;
77 /// Position of the Control (between 0-1).
80 /// Position of the Control (in Pixel).
83 /// Display Position of the Control (between 0-1).
86 /// The control position is relative to this Reference.
89 /// Delta to add to the position because of the Hot Spot.
93 /// Width and Height (between 0-1).
96 /// Width and Height (in pixel).
99 /// Display Width and Height of the Control (between 0-1).
102 /// Reference Size (the OSD size).
106 /// Do the control have to be displayed. true -> yes.
108 /// How to display the control in relation to the position of the control.
110 /// Useful for the Parent to know what reference position to give to the control.
112 /// Pointer on the 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
);
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
);
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.
174 /// Return the Hot Spot.
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 */