diff --git a/docs/changes.txt b/docs/changes.txt index 60a6dd338e..4659001928 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -76,6 +76,7 @@ All (GUI): - Add wxGenericListCtrl::EndEditLabel() (Tim Kosse). - Use native renderer for drawing check boxes in wxPropertyGrid (Eran Ifrah). - Fix drawing custom colours of wxEnumProperty items in wxPG (Artur Wieczorek). +- Add wxBitmap ctor from wxCursor. wxGTK: diff --git a/include/wx/gtk/bitmap.h b/include/wx/gtk/bitmap.h index a7900119dd..c6dc0ba533 100644 --- a/include/wx/gtk/bitmap.h +++ b/include/wx/gtk/bitmap.h @@ -15,6 +15,7 @@ typedef struct _cairo_surface cairo_surface_t; #endif typedef struct _GdkPixbuf GdkPixbuf; class WXDLLIMPEXP_FWD_CORE wxPixelDataBase; +class WXDLLIMPEXP_FWD_CORE wxCursor; //----------------------------------------------------------------------------- // wxMask @@ -81,6 +82,7 @@ public: wxBitmap(const wxImage& image, int depth = wxBITMAP_SCREEN_DEPTH); #endif // wxUSE_IMAGE wxBitmap(GdkPixbuf* pixbuf, int depth = 0); + wxEXPLICIT wxBitmap(const wxCursor& cursor); virtual ~wxBitmap(); bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH) wxOVERRIDE; diff --git a/include/wx/msw/bitmap.h b/include/wx/msw/bitmap.h index 5bf3a15ba5..c7a1f1d1ed 100644 --- a/include/wx/msw/bitmap.h +++ b/include/wx/msw/bitmap.h @@ -97,6 +97,12 @@ public: CopyFromIcon(icon, transp); } + // Convert from wxCursor + wxEXPLICIT wxBitmap(const wxCursor& cursor) + { + (void)CopyFromCursor(cursor, wxBitmapTransparency_Auto); + } + wxBitmap& operator=(const wxIcon& icon) { (void)CopyFromIcon(icon); diff --git a/interface/wx/bitmap.h b/interface/wx/bitmap.h index cfe40aa257..8009dad792 100644 --- a/interface/wx/bitmap.h +++ b/interface/wx/bitmap.h @@ -346,6 +346,21 @@ public: */ wxBitmap(const wxImage& img, int depth = wxBITMAP_SCREEN_DEPTH); + /** + Creates bitmap corresponding to the given cursor. + + This can be useful to display a cursor as it cannot be drawn directly + on a window. + + This constructor only exists in wxMSW and wxGTK (where it is + implemented for GTK+ 2.8 or later) only. + + @param cursor A valid wxCursor. + + @since 3.1.0 + */ + explicit wxBitmap(const wxCursor& cursor); + /** Destructor. See @ref overview_refcount_destruct for more info. diff --git a/src/gtk/bitmap.cpp b/src/gtk/bitmap.cpp index d6513b7cd5..077f06de79 100644 --- a/src/gtk/bitmap.cpp +++ b/src/gtk/bitmap.cpp @@ -515,6 +515,19 @@ wxBitmap::wxBitmap(GdkPixmap* pixmap) } #endif +wxBitmap::wxBitmap(const wxCursor& cursor) +{ +#if GTK_CHECK_VERSION(2,8,0) + if (gtk_check_version(2,8,0) == NULL) + { + GdkPixbuf *pixbuf = gdk_cursor_get_image(cursor.GetCursor()); + *this = wxBitmap(pixbuf); + } +#else + wxUnusedVar(cursor); +#endif +} + wxBitmap::~wxBitmap() { }