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