Re: [gtkmm] gtk+ 2.x TreeView tutorial
- From: Chris Vine <chris cvine freeserve co uk>
- To: gtkmm-list gnome org
- Cc: Vladislav Grinchenko <vgrinche integ com>
- Subject: Re: [gtkmm] gtk+ 2.x TreeView tutorial
- Date: Wed, 14 Jul 2004 22:39:08 +0100
On Wednesday 14 July 2004 21:33, Vladislav Grinchenko wrote:
> Hi,
>
> just came across this *hidden* Gtk+ TreeView tutorial
> for anyone interested.
>
> http://scentric.net/tutorial/
[snip]
> BTW, anyone knows how to change drag icon of TreeView from
> default row?
His advice that using the standard GTK+ drag and drop mechanisms "is most
likely not want you want" (and instead to use the high level
Gtk::TreeView::set_reorderable()) is pretty wide of the mark, since you can
only use the latter to drag within a single tree view. The GTK+ drag and
drop mechanisms are sophisticated and can do practically anything you want,
and not that difficult once you have worked out how they operate. It is the
only way to drag between different tree views.
I am not sure what you mean by the "default row", but to change the drag icon
for the selected row you would do it in a slot connected to the "drag begin"
signal of the tree view. You probably also want to end up with the icon
positioned with respect to the pointer by analogy with what happens if you
use Gtk::TreeView::set_reorderable(). You will probably end up with
something like this:
void tree_view_drag_begin_slot(const Glib::RefPtr<Gdk::DragContext>& context)
{
Gtk::TreeModel::iterator row_iter =
tree_view.get_selection()->get_selected();
if (row_iter) {
// get the cell height for vertical displacement
int x_off, y_off, cell_width, cell_height;
Gdk::Rectangle area;
tree_view.get_column(0)->cell_get_size(area, x_off, y_off, cell_width,
cell_height);
// get the cursor position for horizontal displacement
int x_pos, y_pos;
tree_view.get_pointer(x_pos, y_pos);
if (cell_height < 0) cell_height = 0;
if (x_pos < 0) x_pos = 0;
Glib::RefPtr<Gdk::Pixmap> pixmap =
tree_view.create_row_drag_icon(Gtk::TreeModel::Path(row_iter));
Glib::RefPtr<Gdk::Colormap> colormap =
Gtk::Widget::get_default_colormap();
Glib::RefPtr<Gdk::Bitmap> bitmap;
// this sets the icon and positions it with respect to the cursor
context->set_icon(colormap, pixmap, bitmap, x_pos, cell_height/2);
}
}
Chris.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]