1 /******************************************************************************** 2 * * 3 * C u r s o r - O b j e c t * 4 * * 5 ********************************************************************************* 6 * Copyright (C) 1997,2005 by Jeroen van der Zijp. All Rights Reserved. * 7 ********************************************************************************* 8 * This library is free software; you can redistribute it and/or * 9 * modify it under the terms of the GNU Lesser General Public * 10 * License as published by the Free Software Foundation; either * 11 * version 2.1 of the License, or (at your option) any later version. * 12 * * 13 * This library 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 GNU * 16 * Lesser General Public License for more details. * 17 * * 18 * You should have received a copy of the GNU Lesser General Public * 19 * License along with this library; if not, write to the Free Software * 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 21 ********************************************************************************* 22 * $Id: FXCursor.h,v 1.25.2.1 2005/04/10 03:24:47 fox Exp $ * 23 ********************************************************************************/ 24 #ifndef FXCURSOR_H 25 #define FXCURSOR_H 26 27 #ifndef FXID_H 28 #include "FXId.h" 29 #endif 30 31 namespace FX { 32 33 34 // Stock cursors 35 enum FXStockCursor { 36 CURSOR_ARROW=1, /// Default left pointing arrow 37 CURSOR_RARROW, /// Right arrow 38 CURSOR_IBEAM, /// Text I-Beam 39 CURSOR_WATCH, /// Stopwatch or hourglass 40 CURSOR_CROSS, /// Crosshair 41 CURSOR_UPDOWN, /// Move up, down 42 CURSOR_LEFTRIGHT, /// Move left, right 43 CURSOR_MOVE /// Move up,down,left,right 44 }; 45 46 47 /// Cursor options 48 enum { 49 CURSOR_KEEP = 0x00000100, /// Keep pixel data in client 50 CURSOR_OWNED = 0x00000200 /// Pixel data is owned by image 51 }; 52 53 54 /// Cursor class 55 class FXAPI FXCursor : public FXId { 56 FXDECLARE(FXCursor) 57 protected: 58 FXColor *data; // Source data 59 FXint width; // Width 60 FXint height; // Height 61 FXint hotx; // Hot spot x 62 FXint hoty; // Hot spot y 63 FXuint options; // Options 64 protected: 65 FXCursor(); 66 private: 67 FXCursor(const FXCursor&); 68 FXCursor &operator=(const FXCursor&); 69 public: 70 71 /// Make stock cursor 72 FXCursor(FXApp* a,FXStockCursor curid=CURSOR_ARROW); 73 74 /// Make cursor from source and mask; cursor size should at most 32x32 for portability! 75 FXCursor(FXApp* a,const FXuchar* src,const FXuchar* msk,FXint w=32,FXint h=32,FXint hx=0,FXint hy=0); 76 77 /// Make cursor from FXColor pixels; cursor size should be at most 32x32 for portability! 78 FXCursor(FXApp* a,const FXColor* pix,FXint w=32,FXint h=32,FXint hx=0,FXint hy=0); 79 80 /// Width of cursor; returns 0 for stock cursors getWidth()81 FXint getWidth() const { return width; } 82 83 /// Height of cursor; returns 0 for stock cursors getHeight()84 FXint getHeight() const { return height; } 85 86 /// Set hotspot x; returns 0 for stock cursors setHotX(FXint x)87 void setHotX(FXint x){ hotx=x; } 88 89 /// Get hotspot x; returns 0 for stock cursors getHotX()90 FXint getHotX() const { return hotx; } 91 92 /// Set hotspot y; returns 0 for stock cursors setHotY(FXint y)93 void setHotY(FXint y){ hoty=y; } 94 95 /// Get hotspot y; returns 0 for stock cursors getHotY()96 FXint getHotY() const { return hoty; } 97 98 /// Check if there is color in the cursor 99 FXbool isColor() const; 100 101 /// Create cursor 102 virtual void create(); 103 104 /// Detach cursor 105 virtual void detach(); 106 107 /// Destroy cursor 108 virtual void destroy(); 109 110 /// Release pixels buffer if it was owned 111 virtual void release(); 112 113 /// Save pixel data only 114 virtual FXbool savePixels(FXStream& store) const; 115 116 /// Load pixel data only 117 virtual FXbool loadPixels(FXStream& store); 118 119 /// Save cursor to a stream 120 virtual void save(FXStream& store) const; 121 122 /// Load cursor from a stream 123 virtual void load(FXStream& store); 124 125 /// Destructor 126 virtual ~FXCursor(); 127 }; 128 129 } 130 131 #endif 132