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

uxdisplay.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/ux/uxdisplay 00008 begin : Wed Jul 28 2004 00009 $Id: uxdisplay.hpp,v 1.6 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 UXDISPLAY_HPP 00029 #define UXDISPLAY_HPP 00030 00031 #include "../uabstractdisplay.hpp" 00032 00033 namespace ufo { 00034 00035 class UVideoDriver; 00036 class UXContext; 00037 class UXFrame; 00038 00053 class UFO_EXPORT UXDisplay : public UAbstractDisplay { 00054 UFO_DECLARE_DYNAMIC_CLASS(UXDisplay) 00055 public: 00056 friend class UXContext; 00057 public: 00062 UXDisplay(const std::string & videoDriver = ""); 00063 virtual ~UXDisplay(); 00064 00065 public: 00069 virtual bool isValid() const; 00074 virtual UVideoDriver * getVideoDriver() const; 00075 00082 virtual UXFrame * createFrame(); 00083 00085 virtual std::vector<UXFrame*> getFrames() const; 00086 00087 public: // Implements UDisplay 00088 virtual void pumpEvents(); 00089 virtual std::vector<UContext*> getContexts() const; 00090 00091 public: // general event push methods 00097 virtual void setModState(UMod_t modifiers); 00104 virtual void pushMouseButtonDown(UContext * context, 00105 int x, int y, UMod_t button); 00112 virtual void pushMouseButtonUp(UContext * context, 00113 int x, int y, UMod_t button); 00121 virtual void pushMouseWheelDown(UContext * context, 00122 int x, int y, int delta = -120, int mouseWheelNum = 0); 00130 virtual void pushMouseWheelUp(UContext * context, 00131 int x, int y, int delta = 120, int mouseWheelNum = 0); 00137 virtual void pushMouseMove(UContext * context, 00138 int x, int y); 00144 virtual void pushKeyDown(UContext * context, 00145 UKeyCode_t keyCode, wchar_t keyChar); 00151 virtual void pushKeyUp(UContext * context, 00152 UKeyCode_t keyCode, wchar_t keyChar); 00153 00155 void pushMouseButtonDown(UContext * context, UMod_t modifiers, 00156 int x, int y, UMod_t button) { 00157 pushMouseButtonDown(context, x, y, button); 00158 } 00159 void pushMouseButtonUp(UContext * context, UMod_t modifiers, 00160 int x, int y, UMod_t button) { 00161 pushMouseButtonUp(context, x, y, button); 00162 } 00163 void pushMouseWheelDown(UContext * context, UMod_t modifiers, 00164 int x, int y, int delta = -120, int mouseWheelNum = 0) { 00165 pushMouseWheelDown(context, x, y, delta, mouseWheelNum); 00166 } 00167 void pushMouseWheelUp(UContext * context, UMod_t modifiers, 00168 int x, int y, int delta = 120, int mouseWheelNum = 0) { 00169 pushMouseWheelUp(context, x, y, delta, mouseWheelNum); 00170 } 00171 void pushMouseMove(UContext * context, UMod_t modifiers, 00172 int x, int y) { 00173 pushMouseMove(context, x, y); 00174 } 00175 void pushKeyDown(UContext * context, UMod_t modifiers, 00176 UKeyCode_t keyCode, wchar_t keyChar) { 00177 pushKeyDown(context, keyCode, keyChar); 00178 } 00179 void pushKeyUp(UContext * context, UMod_t modifiers, 00180 UKeyCode_t keyCode, wchar_t keyChar) { 00181 pushKeyUp(context, keyCode, keyChar); 00182 } 00183 public: // general event dispatch methods 00188 virtual bool dispatchMouseButtonDown(UContext * context, 00189 int x, int y, UMod_t button); 00194 virtual bool dispatchMouseButtonUp(UContext * context, 00195 int x, int y, UMod_t button); 00200 virtual bool dispatchMouseWheelDown(UContext * context, 00201 int x, int y, int delta = -120, int mouseWheelNum = 0); 00205 virtual bool dispatchMouseWheelUp(UContext * context, 00206 int x, int y, int delta = 120, int mouseWheelNum = 0); 00211 virtual bool dispatchMouseMove(UContext * context, 00212 int x, int y); 00217 virtual bool dispatchKeyDown(UContext * context, 00218 UKeyCode_t keyCode, wchar_t keyChar); 00223 virtual bool dispatchKeyUp(UContext * context, 00224 UKeyCode_t keyCode, wchar_t keyChar); 00225 00226 protected: // Protected methods 00228 void registerContext(UXContext * context); 00229 void unregisterContext(UXContext * context); 00230 00231 virtual bool mouseButtonDown(UContext * context, 00232 int x, int y, UMod_t button, bool push = true); 00233 virtual bool mouseButtonUp(UContext * context, 00234 int x, int y, UMod_t button, bool push = true); 00235 virtual bool mouseWheelDown(UContext * context, 00236 int x, int y, int delta = -120, int mouseWheelNum = 0, bool push = true); 00237 virtual bool mouseWheelUp(UContext * context, 00238 int x, int y, int delta = 120, int mouseWheelNum = 0, bool push = true); 00239 virtual bool mouseMove(UContext * context, 00240 int x, int y, bool push = true); 00241 virtual bool keyDown(UContext * context, 00242 UKeyCode_t keyCode, wchar_t keyChar, bool push = true); 00243 virtual bool keyUp(UContext * context, 00244 UKeyCode_t keyCode, wchar_t keyChar, bool push = true); 00245 00246 private: // Private attributes 00247 UVideoDriver * m_videoDriver; 00248 std::vector<UXFrame*> m_frames; 00249 std::vector<UContext*> m_contexts; 00250 UPoint m_lastMousePressPos; 00251 uint32_t m_lastMousePressTime; 00252 uint32_t m_clickDelay; 00253 uint32_t m_clickCount; 00254 UPoint m_mousePos; 00255 }; 00256 00257 } // namespace ufo 00258 00259 #endif // UXDISPLAY_HPP

The libUFO Project - written by Johannes Schmidt