![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * C u r s o r - O b j e c t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1997,2009 by Jeroen van der Zijp. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or modify * 00009 * it under the terms of the GNU Lesser General Public License as published by * 00010 * the Free Software Foundation; either version 3 of the License, or * 00011 * (at your option) any later version. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00016 * GNU Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public License * 00019 * along with this program. If not, see <http://www.gnu.org/licenses/> * 00020 ********************************************************************************* 00021 * $Id: FXCursor.h,v 1.34 2009/01/06 13:07:22 fox Exp $ * 00022 ********************************************************************************/ 00023 #ifndef FXCURSOR_H 00024 #define FXCURSOR_H 00025 00026 #ifndef FXID_H 00027 #include "FXId.h" 00028 #endif 00029 00030 namespace FX { 00031 00032 00033 // Stock cursors 00034 enum FXStockCursor { 00035 CURSOR_ARROW=1, /// Default left pointing arrow 00036 CURSOR_RARROW, /// Right arrow 00037 CURSOR_IBEAM, /// Text I-Beam 00038 CURSOR_WATCH, /// Stopwatch or hourglass 00039 CURSOR_CROSS, /// Crosshair 00040 CURSOR_UPDOWN, /// Move up, down 00041 CURSOR_LEFTRIGHT, /// Move left, right 00042 CURSOR_MOVE /// Move up,down,left,right 00043 }; 00044 00045 00046 /// Cursor options 00047 enum { 00048 CURSOR_KEEP = 0x00000100, /// Keep pixel data in client 00049 CURSOR_OWNED = 0x00000200 /// Pixel data is owned by image 00050 }; 00051 00052 00053 /// Cursor class 00054 class FXAPI FXCursor : public FXId { 00055 FXDECLARE(FXCursor) 00056 protected: 00057 FXColor *data; // Source data 00058 FXint width; // Width 00059 FXint height; // Height 00060 FXint hotx; // Hot spot x 00061 FXint hoty; // Hot spot y 00062 FXuint options; // Options 00063 protected: 00064 FXCursor(); 00065 private: 00066 FXCursor(const FXCursor&); 00067 FXCursor &operator=(const FXCursor&); 00068 public: 00069 00070 /// Make stock cursor 00071 FXCursor(FXApp* a,FXStockCursor curid=CURSOR_ARROW); 00072 00073 /// Make cursor from source and mask; cursor size should at most 32x32 for portability! 00074 FXCursor(FXApp* a,const FXuchar* src,const FXuchar* msk,FXint w=32,FXint h=32,FXint hx=0,FXint hy=0); 00075 00076 /// Make cursor from FXColor pixels; cursor size should be at most 32x32 for portability! 00077 FXCursor(FXApp* a,const FXColor* pix,FXint w=32,FXint h=32,FXint hx=0,FXint hy=0); 00078 00079 /// Change options 00080 void setOptions(FXuint opts); 00081 00082 /// To get to the option flags 00083 FXuint getOptions() const { return options; } 00084 00085 /// Set pixel data ownership flag 00086 void setOwned(FXbool owned); 00087 00088 /// Get pixel data ownership flag 00089 FXbool isOwned() const; 00090 00091 /// Width of cursor; returns 0 for stock cursors 00092 FXint getWidth() const { return width; } 00093 00094 /// Height of cursor; returns 0 for stock cursors 00095 FXint getHeight() const { return height; } 00096 00097 /// Set hotspot x; returns 0 for stock cursors 00098 void setHotX(FXint x){ hotx=x; } 00099 00100 /// Get hotspot x; returns 0 for stock cursors 00101 FXint getHotX() const { return hotx; } 00102 00103 /// Set hotspot y; returns 0 for stock cursors 00104 void setHotY(FXint y){ hoty=y; } 00105 00106 /// Get hotspot y; returns 0 for stock cursors 00107 FXint getHotY() const { return hoty; } 00108 00109 /// Check if there is color in the cursor 00110 FXbool isColor() const; 00111 00112 /// Create cursor 00113 virtual void create(); 00114 00115 /// Detach cursor 00116 virtual void detach(); 00117 00118 /// Destroy cursor 00119 virtual void destroy(); 00120 00121 /// Release pixels buffer if it was owned 00122 virtual void release(); 00123 00124 /// Save pixel data only 00125 virtual FXbool savePixels(FXStream& store) const; 00126 00127 /// Load pixel data only 00128 virtual FXbool loadPixels(FXStream& store); 00129 00130 /// Save cursor to a stream 00131 virtual void save(FXStream& store) const; 00132 00133 /// Load cursor from a stream 00134 virtual void load(FXStream& store); 00135 00136 /// Destructor 00137 virtual ~FXCursor(); 00138 }; 00139 00140 } 00141 00142 #endif
![]() |