summaryrefslogtreecommitdiff
path: root/FL
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2014-06-16 11:17:57 +0000
committerPierre Ossman <ossman@cendio.se>2014-06-16 11:17:57 +0000
commit332dc1b7acfedbf80b71cc6f538a14f24d435df3 (patch)
treef690751dd9b592b2b00b4d54c803f98073d74b97 /FL
parentb4013ef60225b91af17d664b0938a074b7115202 (diff)
Add method to set any custom cursor, based on a Fl_RGB_Image object.
Also change our fallback cursors to use this method, so that fallback cursors are handled in a platform independent manner. STR #2660. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10196 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'FL')
-rw-r--r--FL/Enumerations.H52
-rw-r--r--FL/Fl_Window.H19
-rw-r--r--FL/fl_draw.H3
-rw-r--r--FL/mac.H3
-rw-r--r--FL/win32.H3
-rw-r--r--FL/x.H2
6 files changed, 49 insertions, 33 deletions
diff --git a/FL/Enumerations.H b/FL/Enumerations.H
index 97b382d90..13df541aa 100644
--- a/FL/Enumerations.H
+++ b/FL/Enumerations.H
@@ -901,35 +901,37 @@ inline Fl_Color fl_color_cube(int r, int g, int b) {
/** The following constants define the mouse cursors that are available in FLTK.
- The double-headed arrows are bitmaps provided by FLTK on X, the others
- are provided by system-defined cursors.
+ Cursors are provided by the system when available, or bitmaps built into
+ FLTK as a fallback.
\todo enum Fl_Cursor needs maybe an image.
*/
+/* FIXME: We should renumber these, but that will break the ABI */
enum Fl_Cursor {
- FL_CURSOR_DEFAULT = 0, /**< the default cursor, usually an arrow. */
- FL_CURSOR_ARROW = 35, /**< an arrow pointer. */
- FL_CURSOR_CROSS = 66, /**< crosshair. */
- FL_CURSOR_WAIT = 76, /**< watch or hourglass. */
- FL_CURSOR_INSERT = 77, /**< I-beam. */
- FL_CURSOR_HAND = 31, /**< hand (uparrow on MSWindows). */
- FL_CURSOR_HELP = 47, /**< question mark. */
- FL_CURSOR_MOVE = 27, /**< 4-pointed arrow. */
- // fltk provides bitmaps for these:
- FL_CURSOR_NS = 78, /**< up/down arrow. */
- FL_CURSOR_WE = 79, /**< left/right arrow. */
- FL_CURSOR_NWSE = 80, /**< diagonal arrow. */
- FL_CURSOR_NESW = 81, /**< diagonal arrow. */
- FL_CURSOR_NONE =255, /**< invisible. */
- // for back compatibility (non MSWindows ones):
- FL_CURSOR_N = 70, /**< for back compatibility. */
- FL_CURSOR_NE = 69, /**< for back compatibility. */
- FL_CURSOR_E = 49, /**< for back compatibility. */
- FL_CURSOR_SE = 8, /**< for back compatibility. */
- FL_CURSOR_S = 9, /**< for back compatibility. */
- FL_CURSOR_SW = 7, /**< for back compatibility. */
- FL_CURSOR_W = 36, /**< for back compatibility. */
- FL_CURSOR_NW = 68 /**< for back compatibility. */
+ FL_CURSOR_DEFAULT = 0, /**< the default cursor, usually an arrow. */
+ FL_CURSOR_ARROW = 35, /**< an arrow pointer. */
+ FL_CURSOR_CROSS = 66, /**< crosshair. */
+ FL_CURSOR_WAIT = 76, /**< busy indicator (e.g. hourglass). */
+ FL_CURSOR_INSERT = 77, /**< I-beam. */
+ FL_CURSOR_HAND = 31, /**< pointing hand. */
+ FL_CURSOR_HELP = 47, /**< question mark pointer. */
+ FL_CURSOR_MOVE = 27, /**< 4-pointed arrow or hand. */
+
+ /* Resize indicators */
+ FL_CURSOR_NS = 78, /**< up/down resize. */
+ FL_CURSOR_WE = 79, /**< left/right resize. */
+ FL_CURSOR_NWSE = 80, /**< diagonal resize. */
+ FL_CURSOR_NESW = 81, /**< diagonal resize. */
+ FL_CURSOR_N = 70, /**< upwards resize. */
+ FL_CURSOR_NE = 69, /**< upwards, right resize. */
+ FL_CURSOR_E = 49, /**< rightwards resize. */
+ FL_CURSOR_SE = 8, /**< downwards, right resize. */
+ FL_CURSOR_S = 9, /**< downwards resize. */
+ FL_CURSOR_SW = 7, /**< downwards, left resize. */
+ FL_CURSOR_W = 36, /**< leftwards resize. */
+ FL_CURSOR_NW = 68, /**< upwards, left resize. */
+
+ FL_CURSOR_NONE =255, /**< invisible. */
};
/*@}*/ // group: Cursors
diff --git a/FL/Fl_Window.H b/FL/Fl_Window.H
index a9fa82e24..c26f474d2 100644
--- a/FL/Fl_Window.H
+++ b/FL/Fl_Window.H
@@ -28,6 +28,7 @@
#define FL_DOUBLE_WINDOW 0xF1 ///< double window type id
class Fl_X;
+class Fl_RGB_Image;
/**
This widget produces an actual window. This can either be a main
@@ -97,7 +98,10 @@ class FL_EXPORT Fl_Window : public Fl_Group {
uchar size_range_set;
// cursor stuff
Fl_Cursor cursor_default;
+#if FLTK_ABI_VERSION < 10303
+ // legacy, not used
Fl_Color cursor_fg, cursor_bg;
+#endif
void size_range_();
void _Fl_Window(); // constructor innards
void fullscreen_x(); // platform-specific part of sending a window to full screen
@@ -495,14 +499,17 @@ public:
is different.
The type Fl_Cursor is an enumeration defined in <FL/Enumerations.H>.
- (Under X you can get any XC_cursor value by passing
- Fl_Cursor((XC_foo/2)+1)). The colors only work on X, they are
- not implemented on WIN32.
- For back compatibility only.
+ \see cursor(const Fl_RGB_Image*, int, int), default_cursor()
*/
- void cursor(Fl_Cursor, Fl_Color=FL_BLACK, Fl_Color=FL_WHITE); // platform dependent
- void default_cursor(Fl_Cursor, Fl_Color=FL_BLACK, Fl_Color=FL_WHITE);
+ void cursor(Fl_Cursor);
+ void cursor(const Fl_RGB_Image*, int, int);
+ void default_cursor(Fl_Cursor);
+
+ /* for legacy compatibility */
+ void cursor(Fl_Cursor c, Fl_Color, Fl_Color=FL_WHITE);
+ void default_cursor(Fl_Cursor c, Fl_Color, Fl_Color=FL_WHITE);
+
static void default_callback(Fl_Window*, void* v);
/** Returns the window width including any frame added by the window manager.
diff --git a/FL/fl_draw.H b/FL/fl_draw.H
index 3d47a438c..30a3eb5f8 100644
--- a/FL/fl_draw.H
+++ b/FL/fl_draw.H
@@ -769,7 +769,8 @@ FL_EXPORT const char* fl_shortcut_label(unsigned int shortcut, const char **eom)
FL_EXPORT unsigned int fl_old_shortcut(const char* s);
FL_EXPORT void fl_overlay_rect(int x,int y,int w,int h);
FL_EXPORT void fl_overlay_clear();
-FL_EXPORT void fl_cursor(Fl_Cursor, Fl_Color fg=FL_BLACK, Fl_Color bg=FL_WHITE);
+FL_EXPORT void fl_cursor(Fl_Cursor);
+FL_EXPORT void fl_cursor(Fl_Cursor, Fl_Color fg, Fl_Color bg=FL_WHITE);
FL_EXPORT const char* fl_expand_text(const char* from, char* buf, int maxbuf,
double maxw, int& n, double &width,
int wrap, int draw_symbols = 0);
diff --git a/FL/mac.H b/FL/mac.H
index 734786e45..f02094427 100644
--- a/FL/mac.H
+++ b/FL/mac.H
@@ -142,7 +142,8 @@ public:
void collapse(void);
WindowRef window_ref(void);
void set_key_window(void);
- void set_cursor(Fl_Cursor);
+ int set_cursor(Fl_Cursor);
+ int set_cursor(const Fl_RGB_Image*, int, int);
static CGImageRef CGImage_from_window_rect(Fl_Window *win, int x, int y, int w, int h);
static unsigned char *bitmap_from_window_rect(Fl_Window *win, int x, int y, int w, int h, int *bytesPerPixel);
static CFDataRef CGBitmapContextToTIFF(CGContextRef c);
diff --git a/FL/win32.H b/FL/win32.H
index b6cd0edfd..3ecdad79e 100644
--- a/FL/win32.H
+++ b/FL/win32.H
@@ -73,6 +73,7 @@ public:
int wait_for_expose;
HDC private_dc; // used for OpenGL
HCURSOR cursor;
+ int custom_cursor;
HDC saved_hdc; // saves the handle of the DC currently loaded
// static variables, static functions and member functions
static Fl_X* first;
@@ -84,6 +85,8 @@ public:
void flush() {w->flush();}
void set_minmax(LPMINMAXINFO minmax);
void mapraise();
+ int set_cursor(Fl_Cursor);
+ int set_cursor(const Fl_RGB_Image*, int, int);
static Fl_X* make(Fl_Window*);
};
extern FL_EXPORT HCURSOR fl_default_cursor;
diff --git a/FL/x.H b/FL/x.H
index 4381eb350..46f7108e2 100644
--- a/FL/x.H
+++ b/FL/x.H
@@ -150,6 +150,8 @@ public:
static Fl_X* i(const Fl_Window* wi) {return wi->i;}
void setwindow(Fl_Window* wi) {w=wi; wi->i=this;}
void sendxjunk();
+ int set_cursor(Fl_Cursor);
+ int set_cursor(const Fl_RGB_Image*, int, int);
static void make_xid(Fl_Window*,XVisualInfo* =fl_visual, Colormap=fl_colormap);
static Fl_X* set_xid(Fl_Window*, Window);
// kludges to get around protection: