Re: [gtkmm] Changing mouse cursor appearance in a Gtk::Window?



>I've looked at the documentation and there are some functions on how to do thi
>s on a Gdk::Window - set_cursor() - or something like that. And then there's a
> list of some stock cursors in GDK::. Gtk::Window is not derived from Gdk::Win
>dow so I tried to derive my window from Gtk::Window AND Gdk::Window. This ofco
>urse resulted that functions like maximize() and all the functions that were t
>he same for both of them were generating errors while compiling. I'm not very 
>experienced on multiple inheritance but maybe this could've been overridden by
> some Gtk::Window::maximize() and Gdk::Window::set_cursor() type stuff. But I 
>really didn't know how to do it properly.

using namespace Gtk;

Window* window = new Window;
 
window->realize ();
window->get_window().set_cursor (GDK_WACTCH)

you are required to realize the top level window first, since
otherwise it has no Gdk_Window.

>So, is there a standard way of changing the appearance of the cursor. I'd like
>to try out the stock cursors, but I'd also like to use some of my own. Maybe 
>some function that would make a cursor from Gdk::pixmap or even better Gtk::Im
>age.

some sample code. hand_bits, hand_width and hand_height etc. are all
in an include XPM file generated by gimp.

	GdkPixmap *source, *mask;
	GdkColor fg = { 0, 65535, 0, 0 }; /* Red. */
	GdkColor bg = { 0, 0, 0, 65535 }; /* Blue. */
	
	source = gdk_bitmap_create_from_data (NULL, hand_bits,
					      hand_width, hand_height);
	mask = gdk_bitmap_create_from_data (NULL, handmask_bits,
					    handmask_width, handmask_height);
	grabber_cursor = gdk_cursor_new_from_pixmap (source, mask, &fg, &bg, hand_x_hot, hand_y_hot);
	gdk_pixmap_unref (source);
	gdk_pixmap_unref (mask);


ps. just a quick note to point out that whether you know it or not,
the email program you are using is sending out copies of your mail in
both plain text and HTML formats. increasingly on the net, there are
filters being put in place that silently dump HTML-formatted
email. some mailing lists will not ever accept such posts. as long as
you do this, you are (1) wasting network bandwidth by sending messages
that are typically more than twice as long as they could be (2) making
it harder for people using traditional email readers to read them (3)
risking the chance that people will never see your mail because its
filtered before reaching their email inbox.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]