/*# @method new_from_pixmap GdkCursor @brief Creates a new cursor from a given pixmap and mask. @param source the pixmap specifying the cursor (GdkPixmap). @param mask the pixmap specifying the mask, which must be the same size as source (GdkPixmap). @param fg the foreground color, used for the bits in the source which are 1 (GdkColor). @param bg the background color, used for the bits in the source which are 0 (GdkColor). @param x the horizontal offset of the 'hotspot' of the cursor. @param y the vertical offset of the 'hotspot' of the cursor. @return a new GdkCursor. Both the pixmap and mask must have a depth of 1 (i.e. each pixel has only 2 values - on or off). The standard cursor size is 16 by 16 pixels. You can create a bitmap from inline data as in the below example. [...] */ FALCON_FUNC Cursor::new_from_pixmap( VMARG ) { Item* i_src = vm->param( 0 ); Item* i_mask = vm->param( 1 ); Item* i_fg = vm->param( 2 ); Item* i_bg = vm->param( 3 ); Item* i_x = vm->param( 4 ); Item* i_y = vm->param( 5 ); #ifndef NO_PARAMETER_CHECK if ( !i_src || !i_src->isObject() || !IS_DERIVED( i_src, GdkPixmap ) || !i_mask || !i_mask->isObject() || !IS_DERIVED( i_mask, GdkPixmap ) || !i_fg || !i_fg->isObject() || !IS_DERIVED( i_fg, GdkColor ) || !i_bg || !i_bg->isObject() || !IS_DERIVED( i_bg, GdkColor ) || !i_x || !i_x->isInteger() || !i_y || !i_y->isInteger() ) throw_inv_params( "GdkPixmap,GdkPixmap,GdkColor,GdkColor,I,I" ); #endif vm->retval( new Gdk::Cursor( vm->findWKI( "GdkCursor" )->asClass(), gdk_cursor_new_from_pixmap( GET_PIXMAP( *i_src ), GET_PIXMAP( *i_mask ), GET_COLOR( *i_fg ), GET_COLOR( *i_bg ), i_x->asInteger(), i_y->asInteger() ) ) ); }
static gboolean gonna_hide(gpointer data) { beforehiding--; if (beforehiding == 0) { static char source_data[] = { 0 }; static char mask_data[] = { 0 }; GdkCursor *cursor; GdkPixmap *source, *mask; GdkColor fg = { 0, 65535, 65535, 65535 }; GdkColor bg = { 0, 0, 0, 0 }; source = gdk_bitmap_create_from_data(NULL, source_data, 1, 1); mask = gdk_bitmap_create_from_data(NULL, mask_data, 1, 1); cursor = gdk_cursor_new_from_pixmap(source, mask, &fg, &bg, 1, 1); gdk_pixmap_unref(source); gdk_pixmap_unref(mask); gdk_window_set_cursor(GTK_WIDGET(data)->window, cursor); return FALSE; } else { return TRUE; } }
static void gtk_ui_load_cursor(const char *name, int masked, MCursor **cursorp) { MCursor *cursor; GdkBitmap *bitmap, *mask; cursormap *c; cursor = xalloc(sizeof *cursor); for (c = cursors; c->name != NULL; c++) if (strcmp(name, c->name) == 0) break; if (c->name == NULL) fatal("couldn't load cursor: %s", name); bitmap = gdk_bitmap_create_from_data(field->window, c->data, c->width, c->height); if (masked == CURSOR_SEP_MASK) mask = gdk_bitmap_create_from_data(field->window, c->maskdata, c->width, c->height); else mask = bitmap; cursor->cursor = gdk_cursor_new_from_pixmap(bitmap, mask, &black, &white, c->width/2, c->height/2); *cursorp = cursor; }
GdkCursor * gl_view_line_get_create_cursor (void) { GdkCursor *cursor = NULL; GdkPixmap *pixmap_data, *pixmap_mask; GdkColor fg = { 0, 0, 0, 0 }; GdkColor bg = { 0, 65535, 65535, 65535 }; gl_debug (DEBUG_VIEW, "START"); pixmap_data = gdk_bitmap_create_from_data (NULL, (gchar *)cursor_line_bits, cursor_line_width, cursor_line_height); pixmap_mask = gdk_bitmap_create_from_data (NULL, (gchar *)cursor_line_mask_bits, cursor_line_mask_width, cursor_line_mask_height); cursor = gdk_cursor_new_from_pixmap (pixmap_data, pixmap_mask, &fg, &bg, cursor_line_x_hot, cursor_line_y_hot); gl_debug (DEBUG_VIEW, "END"); return cursor; }
/* load in the cursors */ static void ui_common_cursor_init(void) { GdkPixmap *source, *mask; GdkColor fg = { 0, 0, 0, 0 }; /* black. */ GdkColor bg = { 0, 0, 0, 0 }; /* black */ GdkCursor * small_dot; source = gdk_bitmap_create_from_data(NULL, small_dot_bits, small_dot_width, small_dot_height); mask = gdk_bitmap_create_from_data(NULL, small_dot_bits, small_dot_width, small_dot_height); small_dot = gdk_cursor_new_from_pixmap (source, mask, &fg, &bg, 2,2); g_object_unref (source); g_object_unref (mask); /* load in the cursors */ ui_common_cursor[UI_CURSOR_DEFAULT] = NULL; ui_common_cursor[UI_CURSOR_ROI_MODE] = gdk_cursor_new(GDK_DRAFT_SMALL); ui_common_cursor[UI_CURSOR_ROI_RESIZE] = small_dot; /* was GDK_SIZING */ ui_common_cursor[UI_CURSOR_ROI_ROTATE] = small_dot; /* was GDK_EXCHANGE */ ui_common_cursor[UI_CURSOR_ROI_DRAW] = gdk_cursor_new(GDK_PENCIL); ui_common_cursor[UI_CURSOR_OBJECT_SHIFT] = small_dot; /* was GDK_FLEUR */ ui_common_cursor[UI_CURSOR_ROI_ISOCONTOUR] = gdk_cursor_new(GDK_DRAFT_SMALL); ui_common_cursor[UI_CURSOR_ROI_ERASE] = gdk_cursor_new(GDK_DRAFT_SMALL); ui_common_cursor[UI_CURSOR_DATA_SET_MODE] = gdk_cursor_new(GDK_CROSSHAIR); ui_common_cursor[UI_CURSOR_FIDUCIAL_MARK_MODE] = gdk_cursor_new(GDK_DRAFT_SMALL); ui_common_cursor[UI_CURSOR_RENDERING_ROTATE_XY] = gdk_cursor_new(GDK_FLEUR); ui_common_cursor[UI_CURSOR_RENDERING_ROTATE_Z] = gdk_cursor_new(GDK_EXCHANGE); ui_common_cursor[UI_CURSOR_WAIT] = gdk_cursor_new(GDK_WATCH); ui_common_cursors_initialized = TRUE; return; }
void e_cursors_init (void) { int i; e_color_init (); for (i = 0; cursors [i].hot_x; i++) { if (cursors [i].hot_x < 0) cursors [i].cursor = gdk_cursor_new (cursors [i].hot_y); else { GdkBitmap *bitmap = NULL, *mask = NULL; create_bitmap_and_mask_from_xpm (&bitmap, &mask, cursors [i].xpm); /* The foreground and background colours are reversed. * See comment above for explanation. */ cursors [i].cursor = gdk_cursor_new_from_pixmap ( bitmap, mask, &e_black, &e_white, cursors [i].hot_x, cursors [i].hot_y); g_object_unref (bitmap); g_object_unref (mask); } } g_return_if_fail (i == E_CURSOR_NUM_CURSORS); }
static GdkCursor * create_cursor(GdkWindow *window, const gchar *data, int width, int height, const gchar *mask, int hot_x, int hot_y) { GdkBitmap *dbit, *mbit; GdkColor black, white; GdkCursor *cursor; g_return_val_if_fail(window != NULL, NULL); dbit = gdk_bitmap_create_from_data(window, data, width, height); mbit = gdk_bitmap_create_from_data(window, mask, width, height); g_assert(dbit != NULL && mbit != NULL); gdk_color_black(gdk_window_get_colormap(window), &black); gdk_color_white(gdk_window_get_colormap(window), &white); cursor = gdk_cursor_new_from_pixmap(dbit, mbit, &white,&black, hot_x,hot_y); g_assert(cursor != NULL); gdk_bitmap_unref(dbit); gdk_bitmap_unref(mbit); return cursor; }
/** * Grab the keyboard and mouse for the display. The mouse cursor is hidden and * moved to the centre of the window. * * @param win The window receiving the grab * @return TRUE if the grab was successful, FALSE on failure. */ gboolean video_window_grab_display( main_window_t win ) { GdkWindow *gdkwin = win->video->window; GdkColor color = { 0,0,0,0 }; char bytes[32]; /* 16 * 16 / 8 */ memset(bytes, 0, 32); GdkPixmap *pixmap = gdk_bitmap_create_from_data(NULL, bytes, 16, 16); GdkCursor *cursor = gdk_cursor_new_from_pixmap(pixmap, pixmap, &color, &color, 16, 16); gdk_pixmap_unref(pixmap); gboolean success = gdk_pointer_grab( gdkwin, FALSE, GDK_POINTER_MOTION_MASK|GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK, gdkwin, cursor, GDK_CURRENT_TIME ) == GDK_GRAB_SUCCESS; gdk_cursor_unref(cursor); if( success ) { success = gdk_keyboard_grab( gdkwin, FALSE, GDK_CURRENT_TIME ) == GDK_GRAB_SUCCESS; if( !success ) { gdk_pointer_ungrab(GDK_CURRENT_TIME); } } win->is_grabbed = success; main_window_set_running(win, dreamcast_is_running()); return success; }
static GdkCursorType gport_set_cursor (GdkCursorType shape) { GdkWindow *window; GdkCursorType old_shape = gport->X_cursor_shape; GdkColor fg = { 0, 65535, 65535, 65535 }; /* white */ GdkColor bg = { 0, 0, 0, 0 }; /* black */ if (gport->drawing_area == NULL) return GDK_X_CURSOR; window = gtk_widget_get_window (gport->drawing_area); if (gport->X_cursor_shape == shape) return shape; /* check if window exists to prevent from fatal errors */ if (window == NULL) return GDK_X_CURSOR; gport->X_cursor_shape = shape; if (shape > GDK_LAST_CURSOR) { if (shape == CUSTOM_CURSOR_CLOCKWISE) gport->X_cursor = gdk_cursor_new_from_pixmap (XC_clock_source, XC_clock_mask, &fg, &bg, ICON_X_HOT, ICON_Y_HOT); else if (shape == CUSTOM_CURSOR_DRAG) gport->X_cursor = gdk_cursor_new_from_pixmap (XC_hand_source, XC_hand_mask, &fg, &bg, ICON_X_HOT, ICON_Y_HOT); else if (shape == CUSTOM_CURSOR_LOCK) gport->X_cursor = gdk_cursor_new_from_pixmap (XC_lock_source, XC_lock_mask, &fg, &bg, ICON_X_HOT, ICON_Y_HOT); } else gport->X_cursor = gdk_cursor_new (shape); gdk_window_set_cursor (window, gport->X_cursor); gdk_cursor_unref (gport->X_cursor); return old_shape; }
void create_cursors(void) { static GdkColor color1={0,0xFFFF,0xFFFF,0xFFFF}; static GdkColor color2={0,0x0000,0x0000,0x0000}; GdkBitmap *curs_pix, *msk_pix; curs_pix = gdk_bitmap_create_from_data(NULL, (const gchar *)point_bits, point_width, point_height); msk_pix = gdk_bitmap_create_from_data(NULL, (const gchar *)pointmsk_bits, pointmsk_width, pointmsk_height); cpoint = gdk_cursor_new_from_pixmap(curs_pix, msk_pix, &color2, &color1, 3,0); gdk_bitmap_unref(curs_pix); gdk_bitmap_unref(msk_pix); curs_pix = gdk_bitmap_create_from_data(NULL, (const gchar *)pour_bits, pour_width, pour_height); msk_pix = gdk_bitmap_create_from_data(NULL, (const gchar *)pourmsk_bits, pourmsk_width, pourmsk_height); cfill = gdk_cursor_new_from_pixmap(curs_pix, msk_pix, &color2, &color1, 14, 13); gdk_bitmap_unref(curs_pix); gdk_bitmap_unref(msk_pix); curs_pix = gdk_bitmap_create_from_data(NULL, (const gchar *)cross_bits, cross_width, cross_height); msk_pix = gdk_bitmap_create_from_data(NULL, (const gchar *)crossmsk_bits, crossmsk_width, crossmsk_height); ccross = gdk_cursor_new_from_pixmap(curs_pix, msk_pix, &color2, &color1, 8,8); gdk_bitmap_unref(curs_pix); gdk_bitmap_unref(msk_pix); curs_pix = gdk_bitmap_create_from_data(NULL, (const gchar *)select_bits, select_width, select_height); msk_pix = gdk_bitmap_create_from_data(NULL, (const gchar *)selectmsk_bits, selectmsk_width, selectmsk_height); cselect = gdk_cursor_new_from_pixmap(curs_pix, msk_pix, &color2, &color1, 0,select_height); gdk_bitmap_unref(curs_pix); gdk_bitmap_unref(msk_pix); }
static GdkCursorType gport_set_cursor (GdkCursorType shape) { GdkCursorType old_shape = gport->X_cursor_shape; GdkColor fg = { 0, 65535, 65535, 65535 }; /* white */ GdkColor bg = { 0, 0, 0, 0 }; /* black */ if (!gport->drawing_area || !gport->drawing_area->window) return (GdkCursorType)0; if (gport->X_cursor_shape == shape) return shape; /* check if window exists to prevent from fatal errors */ if (gport->drawing_area->window) { gport->X_cursor_shape = shape; if (shape > GDK_LAST_CURSOR) { if (shape == CUSTOM_CURSOR_CLOCKWISE) gport->X_cursor = gdk_cursor_new_from_pixmap (XC_clock_source, XC_clock_mask, &fg, &bg, ICON_X_HOT, ICON_Y_HOT); else if (shape == CUSTOM_CURSOR_DRAG) gport->X_cursor = gdk_cursor_new_from_pixmap (XC_hand_source, XC_hand_mask, &fg, &bg, ICON_X_HOT, ICON_Y_HOT); else if (shape == CUSTOM_CURSOR_LOCK) gport->X_cursor = gdk_cursor_new_from_pixmap (XC_lock_source, XC_lock_mask, &fg, &bg, ICON_X_HOT, ICON_Y_HOT); } else gport->X_cursor = gdk_cursor_new (shape); gdk_window_set_cursor (gport->drawing_area->window, gport->X_cursor); gdk_cursor_unref (gport->X_cursor); return (old_shape); } return (DEFAULT_CURSORSHAPE); }
static PlatformRefPtr<GdkCursor> createNamedCursor(CustomCursorType cursorType) { CustomCursor cursor = CustomCursors[cursorType]; PlatformRefPtr<GdkCursor> c = adoptPlatformRef(gdk_cursor_new_from_name(gdk_display_get_default(), cursor.name)); if (c) return c; const GdkColor fg = { 0, 0, 0, 0 }; const GdkColor bg = { 65535, 65535, 65535, 65535 }; IntSize cursorSize = IntSize(32, 32); PlatformRefPtr<GdkPixmap> source = adoptPlatformRef(createPixmapFromBits(cursor.bits, cursorSize)); PlatformRefPtr<GdkPixmap> mask = adoptPlatformRef(createPixmapFromBits(cursor.mask_bits, cursorSize)); return adoptPlatformRef(gdk_cursor_new_from_pixmap(source.get(), mask.get(), &fg, &bg, cursor.hot_x, cursor.hot_y)); }
GdkCursor* create_blank_cursor(){ GdkPixmap *pixmap; GdkBitmap *mask; char buffer [( 32 * 32 ) / 8]; memset( buffer, 0, ( 32 * 32 ) / 8 ); GdkColor white = {0, 0xffff, 0xffff, 0xffff}; GdkColor black = {0, 0x0000, 0x0000, 0x0000}; pixmap = gdk_bitmap_create_from_data( 0, buffer, 32, 32 ); mask = gdk_bitmap_create_from_data( 0, buffer, 32, 32 ); GdkCursor *cursor = gdk_cursor_new_from_pixmap( pixmap, mask, &white, &black, 1, 1 ); gdk_drawable_unref( pixmap ); gdk_drawable_unref( mask ); return cursor; }
static GdkCursor* customCursorNew(CustomCursorType cursorType) { CustomCursor cursor = CustomCursors[cursorType]; GdkCursor* c = gdk_cursor_new_from_name(gdk_display_get_default(), cursor.name); if (!c) { const GdkColor fg = { 0, 0, 0, 0 }; const GdkColor bg = { 65535, 65535, 65535, 65535 }; GdkPixmap* source = gdk_bitmap_create_from_data(NULL, cursor.bits, 32, 32); GdkPixmap* mask = gdk_bitmap_create_from_data(NULL, cursor.mask_bits, 32, 32); c = gdk_cursor_new_from_pixmap(source, mask, &fg, &bg, cursor.hot_x, cursor.hot_y); g_object_unref(source); g_object_unref(mask); } return c; }
int hide_cursor (GtkWindow* window) { GdkCursor* cursor; GdkPixmap* source, *mask; GdkColor fg = { 0, 0, 0, 0 }; /* Transparent. */ GdkColor bg = { 0, 0, 0, 0 }; /* Transparent. */ source = gdk_bitmap_create_from_data (NULL, cursor1_bits, cursor1_width, cursor1_height); mask = gdk_bitmap_create_from_data (NULL, cursor1mask_bits, cursor1_width, cursor1_height); cursor = gdk_cursor_new_from_pixmap (source, mask, &fg, &bg, 8, 8); gdk_pixmap_unref (source); gdk_pixmap_unref (mask); gdk_window_set_cursor (((GtkWidget*)window)->window, cursor); }
void mouse_init_cursor(void) { #if !GTK_CHECK_VERSION(2, 2, 0) static char cursor[] = { 0x00 }; GdkColor fg = { 0, 0, 0, 0 }; GdkColor bg = { 0, 0, 0, 0 }; GdkBitmap *source = gdk_bitmap_create_from_data (NULL, cursor, 1, 1); GdkBitmap *mask = gdk_bitmap_create_from_data (NULL, cursor, 1, 1); blankCursor = gdk_cursor_new_from_pixmap (source, mask, &fg, &bg, 1, 1); g_object_unref (source); g_object_unref (mask); #else /* GDK_BLANK_CURSOR exists since 2.16 */ /* FIXME: to support multiple screens, we must use gdk_cursor_new_for_display */ blankCursor = gdk_cursor_new(GDK_BLANK_CURSOR); #endif }
/** * cursor_get: * @window: Window whose screen and colormap determine the cursor's. * @type: A cursor type. * * Creates a cursor. * * Return value: The newly-created cursor. **/ GdkCursor* cursor_get (GtkWidget *window, CursorType type) { GdkBitmap *data; GdkBitmap *mask; GdkCursor *cursor; GtkStyle *style; if (type == CURSOR_DEFAULT) return NULL; g_return_val_if_fail (window != NULL, NULL); g_return_val_if_fail (type >= 0 && type < CURSOR_NUM_CURSORS, NULL); g_assert (cursors[type].data_width == cursors[type].mask_width); g_assert (cursors[type].data_height == cursors[type].mask_height); data = gdk_bitmap_create_from_data (window->window, cursors[type].data, cursors[type].data_width, cursors[type].data_height); mask = gdk_bitmap_create_from_data (window->window, cursors[type].mask, cursors[type].mask_width, cursors[type].mask_height); g_assert (data != NULL && mask != NULL); style = gtk_widget_get_style (window); cursor = gdk_cursor_new_from_pixmap (data, mask, &style->white, &style->black, cursors[type].hot_x, cursors[type].hot_y); g_assert (cursor != NULL); g_object_unref (data); g_object_unref (mask); return cursor; }
QCursor::QCursor(const QPixmap &pixmap) : cursor(NULL) { ERROR("not yet implemented"); GdkPixbuf* buf = pixmap.image()->handle(); QPoint hotSpot(0,0); #if (GTK_MAJOR_VERSION >= 2) && (GTK_MINOR_VERSION >=4) cursor = gdk_cursor_new_from_pixbuf(GDK_DISPLAY(), buf, hotSpot.x(), hotSpot.y()); #else GdkPixmap *gdkpixmap; GdkBitmap *mask; gdk_pixbuf_render_pixmap_and_mask(buf, &gdkpixmap, &mask, 100); GdkColor fg = { 0, 65535, 65535, 65535 }; /* White. */ GdkColor bg = { 0, 0, 0, 0 }; /* Black. */ cursor = gdk_cursor_new_from_pixmap(mask, mask, &fg, &bg, hotSpot.x(), hotSpot.y()); g_object_unref(gdkpixmap); g_object_unref(mask); #endif }
int mousemng_initialize(void) { static gchar hide_cursor[16*16/8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; ms = ms_default; ms.cursor_pixmap = gdk_pixmap_create_from_data(main_window->window, hide_cursor, 16, 16, 1, &main_window->style->black, &main_window->style->black); ms.cursor = gdk_cursor_new_from_pixmap(ms.cursor_pixmap, ms.cursor_pixmap, &main_window->style->black, &main_window->style->black, 0, 0); return SUCCESS; }
static GdkCursor* gtkEmptyCursor(Ihandle* ih) { /* creates an empty cursor */ GdkColor cursor_color = {0L,0,0,0}; char bitsnull[1] = {0x00}; GdkWindow* window = ih->handle->window; GdkPixmap* pixmapnull = gdk_bitmap_create_from_data( (GdkDrawable*)window, bitsnull, 1,1); GdkCursor* cur = gdk_cursor_new_from_pixmap( pixmapnull, pixmapnull, &cursor_color, &cursor_color, 0,0); g_object_unref(pixmapnull); return cur; }
static GdkCursor* make_blank_cursor (GdkDisplay *display) { /* Taken and heavily modified from gdkcursor-x11.c */ GdkCursor *cursor; GdkScreen *screen; GdkPixmap *pixmap; GdkColor colour = { 0, 0, 0, 0 }; screen = gdk_display_get_default_screen (display); g_return_val_if_fail (screen, NULL); pixmap = gdk_bitmap_create_from_data (gdk_screen_get_root_window (screen), "\0\0\0\0\0\0\0\0", 1, 1); if (display->closed) return NULL; else cursor = gdk_cursor_new_from_pixmap (pixmap, pixmap, &colour, &colour, 1, 1); g_object_unref (pixmap); return cursor; }
static GdkCursor * get_cursor (void) { GdkBitmap *empty_bitmap; GdkCursor *cursor; GdkColor useless; char invisible_cursor_bits [] = { 0x0 }; useless.red = useless.green = useless.blue = 0; useless.pixel = 0; empty_bitmap = gdk_bitmap_create_from_data (NULL, invisible_cursor_bits, 1, 1); cursor = gdk_cursor_new_from_pixmap (empty_bitmap, empty_bitmap, &useless, &useless, 0, 0); g_object_unref (empty_bitmap); return cursor; }
void update_cursor(void) { GdkPixmap *source, *mask; GdkColor fg = {0, 0, 0, 0}, bg = {0, 65535, 65535, 65535}; ui.is_sel_cursor = FALSE; if (GTK_WIDGET(canvas)->window == NULL) return; if (ui.cursor!=NULL) { gdk_cursor_unref(ui.cursor); ui.cursor = NULL; } if (ui.cur_item_type == ITEM_MOVESEL_VERT) ui.cursor = gdk_cursor_new(GDK_SB_V_DOUBLE_ARROW); else if (ui.cur_item_type == ITEM_MOVESEL) ui.cursor = gdk_cursor_new(GDK_FLEUR); else if (ui.toolno[ui.cur_mapping] == TOOL_PEN) { fg.red = (ui.cur_brush->color_rgba >> 16) & 0xff00; fg.green = (ui.cur_brush->color_rgba >> 8) & 0xff00; fg.blue = (ui.cur_brush->color_rgba >> 0) & 0xff00; source = gdk_bitmap_create_from_data(NULL, cursor_pen_bits, 16, 16); ui.cursor = gdk_cursor_new_from_pixmap(source, source, &fg, &bg, 7, 7); gdk_bitmap_unref(source); }
void Cursor::updateCursor() { XOJ_CHECK_TYPE(Cursor); MainWindow* win = control->getWindow(); if (!win) { return; } XournalView* xournal = win->getXournal(); if (!xournal) { return; } GdkCursor* cursor = NULL; if (this->busy) { cursor = gdk_cursor_new(GDK_WATCH); } else { ToolHandler* handler = control->getToolHandler(); ToolType type = handler->getToolType(); if (type == TOOL_HAND) { if (this->mouseDown) { cursor = gdk_cursor_new(GDK_FLEUR); } else { cursor = gdk_cursor_new(GDK_HAND1); } } else if(!this->insidePage) { // not inside page: so use default cursor } else if (this->selectionType) { switch (this->selectionType) { case CURSOR_SELECTION_MOVE: cursor = gdk_cursor_new(GDK_FLEUR); break; case CURSOR_SELECTION_TOP_LEFT: cursor = gdk_cursor_new(GDK_TOP_LEFT_CORNER); break; case CURSOR_SELECTION_TOP_RIGHT: cursor = gdk_cursor_new(GDK_TOP_RIGHT_CORNER); break; case CURSOR_SELECTION_BOTTOM_LEFT: cursor = gdk_cursor_new(GDK_BOTTOM_LEFT_CORNER); break; case CURSOR_SELECTION_BOTTOM_RIGHT: cursor = gdk_cursor_new(GDK_BOTTOM_RIGHT_CORNER); break; case CURSOR_SELECTION_LEFT: case CURSOR_SELECTION_RIGHT: cursor = gdk_cursor_new(GDK_SB_H_DOUBLE_ARROW); break; case CURSOR_SELECTION_TOP: case CURSOR_SELECTION_BOTTOM: cursor = gdk_cursor_new(GDK_SB_V_DOUBLE_ARROW); break; } } else if (type == TOOL_PEN) { cursor = getPenCursor(); } else if (type == TOOL_ERASER) { GdkColor bg = { 0, 65535, 65535, 65535 }; GdkColor fg = { 0, 0, 0, 0 }; GdkPixmap* source = gdk_bitmap_create_from_data(NULL, (gchar*) CURSOR_HIGLIGHTER_BITS, 16, 16); GdkPixmap* mask = gdk_bitmap_create_from_data(NULL, (gchar*) CURSOR_HILIGHTER_MASK, 16, 16); cursor = gdk_cursor_new_from_pixmap(source, mask, &fg, &bg, 7, 7); gdk_bitmap_unref(source); gdk_bitmap_unref(mask); } else if (type == TOOL_HILIGHTER) { GdkColor fg = { 0, 0, 0, 0 }; GdkColor bg = handler->getGdkColor(); GdkPixmap* source = gdk_bitmap_create_from_data(NULL, (gchar*) CURSOR_HIGLIGHTER_BITS, 16, 16); GdkPixmap* mask = gdk_bitmap_create_from_data(NULL, (gchar*) CURSOR_HILIGHTER_MASK, 16, 16); cursor = gdk_cursor_new_from_pixmap(source, mask, &fg, &bg, 7, 7); gdk_bitmap_unref(source); gdk_bitmap_unref(mask); } else if (type == TOOL_TEXT) { if (this->invisible) { cursor = gdk_cursor_new(GDK_BLANK_CURSOR); } else { cursor = gdk_cursor_new(GDK_XTERM); } } else if (type == TOOL_IMAGE) { // No special cursor needed } else if (type == TOOL_VERTICAL_SPACE) { if (this->mouseDown) { cursor = gdk_cursor_new(GDK_SB_V_DOUBLE_ARROW); } } else if (type != TOOL_SELECT_OBJECT) // other selections are handled before anyway, because you can move a selection with every tool { cursor = gdk_cursor_new(GDK_TCROSS); } } if (gtk_widget_get_window(xournal->getWidget())) { gdk_window_set_cursor(gtk_widget_get_window(xournal->getWidget()), cursor); gtk_widget_set_sensitive(xournal->getWidget(), !this->busy); } gdk_display_sync(gdk_display_get_default()); if (cursor) { gdk_cursor_unref(cursor); } }
void* iupdrvImageCreateCursor(Ihandle *ih) { GdkCursor *cursor; int hx, hy, bpp; hx=0; hy=0; iupStrToIntInt(iupAttribGet(ih, "HOTSPOT"), &hx, &hy, ':'); bpp = iupAttribGetInt(ih, "BPP"); if (bpp == 8 && !iupAttribGet(ih, "3")) { GdkPixmap *source, *mask; GdkColor fg, bg; unsigned char r, g, b; char *sbits, *mbits, *sb, *mb; int y, x, line_size = (ih->currentwidth+7)/8; int size_bytes = line_size*ih->currentheight; unsigned char* imgdata = (unsigned char*)iupAttribGetStr(ih, "WID"); r = 255; g = 255; b = 255; iupStrToRGB(iupAttribGet(ih, "1"), &r, &g, &b ); iupgdkColorSet(&fg, r, g, b); r = 0; g = 0; b = 0; iupStrToRGB(iupAttribGet(ih, "2"), &r, &g, &b ); iupgdkColorSet(&bg, r, g, b); sbits = (char*)malloc(2*size_bytes); if (!sbits) return NULL; memset(sbits, 0, 2*size_bytes); mbits = sbits + size_bytes; sb = sbits; mb = mbits; for (y=0; y<ih->currentheight; y++) { for (x=0; x<ih->currentwidth; x++) { int byte = x/8; int bit = x%8; int index = (int)imgdata[y*ih->currentwidth+x]; /* index==0 is transparent */ if (index == 1) sb[byte] = (char)(sb[byte] | (1<<bit)); if (index != 0) mb[byte] = (char)(mb[byte] | (1<<bit)); } sb += line_size; mb += line_size; } source = gdk_bitmap_create_from_data(NULL, sbits, ih->currentwidth, ih->currentheight); mask = gdk_bitmap_create_from_data(NULL, mbits, ih->currentwidth, ih->currentheight); cursor = gdk_cursor_new_from_pixmap(source, mask, &fg, &bg, hx, hy); gdk_pixmap_unref(source); gdk_pixmap_unref(mask); free(sbits); } else { GdkPixbuf* pixbuf = iupdrvImageCreateImage(ih, NULL, 0); cursor = gdk_cursor_new_from_pixbuf(gdk_display_get_default(), pixbuf, hx, hy); g_object_unref(pixbuf); } return cursor; }
void wxCursor::InitFromStock( wxStockCursor cursorId ) { m_refData = new wxCursorRefData(); GdkCursorType gdk_cur = GDK_LEFT_PTR; switch (cursorId) { #ifdef __WXGTK3__ case wxCURSOR_BLANK: gdk_cur = GDK_BLANK_CURSOR; break; #else case wxCURSOR_BLANK: { const char bits[] = { 0 }; const GdkColor color = { 0, 0, 0, 0 }; GdkPixmap *pixmap = gdk_bitmap_create_from_data(NULL, bits, 1, 1); M_CURSORDATA->m_cursor = gdk_cursor_new_from_pixmap(pixmap, pixmap, &color, &color, 0, 0); g_object_unref(pixmap); } return; #endif case wxCURSOR_ARROW: // fall through to default case wxCURSOR_DEFAULT: gdk_cur = GDK_LEFT_PTR; break; case wxCURSOR_RIGHT_ARROW: gdk_cur = GDK_RIGHT_PTR; break; case wxCURSOR_HAND: gdk_cur = GDK_HAND2; break; case wxCURSOR_CROSS: gdk_cur = GDK_CROSSHAIR; break; case wxCURSOR_SIZEWE: gdk_cur = GDK_SB_H_DOUBLE_ARROW; break; case wxCURSOR_SIZENS: gdk_cur = GDK_SB_V_DOUBLE_ARROW; break; case wxCURSOR_ARROWWAIT: case wxCURSOR_WAIT: case wxCURSOR_WATCH: gdk_cur = GDK_WATCH; break; case wxCURSOR_SIZING: gdk_cur = GDK_SIZING; break; case wxCURSOR_SPRAYCAN: gdk_cur = GDK_SPRAYCAN; break; case wxCURSOR_IBEAM: gdk_cur = GDK_XTERM; break; case wxCURSOR_PENCIL: gdk_cur = GDK_PENCIL; break; case wxCURSOR_NO_ENTRY: gdk_cur = GDK_PIRATE; break; case wxCURSOR_SIZENWSE: case wxCURSOR_SIZENESW: gdk_cur = GDK_FLEUR; break; case wxCURSOR_QUESTION_ARROW: gdk_cur = GDK_QUESTION_ARROW; break; case wxCURSOR_PAINT_BRUSH: gdk_cur = GDK_SPRAYCAN; break; case wxCURSOR_MAGNIFIER: gdk_cur = GDK_PLUS; break; case wxCURSOR_CHAR: gdk_cur = GDK_XTERM; break; case wxCURSOR_LEFT_BUTTON: gdk_cur = GDK_LEFTBUTTON; break; case wxCURSOR_MIDDLE_BUTTON: gdk_cur = GDK_MIDDLEBUTTON; break; case wxCURSOR_RIGHT_BUTTON: gdk_cur = GDK_RIGHTBUTTON; break; case wxCURSOR_BULLSEYE: gdk_cur = GDK_TARGET; break; case wxCURSOR_POINT_LEFT: gdk_cur = GDK_SB_LEFT_ARROW; break; case wxCURSOR_POINT_RIGHT: gdk_cur = GDK_SB_RIGHT_ARROW; break; /* case wxCURSOR_DOUBLE_ARROW: gdk_cur = GDK_DOUBLE_ARROW; break; case wxCURSOR_CROSS_REVERSE: gdk_cur = GDK_CROSS_REVERSE; break; case wxCURSOR_BASED_ARROW_UP: gdk_cur = GDK_BASED_ARROW_UP; break; case wxCURSOR_BASED_ARROW_DOWN: gdk_cur = GDK_BASED_ARROW_DOWN; break; */ default: wxFAIL_MSG(wxT("unsupported cursor type")); // will use the standard one break; } M_CURSORDATA->m_cursor = gdk_cursor_new( gdk_cur ); }
void InitCursors(void) { GdkPixmap *image, *mask; static GdkColor white = { 0xffffffff, 0xffff, 0xffff, 0xffff }, black = { 0xffffffff, 0 , 0 , 0 }, red = { 0xffffffff, 0xffff, 0 , 0 }; image = gdk_pixmap_create_from_data(NULL,(guchar *)magplus_bits,magplus_width,magplus_height, 1, &black, &white); ct_magplus = gdk_cursor_new_from_pixmap( image,image,&black,&white,magplus_x_hot, magplus_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)magminus_bits,magminus_width,magminus_height, 1, &black, &white); ct_magminus = gdk_cursor_new_from_pixmap( image,image,&black,&white,magminus_x_hot, magminus_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)pointercur_bits,pointercur_width,pointercur_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)pointercurmask_bits,pointercurmask_width,pointercurmask_height, 1, &black, &white); ct_mypointer = gdk_cursor_new_from_pixmap( image,mask,&black,&white,pointercur_x_hot, pointercur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)pointercirc_bits,pointercirc_width,pointercirc_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)pointercircmask_bits,pointercircmask_width,pointercircmask_height, 1, &black, &white); ct_circle = gdk_cursor_new_from_pixmap( image,mask,&black,&white,pointercirc_x_hot, pointercirc_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)pointertri_bits,pointertri_width,pointertri_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)pointertrimask_bits,pointertrimask_width,pointertrimask_height, 1, &black, &white); ct_triangle = gdk_cursor_new_from_pixmap( image,mask,&black,&white,pointertri_x_hot, pointertri_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)pointersqr_bits,pointersqr_width,pointersqr_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)pointersqrmask_bits,pointersqrmask_width,pointersqrmask_height, 1, &black, &white); ct_square = gdk_cursor_new_from_pixmap( image,mask,&black,&white,pointersqr_x_hot, pointersqr_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)pencur_bits,pencur_width,pencur_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)pencurmask_bits,pencurmask_width,pencurmask_height, 1, &black, &white); ct_pen = gdk_cursor_new_from_pixmap( image,mask,&black,&white,pencur_x_hot, pencur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)setwidthcur_bits,setwidthcur_width,setwidthcur_height, 1, &black, &white); /* mask = gdk_pixmap_create_from_data(NULL,(guchar *)setwidthcurmask_bits,setwidthcurmask_width,setwidthcurmask_height, 1, &black, &white);*/ ct_setwidth = gdk_cursor_new_from_pixmap( image,image,&black,&white,setwidthcur_x_hot, setwidthcur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)pointerhvcirc_bits,pointerhvcirc_width,pointerhvcirc_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)pointerhvcircmask_bits,pointerhvcircmask_width,pointerhvcircmask_height, 1, &black, &white); ct_hvcircle = gdk_cursor_new_from_pixmap( image,mask,&black,&white,pointerhvcirc_x_hot, pointerhvcirc_y_hot); #if _CursorsMustBe16x16 ct_g2circle = ct_hvcircle; #else image = gdk_pixmap_create_from_data(NULL,(guchar *)pointerg2circ_bits,pointerg2circ_width,pointerg2circ_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)pointerg2circmask_bits,pointerg2circmask_width,pointerg2circmask_height, 1, &black, &white); ct_g2circle = gdk_cursor_new_from_pixmap( image,mask,&black,&white,pointerg2circ_x_hot, pointerg2circ_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)pointerright_bits,pointerright_width,pointerright_height, 1, &black, &white); #endif mask = gdk_pixmap_create_from_data(NULL,(guchar *)pointerrightmask_bits,pointerrightmask_width,pointerrightmask_height, 1, &black, &white); ct_spiroright = gdk_cursor_new_from_pixmap( image,mask,&black,&white,pointerright_x_hot, pointerright_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)pointerleft_bits,pointerleft_width,pointerleft_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)pointerleftmask_bits,pointerleftmask_width,pointerleftmask_height, 1, &black, &white); ct_spiroleft = gdk_cursor_new_from_pixmap( image,mask,&black,&white,pointerleft_x_hot, pointerleft_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)rulercur_bits,rulercur_width,rulercur_height, 1, &black, &white); ct_ruler = gdk_cursor_new_from_pixmap( image,image,&black,&white,rulercur_x_hot, rulercur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)knifecur_bits,knifecur_width,knifecur_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)knifecurmask_bits,knifecurmask_width,knifecurmask_height, 1, &black, &white); ct_knife = gdk_cursor_new_from_pixmap( image,mask,&black,&white,knifecur_x_hot, knifecur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)flipcur_bits,flipcur_width,flipcur_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)flipcurmask_bits,flipcurmask_width,flipcurmask_height, 1, &black, &white); ct_flip = gdk_cursor_new_from_pixmap( image,mask,&red,&white,flipcur_x_hot, flipcur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)rotatecur_bits,rotatecur_width,rotatecur_height, 1, &black, &white); ct_rotate = gdk_cursor_new_from_pixmap( image,image,&red,&white,rotatecur_x_hot, rotatecur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)scalecur_bits,scalecur_width,scalecur_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)scalecurmask_bits,scalecur_width,scalecur_height, 1, &black, &white); ct_scale = gdk_cursor_new_from_pixmap( image,mask,&red,&white,scalecur_x_hot, scalecur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)skewcur_bits,skewcur_width,skewcur_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)skewcurmask_bits,skewcur_width,skewcur_height, 1, &black, &white); ct_skew = gdk_cursor_new_from_pixmap( image,mask,&red,&white,skewcur_x_hot, skewcur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)rotate3dcur_bits,rotate3dcur_width,rotate3dcur_height, 1, &black, &white); ct_3drotate = gdk_cursor_new_from_pixmap( image,image,&red,&white,rotate3dcur_x_hot, rotate3dcur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)perspectivecur_bits,perspectivecur_width,perspectivecur_height, 1, &black, &white); ct_perspective = gdk_cursor_new_from_pixmap( image,image,&red,&white,perspectivecur_x_hot, perspectivecur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)rectcur_bits,rectcur_width,rectcur_height, 1, &black, &white); ct_rect = gdk_cursor_new_from_pixmap( image,image,&red,&white,rectcur_x_hot, rectcur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)elipsecur_bits,elipsecur_width,elipsecur_height, 1, &black, &white); ct_elipse = gdk_cursor_new_from_pixmap( image,image,&red,&white,elipsecur_x_hot, elipsecur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)polycur_bits,polycur_width,polycur_height, 1, &black, &white); ct_poly = gdk_cursor_new_from_pixmap( image,image,&red,&white,polycur_x_hot, polycur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)starcur_bits,starcur_width,starcur_height, 1, &black, &white); ct_star = gdk_cursor_new_from_pixmap( image,image,&red,&white,starcur_x_hot, starcur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)nwse_bits,nwse_width,nwse_height, 1, &black, &white); ct_nwse = gdk_cursor_new_from_pixmap( image,image,&red,&white,nwse_x_hot, nwse_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)nesw_bits,nesw_width,nesw_height, 1, &black, &white); ct_nesw = gdk_cursor_new_from_pixmap( image,image,&red,&white,nesw_x_hot, nesw_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)leftright_bits,leftright_width,leftright_height, 1, &black, &white); ct_leftright = gdk_cursor_new_from_pixmap( image,image,&red,&white,leftright_x_hot, leftright_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)updown_bits,updown_width,updown_height, 1, &black, &white); ct_updown = gdk_cursor_new_from_pixmap( image,image,&red,&white,updown_x_hot, updown_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)pencil_bits,pencil_width,pencil_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)pencilmask_bits,pencil_width,pencil_height, 1, &black, &white); ct_pencil = gdk_cursor_new_from_pixmap( image,mask,&red,&white,pencil_x_hot, pencil_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)eyedropper_bits,eyedropper_width,eyedropper_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)eyedroppermask_bits,eyedropper_width,eyedropper_height, 1, &black, &white); ct_eyedropper = gdk_cursor_new_from_pixmap( image,mask,&red,&white,eyedropper_x_hot, eyedropper_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)shift_bits,shift_width,shift_height, 1, &black, &white); ct_shift = gdk_cursor_new_from_pixmap( image,image,&red,&white,shift_x_hot, shift_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)linecur_bits,linecur_width,linecur_height, 1, &black, &white); ct_line = gdk_cursor_new_from_pixmap( image,image,&red,&white,linecur_x_hot, linecur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)hand_bits,hand_width,hand_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)handmask_bits,hand_width,hand_height, 1, &black, &white); ct_myhand = gdk_cursor_new_from_pixmap( image,mask,&red,&white,hand_x_hot, hand_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)filledrectcur_bits,filledrectcur_width,filledrectcur_height, 1, &black, &white); ct_filledrect = gdk_cursor_new_from_pixmap( image,image,&red,&white,filledrectcur_x_hot, filledrectcur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)filledelipsecur_bits,filledelipsecur_width,filledelipsecur_height, 1, &black, &white); ct_filledelipse = gdk_cursor_new_from_pixmap( image,image,&red,&white,filledelipsecur_x_hot, filledelipsecur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)kerncur_bits,kerncur_width,kerncur_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)rbearmask_bits,kerncur_width,kerncur_height, 1, &black, &white); ct_kerning = gdk_cursor_new_from_pixmap( image,mask,&red,&white,kerncur_x_hot, kerncur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)rbearcur_bits,rbearcur_width,rbearcur_height, 1, &black, &white); ct_rbearing = gdk_cursor_new_from_pixmap( image,mask,&red,&white,rbearcur_x_hot, rbearcur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)lbearcur_bits,lbearcur_width,lbearcur_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)lbearmask_bits,lbearcur_width,lbearcur_height, 1, &black, &white); ct_lbearing = gdk_cursor_new_from_pixmap( image,mask,&red,&white,lbearcur_x_hot, lbearcur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)prohibition_bits,prohibition_width,prohibition_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)prohibitionmask_bits,prohibition_width,prohibition_height, 1, &black, &white); ct_prohibition = gdk_cursor_new_from_pixmap( image,mask,&red,&white,prohibition_x_hot, prohibition_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)ddcursor_bits,ddcursor_width,ddcursor_height, 1, &black, &white); ct_ddcursor = gdk_cursor_new_from_pixmap( image,image,&red,&white,ddcursor_x_hot, ddcursor_y_hot); ct_pointer = gdk_cursor_new(GDK_LEFT_PTR); ct_4way = gdk_cursor_new(GDK_FLEUR); ct_watch = gdk_cursor_new(GDK_WATCH); ct_draganddrop = gdk_cursor_new(GDK_RIGHT_PTR); image = gdk_pixmap_create_from_data(NULL,(guchar *)zeroes,16,16, 1, &black, &white); ct_invisible = gdk_cursor_new_from_pixmap( image,image,&red,&white,0,0); /*ct_backpointer = gdk_cursor_new(GDK_RIGHT_PTR);*/ /*ct_hand = gdk_cursor_new(GDK_HAND2);*/ /*ct_question = gdk_cursor_new(GDK_QUESTION_ARROW);*/ /*ct_cross = gdk_cursor_new(GDK_TCROSS);*/ /*ct_text = gdk_cursor_new(GDK_XTERM);*/ }
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 ); g_object_unref (data); g_object_unref (mask); #endif }