Re: How to restore cursor?



On Wed, 2002-08-28 at 12:51, Andrew E. Makeev wrote:
> Hi,
> 
> I've tried to play with window cursor for toplevel window:
> 
>     Gdk::Cursor cur(Gdk::WATCH);
>     get_window()->set_cursor (cur);
> 
>     ...
> 
>     Gdk::Cursor cur(0);
>     get_window()->set_cursor (cur);
> 
> Gdk-CRITICAL **: file gdkcursor.c: line 53 (gdk_cursor_ref): assertion
> `cursor != NULL' failed
> 
> I haven't tried gdk_window_set_cursor (window, NULL) that supposed to
> restore cursor from parent. Anyway, I would to know how to do it using
> gtkmm?
> 
> There is no Gdk::window::get_cursor method to store old cursor, neither
> set_cursor(default), isn't it?
> 
> Probably, I am doing all wrong, so, my goal is to set cursor to watch
> for one toplevel window and all it's children, then restore it at some
> time, any suggestions?
> 
> thanks in advance,
> -andrew

Here is a snippet from a bit of code I've been working on:

Guide::SetCursor(const char *name) {
    static GdkCursor * hglass = gdk_cursor_new(GDK_WATCH);

    GdkWindow *w = window->window;
    if( strcmp(name, "hourglass") == 0 ) {
        gdk_window_set_cursor(w, hglass);
        gtk_widget_set_sensitive(this->window, false);
    } else {
        gdk_window_set_cursor(w, NULL);
        gtk_widget_set_sensitive(this->window, true);
    }
}

Hard coding the "hourglass" string is horrible but necessary for
backwards compatibility.

The first window is a GtkWindow * contained within the class.

James


-- 
James Durie               Phone:  +44 20 7749 7904
Anvil Software Limited    Fax:    +44 20 7749 7916
46-48 Rivington Street    e-mail: jdurie anvil co uk
London EC2A 3QP




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