dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Setting a cursor - any GDK experts..?

  1. #1
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,573

    Setting a cursor - any GDK experts..?

    I'm adapting a GDK program that was started by someone else. At one particular point it starts a process running and precedes this by setting a 'timer' cursor, like so:-

    Code:
    	Glib::RefPtr<Gdk::Window> win (get_window());
    
    	if (win) {
    		win->set_cursor(Gdk::Cursor(Gdk::WATCH));
    
    		// Carry out the process
    	}
    Whilst this works, the watch cursor then remains until the end of time (excuse the pun!) so one of the things I want to do is reset it again after the process has finished. However, unlike Windows SetCursor(), GDK's version doesn't return anything that references the previous cursor. Nor (AFAICT) is there any get_cursor() functionality. I did come across an enum called LAST_CURSOR so I tried this:-

    Code:
    	Glib::RefPtr<Gdk::Window> win (get_window());
    
    	if (win) {
    		win->set_cursor(Gdk::Cursor(Gdk::WATCH));
    
    		// Carry out the process
    
    		win->set_cursor(Gdk::Cursor(Gdk::LAST_CURSOR));
    	}
    Unfortunately, this reliably crashes the app!! On the other hand, this seems to work:-

    Code:
    	Glib::RefPtr<Gdk::Window> win (get_window());
    
    	if (win) {
    		win->set_cursor(Gdk::Cursor(Gdk::WATCH));
    
    		// Carry out the process
    
    		win->set_cursor(Gdk::Cursor(Gdk::ARROW));
    	}
    except that I can't guarantee that the previous cursor was an arrow. What's the correct way of doing this..?
    "A problem well stated is a problem half solved. - Charles F. Kettering

  2. #2
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,573

    Re: Setting a cursor - any GDK experts..?

    It seems that this can't be done. 'X' offers no API for getting the current cursor so you can't save it to be restored later. The best you can do in GDK is call Gdk::Window::set_cursor(); (with no parameters) which sets the cursor to be the same cursor that's being used in the parent window.
    "A problem well stated is a problem half solved. - Charles F. Kettering

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)