Linux multi-monitor fullscreen support
[ryzomcore.git] / nel / src / gui / group_wheel.cpp
blob3c191053e5f1cb420cc69036b26e000840f858ac
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
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>
7 //
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/>.
22 #include "stdpch.h"
23 #include "nel/gui/group_wheel.h"
25 #ifdef DEBUG_NEW
26 #define new DEBUG_NEW
27 #endif
29 NLMISC_REGISTER_OBJECT(CViewBase, CInterfaceGroupWheel, std::string, "group_wheel");
31 namespace NLGUI
34 void force_link_group_wheel_cpp() { }
36 // *****************************************************************************************************************
37 CInterfaceGroupWheel::CInterfaceGroupWheel(const TCtorParam &param) : CInterfaceGroup(param)
39 _AHWheelUp = NULL;
40 _AHWheelDown = NULL;
43 std::string CInterfaceGroupWheel::getProperty( const std::string &name ) const
45 if( name == "on_wheel_up" )
47 return getAHString( name );
49 else
50 if( name == "on_wheel_up_params" )
52 return _AHWheelUpParams;
54 else
55 if( name == "on_wheel_down" )
57 return getAHString( name );
59 else
60 if( name == "on_wheel_down_params" )
62 return _AHWheelDownParams;
64 else
65 return CInterfaceGroup::getProperty( name );
68 void CInterfaceGroupWheel::setProperty( const std::string &name, const std::string &value )
70 if( name == "on_wheel_up" )
72 std::string dummy;
73 _AHWheelUp = CAHManager::getInstance()->getAH( value, dummy );
74 mapAHString( name, value );
75 return;
77 else
78 if( name == "on_wheel_up_params" )
80 _AHWheelUpParams = value;
81 return;
83 else
84 if( name == "on_wheel_down" )
86 std::string dummy;
87 _AHWheelDown = CAHManager::getInstance()->getAH( value, dummy );
88 mapAHString( name, value );
89 return;
91 else
92 if( name == "on_wheel_down_params" )
94 _AHWheelDownParams = value;
95 return;
97 else
98 CInterfaceGroup::setProperty( name, value );
102 xmlNodePtr CInterfaceGroupWheel::serialize( xmlNodePtr parentNode, const char *type ) const
104 xmlNodePtr node = CInterfaceGroup::serialize( parentNode, type );
105 if( node == NULL )
106 return NULL;
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() );
118 return node;
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);
128 if( editorMode )
130 CXMLAutoPtr ptr( (char*) xmlGetProp( cur, BAD_CAST "on_wheel_up" ) );
131 if( ptr )
132 mapAHString( "on_wheel_up", std::string( (const char*)ptr ) );
134 ptr = (char*) xmlGetProp( cur, BAD_CAST "on_wheel_down" );
135 if( ptr )
136 mapAHString( "on_wheel_down", std::string( (const char*)ptr ) );
140 return true;
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);
155 return true;
157 else if (_AHWheelDown)
159 CAHManager::getInstance()->runActionHandler (_AHWheelDown, this, _AHWheelDownParams);
160 return true;
164 return false;