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,2002 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.13 2002/01/18 22:42:51 jeroen Exp $                       *
00023 ********************************************************************************/
00024 #ifndef FXCURSOR_H
00025 #define FXCURSOR_H
00026 
00027 #ifndef FXID_H
00028 #include "FXId.h"
00029 #endif
00030 
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 
00047 /// Cursor class
00048 class FXAPI FXCursor : public FXId {
00049   FXDECLARE(FXCursor)
00050 protected:
00051   FXuchar *source;            // Source data
00052   FXuchar *mask;              // Mask data
00053   FXint    width;             // Width
00054   FXint    height;            // Height
00055   FXint    hotx;              // Hot spot x
00056   FXint    hoty;              // Hot spot y
00057   FXuchar  glyph;             // Glyph type cursor (stock cursor)
00058   FXbool   owned;             // Owns data
00059 protected:
00060   FXCursor();
00061 private:
00062   FXCursor(const FXCursor&);
00063   FXCursor &operator=(const FXCursor&);
00064 public:
00065 
00066   /// Make stock cursor
00067   FXCursor(FXApp* a,FXStockCursor curid=CURSOR_ARROW);
00068 
00069   /// Make cursor from source and mask; cursor size should at most 32x32 for portability!
00070   FXCursor(FXApp* a,const void* src,const void* msk,FXint w=32,FXint h=32,FXint hx=-1,FXint hy=-1);
00071 
00072   /// Width of cursor
00073   FXint getWidth() const { return width; }
00074 
00075   /// Height or cursor
00076   FXint getHeight() const { return height; }
00077 
00078   /// Get hotspot x
00079   FXint getHotX() const { return hotx; }
00080 
00081   /// Get hotspot y
00082   FXint getHotY() const { return hoty; }
00083 
00084   /// Create cursor
00085   virtual void create();
00086 
00087   /// Detach cursor
00088   virtual void detach();
00089 
00090   /// Destroy cursor
00091   virtual void destroy();
00092 
00093   /// Save pixel data only
00094   virtual void savePixels(FXStream& store) const;
00095 
00096   /// Load pixel data only
00097   virtual void loadPixels(FXStream& store);
00098 
00099   /// Save cursor to a stream
00100   virtual void save(FXStream& store) const;
00101 
00102   /// Load cursor from a stream
00103   virtual void load(FXStream& store);
00104 
00105   /// Destructor
00106   virtual ~FXCursor();
00107   };
00108 
00109 
00110 #endif