Resolve "Toggle Free Look with Hotkey"
[ryzomcore.git] / ryzom / client / src / interfaces_manager / spell_control.h
blob4451d644356d75959b7fa4bc52de9af18003ef28
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 NL_SPELL_CONTROL_H
20 #define NL_SPELL_CONTROL_H
23 /////////////
24 // Include //
25 /////////////
26 // Misc
27 #include "nel/misc/types_nl.h"
28 #include "nel/misc/debug.h"
30 // Client
31 #include "control.h"
32 #include "bitmap.h"
33 #include "spell_client.h"
34 #include "pen.h"
35 #include "button.h"
36 #include "text.h"
40 /**
41 * define the control used to display spells in control list objects
42 * \author David Fleury
43 * \author Nevrax France
44 * \date 2001
46 class CSpellControl : public CControl
48 public:
50 /// Constructor
51 explicit CSpellControl(uint id, float x, float y, float x_pixel, float y_pixel, float w, float h, float w_pixel, float h_pixel,
52 uint16 spacing, const CPen &pen1, const CPen &pen2);
54 /// Constructor
55 explicit CSpellControl(uint id, float x, float y, float x_pixel, float y_pixel, float w, float h, float w_pixel, float h_pixel,
56 uint16 spacing, uint32 fontSize1, const CRGBA &color1, bool shadow1, uint32 fontSize2, const CRGBA &color2, bool shadow2);
58 /// destuctor
59 ~CSpellControl();
61 /// display the control
62 virtual void display();
64 /// Manage the click for the control.
65 virtual void click(float x, float y, bool &taken);
67 /// Manage the right click for the control.
68 virtual void clickRight(float x, float y, bool &taken);
70 /**
71 * set the spell pointed by this control
72 * \param CSpellClient *spell
74 void setSpell( CSpellClient *spell)
76 //nlassert( spell );
77 if (!spell)
79 nlwarning("<CSpellControl::setSpell> : spell in param is NULL, abort");
80 return;
83 _Spell = spell ;
84 _SpellText.text(spell->getPhrase());
85 _Comment.text( spell->getComment() );
87 TBrickList::iterator it = spell->getBricks().begin();
89 if (it != spell->getBricks().end() )
91 nlassert( *it );
92 CBrickClient *brick = (*it);
93 _RootIcon.texture( brick->getTexture() );
97 /**
98 * get the spell pointed by this control
99 * \return CSpellClient *spell
101 CSpellClient *getSpell() { return _Spell; }
105 * set the size of the selection button
106 * \param float wPixel the new width (in pixels) of the button
107 * \param float hPixel the new height (in pixels) of the button
109 void setButtonSize(float wPixel, float hPixel)
111 _Button.setSize(0,0,wPixel,hPixel);
112 _RootIcon.setSize(0,0,wPixel,hPixel);
116 /// \name set the textures, color and BGMode for the selection button
117 // @{
119 * set the texture when 'on'
120 * \param uint tOn new texture when the button is selected
122 void setButtonTextureOn( uint tOn) { _Button.textureOn( tOn ); }
124 * set the texture when 'off'
125 * \param uint tOff new texture when the button is unselected
127 void setButtonTextureOff( uint tOff) { _Button.textureOff( tOff ); }
129 * set the texture when 'disabled'
130 * \param uint tDis new texture when the button is disabled
132 void setButtonTextureDisable( uint tDis) { _Button.textureDisable( tDis ); }
134 * set the color when 'on'
135 * \param CRGBA& color new color when the button is selected
137 void setButtonColorOn( const CRGBA &color) { _Button.colorOn( color ); }
139 * set the color when 'off'
140 * \param CRGBA& color new color when the button is unselected
142 void setButtonColorOff(const CRGBA &color) { _Button.colorOff( color ); }
144 * set the color when 'disabled'
145 * \param CRGBA& color new color when the button is disabled
147 void setButtonColorDisable(const CRGBA &color) { _Button.colorDisable( color ); }
150 * set the color when 'on'
151 * \param CRGBA& color new color when the button is selected
153 void setButtonBGModeOn( const CButtonBase::TBG &mode) { _Button.bgModeOn( mode ); }
155 * set the color when 'off'
156 * \param CRGBA& color new color when the button is unselected
158 void setButtonBGModeOff(const CButtonBase::TBG &mode) { _Button.bgModeOff( mode ); }
160 * set the color when 'disabled'
161 * \param CRGBA& color new color when the button is disabled
163 void setButtonBGModeDisable(const CButtonBase::TBG &mode) { _Button.bgModeDisable( mode ); }
164 //@}
166 /// \name text properties
167 // @{
168 /// get spell text
169 const CText &getSpellText() const { return _SpellText; }
171 /// set spell text pen
172 void setSpellTextPen( const CPen &pen)
174 _SpellText.fontSize( pen.fontSize());
175 _SpellText.color( pen.color());
176 _SpellText.shadow( pen.shadow());
179 /// get comment
180 const CText &getComment() const { return _Comment; }
181 /// set Comment pen
182 void setCommentPen( const CPen &pen)
184 _Comment.fontSize( pen.fontSize());
185 _Comment.color( pen.color());
186 _Comment.shadow( pen.shadow());
188 // @}
190 /// \name functions
191 // @{
192 /// set function called on left click on the control
193 void setLeftClickFunc( uint num) { _NumFuncOn = num; }
194 /// set function called on right click on the control
195 void setRightClickFunc( uint num) { _NumFuncRightClick = num; }
196 // @}
198 void ref(float x, float y, float w, float h);
202 * get the state of this control (slected or not)
203 * \return bool true of the control is selected, false otherwise
205 bool isSelected() const { return _Button.isSelected(); }
207 private:
208 /// Initialize the object (1 function called for all constructors -> easier).
209 inline void init( uint16 spacing, const CPen &spellPen, const CPen &commentPen);
211 /// init the root icon bitmap
212 // inline void initRootBitmap( CSpellClient *spell); // ????
214 private:
215 /// the spell pointed by this control
216 CSpellClient *_Spell;
218 /// the bitmap for the root brick of the spell
219 CBitm _RootIcon;
221 /// the selection button
222 CButton _Button;
224 /// the spell text
225 CText _SpellText;
227 /// the comment
228 CText _Comment;
230 /// function called with a left click on the control
231 uint _NumFuncOn;
233 /// function called with a right click on the control
234 uint _NumFuncRightClick;
236 /// spacing (in pixels)
237 uint16 _Spacing;
241 #endif // NL_SPELL_CONTROL_H
243 /* End of spell_control.h */