Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXCursor.h

00001 /******************************************************************************** 00002 * * 00003 * C u r s o r - O b j e c t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1997,2004 by Jeroen van der Zijp. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or * 00009 * modify it under the terms of the GNU Lesser General Public * 00010 * License as published by the Free Software Foundation; either * 00011 * version 2.1 of the License, or (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 GNU * 00016 * Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public * 00019 * License along with this library; if not, write to the Free Software * 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 00021 ********************************************************************************* 00022 * $Id: FXCursor.h,v 1.23 2004/03/06 21:21:23 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXCURSOR_H 00025 #define FXCURSOR_H 00026 00027 #ifndef FXID_H 00028 #include "FXId.h" 00029 #endif 00030 00031 namespace FX { 00032 00033 00034 // Stock cursors 00035 enum FXStockCursor { 00036 CURSOR_ARROW=1, /// Default left pointing arrow 00037 CURSOR_RARROW, /// Right arrow 00038 CURSOR_IBEAM, /// Text I-Beam 00039 CURSOR_WATCH, /// Stopwatch or hourglass 00040 CURSOR_CROSS, /// Crosshair 00041 CURSOR_UPDOWN, /// Move up, down 00042 CURSOR_LEFTRIGHT, /// Move left, right 00043 CURSOR_MOVE /// Move up,down,left,right 00044 }; 00045 00046 00047 /// Cursor options 00048 enum { 00049 CURSOR_KEEP = 0x00000100, /// Keep pixel data in client 00050 CURSOR_OWNED = 0x00000200 /// Pixel data is owned by image 00051 }; 00052 00053 00054 /// Cursor class 00055 class FXAPI FXCursor : public FXId { 00056 FXDECLARE(FXCursor) 00057 protected: 00058 FXColor *data; // Source data 00059 FXint width; // Width 00060 FXint height; // Height 00061 FXint hotx; // Hot spot x 00062 FXint hoty; // Hot spot y 00063 FXuint options; // Options 00064 protected: 00065 FXCursor(); 00066 private: 00067 FXCursor(const FXCursor&); 00068 FXCursor &operator=(const FXCursor&); 00069 public: 00070 00071 /// Make stock cursor 00072 FXCursor(FXApp* a,FXStockCursor curid=CURSOR_ARROW); 00073 00074 /// Make cursor from source and mask; cursor size should at most 32x32 for portability! 00075 FXCursor(FXApp* a,const FXuchar* src,const FXuchar* msk,FXint w=32,FXint h=32,FXint hx=0,FXint hy=0); 00076 00077 /// Make cursor from FXColor pixels; cursor size should be at most 32x32 for portability! 00078 FXCursor(FXApp* a,const FXColor* pix,FXint w=32,FXint h=32,FXint hx=0,FXint hy=0); 00079 00080 /// Width of cursor; returns 0 for stock cursors 00081 FXint getWidth() const { return width; } 00082 00083 /// Height of cursor; returns 0 for stock cursors 00084 FXint getHeight() const { return height; } 00085 00086 /// Get hotspot x; returns 0 for stock cursors 00087 FXint getHotX() const { return hotx; } 00088 00089 /// Get hotspot y; returns 0 for stock cursors 00090 FXint getHotY() const { return hoty; } 00091 00092 /// Check if there is color in the cursor 00093 FXbool isColor() const; 00094 00095 /// Create cursor 00096 virtual void create(); 00097 00098 /// Detach cursor 00099 virtual void detach(); 00100 00101 /// Destroy cursor 00102 virtual void destroy(); 00103 00104 /// Release pixels buffer if it was owned 00105 virtual void release(); 00106 00107 /// Save pixel data only 00108 virtual FXbool savePixels(FXStream& store) const; 00109 00110 /// Load pixel data only 00111 virtual FXbool loadPixels(FXStream& store); 00112 00113 /// Save cursor to a stream 00114 virtual void save(FXStream& store) const; 00115 00116 /// Load cursor from a stream 00117 virtual void load(FXStream& store); 00118 00119 /// Destructor 00120 virtual ~FXCursor(); 00121 }; 00122 00123 } 00124 00125 #endif

Copyright © 1997-2004 Jeroen van der Zijp