1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
6 // Copyright (C) 2014 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU Affero General Public License as
10 // published by the Free Software Foundation, either version 3 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU Affero General Public License for more details.
18 // You should have received a copy of the GNU Affero General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "nel/gui/group_wheel.h"
29 NLMISC_REGISTER_OBJECT(CViewBase
, CInterfaceGroupWheel
, std::string
, "group_wheel");
34 void force_link_group_wheel_cpp() { }
36 // *****************************************************************************************************************
37 CInterfaceGroupWheel::CInterfaceGroupWheel(const TCtorParam
¶m
) : CInterfaceGroup(param
)
43 std::string
CInterfaceGroupWheel::getProperty( const std::string
&name
) const
45 if( name
== "on_wheel_up" )
47 return getAHString( name
);
50 if( name
== "on_wheel_up_params" )
52 return _AHWheelUpParams
;
55 if( name
== "on_wheel_down" )
57 return getAHString( name
);
60 if( name
== "on_wheel_down_params" )
62 return _AHWheelDownParams
;
65 return CInterfaceGroup::getProperty( name
);
68 void CInterfaceGroupWheel::setProperty( const std::string
&name
, const std::string
&value
)
70 if( name
== "on_wheel_up" )
73 _AHWheelUp
= CAHManager::getInstance()->getAH( value
, dummy
);
74 mapAHString( name
, value
);
78 if( name
== "on_wheel_up_params" )
80 _AHWheelUpParams
= value
;
84 if( name
== "on_wheel_down" )
87 _AHWheelDown
= CAHManager::getInstance()->getAH( value
, dummy
);
88 mapAHString( name
, value
);
92 if( name
== "on_wheel_down_params" )
94 _AHWheelDownParams
= value
;
98 CInterfaceGroup::setProperty( name
, value
);
102 xmlNodePtr
CInterfaceGroupWheel::serialize( xmlNodePtr parentNode
, const char *type
) const
104 xmlNodePtr node
= CInterfaceGroup::serialize( parentNode
, type
);
108 xmlSetProp( node
, BAD_CAST
"type", BAD_CAST
"group_wheel" );
110 xmlSetProp( node
, BAD_CAST
"on_wheel_up", BAD_CAST
getAHString( "on_wheel_up" ).c_str() );
112 xmlSetProp( node
, BAD_CAST
"on_wheel_up_params", BAD_CAST _AHWheelUpParams
.toString().c_str() );
114 xmlSetProp( node
, BAD_CAST
"on_wheel_down", BAD_CAST
getAHString( "on_wheel_down" ).c_str() );
116 xmlSetProp( node
, BAD_CAST
"on_wheel_down_params", BAD_CAST _AHWheelDownParams
.toString().c_str() );
121 // *****************************************************************************************************************
122 bool CInterfaceGroupWheel::parse(xmlNodePtr cur
, CInterfaceGroup
* parentGroup
)
124 if (!CInterfaceGroup::parse(cur
, parentGroup
)) return false;
125 CAHManager::getInstance()->parseAH(cur
, "on_wheel_up", "on_wheel_up_params", _AHWheelUp
, _AHWheelUpParams
);
126 CAHManager::getInstance()->parseAH(cur
, "on_wheel_down", "on_wheel_down_params", _AHWheelDown
, _AHWheelDownParams
);
130 CXMLAutoPtr
ptr( (char*) xmlGetProp( cur
, BAD_CAST
"on_wheel_up" ) );
132 mapAHString( "on_wheel_up", std::string( (const char*)ptr
) );
134 ptr
= (char*) xmlGetProp( cur
, BAD_CAST
"on_wheel_down" );
136 mapAHString( "on_wheel_down", std::string( (const char*)ptr
) );
143 // *****************************************************************************************************************
144 bool CInterfaceGroupWheel::handleEvent(const NLGUI::CEventDescriptor
&event
)
146 if (CInterfaceGroup::handleEvent(event
)) return true;
147 if (event
.getType() == NLGUI::CEventDescriptor::mouse
)
149 const NLGUI::CEventDescriptorMouse
&eventDesc
= (const NLGUI::CEventDescriptorMouse
&)event
;
150 if (eventDesc
.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel
)
152 if (eventDesc
.getWheel() > 0 && _AHWheelUp
)
154 CAHManager::getInstance()->runActionHandler (_AHWheelUp
, this, _AHWheelUpParams
);
157 else if (_AHWheelDown
)
159 CAHManager::getInstance()->runActionHandler (_AHWheelDown
, this, _AHWheelDownParams
);