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

FXCursor.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * C u r s o r - O b j e c t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1997,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXCursor.h,v 1.28 2006/01/22 17:58:00 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXCURSOR_H
25 #define FXCURSOR_H
26 
27 #ifndef FXID_H
28 #include "FXId.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 // Stock cursors
35 enum FXStockCursor {
36  CURSOR_ARROW=1, /// Default left pointing arrow
37  CURSOR_RARROW, /// Right arrow
38  CURSOR_IBEAM, /// Text I-Beam
39  CURSOR_WATCH, /// Stopwatch or hourglass
40  CURSOR_CROSS, /// Crosshair
41  CURSOR_UPDOWN, /// Move up, down
42  CURSOR_LEFTRIGHT, /// Move left, right
43  CURSOR_MOVE /// Move up,down,left,right
44  };
45 
46 
47 /// Cursor options
48 enum {
49  CURSOR_KEEP = 0x00000100, /// Keep pixel data in client
50  CURSOR_OWNED = 0x00000200 /// Pixel data is owned by image
51  };
52 
53 
54 /// Cursor class
55 class FXAPI FXCursor : public FXId {
57 protected:
58  FXColor *data; // Source data
59  FXint width; // Width
60  FXint height; // Height
61  FXint hotx; // Hot spot x
62  FXint hoty; // Hot spot y
63  FXuint options; // Options
64 protected:
65  FXCursor();
66 private:
67  FXCursor(const FXCursor&);
68  FXCursor &operator=(const FXCursor&);
69 public:
70 
71  /// Make stock cursor
72  FXCursor(FXApp* a,FXStockCursor curid=CURSOR_ARROW);
73 
74  /// Make cursor from source and mask; cursor size should at most 32x32 for portability!
75  FXCursor(FXApp* a,const FXuchar* src,const FXuchar* msk,FXint w=32,FXint h=32,FXint hx=0,FXint hy=0);
76 
77  /// Make cursor from FXColor pixels; cursor size should be at most 32x32 for portability!
78  FXCursor(FXApp* a,const FXColor* pix,FXint w=32,FXint h=32,FXint hx=0,FXint hy=0);
79 
80  /// Width of cursor; returns 0 for stock cursors
81  FXint getWidth() const { return width; }
82 
83  /// Height of cursor; returns 0 for stock cursors
84  FXint getHeight() const { return height; }
85 
86  /// Set hotspot x; returns 0 for stock cursors
87  void setHotX(FXint x){ hotx=x; }
88 
89  /// Get hotspot x; returns 0 for stock cursors
90  FXint getHotX() const { return hotx; }
91 
92  /// Set hotspot y; returns 0 for stock cursors
93  void setHotY(FXint y){ hoty=y; }
94 
95  /// Get hotspot y; returns 0 for stock cursors
96  FXint getHotY() const { return hoty; }
97 
98  /// Check if there is color in the cursor
99  bool isColor() const;
100 
101  /// Create cursor
102  virtual void create();
103 
104  /// Detach cursor
105  virtual void detach();
106 
107  /// Destroy cursor
108  virtual void destroy();
109 
110  /// Release pixels buffer if it was owned
111  virtual void release();
112 
113  /// Save pixel data only
114  virtual bool savePixels(FXStream& store) const;
115 
116  /// Load pixel data only
117  virtual bool loadPixels(FXStream& store);
118 
119  /// Save cursor to a stream
120  virtual void save(FXStream& store) const;
121 
122  /// Load cursor from a stream
123  virtual void load(FXStream& store);
124 
125  /// Destructor
126  virtual ~FXCursor();
127  };
128 
129 }
130 
131 #endif
Crosshair.
Definition: FXCursor.h:43
Move up, down.
Definition: FXCursor.h:44
unsigned int FXuint
Definition: fxdefs.h:396
FXStockCursor
Definition: FXCursor.h:38
Pixel data is owned by image.
Definition: FXCursor.h:57
Default left pointing arrow.
Definition: FXCursor.h:39
#define FXAPI
Definition: fxdefs.h:122
Keep pixel data in client.
Definition: FXCursor.h:56
Application Object.
Definition: FXApp.h:158
FXuint FXColor
Definition: fxdefs.h:454
Stopwatch or hourglass.
Definition: FXCursor.h:42
Move left, right.
Definition: FXCursor.h:45
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:99
Definition: FX4Splitter.h:31
int FXint
Definition: fxdefs.h:397
Cursor class.
Definition: FXCursor.h:68
Move up,down,left,right.
Definition: FXCursor.h:46
unsigned char FXuchar
Definition: fxdefs.h:392
Text I-Beam.
Definition: FXCursor.h:41
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92
Right arrow.
Definition: FXCursor.h:40

Copyright © 1997-2005 Jeroen van der Zijp