RE: Making a cursor (cross hair) track between image displays



Hi GTK+ application developers:

As it often happens, the inquirer often answers his own question. I finally found clear enough example of 
something similar in gtkmm 3 and through a little trial and error found the solution. Here it is for gtkmm 3:

      Glib::RefPtr <Gdk::Window> ref_Gdk_window = get_window();
      Glib::RefPtr<Gdk::Cursor> display_cursor = Gdk::Cursor::create(ref_Gdk_window->get_display(), 
Gdk::CROSSHAIR);
      ref_Gdk_window->set_cursor(display_cursor);

Now, to complete my application, I just need to draw a cursor "clone" (crosshair) at the corresponding 
location in the associated gtkmm windows.

Jim Tilton

-----Original Message-----
From: gtk-app-devel-list-bounces gnome org [mailto:gtk-app-devel-list-bounces gnome org] On Behalf Of Tilton, 
James C. (GSFC-6063)
Sent: Tuesday, April 10, 2012 9:28 AM
To: gtk-app-devel-list gnome org
Subject: RE: Making a cursor (cross hair) track between image displays

Hi again,

I've made a lot of progress on this task - but I still am having trouble with manipulating the appearance of 
the Cursor. Apparently the approach for doing this has changed between gtkmm 2 and 3, and apparently all the 
solutions I can find via Google are for gtkmm 2.  How can I change the default appearance of my cursor from 
the default cursor to something else (e.g. a CrossHair) in gtkmm 3?

Thanks.

Jim Tilton

-----Original Message-----
From: gtk-app-devel-list-bounces gnome org [mailto:gtk-app-devel-list-bounces gnome org] On Behalf Of Tilton, 
James C. (GSFC-6063)
Sent: Monday, April 02, 2012 12:00 PM
To: gtk-app-devel-list gnome org
Subject: Making a cursor (cross hair) track between image displays

Hi GTK+ application developers!

I have developed an application using gtkmm in which I display related images in multiple Gtk::Window's.

I have two types of "display images."  One is based on Gtk::Image and the other is based on Gtk::DrawingArea.
For the Gtk::Image case I add the Gtk::Image to a Gtk::EventBox, which in turn I add to a Gtk::ScrolledWindow.
For the Gtk::DrawingArea, is directly add the Gtk::DrawingArea to a Gtk::ScrolledWindow (without the 
intervening Gtk::EventBox).

When the image sizes exceed the ScrolledWindow display area, I use the Gtk::Adjustment associated with each 
Gtk::ScrolledWindow to have the pan-scrolling of each window track each other.

When I place the cursor in one of the display images, I would like to have a cross hair appear at the cursor 
location of the window in which the cursor is placed at the location currently pointed to by the cursor. I 
would ALSO like to have a similar cross hair appear in each of the other associated display images.

How can I make this happen with GTK+/gtkmm? I've looked for examples of this and haven't found any. Can 
anyone point me in the right direction for implementing this feature in my application?

(In my current application, the normal arrow cursor appears in just one window, and if I hold the either the 
left or right mouse button down, I have the column and row location and image data value(s) appear in text 
below the Scrolled Window image display.)

Thanks.

Jim Tilton
________________________________
Dr. James C. Tilton                                                Voice:   301-286-9510
NASA Goddard Space Flight Center                   FAX:     301-286-1776
Mail Code 606.3                                                    E-Mail:  James C Tilton nasa 
gov<mailto:James C Tilton nasa gov>
(Computational & Information Sciences and Technology Office)
Greenbelt, MD 20771
URLs:      http://ipp.gsfc.nasa.gov/ft_tech_rhseg.shtm and http://science.gsfc.nasa.gov/606.3/TILTON/



_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



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