GtkSharp/gtk/TreeView.custom

142 lines
4 KiB
Plaintext
Raw Normal View History

// Gtk.TreeView.Custom - Gtk TreeView class customizations
//
// Authors:
// Kristian Rietveld <kris@gtk.org>
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
// (c) 2002 Kristian Rietveld
// (c) 2003 Ximian, Inc. (http://www.ximian.com)
//
// This code is inserted after the automatically generated code.
public TreeView (NodeStore store) : base (IntPtr.Zero)
{
if (GetType() != typeof (TreeView)) {
string[] names = new string [1];
GLib.Value[] vals = new GLib.Value [1];
names [0] = "model";
vals [0] = new GLib.Value (store);
CreateNativeObject (names, vals);
vals [0].Dispose ();
return;
}
Raw = gtk_tree_view_new_with_model (store.Handle);
}
[DllImport("libgtk-win32-2.0-0.dll")]
static extern IntPtr gtk_tree_view_get_columns (IntPtr raw);
public TreeViewColumn[] Columns {
get {
IntPtr raw_ret = gtk_tree_view_get_columns (Handle);
if (raw_ret == IntPtr.Zero)
return new TreeViewColumn [0];
GLib.List list = new GLib.List (raw_ret);
TreeViewColumn[] result = new TreeViewColumn [list.Count];
for (int i = 0; i < list.Count; i++)
result [i] = list [i] as TreeViewColumn;
return result;
}
}
[DllImport("libgtk-win32-2.0-0.dll")]
static extern IntPtr gtk_tree_view_get_model (IntPtr raw);
[DllImport("libgtk-win32-2.0-0.dll")]
static extern IntPtr gtk_tree_view_set_model (IntPtr raw, IntPtr raw_model);
public Gtk.TreeModel Model {
get {
IntPtr raw_ret = gtk_tree_view_get_model (Handle);
Gtk.TreeModel ret = (Gtk.TreeModel) GLib.Object.GetObject (raw_ret, false);
return ret;
}
set {
gtk_tree_view_set_model (Handle, value.Handle);
}
}
[DllImport("libgtk-win32-2.0-0.dll")]
static extern bool gtk_tree_view_get_path_at_pos (IntPtr raw,
int x,
int y,
out IntPtr path,
out IntPtr column,
out int cell_x,
out int cell_y);
[DllImport("libgtk-win32-2.0-0.dll", EntryPoint="gtk_tree_view_get_path_at_pos")]
static extern bool gtk_tree_view_get_path_at_pos_intptr (IntPtr raw,
int x,
int y,
out IntPtr path,
out IntPtr column,
IntPtr cell_x,
IntPtr cell_y);
public bool GetPathAtPos (int x, int y, out Gtk.TreePath path, out Gtk.TreeViewColumn column, out int cell_x, out int cell_y)
{
IntPtr pathHandle;
IntPtr columnHandle;
bool raw_ret = gtk_tree_view_get_path_at_pos (Handle, x, y, out pathHandle, out columnHandle, out cell_x, out cell_y);
if (raw_ret) {
column = (Gtk.TreeViewColumn) GLib.Object.GetObject (columnHandle, false);
path = new TreePath (pathHandle);
} else {
path = null;
column = null;
}
return raw_ret;
}
public bool GetPathAtPos (int x, int y, out Gtk.TreePath path)
{
IntPtr pathHandle;
IntPtr columnHandle;
bool raw_ret = gtk_tree_view_get_path_at_pos_intptr (Handle, x, y, out pathHandle, out columnHandle, IntPtr.Zero, IntPtr.Zero);
if (raw_ret)
path = new TreePath (pathHandle);
else
path = null;
return raw_ret;
}
public bool GetPathAtPos (int x, int y, out Gtk.TreePath path, out Gtk.TreeViewColumn column)
{
IntPtr pathHandle;
IntPtr columnHandle;
bool raw_ret = gtk_tree_view_get_path_at_pos_intptr (Handle, x, y, out pathHandle, out columnHandle, IntPtr.Zero, IntPtr.Zero);
if (raw_ret) {
path = new TreePath (pathHandle);
column = (Gtk.TreeViewColumn) GLib.Object.GetObject (columnHandle, false);
} else {
path = null;
column = null;
}
return raw_ret;
}
public Gtk.TreeViewColumn AppendColumn (string title, Gtk.CellRenderer cell, Gtk.TreeCellDataFunc cell_data) {
Gtk.TreeViewColumn col = new Gtk.TreeViewColumn ();
col.Title = title;
col.PackStart (cell, true);
col.SetCellDataFunc (cell, cell_data);
AppendColumn (col);
return col;
}
public Gtk.TreeViewColumn AppendColumn (string title, Gtk.CellRenderer cell, params object[] attrs) {
Gtk.TreeViewColumn col = new Gtk.TreeViewColumn (title, cell, attrs);
AppendColumn (col);
return col;
}