![]() |
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,2010 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 #ifndef FXCURSOR_H 00022 #define FXCURSOR_H 00023 00024 #ifndef FXID_H 00025 #include "FXId.h" 00026 #endif 00027 00028 namespace FX { 00029 00030 00031 // Stock cursors 00032 enum FXStockCursor { 00033 CURSOR_ARROW=1, /// Default left pointing arrow 00034 CURSOR_RARROW, /// Right arrow 00035 CURSOR_IBEAM, /// Text I-Beam 00036 CURSOR_WATCH, /// Stopwatch or hourglass 00037 CURSOR_CROSS, /// Crosshair 00038 CURSOR_UPDOWN, /// Move up, down 00039 CURSOR_LEFTRIGHT, /// Move left, right 00040 CURSOR_MOVE /// Move up,down,left,right 00041 }; 00042 00043 00044 /// Cursor options 00045 enum { 00046 CURSOR_KEEP = 0x00000100, /// Keep pixel data in client 00047 CURSOR_OWNED = 0x00000200 /// Pixel data is owned by image 00048 }; 00049 00050 00051 /// Cursor class 00052 class FXAPI FXCursor : public FXId { 00053 FXDECLARE(FXCursor) 00054 protected: 00055 FXColor *data; // Source data 00056 FXint width; // Width 00057 FXint height; // Height 00058 FXint hotx; // Hot spot x 00059 FXint hoty; // Hot spot y 00060 FXuint options; // Options 00061 protected: 00062 FXCursor(); 00063 private: 00064 FXCursor(const FXCursor&); 00065 FXCursor &operator=(const FXCursor&); 00066 public: 00067 00068 /// Make stock cursor 00069 FXCursor(FXApp* a,FXStockCursor curid=CURSOR_ARROW); 00070 00071 /// Make cursor from source and mask; cursor size should at most 32x32 for portability! 00072 FXCursor(FXApp* a,const FXuchar* src,const FXuchar* msk,FXint w=32,FXint h=32,FXint hx=0,FXint hy=0); 00073 00074 /// Make cursor from FXColor pixels; cursor size should be at most 32x32 for portability! 00075 FXCursor(FXApp* a,const FXColor* pix,FXint w=32,FXint h=32,FXint hx=0,FXint hy=0); 00076 00077 /// Change options 00078 void setOptions(FXuint opts); 00079 00080 /// To get to the option flags 00081 FXuint getOptions() const { return options; } 00082 00083 /// Set pixel data ownership flag 00084 void setOwned(FXbool owned); 00085 00086 /// Get pixel data ownership flag 00087 FXbool isOwned() const; 00088 00089 /// Width of cursor; returns 0 for stock cursors 00090 FXint getWidth() const { return width; } 00091 00092 /// Height of cursor; returns 0 for stock cursors 00093 FXint getHeight() const { return height; } 00094 00095 /// Set hotspot x; returns 0 for stock cursors 00096 void setHotX(FXint x){ hotx=x; } 00097 00098 /// Get hotspot x; returns 0 for stock cursors 00099 FXint getHotX() const { return hotx; } 00100 00101 /// Set hotspot y; returns 0 for stock cursors 00102 void setHotY(FXint y){ hoty=y; } 00103 00104 /// Get hotspot y; returns 0 for stock cursors 00105 FXint getHotY() const { return hoty; } 00106 00107 /// Check if there is color in the cursor 00108 FXbool isColor() const; 00109 00110 /// Create cursor 00111 virtual void create(); 00112 00113 /// Detach cursor 00114 virtual void detach(); 00115 00116 /// Destroy cursor 00117 virtual void destroy(); 00118 00119 /// Release pixels buffer if it was owned 00120 virtual void release(); 00121 00122 /// Save pixel data only 00123 virtual FXbool savePixels(FXStream& store) const; 00124 00125 /// Load pixel data only 00126 virtual FXbool loadPixels(FXStream& store); 00127 00128 /// Save cursor to a stream 00129 virtual void save(FXStream& store) const; 00130 00131 /// Load cursor from a stream 00132 virtual void load(FXStream& store); 00133 00134 /// Destructor 00135 virtual ~FXCursor(); 00136 }; 00137 00138 } 00139 00140 #endif
|
|