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"
28 #include "nel/misc/ucstring.h"
31 #include "button_base.h"
43 * Manages "Button" control in Interface.
44 * \author Guillaume PUZIN
45 * \author Nevrax France
48 class CButton
: public CControl
, public CButtonBase
53 released
, // unselected
54 left_clicked
, // selected with a single click with the left mouse button
55 right_clicked
, // selected with a single click with the right mouse button
56 double_clicked
, // selected with a double click with the left mouse button
60 /// Initialize the button (1 function called for all constructors -> easier).
61 inline void init(uint numFuncOn
, uint numFuncR
, uint numFuncD
);
64 /// Text of the button.
66 /// Pen used to display the text.
69 /// function called with a left click on the button
72 /// function called with a right click on the button
73 uint _NumFuncRightClick
;
75 /// function called with a double (left) click on the button
76 uint _NumFuncDbleClick
;
78 /// state of the button
84 explicit CButton(uint id
, float x
, float y
, float x_pixel
, float y_pixel
, float w
, float h
, float w_pixel
, float h_pixel
, uint numFuncOn
, uint numFuncR
, uint numFuncD
, const CButtonBase
&buttonBase
);
85 explicit CButton(uint id
, float x
, float y
, float x_pixel
, float y_pixel
, float w
, float h
, float w_pixel
, float h_pixel
, uint numFuncOn
, uint numFuncR
, uint numFuncD
, CRGBA on
, CRGBA off
, CRGBA disable
);
87 /// Set the Pen to use for the Text of the button.
88 void pen(const CPen
&pen
);
90 /// unSelect the button.
91 virtual void unSelect();
93 /// Display the Bitmap.
94 virtual void display();
96 /// Manage the click of the mouse for the Button.
97 virtual void click(float x
, float y
, bool &taken
);
99 /// Manage the right click of the mouse for the Button.
100 virtual void clickRight(float x
, float y
, bool &taken
);
102 /// get the state of the button (clicked, released (unselected), etc...)
103 TState
getState() const { return _State
; }
106 * set the text displayed in the button.
107 * \param text : the new text to display.
109 void text(const ucstring
&text
) { _Text
= text
; }
112 * get the text displayed in the button
113 * \return cont ucstring& : the text displayed by the button.
115 const ucstring
&text() const { return _Text
; }
119 #endif // CL_BUTTON_H
121 /* End of button.h */