FIFE
2008.0
|
00001 /*************************************************************************** 00002 * Copyright (C) 2005-2008 by the FIFE team * 00003 * http://www.fifengine.de * 00004 * This file is part of FIFE. * 00005 * * 00006 * FIFE is free software; you can redistribute it and/or * 00007 * modify it under the terms of the GNU Lesser General Public * 00008 * License as published by the Free Software Foundation; either * 00009 * version 2.1 of the License, or (at your option) any later version. * 00010 * * 00011 * This library is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * Lesser General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Lesser General Public * 00017 * License along with this library; if not, write to the * 00018 * Free Software Foundation, Inc., * 00019 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * 00020 ***************************************************************************/ 00021 00022 #ifndef FIFE_CURSOR_H 00023 #define FIFE_CURSOR_H 00024 00025 // Standard C++ library includes 00026 00027 // 3rd party library includes 00028 00029 // FIFE includes 00030 // These includes are split up in two parts, separated by one empty line 00031 // First block: files included from the FIFE root src directory 00032 // Second block: files included from the same folder 00033 00034 struct SDL_Cursor; 00035 00036 namespace FIFE { 00037 00038 class ImagePool; 00039 class AnimationPool; 00040 class RenderBackend; 00041 class TimeManager; 00042 00048 enum MouseCursorType { 00049 CURSOR_NONE, 00050 CURSOR_NATIVE, 00051 CURSOR_IMAGE, 00052 CURSOR_ANIMATION 00053 }; 00054 00060 enum NativeCursor { 00061 // Start on 1000000 to avoid id-clashes with X11 and windows 00062 NC_ARROW = 1000000, // Standard arrow 00063 NC_IBEAM, // I-beam for text selection 00064 NC_WAIT, // Hourglass 00065 NC_CROSS, // Crosshair 00066 NC_UPARROW, // Vertical arrow 00067 NC_RESIZENW, // Cursor for resize in northwest corner 00068 NC_RESIZESE, // 00069 NC_RESIZESW, // 00070 NC_RESIZENE, // 00071 NC_RESIZEE, // 00072 NC_RESIZEW, // 00073 NC_RESIZEN, // 00074 NC_RESIZES, // 00075 NC_RESIZEALL, // Four-pointed arrow pointing north, south, east, and west 00076 NC_NO, // Slashed circle 00077 NC_HAND, // Hand. Common for links, etc. 00078 NC_APPSTARTING, // Standard arrow and small hourglass 00079 NC_HELP // Arrow and question mark 00080 }; 00081 00084 class Cursor { 00085 public: 00088 Cursor(ImagePool* imgpool, AnimationPool* animpool, RenderBackend* renderbackend); 00089 00092 virtual ~Cursor() { invalidate(); } 00093 00094 void invalidate(); 00095 00098 virtual void draw(); 00099 00104 void set(MouseCursorType ctype, unsigned int cursor_id=0); 00105 00111 void setDrag(MouseCursorType ctype, unsigned int drag_id=0, int drag_offset_x=0, int drag_offset_y=0); 00112 00115 MouseCursorType getType() const { return m_cursor_type; } 00116 00119 unsigned int getId() const { return m_cursor_id; } 00120 00123 MouseCursorType getDragType() const { return m_drag_type; } 00124 00127 unsigned int getDragId() const { return m_drag_id; } 00128 00131 unsigned int getX() const {return m_mx;} 00132 00135 unsigned int getY() const {return m_my;} 00136 00137 protected: 00141 void setNativeCursor(unsigned int cursor_id); 00142 00150 unsigned int getNativeId(unsigned int cursor_id); 00151 00152 private: 00153 unsigned int m_cursor_id; 00154 unsigned int m_drag_id; 00155 MouseCursorType m_cursor_type; 00156 MouseCursorType m_drag_type; 00157 00158 SDL_Cursor* m_native_cursor; 00159 00160 RenderBackend* m_renderbackend; 00161 ImagePool* m_imgpool; 00162 AnimationPool* m_animpool; 00163 00164 unsigned int m_animtime; 00165 unsigned int m_drag_animtime; 00166 00167 int m_drag_offset_x; 00168 int m_drag_offset_y; 00169 int m_mx; 00170 int m_my; 00171 TimeManager* m_timemanager; 00172 00173 bool m_invalidated; 00174 }; 00175 00176 } //FIFE 00177 00178 #endif