Back to index

gcompris  8.2.2
Functions | Variables
cursor.h File Reference
#include <gtk/gtk.h>
#include <stdio.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

GdkCursor * gdk_cursor_new_from_data (const gchar *bits[], gint width, gint height, GdkColor *fg, GdkColor *bg, gint hot_x, gint hot_y)

Variables

static const gchar * big_red_arrow_cursor_bits []
static const gchar * bird_cursor_bits []
static const gchar * big_red_line_cursor_bits []
static const gchar * big_red_rectangle_cursor_bits []
static const gchar * big_red_filledrectangle_cursor_bits []
static const gchar * big_red_circle_cursor_bits []
static const gchar * big_red_filledcircle_cursor_bits []
static const gchar * big_red_fill_cursor_bits []
static const gchar * big_red_del_cursor_bits []
static const gchar * big_red_select_cursor_bits []

Function Documentation

GdkCursor* gdk_cursor_new_from_data ( const gchar *  bits[],
gint  width,
gint  height,
GdkColor *  fg,
GdkColor *  bg,
gint  hot_x,
gint  hot_y 
)

Definition at line 37 of file cursor.c.

{
  GdkBitmap *bitmap, *mask;
  GdkCursor *cursor;
  guchar *data, *ptr;
  gint i, j;

  /* Though it does not say so on the X11 manual pages, the bitmap
   * format consists of scan lines padded to byte boundaries with the
   * bits in "reverse" order within each byte (lo bits come before hi
   * bits in the bitmap).  I assume this representation is platform
   * independent.  Let me know if it doesn't work for you. */

  /* Create space for the bitmap, padding the scanlines to byte boundaries. */
  data = g_new(guchar, ((width+7)/8)*height);

  /* Build bitmap */
  ptr = data;
  for (i=0; i < height; i++) {
    for (j=0; j < width; j++) {
      *ptr = (*ptr >> 1)|(bits[i][j]=='1'?0x80:0);
      if (j%8 == 7) ptr++;
    }
    if (j%8) *ptr++ >>= 8-j%8;
  }
  bitmap = gdk_bitmap_create_from_data(NULL, (gchar *)data, width, height);

  /* Build mask */
  ptr = data;
  for (i=0; i < height; i++) {
    for (j=0; j < width; j++) {
      *ptr = (*ptr >> 1)|(bits[i][j]==' '?0:0x80);
      if (j%8 == 7) ptr++;
    }
    if (j%8) *ptr++ >>= 8-j%8;
  }
  mask = gdk_bitmap_create_from_data(NULL, (gchar *)data, width, height);

  /* Build cursor from bitmap and mask */
  cursor = gdk_cursor_new_from_pixmap(bitmap, mask, /* Image and mask */
                                  fg, bg, /* colors */
                                  hot_x, hot_y); /* Hot point */

  /* No longer need bitmap or mask */
  gdk_pixmap_unref(bitmap);
  gdk_pixmap_unref(mask);
  g_free(data);

  return cursor;
}

Here is the caller graph for this function:


Variable Documentation

const gchar* big_red_arrow_cursor_bits[] [static]

Definition at line 32 of file cursor.h.

const gchar* big_red_circle_cursor_bits[] [static]

Definition at line 245 of file cursor.h.

const gchar* big_red_del_cursor_bits[] [static]

Definition at line 371 of file cursor.h.

const gchar* big_red_fill_cursor_bits[] [static]

Definition at line 329 of file cursor.h.

const gchar* big_red_filledcircle_cursor_bits[] [static]

Definition at line 287 of file cursor.h.

const gchar* big_red_filledrectangle_cursor_bits[] [static]

Definition at line 203 of file cursor.h.

const gchar* big_red_line_cursor_bits[] [static]

Definition at line 117 of file cursor.h.

const gchar* big_red_rectangle_cursor_bits[] [static]

Definition at line 160 of file cursor.h.

const gchar* big_red_select_cursor_bits[] [static]

Definition at line 413 of file cursor.h.

const gchar* bird_cursor_bits[] [static]

Definition at line 74 of file cursor.h.