Merge branch '138-toggle-free-look-with-hotkey' into main/gingo-test
[ryzomcore.git] / ryzom / client / src / interfaces_manager / radio_button.cpp
blobabace5f02af9c997f4232b4f613d01c577b7d10c
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 #include "stdpch.h"
21 // Misc
22 #include "nel/misc/debug.h"
23 // Client
24 #include "radio_button.h"
25 #include "radio_controller.h"
26 #include "interfaces_manager.h"
30 ///////////////
31 // Functions //
32 ///////////////
34 //-----------------------------------------------
35 // CRadioButton :
36 // Default Constructor.
37 //-----------------------------------------------
38 CRadioButton::CRadioButton(uint id)
39 : CButton(id)
41 _Controller = NULL;
42 }// CRadioButton //
44 //-----------------------------------------------
45 // CRadioButton :
46 // Constructor.
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)
51 _Controller = NULL;
52 }// CRadioButton //
54 //-----------------------------------------------
55 // CRadioButton :
56 // Constructor.
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)
61 _Controller = NULL;
62 }// CRadioButton //
66 //-----------------------------------------------
67 // radioClick :
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) )
80 select();
81 _State = double_clicked;
82 CInterfMngr::runFuncCtrl(_NumFuncDbleClick, id());
83 taken = true;
85 else if (_NumFuncOn != 0)
87 select();
88 _State = left_clicked;
89 CInterfMngr::runFuncCtrl(_NumFuncOn, id());
90 taken = true;
94 }// radioClick //
97 //-----------------------------------------------
98 // click :
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);
108 }// click //
110 //-----------------------------------------------
111 // setController :
112 //-----------------------------------------------
113 void CRadioButton::setController(CRadioController *controller)
115 nlassert( controller );
116 _Controller = controller;
117 }// setController //
120 //-----------------------------------------------
121 // select :
122 //-----------------------------------------------
123 void CRadioButton::select()
125 if( _Controller )
127 _Controller->unselectAll();
130 CButton::select();
131 }// select //