+}
+
+#if wxUSE_IMAGE
+wxCursor::wxCursor(const wxString& cursor_file,
+ wxBitmapType type,
+ int hotSpotX, int hotSpotY)
+{
+ wxImage img;
+ if (!img.LoadFile(cursor_file, type))
+ return;
+
+ // eventually set the hotspot:
+ if (!img.HasOption(wxIMAGE_OPTION_CUR_HOTSPOT_X))
+ img.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X, hotSpotX);
+ if (!img.HasOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y))
+ img.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y, hotSpotY);
+
+ InitFromImage(img);
+}
+
+wxCursor::wxCursor(const wxImage& img)
+{
+ InitFromImage(img);
+}
+#endif
+
+wxCursor::wxCursor(const char bits[], int width, int height,
+ int hotSpotX, int hotSpotY,
+ const char maskBits[], const wxColour *fg, const wxColour *bg)
+{
+ m_refData = new wxCursorRefData;
+ if (hotSpotX < 0 || hotSpotX >= width)
+ hotSpotX = 0;
+ if (hotSpotY < 0 || hotSpotY >= height)
+ hotSpotY = 0;
+#ifdef __WXGTK3__
+ wxBitmap bitmap(bits, width, height);
+ if (maskBits)
+ bitmap.SetMask(new wxMask(wxBitmap(maskBits, width, height)));
+ GdkPixbuf* pixbuf = bitmap.GetPixbuf();
+ if (fg || bg)
+ {
+ const int stride = gdk_pixbuf_get_rowstride(pixbuf);
+ const int n_channels = gdk_pixbuf_get_n_channels(pixbuf);
+ guchar* data = gdk_pixbuf_get_pixels(pixbuf);
+ for (int j = 0; j < height; j++, data += stride)
+ {
+ guchar* p = data;
+ for (int i = 0; i < width; i++, p += n_channels)
+ {
+ if (p[0])
+ {
+ if (fg)
+ {
+ p[0] = fg->Red();
+ p[1] = fg->Green();
+ p[2] = fg->Blue();
+ }
+ }
+ else
+ {
+ if (bg)
+ {
+ p[0] = bg->Red();
+ p[1] = bg->Green();
+ p[2] = bg->Blue();
+ }
+ }
+ }
+ }
+ }
+ M_CURSORDATA->m_cursor = gdk_cursor_new_from_pixbuf(gtk_widget_get_display(wxGetRootWindow()), pixbuf, hotSpotX, hotSpotY);
+#else
+ if (!maskBits)
+ maskBits = bits;
+ if (!fg)
+ fg = wxBLACK;
+ if (!bg)
+ bg = wxWHITE;
+
+ GdkBitmap* data = gdk_bitmap_create_from_data(
+ gtk_widget_get_window(wxGetRootWindow()), const_cast<char*>(bits), width, height);
+ GdkBitmap* mask = gdk_bitmap_create_from_data(
+ gtk_widget_get_window(wxGetRootWindow()), const_cast<char*>(maskBits), width, height);
+
+ M_CURSORDATA->m_cursor = gdk_cursor_new_from_pixmap(
+ data, mask, fg->GetColor(), bg->GetColor(),
+ hotSpotX, hotSpotY );