Re: difference of the get_dest_row_at_pos and get_path_at_pos in treeview class



On Tue, 2007-10-02 at 22:34 +0800, Liangxu Wang wrote:
> Hi,
> 	Sorry if I misunderstanding of these two function in treeview class,
> from my understanding, the two function should get the path result, but
> if I set the headers visible(this is the default behavior), the two
> function return different path. So is this a bug or feature?
> 	Thanks.
> 
> code example:
> ++++++++++++++++++
> 		Gtk::TreeModel::Path path;
> 		Gtk::TreeViewColumn* c=0;
> 		int cellx,celly;
> 		get_path_at_pos(x,y,path,c,cellx,celly);
> 		Gtk::TreeModel::iterator iter = refTreeModel->get_iter(path);
> 		std::cout<<"x,y:"<<x<<","<<y<<std::endl;
> 		if (iter)
> 		{
> 			std::cout<<(*iter)[columns.name]<<std::endl;
> 		}
> 		Gtk::TreeViewDropPosition 	 pos;
> 		get_dest_row_at_pos(x,y,path,pos);
> 		iter = refTreeModel->get_iter(path);
> 		std::cout<<"x,y:"<<x<<","<<y<<std::endl;
> 		if (iter)
> 		{
> 			std::cout<<(*iter)[columns.name]<<std::endl;

The GTK+ functions gtk_tree_view_get_dest_row_at_pos() takes widget
co-ordinates, whereas gtk_tree_view_get_path_at_pos() takes GdkWindow
(event) co-ordinates.  They will be different if your tree view has
headers, as you have found.  If you want more information see
file:///opt/gnome2/share/gtk-doc/html/gtk/GtkTreeView.html#gtk-tree-view-get-path-at-pos

Assuming that Gtk::TreeView::get_path_at_pos() just wraps
gtk_treeview_get_path_at_pos() without carrying out co-ordinate
translation, then the gtkmm documentation is wrong in saying that it
takes widget co-ordinates (that is,
http://www.gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGtk_1_1TreeView.html#71e5b97b84689b0dfd48426f440313dd would be wrong).  I suggest you put a documentation bug in Bugzilla.

If you want widget co-ordinates in an event handler (such as when
overriding Gtk::Widget::on_motion_notify_event() or attaching a callback
to the Gtk::Widget::signal_motion_notify_event() signal) in order to
call Gtk::TreeView::get_dest_row_at_pos(), you will need to use
Gtk::Widget::get_pointer() in the handler to obtain them rather than use
the co-ordinates passed as arguments to the callback.  If you want
GdkWindow co-ordinates, then you should use the arguments which are
passed to the callback.

Chris





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