Ticket #15699: Allow-creating-wxBitmap-from-wxCursor-wxGTK-v2.patch

File Allow-creating-wxBitmap-from-wxCursor-wxGTK-v2.patch, 1.1 KB (added by awi, 6 years ago)

Allow converting wxCursor to wxBitmap under wxGTK.

  • include/wx/gtk/bitmap.h

    diff --git a/include/wx/gtk/bitmap.h b/include/wx/gtk/bitmap.h
    a b typedef struct _cairo_surface cairo_surface_t; 
    1515#endif
    1616typedef struct _GdkPixbuf GdkPixbuf;
    1717class WXDLLIMPEXP_FWD_CORE wxPixelDataBase;
     18class WXDLLIMPEXP_FWD_CORE wxCursor;
    1819
    1920//-----------------------------------------------------------------------------
    2021// wxMask
    public: 
    8182    wxBitmap(const wxImage& image, int depth = wxBITMAP_SCREEN_DEPTH);
    8283#endif // wxUSE_IMAGE
    8384    wxBitmap(GdkPixbuf* pixbuf, int depth = 0);
     85    wxEXPLICIT wxBitmap(const wxCursor& cursor);
    8486    virtual ~wxBitmap();
    8587
    8688    bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH) wxOVERRIDE;
  • src/gtk/bitmap.cpp

    diff --git a/src/gtk/bitmap.cpp b/src/gtk/bitmap.cpp
    a b wxBitmap::wxBitmap(GdkPixmap* pixmap) 
    515515}
    516516#endif
    517517
     518wxBitmap::wxBitmap(const wxCursor& cursor)
     519{
     520#if GTK_CHECK_VERSION(2,8,0)
     521    GdkPixbuf *pixbuf = gdk_cursor_get_image(cursor.GetCursor());
     522    *this = wxBitmap(pixbuf);
     523#else
     524    wxUnusedVar(cursor);
     525#endif
     526}
     527
    518528wxBitmap::~wxBitmap()
    519529{
    520530}