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/>.
22 #include "nel/misc/debug.h"
24 #include "radio_button.h"
25 #include "radio_controller.h"
26 #include "interfaces_manager.h"
34 //-----------------------------------------------
36 // Default Constructor.
37 //-----------------------------------------------
38 CRadioButton::CRadioButton(uint id
)
44 //-----------------------------------------------
47 //-----------------------------------------------
48 CRadioButton::CRadioButton(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
)
49 : CButton(id
, x
, y
, x_pixel
, y_pixel
, w
, h
, w_pixel
, h_pixel
, numFuncOn
, numFuncR
, numFuncD
, buttonBase
)
54 //-----------------------------------------------
57 //-----------------------------------------------
58 CRadioButton::CRadioButton(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
)
59 : CButton(id
, x
, y
, x_pixel
, y_pixel
, w
, h
, w_pixel
, h_pixel
, numFuncOn
, numFuncR
, numFuncD
, on
, off
, disable
)
66 //-----------------------------------------------
68 //-----------------------------------------------
69 void CRadioButton::radioClick(float x
, float y
, bool &taken
)
71 // If the button is enabled and taken is false
72 if(_Enable
&& (!taken
) )
74 // test click coordinates
75 if(x
>=_X_Display
&& x
<=(_X_Display
+_W_Display
) && y
>=_Y_Display
&& y
<=(_Y_Display
+_H_Display
))
77 // TO DO : SIMULATE DOUBLE CLICK !!!!!!! SHOULD MAKE A REAL DOUBLE CLICK EVENT
78 if ( (_State
== left_clicked
) && (_NumFuncDbleClick
!= 0) )
81 _State
= double_clicked
;
82 CInterfMngr::runFuncCtrl(_NumFuncDbleClick
, id());
85 else if (_NumFuncOn
!= 0)
88 _State
= left_clicked
;
89 CInterfMngr::runFuncCtrl(_NumFuncOn
, id());
97 //-----------------------------------------------
99 //-----------------------------------------------
100 void CRadioButton::click(float x
, float y
, bool &taken
)
102 // if this button is controlled by a radio controller, do nothing,
103 // if it's not controlled, call radioClick
104 if ( _Controller
== NULL
)
106 radioClick(x
,y
,taken
);
110 //-----------------------------------------------
112 //-----------------------------------------------
113 void CRadioButton::setController(CRadioController
*controller
)
115 nlassert( controller
);
116 _Controller
= controller
;
120 //-----------------------------------------------
122 //-----------------------------------------------
123 void CRadioButton::select()
127 _Controller
->unselectAll();