- Your Widget Set For OpenGL
Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | Related Pages

umousewheelevent.hpp

00001 /*************************************************************************** 00002 LibUFO - UI For OpenGL 00003 copyright : (C) 2001-2005 by Johannes Schmidt 00004 email : schmidtjf at users.sourceforge.net 00005 ------------------- 00006 00007 file : include/ufo/events/umousewheelevent.hpp 00008 begin : Sun Jul 21 2002 00009 $Id: umousewheelevent.hpp,v 1.8 2005/05/21 15:17:23 schmidtjf Exp $ 00010 ***************************************************************************/ 00011 00012 /*************************************************************************** 00013 * This library is free software; you can redistribute it and/or * 00014 * modify it under the terms of the GNU Lesser General Public * 00015 * License as published by the Free Software Foundation; either * 00016 * version 2.1 of the License, or (at your option) any later version. * 00017 * * 00018 * This library is distributed in the hope that it will be useful, * 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00021 * Lesser General Public License for more details. * 00022 * * 00023 * You should have received a copy of the GNU Lesser General Public * 00024 * License along with this library; if not, write to the Free Software * 00025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 00026 ***************************************************************************/ 00027 00028 #ifndef UMOUSEWHEELEVENT_HPP 00029 #define UMOUSEWHEELEVENT_HPP 00030 00031 #include "uinputevent.hpp" 00032 00033 #include "../util/upoint.hpp" 00034 00035 namespace ufo { 00036 00043 class UFO_EXPORT UMouseWheelEvent : public UInputEvent { 00044 UFO_DECLARE_DYNAMIC_CLASS(UMouseWheelEvent) 00045 public: // Public types 00046 enum { 00047 WHEEL_DATA = 120 00048 }; 00049 public: 00062 UMouseWheelEvent( 00063 UWidget * source, 00064 Type type, 00065 UMod_t modifiersA, 00066 const UPoint & pos, 00067 const UPoint & root, 00068 int delta, 00069 int wheel); 00070 00071 UMouseWheelEvent( 00072 UWidget * source, 00073 Type type, 00074 UMod_t modifiersA, 00075 const UPoint & pos, 00076 int delta, 00077 int wheel); 00078 00079 // 00080 // similar to mouse events 00081 // 00082 00083 const UPoint & getLocation() const; 00084 const UPoint & getRootLocation() const; 00085 00087 int getX() const; 00089 int getY() const; 00090 00092 int getRootX() const; 00094 int getRootY() const; 00095 00097 void translate(const UPoint & pos); 00098 00099 // 00100 // new methods 00101 // 00102 00103 int getWheel() const; 00104 00108 int getDelta() const; 00109 00116 int getWheelRotation() const; 00117 00118 protected: // Protected methods 00119 virtual std::ostream & paramString(std::ostream & os) const; 00120 00121 private: // Private attributes 00122 UPoint m_pos; 00123 UPoint m_root; 00124 00125 int m_delta; 00126 int m_wheel; 00127 }; 00128 00129 00130 // 00131 // inline implementation 00132 // 00133 00134 00135 inline 00136 UMouseWheelEvent::UMouseWheelEvent( 00137 UWidget * source, 00138 Type type, 00139 UMod_t modifiersA, 00140 const UPoint & pos, 00141 const UPoint & root, 00142 int delta, 00143 int wheel) 00144 : UInputEvent(source, type, modifiersA) 00145 , m_pos(pos) 00146 , m_root(root) 00147 , m_delta(delta) 00148 , m_wheel(wheel) {} 00149 00150 inline 00151 UMouseWheelEvent::UMouseWheelEvent( 00152 UWidget * source, 00153 Type type, 00154 UMod_t modifiersA, 00155 const UPoint & pos, 00156 int delta, 00157 int wheel) 00158 : UInputEvent(source, type, modifiersA) 00159 , m_pos(pos) 00160 , m_root(pos) 00161 , m_delta(delta) 00162 , m_wheel(wheel) {} 00163 00164 00165 inline const UPoint & 00166 UMouseWheelEvent::getLocation() const { 00167 return m_pos; 00168 } 00169 00170 inline const UPoint & 00171 UMouseWheelEvent::getRootLocation() const { 00172 return m_root; 00173 } 00174 00175 inline int 00176 UMouseWheelEvent::getX() const { 00177 return m_pos.x; 00178 } 00179 00180 inline int 00181 UMouseWheelEvent::getY() const { 00182 return m_pos.y; 00183 } 00184 00185 inline int 00186 UMouseWheelEvent::getRootX() const { 00187 return m_root.x; 00188 } 00189 00190 inline int 00191 UMouseWheelEvent::getRootY() const { 00192 return m_root.y; 00193 } 00194 00195 inline void 00196 UMouseWheelEvent::translate(const UPoint & pos) { 00197 m_pos.translate(pos); 00198 m_root.translate(pos); 00199 } 00200 00201 inline int 00202 UMouseWheelEvent::getWheel() const { 00203 return m_wheel; 00204 } 00205 inline int 00206 UMouseWheelEvent::getDelta() const { 00207 return m_delta; 00208 } 00209 00210 inline int 00211 UMouseWheelEvent::getWheelRotation() const { 00212 return m_delta / WHEEL_DATA; 00213 } 00214 00215 } // namespace ufo 00216 00217 #endif // UMOUSEWHEELEVENT_HPP

The libUFO Project - written by Johannes Schmidt