creating pixmaps and cursors
- From: Ian Zimmerman <itz speakeasy org>
- To: gtk-app-devel-list gnome org
- Subject: creating pixmaps and cursors
- Date: 02 Sep 2002 21:30:53 -0700
This is my first g*k* program, please be tolerant. If ignored I'll
know that this is a FAQ answered in some obvious place ... but the
gtk documentation certainly is not that place.
Using gtkmm1.2, I am trying to create 2 pixmaps from xpm data, and
from these pixmaps a cursor:
#include "cursor_image.xpm"
#include "cursor_mask.xpm"
#include <gtk--/main.h>
#include <gdk--/color.h>
#include <gdk--/pixmap.h>
#include <gdk/gdk.h>
#include <gdk/gdktypes.h>
// ...
void
my_window::broken()
{
static Gdk_Bitmap dummy_bitmap;
Gdk_Pixmap cursor_image;
cursor_image.create_from_xpm_d(get_window(), dummy_bitmap, Gdk_Color(0),
cursor_image_xpm);
Gdk_Pixmap cursor_mask;
cursor_mask.create_from_xpm_d(get_window(), dummy_bitmap, Gdk_Color(0),
cursor_mask_xpm);
Gdk_Color black; black.set_rgb(0, 0, 0);
Gdk_Color white; white.set_rgb(65535, 65535, 65535);
Gdk_Cursor cursor(cursor_image, cursor_mask, black, white, 5, 5);
return;
}
here are the xpm files:
/* XPM */
static char * cursor_image_xpm[] = {
"32 32 3 1",
" c None",
". c #000000",
"+ c #FFFFFF",
"++++++++++++++++++++++++++++++++",
"+++++++++...++++++++++++++++++++",
"++++++...+++...+++++++++++++++++",
"+++++.+++...+++.++++++++++++++++",
"++++.+...+.+...+.+++++++++++++++",
"+++.+.++++.++++.+.++++++++++++++",
"++.+.+++++.+++++.+.+++++++++++++",
"++..++++++.++++++..+++++++++++++",
"++.+++++++.+++++++.+++++++++++++",
"+..+++++++.+++++++..++++++++++++",
"+..+++++++++++++++..++++++++++++",
"+........+++........++++++++++++",
"+..+++++++++++++++..++++++++++++",
"+..+++++++.+++++++..++++++++++++",
"++.+++++++.+++++++.+++++++++++++",
"++..++++++.++++++..+++++++++++++",
"++.+.+++++.+++++...+++++++++++++",
"+++.+.++++.++++.++.+++++++++++++",
"++++.+...+.+...++++.++++++++++++",
"+++++.+++...+++.++++.+++++++++++",
"++++++...+++...+.++++.++++++++++",
"+++++++++...+++++.++++.+++++++++",
"++++++++++++++++++.++++.++++++++",
"+++++++++++++++++++.++++.+++++++",
"++++++++++++++++++++.++++.++++++",
"+++++++++++++++++++++.++++.+++++",
"++++++++++++++++++++++.++++.++++",
"+++++++++++++++++++++++.+++..+++",
"++++++++++++++++++++++++.+.++.++",
"+++++++++++++++++++++++++..++.++",
"++++++++++++++++++++++++++...+++",
"++++++++++++++++++++++++++++++++"};
/* XPM */
static char *cursor_mask_xpm[] = {
/* columns rows colors chars-per-pixel */
"32 32 2 1",
" c opaque",
". c white",
/* pixels */
"........ ...................",
"..... ................",
".... ...............",
"... ..............",
".. .............",
". ............",
". .. .. ............",
". ... ... ............",
". .... .... ...........",
" ..... ..... ...........",
" ... ...........",
" ... ...........",
" ... ...........",
" ..... ..... ...........",
". .... .... ...........",
". ... ... ............",
". .. .. ............",
". ...........",
".. ..........",
"... .........",
".... ........",
"..... .......",
"........ ... ......",
"................. .....",
".................. ....",
"................... ...",
".................... ..",
"..................... ..",
"...................... .",
"....................... .",
"........................ ..",
"......................... .."
};
what I get is:
Gdk-ERROR **: BadMatch (invalid parameter attributes)
serial 1223 error_code 8 request_code 93 minor_code 0
from the GdkCursor constructor. What is wrong?
BTW, why not a newsgroup? All these zillions of mailing lists are a
waste.
--
Ian Zimmerman, Oakland, California, U.S.A.
GPG: 433BA087 9C0F 194F 203A 63F7 B1B8 6E5A 8CA3 27DB 433B A087
EngSoc adopts market economy: cheap is wasteful, efficient is expensive.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]