provide backward-compat wxCursor(int) ctor; remove empty stubs of XBM ctor from all ports except gtk,motif; make all ports emit wxLogError on invalid bitmap types; implement wxCursor(const wxString&, ...) ctor on GTK (not tested yet)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55884 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Francesco Montorsi
2008-09-25 17:56:07 +00:00
parent 5a8009d2f1
commit 0ef5b1dad1
23 changed files with 216 additions and 167 deletions

View File

@@ -39,14 +39,13 @@ class WXDLLIMPEXP_CORE wxCursor: public wxBitmap
public: public:
wxCursor(); wxCursor();
wxCursor(const char bits[], int width, int height, wxCursor(const wxString& name, wxBitmapType type = wxCURSOR_DEFAULT_TYPE,
int hotSpotX = -1, int hotSpotY = -1,
const char maskBits[] = NULL);
wxCursor(const wxString& name, long flags = 0,
int hotSpotX = 0, int hotSpotY = 0); int hotSpotX = 0, int hotSpotY = 0);
wxCursor(wxStockCursor cursor_type); wxCursor(wxStockCursor id) { InitFromStock(id); }
#if WXWIN_COMPATIBILITY_2_8
wxCursor(int id) { InitFromStock((wxStockCursor)id); }
#endif
virtual ~wxCursor(); virtual ~wxCursor();
// FIXME: operator==() is wrong! // FIXME: operator==() is wrong!
@@ -55,6 +54,8 @@ public:
WX_NSCursor GetNSCursor() const { return M_CURSORDATA ? M_CURSORDATA->m_hCursor : 0; } WX_NSCursor GetNSCursor() const { return M_CURSORDATA ? M_CURSORDATA->m_hCursor : 0; }
private:
void InitFromStock(wxStockCursor);
DECLARE_DYNAMIC_CLASS(wxCursor) DECLARE_DYNAMIC_CLASS(wxCursor)
}; };

View File

@@ -15,26 +15,37 @@
#include "wx/defs.h" #include "wx/defs.h"
#if defined(__WXPALMOS__) #if defined(__WXPALMOS__)
#define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_CUR_RESOURCE
#include "wx/palmos/cursor.h" #include "wx/palmos/cursor.h"
#elif defined(__WXMSW__) #elif defined(__WXMSW__)
#define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_CUR_RESOURCE
#include "wx/msw/cursor.h" #include "wx/msw/cursor.h"
#elif defined(__WXMOTIF__) #elif defined(__WXMOTIF__)
#define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_XBM
#include "wx/motif/cursor.h" #include "wx/motif/cursor.h"
#elif defined(__WXGTK20__) #elif defined(__WXGTK20__)
#define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_XPM
#include "wx/gtk/cursor.h" #include "wx/gtk/cursor.h"
#elif defined(__WXGTK__) #elif defined(__WXGTK__)
#define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_XPM
#include "wx/gtk1/cursor.h" #include "wx/gtk1/cursor.h"
#elif defined(__WXX11__) #elif defined(__WXX11__)
#define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_XPM
#include "wx/x11/cursor.h" #include "wx/x11/cursor.h"
#elif defined(__WXMGL__) #elif defined(__WXMGL__)
#define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_CUR_RESOURCE
#include "wx/mgl/cursor.h" #include "wx/mgl/cursor.h"
#elif defined(__WXDFB__) #elif defined(__WXDFB__)
#define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_CUR_RESOURCE
#include "wx/dfb/cursor.h" #include "wx/dfb/cursor.h"
#elif defined(__WXMAC__) #elif defined(__WXMAC__)
#define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_MACCURSOR_RESOURCE
#include "wx/osx/cursor.h" #include "wx/osx/cursor.h"
#elif defined(__WXCOCOA__) #elif defined(__WXCOCOA__)
#define wxCURSOR_DEFAULT_TYPE 0
#include "wx/cocoa/cursor.h" #include "wx/cocoa/cursor.h"
#elif defined(__WXPM__) #elif defined(__WXPM__)
#define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_CUR_RESOURCE
#include "wx/os2/cursor.h" #include "wx/os2/cursor.h"
#endif #endif

View File

@@ -24,18 +24,20 @@ class WXDLLIMPEXP_CORE wxCursor : public wxGDIObject
{ {
public: public:
wxCursor() {} wxCursor() {}
wxCursor(wxStockCursor cursorId); wxCursor(wxStockCursor id) { InitFromStock(id); }
wxCursor(const char bits[], int width, int height, #if WXWIN_COMPATIBILITY_2_8
int hotSpotX=-1, int hotSpotY=-1, wxCursor(int id) { InitFromStock((wxStockCursor)id); }
const char maskBits[]=0, wxColour *fg=0, wxColour *bg=0); #endif
wxCursor(const wxString& name, wxCursor(const wxString& name,
long flags = wxBITMAP_TYPE_CUR_RESOURCE, wxBitmapType type = wxCURSOR_DEFAULT_TYPE,
int hotSpotX = 0, int hotSpotY = 0); int hotSpotX = 0, int hotSpotY = 0);
// implementation // implementation
wxBitmap GetBitmap() const; wxBitmap GetBitmap() const;
protected: protected:
void InitFromStock(wxStockCursor);
// ref counting code // ref counting code
virtual wxGDIRefData *CreateGDIRefData() const; virtual wxGDIRefData *CreateGDIRefData() const;
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const; virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;

View File

@@ -24,7 +24,10 @@ class WXDLLIMPEXP_CORE wxCursor : public wxGDIObject
{ {
public: public:
wxCursor(); wxCursor();
wxCursor( wxStockCursor cursorId ); wxCursor(wxStockCursor id) { InitFromStock(id); }
#if WXWIN_COMPATIBILITY_2_8
wxCursor(int id) { InitFromStock((wxStockCursor)id); }
#endif
#if wxUSE_IMAGE #if wxUSE_IMAGE
wxCursor( const wxImage & image ); wxCursor( const wxImage & image );
#endif #endif
@@ -32,6 +35,9 @@ public:
int hotSpotX = -1, int hotSpotY = -1, int hotSpotX = -1, int hotSpotY = -1,
const char maskBits[] = NULL, const char maskBits[] = NULL,
const wxColour* fg = NULL, const wxColour* bg = NULL); const wxColour* fg = NULL, const wxColour* bg = NULL);
wxCursor(const wxString& name,
wxBitmapType type = wxCURSOR_DEFAULT_TYPE,
int hotSpotX = 0, int hotSpotY = 0);
virtual ~wxCursor(); virtual ~wxCursor();
// implementation // implementation
@@ -39,6 +45,8 @@ public:
GdkCursor *GetCursor() const; GdkCursor *GetCursor() const;
protected: protected:
void InitFromStock(wxStockCursor);
virtual wxGDIRefData *CreateGDIRefData() const; virtual wxGDIRefData *CreateGDIRefData() const;
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const; virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;

View File

@@ -25,13 +25,25 @@ class WXDLLIMPEXP_CORE wxCursor : public wxGDIObject
{ {
public: public:
wxCursor(); wxCursor();
wxCursor( wxStockCursor cursorId ); wxCursor(wxStockCursor id) { InitFromStock(id); }
#if WXWIN_COMPATIBILITY_2_8
wxCursor(int id) { InitFromStock((wxStockCursor)id); }
#endif
#if wxUSE_IMAGE #if wxUSE_IMAGE
wxCursor( const wxImage & image ); wxCursor( const wxImage & image );
#endif #endif
wxCursor( const char bits[], int width, int height, wxCursor( const char bits[], int width, int height,
int hotSpotX=-1, int hotSpotY=-1, int hotSpotX=-1, int hotSpotY=-1,
const char maskBits[] = NULL, const wxColour *fg = NULL, const wxColour *bg = NULL ); const char maskBits[] = NULL,
const wxColour* fg = NULL, const wxColour* bg = NULL);
/* WARNING: the following ctor is missing:
wxCursor(const wxString& name,
wxBitmapType type = wxCURSOR_DEFAULT_TYPE,
int hotSpotX = 0, int hotSpotY = 0);
*/
virtual ~wxCursor(); virtual ~wxCursor();
// implementation // implementation
@@ -39,6 +51,8 @@ public:
GdkCursor *GetCursor() const; GdkCursor *GetCursor() const;
protected: protected:
void InitFromStock(wxStockCursor);
virtual wxGDIRefData *CreateGDIRefData() const; virtual wxGDIRefData *CreateGDIRefData() const;
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const; virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;

View File

@@ -24,12 +24,12 @@ class WXDLLIMPEXP_CORE wxCursor : public wxGDIObject
public: public:
wxCursor(); wxCursor();
wxCursor(wxStockCursor cursorId); wxCursor(wxStockCursor id) { InitFromStock(id); }
wxCursor(const char bits[], int width, int height, #if WXWIN_COMPATIBILITY_2_8
int hotSpotX=-1, int hotSpotY=-1, wxCursor(int id) { InitFromStock((wxStockCursor)id); }
const char maskBits[]=0, wxColour *fg=0, wxColour *bg=0); #endif
wxCursor(const wxString& name, wxCursor(const wxString& name,
long flags = wxBITMAP_TYPE_CUR_RESOURCE, wxBitmapType type = wxCURSOR_DEFAULT_TYPE,
int hotSpotX = 0, int hotSpotY = 0); int hotSpotX = 0, int hotSpotY = 0);
virtual ~wxCursor(); virtual ~wxCursor();
@@ -37,6 +37,8 @@ public:
MGLCursor *GetMGLCursor() const; MGLCursor *GetMGLCursor() const;
private: private:
void InitFromStock(wxStockCursor);
DECLARE_DYNAMIC_CLASS(wxCursor) DECLARE_DYNAMIC_CLASS(wxCursor)
}; };

View File

@@ -25,16 +25,22 @@ public:
wxCursor(const char bits[], int width, int height, wxCursor(const char bits[], int width, int height,
int hotSpotX = -1, int hotSpotY = -1, int hotSpotX = -1, int hotSpotY = -1,
const char maskBits[] = NULL); const char maskBits[] = NULL,
const wxColour* fg = NULL, const wxColour* bg = NULL);
wxCursor(const wxString& name, long flags = wxBITMAP_TYPE_XBM, wxCursor(const wxString& name,
int hotSpotX = 0, int hotSpotY = 0); wxBitmapType type = wxCURSOR_DEFAULT_TYPE,
int hotSpotX = 0, int hotSpotY = 0);
#if wxUSE_IMAGE #if wxUSE_IMAGE
wxCursor(const wxImage& image); wxCursor(const wxImage& image);
#endif #endif
wxCursor(wxStockCursor id); wxCursor(wxStockCursor id) { InitFromStock(id); }
#if WXWIN_COMPATIBILITY_2_8
wxCursor(int id) { InitFromStock((wxStockCursor)id); }
#endif
virtual ~wxCursor(); virtual ~wxCursor();
// Motif-specific. // Motif-specific.
@@ -46,6 +52,8 @@ protected:
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const; virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
private: private:
void InitFromStock(wxStockCursor);
void Create(const char bits[], int width, int height, void Create(const char bits[], int width, int height,
int hotSpotX = -1, int hotSpotY = -1, int hotSpotX = -1, int hotSpotY = -1,
const char maskBits[] = NULL); const char maskBits[] = NULL);

View File

@@ -23,13 +23,13 @@ public:
// constructors // constructors
wxCursor(); wxCursor();
wxCursor(const wxImage& image); wxCursor(const wxImage& image);
wxCursor(const char bits[], int width, int height,
int hotSpotX = -1, int hotSpotY = -1,
const char maskBits[] = NULL);
wxCursor(const wxString& name, wxCursor(const wxString& name,
wxBitmapType flags = wxBITMAP_TYPE_CUR_RESOURCE, wxBitmapType type = wxCURSOR_DEFAULT_TYPE,
int hotSpotX = 0, int hotSpotY = 0); int hotSpotX = 0, int hotSpotY = 0);
wxCursor(wxStockCursor idCursor); wxCursor(wxStockCursor id) { InitFromStock(id); }
#if WXWIN_COMPATIBILITY_2_8
wxCursor(int id) { InitFromStock((wxStockCursor)id); }
#endif
virtual ~wxCursor(); virtual ~wxCursor();
// implementation only // implementation only
@@ -37,6 +37,8 @@ public:
WXHCURSOR GetHCURSOR() const { return (WXHCURSOR)GetHandle(); } WXHCURSOR GetHCURSOR() const { return (WXHCURSOR)GetHandle(); }
protected: protected:
void InitFromStock(wxStockCursor);
virtual wxGDIImageRefData *CreateData() const; virtual wxGDIImageRefData *CreateData() const;
private: private:

View File

@@ -34,25 +34,22 @@ public:
wxCursor(const wxImage& rImage); wxCursor(const wxImage& rImage);
wxCursor( const char acBits[]
,int nWidth
,int nHeight
,int nHotSpotX = -1
,int nHotSpotY = -1
,const char zMaskBits[] = NULL
);
wxCursor( const wxString& rsName wxCursor( const wxString& rsName
,long lFlags = wxBITMAP_TYPE_CUR_RESOURCE ,wxBitmapType lType = wxCURSOR_DEFAULT_TYPE
,int nHotSpotX = 0 ,int nHotSpotX = 0
,int nHotSpotY = 0 ,int nHotSpotY = 0
); );
wxCursor(wxStockCursor nCursorType); wxCursor(wxStockCursor id) { InitFromStock(id); }
#if WXWIN_COMPATIBILITY_2_8
wxCursor(int id) { InitFromStock((wxStockCursor)id); }
#endif
inline ~wxCursor() { } inline ~wxCursor() { }
inline WXHCURSOR GetHCURSOR(void) const { return (M_CURSORDATA ? M_CURSORDATA->m_hCursor : 0); } inline WXHCURSOR GetHCURSOR(void) const { return (M_CURSORDATA ? M_CURSORDATA->m_hCursor : 0); }
inline void SetHCURSOR(WXHCURSOR hCursor) { SetHandle((WXHANDLE)hCursor); } inline void SetHCURSOR(WXHCURSOR hCursor) { SetHandle((WXHANDLE)hCursor); }
protected: protected:
void InitFromStock(wxStockCursor);
inline virtual wxGDIImageRefData* CreateData(void) const { return (new wxCursorRefData); } inline virtual wxGDIImageRefData* CreateData(void) const { return (new wxCursorRefData); }
private: private:

View File

@@ -20,17 +20,16 @@ class WXDLLIMPEXP_CORE wxCursor : public wxGDIObject
public: public:
wxCursor(); wxCursor();
wxCursor(const char bits[], int width, int height,
int hotSpotX = -1, int hotSpotY = -1,
const char maskBits[] = NULL);
wxCursor(const wxImage & image) ; wxCursor(const wxImage & image) ;
wxCursor(const char* const* bits); wxCursor(const char* const* bits);
wxCursor(const wxString& name, wxCursor(const wxString& name,
wxBitmapType flags = wxBITMAP_TYPE_MACCURSOR_RESOURCE, wxBitmapType type = wxCURSOR_DEFAULT_TYPE,
int hotSpotX = 0, int hotSpotY = 0); int hotSpotX = 0, int hotSpotY = 0);
wxCursor(wxStockCursor cursor_type); wxCursor(wxStockCursor id) { InitFromStock(id); }
#if WXWIN_COMPATIBILITY_2_8
wxCursor(int id) { InitFromStock((wxStockCursor)id); }
#endif
virtual ~wxCursor(); virtual ~wxCursor();
bool CreateFromXpm(const char* const* bits); bool CreateFromXpm(const char* const* bits);
@@ -41,6 +40,8 @@ public:
WXHCURSOR GetHCURSOR() const; WXHCURSOR GetHCURSOR() const;
private: private:
void InitFromStock(wxStockCursor);
virtual wxGDIRefData *CreateGDIRefData() const; virtual wxGDIRefData *CreateGDIRefData() const;
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const; virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;

View File

@@ -23,13 +23,13 @@ public:
// constructors // constructors
wxCursor(); wxCursor();
wxCursor(const wxImage& image); wxCursor(const wxImage& image);
wxCursor(const char bits[], int width, int height,
int hotSpotX = -1, int hotSpotY = -1,
const char maskBits[] = NULL);
wxCursor(const wxString& name, wxCursor(const wxString& name,
long flags = wxBITMAP_TYPE_CUR_RESOURCE, wxBitmapType type = wxCURSOR_DEFAULT_TYPE,
int hotSpotX = 0, int hotSpotY = 0); int hotSpotX = 0, int hotSpotY = 0);
wxCursor(wxStockCursor idCursor); wxCursor(wxStockCursor id) { InitFromStock(id); }
#if WXWIN_COMPATIBILITY_2_8
wxCursor(int id) { InitFromStock((wxStockCursor)id); }
#endif
virtual ~wxCursor(); virtual ~wxCursor();
// implementation only // implementation only
@@ -37,6 +37,7 @@ public:
WXHCURSOR GetHCURSOR() const { return (WXHCURSOR)GetHandle(); } WXHCURSOR GetHCURSOR() const { return (WXHCURSOR)GetHandle(); }
protected: protected:
void InitFromStock(wxStockCursor);
virtual wxGDIImageRefData *CreateData() const; virtual wxGDIImageRefData *CreateData() const;
private: private:

View File

@@ -25,14 +25,17 @@ class WXDLLIMPEXP_CORE wxCursor : public wxGDIObject
{ {
public: public:
wxCursor(); wxCursor();
wxCursor( wxStockCursor cursorId ); wxCursor(wxStockCursor id) { InitFromStock(id); }
#if WXWIN_COMPATIBILITY_2_8
wxCursor(int id) { InitFromStock((wxStockCursor)id); }
#endif
#if wxUSE_IMAGE #if wxUSE_IMAGE
wxCursor( const wxImage & image ); wxCursor( const wxImage & image );
#endif #endif
wxCursor( const char bits[], int width, int height, wxCursor(const wxString& name,
int hotSpotX=-1, int hotSpotY=-1, wxBitmapType type = wxCURSOR_DEFAULT_TYPE,
const char maskBits[]=0, wxColour *fg=0, wxColour *bg=0 ); int hotSpotX = 0, int hotSpotY = 0);
virtual ~wxCursor(); virtual ~wxCursor();
// implementation // implementation
@@ -40,6 +43,8 @@ public:
WXCursor GetCursor() const; WXCursor GetCursor() const;
protected: protected:
void InitFromStock(wxStockCursor);
virtual wxGDIRefData *CreateGDIRefData() const; virtual wxGDIRefData *CreateGDIRefData() const;
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const; virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;

View File

@@ -13,7 +13,7 @@
pointer is, with a picture that might indicate the interpretation of a pointer is, with a picture that might indicate the interpretation of a
mouse click. As with icons, cursors in X and MS Windows are created in a mouse click. As with icons, cursors in X and MS Windows are created in a
different manner. Therefore, separate cursors will be created for the different manner. Therefore, separate cursors will be created for the
different environments. Platform-specific methods for creating a wxCursor different environments. Platform-specific methods for creating a wxCursor
object are catered for, and this is an occasion where conditional object are catered for, and this is an occasion where conditional
compilation will probably be required (see wxIcon for an example). compilation will probably be required (see wxIcon for an example).
@@ -26,8 +26,8 @@
The following is an example of creating a cursor from 32x32 bitmap data The following is an example of creating a cursor from 32x32 bitmap data
(down_bits) and a mask (down_mask) where 1 is black and 0 is white for the (down_bits) and a mask (down_mask) where 1 is black and 0 is white for the
bits, and 1 is opaque and 0 is transparent for the mask. It works on bits, and 1 is opaque and 0 is transparent for the mask.
Windows and GTK+. It works on Windows and GTK+.
@code @code
static char down_bits[] = { 255, 255, 255, 255, 31, static char down_bits[] = { 255, 255, 255, 255, 31,
@@ -63,7 +63,7 @@
down_image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X, 6); down_image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X, 6);
down_image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y, 14); down_image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y, 14);
wxCursor down_cursor = wxCursor(down_image); wxCursor down_cursor = wxCursor(down_image);
#else #elif defined(__WXGTK__) or defined(__WXMOTIF__)
wxCursor down_cursor = wxCursor(down_bits, 32, 32, 6, 14, wxCursor down_cursor = wxCursor(down_bits, 32, 32, 6, 14,
down_mask, wxWHITE, wxBLACK); down_mask, wxWHITE, wxBLACK);
#endif #endif
@@ -78,8 +78,7 @@
- ::wxHOURGLASS_CURSOR - ::wxHOURGLASS_CURSOR
- ::wxCROSS_CURSOR - ::wxCROSS_CURSOR
@see wxBitmap, wxIcon, wxWindow::SetCursor(), wxSetCursor(), @see wxBitmap, wxIcon, wxWindow::SetCursor(), wxSetCursor(), ::wxStockCursor
::wxStockCursor
*/ */
class wxCursor : public wxBitmap class wxCursor : public wxBitmap
{ {
@@ -88,19 +87,18 @@ public:
Default constructor. Default constructor.
*/ */
wxCursor(); wxCursor();
/** /**
Constructs a cursor by passing an array of bits (Motif and GTK+ only). Constructs a cursor by passing an array of bits (XBM data).
@a maskBits is used only under Motif and GTK+. The parameters @a fg and
@a bg are only present on GTK+, and force the cursor to use particular The parameters @a fg and @a bg have an effect only on GTK+, and force
background and foreground colours. the cursor to use particular background and foreground colours.
If either @a hotSpotX or @a hotSpotY is -1, the hotspot will be the If either @a hotSpotX or @a hotSpotY is -1, the hotspot will be the
centre of the cursor image (Motif only). centre of the cursor image (Motif only).
@param bits @param bits
An array of bits. An array of XBM data bits.
@param maskBits
Bits for a mask bitmap.
@param width @param width
Cursor width. Cursor width.
@param height @param height
@@ -109,14 +107,19 @@ public:
Hotspot x coordinate. Hotspot x coordinate.
@param hotSpotY @param hotSpotY
Hotspot y coordinate. Hotspot y coordinate.
@param maskBits
Bits for a mask bitmap.
@onlyfor{wxgtk,wxmotif}
*/ */
wxCursor(const char bits[], int width, int height, wxCursor(const char bits[], int width, int height,
int hotSpotX = -1, int hotSpotY = -1, int hotSpotX = -1, int hotSpotY = -1,
const char maskBits[] = NULL, const char maskBits[] = NULL);
wxColour* fg = NULL, wxColour* bg = NULL);
/** /**
Constructs a cursor by passing a string resource name or filename. Constructs a cursor by passing a string resource name or filename.
@note
On MacOS when specifying a string resource name, first the color On MacOS when specifying a string resource name, first the color
cursors 'crsr' and then the black/white cursors 'CURS' in the resource cursors 'crsr' and then the black/white cursors 'CURS' in the resource
chain are scanned through. chain are scanned through.
@@ -125,20 +128,24 @@ public:
loading from an icon file, to specify the cursor hotspot relative to loading from an icon file, to specify the cursor hotspot relative to
the top left of the image. the top left of the image.
@param cursorName
The name of the resource or the image file to load.
@param type @param type
Icon type to load. Under Motif, type defaults to wxBITMAP_TYPE_XBM. Icon type to load. It defaults to wxCURSOR_DEFAULT_TYPE,
Under Windows, it defaults to wxBITMAP_TYPE_CUR_RESOURCE. Under which is a #define associated to different values on different
MacOS, it defaults to wxBITMAP_TYPE_MACCURSOR_RESOURCE. platforms:
Under X, the permitted cursor types are: - under Windows, it defaults to wxBITMAP_TYPE_CUR_RESOURCE.
<ul> - under MacOS, it defaults to wxBITMAP_TYPE_MACCURSOR_RESOURCE.
<li>wxBITMAP_TYPE_XBM - Load an X bitmap file.</li> - under GTK, it defaults to wxBITMAP_TYPE_XPM.
</ul> - under X11, it defaults to wxBITMAP_TYPE_XPM.
- under Motif, type defaults to wxBITMAP_TYPE_XBM.
Under Windows, the permitted types are: Under Windows, the permitted types are:
- wxBITMAP_TYPE_CUR - Load a cursor from a .cur cursor file (only - wxBITMAP_TYPE_CUR - Load a cursor from a .cur cursor file (only
if USE_RESOURCE_LOADING_IN_MSW is enabled in if USE_RESOURCE_LOADING_IN_MSW is enabled in
setup.h). setup.h).
- wxBITMAP_TYPE_CUR_RESOURCE - Load a Windows resource (as - wxBITMAP_TYPE_CUR_RESOURCE - Load a Windows resource
specified in the .rc file). (as specified in the .rc file).
- wxBITMAP_TYPE_ICO - Load a cursor from a .ico icon file (only if - wxBITMAP_TYPE_ICO - Load a cursor from a .ico icon file (only if
USE_RESOURCE_LOADING_IN_MSW is enabled in USE_RESOURCE_LOADING_IN_MSW is enabled in
setup.h). Specify @a hotSpotX and @a hotSpotY. setup.h). Specify @a hotSpotX and @a hotSpotY.
@@ -147,8 +154,10 @@ public:
@param hotSpotY @param hotSpotY
Hotspot y coordinate. Hotspot y coordinate.
*/ */
wxCursor(const wxString& cursorName, long type, wxCursor(const wxString& cursorName,
wxBitmapType type = wxCURSOR_DEFAULT_TYPE,
int hotSpotX = 0, int hotSpotY = 0); int hotSpotX = 0, int hotSpotY = 0);
/** /**
Constructs a cursor using a cursor identifier. Constructs a cursor using a cursor identifier.
@@ -156,24 +165,26 @@ public:
A stock cursor identifier. See ::wxStockCursor. A stock cursor identifier. See ::wxStockCursor.
*/ */
wxCursor(wxStockCursor cursorId); wxCursor(wxStockCursor cursorId);
/** /**
Constructs a cursor from a wxImage. If cursor are monochrome on the Constructs a cursor from a wxImage. If cursor are monochrome on the
current platform, colors with the RGB elements all greater than 127 current platform, colors with the RGB elements all greater than 127
will be foreground, colors less than this background. The mask (if any) will be foreground, colors less than this background. The mask (if any)
will be used to specify the transparent area. will be used to specify the transparent area.
In wxMSW the foreground will be white and the background black. If the In wxMSW the foreground will be white and the background black.
cursor is larger than 32x32 it is resized. If the cursor is larger than 32x32 it is resized.
In wxGTK, colour cursors and alpha channel are supported (starting from In wxGTK, colour cursors and alpha channel are supported (starting from
GTK+ 2.2). Otherwise the two most frequent colors will be used for GTK+ 2.2). Otherwise the two most frequent colors will be used for
foreground and background. In any case, the cursor will be displayed at foreground and background. In any case, the cursor will be displayed
the size of the image. at the size of the image.
In wxMac, if the cursor is larger than 16x16 it is resized and In wxMac, if the cursor is larger than 16x16 it is resized and
currently only shown as black/white (mask respected). currently only shown as black/white (mask respected).
*/ */
wxCursor(const wxImage& image); wxCursor(const wxImage& image);
/** /**
Copy constructor, uses @ref overview_refcount "reference counting". Copy constructor, uses @ref overview_refcount "reference counting".
@@ -201,7 +212,7 @@ public:
/** /**
Assignment operator, using @ref overview_refcount "reference counting". Assignment operator, using @ref overview_refcount "reference counting".
*/ */
wxCursor operator =(const wxCursor& cursor); wxCursor& operator =(const wxCursor& cursor);
}; };

View File

@@ -43,23 +43,13 @@ public:
IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxObject)
wxCursor::wxCursor(wxStockCursor cursorId) void wxCursor::InitFromStock(wxStockCursor cursorId)
{ {
#warning "FIXME -- implement the cursor as bitmaps (that's what DFB uses)" #warning "FIXME -- implement the cursor as bitmaps (that's what DFB uses)"
} }
wxCursor::wxCursor(const char WXUNUSED(bits)[],
int WXUNUSED(width),
int WXUNUSED(height),
int WXUNUSED(hotSpotX), int WXUNUSED(hotSpotY),
const char WXUNUSED(maskBits)[],
wxColour * WXUNUSED(fg), wxColour * WXUNUSED(bg) )
{
#warning "FIXME"
}
wxCursor::wxCursor(const wxString& cursor_file, wxCursor::wxCursor(const wxString& cursor_file,
long flags, wxBitmapType type,
int WXUNUSED(hotSpotX), int WXUNUSED(hotSpotY)) int WXUNUSED(hotSpotX), int WXUNUSED(hotSpotY))
{ {
#warning "FIXME" #warning "FIXME"

View File

@@ -56,7 +56,7 @@ wxCursor::wxCursor()
{ {
} }
wxCursor::wxCursor( wxStockCursor cursorId ) void wxCursor::InitFromStock( wxStockCursor cursorId )
{ {
m_refData = new wxCursorRefData(); m_refData = new wxCursorRefData();
@@ -122,9 +122,49 @@ wxCursor::wxCursor( wxStockCursor cursorId )
M_CURSORDATA->m_cursor = gdk_cursor_new( gdk_cur ); M_CURSORDATA->m_cursor = gdk_cursor_new( gdk_cur );
} }
// used in the following two ctors
extern GtkWidget *wxGetRootWindow(); extern GtkWidget *wxGetRootWindow();
wxCursor::wxCursor(const char bits[], int width, int height, wxCursor::wxCursor(const wxString& cursor_file,
wxBitmapType type,
int hotSpotX, int hotSpotY)
{
/* TODO: test this code! */
// Must be an XBM file
if (type != wxBITMAP_TYPE_XPM) {
wxLogError("Invalid cursor bitmap type '%d'", type);
return;
}
// load the XPM
GdkBitmap *mask = NULL;
GdkBitmap *data = gdk_pixmap_create_from_xpm( wxGetRootWindow()->window,
&mask, NULL, cursor_file.mb_str() );
if (!data)
return;
// check given hotspot
gint w, h;
gdk_drawable_get_size( data, &w, &h );
if (hotSpotX < 0 || hotSpotX >= w)
hotSpotX = 0;
if (hotSpotY < 0 || hotSpotY >= h)
hotSpotY = 0;
// create the real cursor
m_refData = new wxCursorRefData;
M_CURSORDATA->m_cursor =
gdk_cursor_new_from_pixmap( data, mask,
wxBLACK->GetColor(), wxWHITE->GetColor(),
hotSpotX, hotSpotY );
g_object_unref (data);
g_object_unref (mask);
}
wxCursor::wxCursor(const char bits[], int width, int height,
int hotSpotX, int hotSpotY, int hotSpotX, int hotSpotY,
const char maskBits[], const wxColour *fg, const wxColour *bg) const char maskBits[], const wxColour *fg, const wxColour *bg)
{ {

View File

@@ -61,7 +61,7 @@ wxCursor::wxCursor()
} }
wxCursor::wxCursor( wxStockCursor cursorId ) void wxCursor::InitFromStock( wxStockCursor cursorId )
{ {
m_refData = new wxCursorRefData(); m_refData = new wxCursorRefData();

View File

@@ -65,7 +65,7 @@ wxCursor::wxCursor()
{ {
} }
wxCursor::wxCursor(wxStockCursor cursorId) void wxCursor::InitFromStock(wxStockCursor cursorId)
{ {
if ( !gs_cursorsHash ) if ( !gs_cursorsHash )
gs_cursorsHash = new wxCursorsHash; gs_cursorsHash = new wxCursorsHash;
@@ -140,21 +140,11 @@ wxCursor::wxCursor(wxStockCursor cursorId)
} }
} }
wxCursor::wxCursor(const char WXUNUSED(bits)[],
int WXUNUSED(width),
int WXUNUSED(height),
int WXUNUSED(hotSpotX), int WXUNUSED(hotSpotY),
const char WXUNUSED(maskBits)[],
wxColour * WXUNUSED(fg), wxColour * WXUNUSED(bg) )
{
//FIXME_MGL
}
wxCursor::wxCursor(const wxString& cursor_file, wxCursor::wxCursor(const wxString& cursor_file,
long flags, wxBitmapType type,
int WXUNUSED(hotSpotX), int WXUNUSED(hotSpotY)) int WXUNUSED(hotSpotX), int WXUNUSED(hotSpotY))
{ {
if ( flags == wxBITMAP_TYPE_CUR || flags == wxBITMAP_TYPE_CUR_RESOURCE ) if ( type == wxBITMAP_TYPE_CUR || type == wxBITMAP_TYPE_CUR_RESOURCE )
{ {
m_refData = new wxCursorRefData(); m_refData = new wxCursorRefData();
M_CURSORDATA->m_cursor = new MGLCursor(cursor_file.mb_str()); M_CURSORDATA->m_cursor = new MGLCursor(cursor_file.mb_str());

View File

@@ -244,11 +244,14 @@ wxCursor::wxCursor(const char bits[], int width, int height,
Create(bits, width, height, hotSpotX, hotSpotY, maskBits); Create(bits, width, height, hotSpotX, hotSpotY, maskBits);
} }
wxCursor::wxCursor(const wxString& name, long flags, int hotSpotX, int hotSpotY) wxCursor::wxCursor(const wxString& name, wxBitmapType type, int hotSpotX, int hotSpotY,
const wxColour* WXUNUSED(fg), const wxColour* WXUNUSED(bg))
{ {
// Must be an XBM file // Must be an XBM file
if (flags != wxBITMAP_TYPE_XBM) if (type != wxBITMAP_TYPE_XBM) {
wxLogError("Invalid cursor bitmap type '%d'", type);
return; return;
}
m_refData = new wxCursorRefData; m_refData = new wxCursorRefData;
@@ -284,7 +287,7 @@ wxCursor::wxCursor(const wxString& name, long flags, int hotSpotX, int hotSpotY)
} }
// Cursors by stock number // Cursors by stock number
wxCursor::wxCursor(wxStockCursor id) void wxCursor::InitFromStock(wxStockCursor id)
{ {
m_refData = new wxCursorRefData; m_refData = new wxCursorRefData;
M_CURSORDATA->m_cursorId = id; M_CURSORDATA->m_cursorId = id;

View File

@@ -219,25 +219,10 @@ wxCursor::wxCursor(const wxImage& image)
} }
#endif // wxUSE_IMAGE #endif // wxUSE_IMAGE
wxCursor::wxCursor(const char WXUNUSED(bits)[],
int WXUNUSED(width),
int WXUNUSED(height),
int WXUNUSED(hotSpotX), int WXUNUSED(hotSpotY),
const char WXUNUSED(maskBits)[])
{
}
// MicroWin doesn't have support needed for the other ctors // MicroWin doesn't have support needed for the other ctors
#ifdef __WXMICROWIN__ #ifdef __WXMICROWIN__
wxCursor::wxCursor(const wxString& WXUNUSED(filename), wxCursor::InitFromStock(wxStockCursor WXUNUSED(cursor_type))
wxBitmapType WXUNUSED(kind),
int WXUNUSED(hotSpotX),
int WXUNUSED(hotSpotY))
{
}
wxCursor::wxCursor(int WXUNUSED(cursor_type))
{ {
} }
@@ -280,7 +265,7 @@ wxCursor::wxCursor(const wxString& filename,
break; break;
default: default:
wxFAIL_MSG( _T("unknown cursor resource type") ); wxLogError( _T("unknown cursor resource type '%d'"), kind );
hcursor = NULL; hcursor = NULL;
} }
@@ -292,7 +277,7 @@ wxCursor::wxCursor(const wxString& filename,
} }
// Cursors by stock number // Cursors by stock number
wxCursor::wxCursor(wxStockCursor idCursor) void wxCursor::InitFromStock(wxStockCursor idCursor)
{ {
// all wxWidgets standard cursors // all wxWidgets standard cursors
static const struct StdCursor static const struct StdCursor

View File

@@ -53,15 +53,6 @@ wxCursor::wxCursor(void)
{ {
} }
wxCursor::wxCursor(const char WXUNUSED(bits)[],
int WXUNUSED(width),
int WXUNUSED(height),
int WXUNUSED(hotSpotX),
int WXUNUSED(hotSpotY),
const char WXUNUSED(maskBits)[])
{
}
wxCursor::wxCursor(const wxImage& rImage) wxCursor::wxCursor(const wxImage& rImage)
{ {
wxImage vImage32 = rImage.Scale(32,32); wxImage vImage32 = rImage.Scale(32,32);
@@ -94,7 +85,7 @@ wxCursor::wxCursor(const wxImage& rImage)
} // end of wxCursor::wxCursor } // end of wxCursor::wxCursor
wxCursor::wxCursor( const wxString& WXUNUSED(rsCursorFile), wxCursor::wxCursor( const wxString& WXUNUSED(rsCursorFile),
long lFlags, wxBitmapType type,
int WXUNUSED(nHotSpotX), int WXUNUSED(nHotSpotX),
int WXUNUSED(nHotSpotY) ) int WXUNUSED(nHotSpotY) )
{ {
@@ -103,17 +94,19 @@ wxCursor::wxCursor( const wxString& WXUNUSED(rsCursorFile),
pRefData = new wxCursorRefData; pRefData = new wxCursorRefData;
m_refData = pRefData; m_refData = pRefData;
pRefData->m_bDestroyCursor = false; pRefData->m_bDestroyCursor = false;
if (lFlags == wxBITMAP_TYPE_CUR_RESOURCE) if (type == wxBITMAP_TYPE_CUR_RESOURCE)
{ {
pRefData->m_hCursor = (WXHCURSOR) ::WinLoadPointer( HWND_DESKTOP pRefData->m_hCursor = (WXHCURSOR) ::WinLoadPointer( HWND_DESKTOP
,0 ,0
,(ULONG)lFlags // if OS/2 this should be the resource Id ,(ULONG)type // if OS/2 this should be the resource Id
); );
} }
else
wxLogError("Invalid cursor bitmap type '%d'", type);
} // end of wxCursor::wxCursor } // end of wxCursor::wxCursor
// Cursors by stock number // Cursors by stock number
wxCursor::wxCursor(wxStockCursor nCursorType) void wxCursor::InitFromStock(wxStockCursor nCursorType)
{ {
wxCursorRefData* pRefData = new wxCursorRefData; wxCursorRefData* pRefData = new wxCursorRefData;

View File

@@ -274,11 +274,6 @@ wxCursor::wxCursor()
{ {
} }
wxCursor::wxCursor(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSED(height),
int WXUNUSED(hotSpotX), int WXUNUSED(hotSpotY), const char WXUNUSED(maskBits)[])
{
}
wxCursor::wxCursor( const wxImage &image ) wxCursor::wxCursor( const wxImage &image )
{ {
#if wxUSE_IMAGE #if wxUSE_IMAGE
@@ -556,7 +551,7 @@ wxCursor::wxCursor(const wxString& cursor_file, wxBitmapType flags, int hotSpotX
} }
// Cursors by stock number // Cursors by stock number
wxCursor::wxCursor(wxStockCursor cursor_type) wxCursor::InitFromStock(wxStockCursor cursor_type)
{ {
m_refData = new wxCursorRefData; m_refData = new wxCursorRefData;
#if wxOSX_USE_COCOA #if wxOSX_USE_COCOA

View File

@@ -80,23 +80,15 @@ wxCursor::wxCursor(const wxImage& image)
} }
#endif #endif
wxCursor::wxCursor(const char WXUNUSED(bits)[],
int WXUNUSED(width),
int WXUNUSED(height),
int WXUNUSED(hotSpotX), int WXUNUSED(hotSpotY),
const char WXUNUSED(maskBits)[])
{
}
wxCursor::wxCursor(const wxString& filename, wxCursor::wxCursor(const wxString& filename,
long kind, wxBitmapType kind,
int hotSpotX, int hotSpotX,
int hotSpotY) int hotSpotY)
{ {
} }
// Cursors by stock number // Cursors by stock number
wxCursor::wxCursor(wxStockCursor idCursor) void wxCursor::InitFromStock(wxStockCursor idCursor)
{ {
} }

View File

@@ -66,7 +66,7 @@ wxCursor::wxCursor()
} }
wxCursor::wxCursor( wxStockCursor cursorId ) void wxCursor::InitFromStock( wxStockCursor cursorId )
{ {
m_refData = new wxCursorRefData(); m_refData = new wxCursorRefData();
@@ -124,13 +124,11 @@ wxCursor::wxCursor( wxStockCursor cursorId )
#endif #endif
} }
wxCursor::wxCursor(const char WXUNUSED(bits)[], wxCursor::wxCursor(const wxString& name,
int WXUNUSED(width), int WXUNUSED(height), wxBitmapType type,
int WXUNUSED(hotSpotX), int WXUNUSED(hotSpotY), int hotSpotX, int hotSpotY)
const char WXUNUSED(maskBits)[],
wxColour *WXUNUSED(fg), wxColour *WXUNUSED(bg))
{ {
wxFAIL_MSG( wxT("wxCursor creation from bits not yet implemented") ); wxFAIL_MSG( wxT("wxCursor creation from file not yet implemented") );
} }
#if wxUSE_IMAGE #if wxUSE_IMAGE