2002-08-10 23:40:20 +00:00
|
|
|
// Gtk.TreeView.Custom - Gtk TreeView class customizations
|
|
|
|
//
|
2003-04-16 02:26:12 +00:00
|
|
|
// Authors:
|
|
|
|
// Kristian Rietveld <kris@gtk.org>
|
|
|
|
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
|
2002-08-10 23:40:20 +00:00
|
|
|
//
|
2004-06-25 18:42:19 +00:00
|
|
|
// Copyright (c) 2002 Kristian Rietveld
|
|
|
|
// Copyright (c) 2003 Ximian, Inc. (http://www.ximian.com)
|
2002-08-10 23:40:20 +00:00
|
|
|
//
|
|
|
|
// This code is inserted after the automatically generated code.
|
2004-06-25 18:42:19 +00:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of version 2 of the Lesser GNU General
|
|
|
|
// Public License as published by the Free Software Foundation.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this program; if not, write to the
|
|
|
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
// Boston, MA 02111-1307, USA.
|
|
|
|
|
2002-08-10 23:40:20 +00:00
|
|
|
|
2004-12-16 20:30:43 +00:00
|
|
|
[Obsolete ("Use NodeView with NodeStores")]
|
2004-04-07 19:15:01 +00:00
|
|
|
public TreeView (NodeStore store) : base (IntPtr.Zero)
|
2003-11-04 23:20:15 +00:00
|
|
|
{
|
2004-05-07 20:23:58 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2003-11-04 23:20:15 +00:00
|
|
|
Raw = gtk_tree_view_new_with_model (store.Handle);
|
|
|
|
}
|
|
|
|
|
2004-02-11 21:34:32 +00:00
|
|
|
[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)
|
2004-02-11 21:58:47 +00:00
|
|
|
return new TreeViewColumn [0];
|
2004-02-11 22:23:11 +00:00
|
|
|
GLib.List list = new GLib.List (raw_ret);
|
2004-02-11 21:34:32 +00:00
|
|
|
TreeViewColumn[] result = new TreeViewColumn [list.Count];
|
|
|
|
for (int i = 0; i < list.Count; i++)
|
|
|
|
result [i] = list [i] as TreeViewColumn;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-04-16 02:26:12 +00:00
|
|
|
[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,
|
2004-05-22 08:49:58 +00:00
|
|
|
out IntPtr column,
|
2003-04-16 02:26:12 +00:00
|
|
|
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,
|
2004-05-22 08:49:58 +00:00
|
|
|
out IntPtr column,
|
2003-04-16 02:26:12 +00:00
|
|
|
IntPtr cell_x,
|
|
|
|
IntPtr cell_y);
|
|
|
|
|
2004-05-22 08:49:58 +00:00
|
|
|
public bool GetPathAtPos (int x, int y, out Gtk.TreePath path, out Gtk.TreeViewColumn column, out int cell_x, out int cell_y)
|
2003-04-16 02:26:12 +00:00
|
|
|
{
|
|
|
|
IntPtr pathHandle;
|
2004-05-22 08:49:58 +00:00
|
|
|
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) {
|
2004-05-22 08:58:21 +00:00
|
|
|
column = (Gtk.TreeViewColumn) GLib.Object.GetObject (columnHandle, false);
|
2003-04-16 02:26:12 +00:00
|
|
|
path = new TreePath (pathHandle);
|
Automatic memory management for opaque types [#49565]
* glib/Opaque.cs (Owned): new property saying whether or not gtk#
owns the memory.
(Opaque): Set Owned to true in the void ctor and false in the
IntPtr one.
(GetOpaque): add a new overload that can also create opaques, a la
GLib.Object.GetObject.
(Ref, Unref, Free): empty virtual methods to be overridden by
subclasses.
(set_Raw): Unref() and possibly Free() the old value, Ref() the
new one.
(~Opaque, Dispose): set Raw to IntPtr.Zero (triggering Free/Unref
if needed)
* parser/gapi2xml.pl (addReturnElem): if the method is named Copy
and returns a pointer, set the "owned" attribute on the
return-type.
* */*-api.raw: Regen
* generator/HandleBase.cs (FromNative): Add new
FromNative/FromNativeReturn overloads that takes a "bool owned"
param. Implement the 1-arg FromNative and FromNativeReturn in
terms of that.
* generator/ObjectBase.cs (FromNative): Implement HandleBase's new
overload. Use the two-arg version of GLib.Object.GetObject when
"owned" is true.
* generator/OpaqueGen.cs (Generate): Pull out Ref, Unref, and
Free/Destroy/Dispose methods and handle them specially by
overriding Opaque.Ref, .Unref, and .Free appropriately. (If any
of the methods are marked deprecated, output a deprecated
do-nothing method as well, to save us from having to write all
those deprecated methods by hand.)
(FromNative): use GetOpaque, passing "owned".
* generator/ReturnValue.cs (FromNative): if the value is a
HandleBase, pass Owned to its FromNative().
* generator/Parameters.cs (Owned): new property (for use on out
params)
(FromNative): Call FromNative() on the generatable, handling Owned
in the case of HandleBase.
* generator/ManagedCallString.cs:
* generator/MethodBody.cs:
* generator/Signal.cs: use param.FromNative() rather than
param.Generatable.FromNative(), to get ownership right.
* */*.metadata: Mark opaque ref/unref/free methods deprecated
(except where we were hiding them before). Add "owned" attributes
to return values and out params as needed.
* pango/AttrIterator.custom (GetFont): work around a
memory-management oddity of the underlying method.
* pango/AttrFontDesc.cs (AttrFontDesc): copy the passed-in
FontDescriptor, since the attribute will assume ownership of it.
* gtk/TreeView.custom (GetPathAtPos): set the "owned" flag on the
returned TreePaths.
* gtk/TargetList.custom: Remove refcounting stuff, which is
now handled automatically
* gtk/NodeStore.cs (GetPath): clear the Owned flag on the created
TreePath so that the underlying structure doesn't get freed when
the function returns
* gtkhtml/HTMLStream.custom (Destroy): hide this and then
reimplement it by hand to keep OpaqueGen from using it in
Dispose(), since calling it after an HTMLStream.Close() will
result in a crash.
svn path=/trunk/gtk-sharp/; revision=47928
2005-08-02 18:45:21 +00:00
|
|
|
path.Owned = true;
|
2004-05-22 08:49:58 +00:00
|
|
|
} else {
|
2003-04-16 02:26:12 +00:00
|
|
|
path = null;
|
2004-05-22 08:49:58 +00:00
|
|
|
column = null;
|
|
|
|
}
|
2003-04-16 02:26:12 +00:00
|
|
|
|
|
|
|
return raw_ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool GetPathAtPos (int x, int y, out Gtk.TreePath path)
|
|
|
|
{
|
|
|
|
IntPtr pathHandle;
|
2004-05-22 08:49:58 +00:00
|
|
|
IntPtr columnHandle;
|
|
|
|
bool raw_ret = gtk_tree_view_get_path_at_pos_intptr (Handle, x, y, out pathHandle, out columnHandle, IntPtr.Zero, IntPtr.Zero);
|
Automatic memory management for opaque types [#49565]
* glib/Opaque.cs (Owned): new property saying whether or not gtk#
owns the memory.
(Opaque): Set Owned to true in the void ctor and false in the
IntPtr one.
(GetOpaque): add a new overload that can also create opaques, a la
GLib.Object.GetObject.
(Ref, Unref, Free): empty virtual methods to be overridden by
subclasses.
(set_Raw): Unref() and possibly Free() the old value, Ref() the
new one.
(~Opaque, Dispose): set Raw to IntPtr.Zero (triggering Free/Unref
if needed)
* parser/gapi2xml.pl (addReturnElem): if the method is named Copy
and returns a pointer, set the "owned" attribute on the
return-type.
* */*-api.raw: Regen
* generator/HandleBase.cs (FromNative): Add new
FromNative/FromNativeReturn overloads that takes a "bool owned"
param. Implement the 1-arg FromNative and FromNativeReturn in
terms of that.
* generator/ObjectBase.cs (FromNative): Implement HandleBase's new
overload. Use the two-arg version of GLib.Object.GetObject when
"owned" is true.
* generator/OpaqueGen.cs (Generate): Pull out Ref, Unref, and
Free/Destroy/Dispose methods and handle them specially by
overriding Opaque.Ref, .Unref, and .Free appropriately. (If any
of the methods are marked deprecated, output a deprecated
do-nothing method as well, to save us from having to write all
those deprecated methods by hand.)
(FromNative): use GetOpaque, passing "owned".
* generator/ReturnValue.cs (FromNative): if the value is a
HandleBase, pass Owned to its FromNative().
* generator/Parameters.cs (Owned): new property (for use on out
params)
(FromNative): Call FromNative() on the generatable, handling Owned
in the case of HandleBase.
* generator/ManagedCallString.cs:
* generator/MethodBody.cs:
* generator/Signal.cs: use param.FromNative() rather than
param.Generatable.FromNative(), to get ownership right.
* */*.metadata: Mark opaque ref/unref/free methods deprecated
(except where we were hiding them before). Add "owned" attributes
to return values and out params as needed.
* pango/AttrIterator.custom (GetFont): work around a
memory-management oddity of the underlying method.
* pango/AttrFontDesc.cs (AttrFontDesc): copy the passed-in
FontDescriptor, since the attribute will assume ownership of it.
* gtk/TreeView.custom (GetPathAtPos): set the "owned" flag on the
returned TreePaths.
* gtk/TargetList.custom: Remove refcounting stuff, which is
now handled automatically
* gtk/NodeStore.cs (GetPath): clear the Owned flag on the created
TreePath so that the underlying structure doesn't get freed when
the function returns
* gtkhtml/HTMLStream.custom (Destroy): hide this and then
reimplement it by hand to keep OpaqueGen from using it in
Dispose(), since calling it after an HTMLStream.Close() will
result in a crash.
svn path=/trunk/gtk-sharp/; revision=47928
2005-08-02 18:45:21 +00:00
|
|
|
if (raw_ret) {
|
2003-04-16 02:26:12 +00:00
|
|
|
path = new TreePath (pathHandle);
|
Automatic memory management for opaque types [#49565]
* glib/Opaque.cs (Owned): new property saying whether or not gtk#
owns the memory.
(Opaque): Set Owned to true in the void ctor and false in the
IntPtr one.
(GetOpaque): add a new overload that can also create opaques, a la
GLib.Object.GetObject.
(Ref, Unref, Free): empty virtual methods to be overridden by
subclasses.
(set_Raw): Unref() and possibly Free() the old value, Ref() the
new one.
(~Opaque, Dispose): set Raw to IntPtr.Zero (triggering Free/Unref
if needed)
* parser/gapi2xml.pl (addReturnElem): if the method is named Copy
and returns a pointer, set the "owned" attribute on the
return-type.
* */*-api.raw: Regen
* generator/HandleBase.cs (FromNative): Add new
FromNative/FromNativeReturn overloads that takes a "bool owned"
param. Implement the 1-arg FromNative and FromNativeReturn in
terms of that.
* generator/ObjectBase.cs (FromNative): Implement HandleBase's new
overload. Use the two-arg version of GLib.Object.GetObject when
"owned" is true.
* generator/OpaqueGen.cs (Generate): Pull out Ref, Unref, and
Free/Destroy/Dispose methods and handle them specially by
overriding Opaque.Ref, .Unref, and .Free appropriately. (If any
of the methods are marked deprecated, output a deprecated
do-nothing method as well, to save us from having to write all
those deprecated methods by hand.)
(FromNative): use GetOpaque, passing "owned".
* generator/ReturnValue.cs (FromNative): if the value is a
HandleBase, pass Owned to its FromNative().
* generator/Parameters.cs (Owned): new property (for use on out
params)
(FromNative): Call FromNative() on the generatable, handling Owned
in the case of HandleBase.
* generator/ManagedCallString.cs:
* generator/MethodBody.cs:
* generator/Signal.cs: use param.FromNative() rather than
param.Generatable.FromNative(), to get ownership right.
* */*.metadata: Mark opaque ref/unref/free methods deprecated
(except where we were hiding them before). Add "owned" attributes
to return values and out params as needed.
* pango/AttrIterator.custom (GetFont): work around a
memory-management oddity of the underlying method.
* pango/AttrFontDesc.cs (AttrFontDesc): copy the passed-in
FontDescriptor, since the attribute will assume ownership of it.
* gtk/TreeView.custom (GetPathAtPos): set the "owned" flag on the
returned TreePaths.
* gtk/TargetList.custom: Remove refcounting stuff, which is
now handled automatically
* gtk/NodeStore.cs (GetPath): clear the Owned flag on the created
TreePath so that the underlying structure doesn't get freed when
the function returns
* gtkhtml/HTMLStream.custom (Destroy): hide this and then
reimplement it by hand to keep OpaqueGen from using it in
Dispose(), since calling it after an HTMLStream.Close() will
result in a crash.
svn path=/trunk/gtk-sharp/; revision=47928
2005-08-02 18:45:21 +00:00
|
|
|
path.Owned = true;
|
|
|
|
} else
|
2003-04-16 02:26:12 +00:00
|
|
|
path = null;
|
|
|
|
|
|
|
|
return raw_ret;
|
|
|
|
}
|
|
|
|
|
2004-05-22 08:49:58 +00:00
|
|
|
public bool GetPathAtPos (int x, int y, out Gtk.TreePath path, out Gtk.TreeViewColumn column)
|
2003-04-16 02:26:12 +00:00
|
|
|
{
|
|
|
|
IntPtr pathHandle;
|
2004-05-22 08:49:58 +00:00
|
|
|
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) {
|
2003-04-16 02:26:12 +00:00
|
|
|
path = new TreePath (pathHandle);
|
Automatic memory management for opaque types [#49565]
* glib/Opaque.cs (Owned): new property saying whether or not gtk#
owns the memory.
(Opaque): Set Owned to true in the void ctor and false in the
IntPtr one.
(GetOpaque): add a new overload that can also create opaques, a la
GLib.Object.GetObject.
(Ref, Unref, Free): empty virtual methods to be overridden by
subclasses.
(set_Raw): Unref() and possibly Free() the old value, Ref() the
new one.
(~Opaque, Dispose): set Raw to IntPtr.Zero (triggering Free/Unref
if needed)
* parser/gapi2xml.pl (addReturnElem): if the method is named Copy
and returns a pointer, set the "owned" attribute on the
return-type.
* */*-api.raw: Regen
* generator/HandleBase.cs (FromNative): Add new
FromNative/FromNativeReturn overloads that takes a "bool owned"
param. Implement the 1-arg FromNative and FromNativeReturn in
terms of that.
* generator/ObjectBase.cs (FromNative): Implement HandleBase's new
overload. Use the two-arg version of GLib.Object.GetObject when
"owned" is true.
* generator/OpaqueGen.cs (Generate): Pull out Ref, Unref, and
Free/Destroy/Dispose methods and handle them specially by
overriding Opaque.Ref, .Unref, and .Free appropriately. (If any
of the methods are marked deprecated, output a deprecated
do-nothing method as well, to save us from having to write all
those deprecated methods by hand.)
(FromNative): use GetOpaque, passing "owned".
* generator/ReturnValue.cs (FromNative): if the value is a
HandleBase, pass Owned to its FromNative().
* generator/Parameters.cs (Owned): new property (for use on out
params)
(FromNative): Call FromNative() on the generatable, handling Owned
in the case of HandleBase.
* generator/ManagedCallString.cs:
* generator/MethodBody.cs:
* generator/Signal.cs: use param.FromNative() rather than
param.Generatable.FromNative(), to get ownership right.
* */*.metadata: Mark opaque ref/unref/free methods deprecated
(except where we were hiding them before). Add "owned" attributes
to return values and out params as needed.
* pango/AttrIterator.custom (GetFont): work around a
memory-management oddity of the underlying method.
* pango/AttrFontDesc.cs (AttrFontDesc): copy the passed-in
FontDescriptor, since the attribute will assume ownership of it.
* gtk/TreeView.custom (GetPathAtPos): set the "owned" flag on the
returned TreePaths.
* gtk/TargetList.custom: Remove refcounting stuff, which is
now handled automatically
* gtk/NodeStore.cs (GetPath): clear the Owned flag on the created
TreePath so that the underlying structure doesn't get freed when
the function returns
* gtkhtml/HTMLStream.custom (Destroy): hide this and then
reimplement it by hand to keep OpaqueGen from using it in
Dispose(), since calling it after an HTMLStream.Close() will
result in a crash.
svn path=/trunk/gtk-sharp/; revision=47928
2005-08-02 18:45:21 +00:00
|
|
|
path.Owned = true;
|
2004-05-22 08:58:21 +00:00
|
|
|
column = (Gtk.TreeViewColumn) GLib.Object.GetObject (columnHandle, false);
|
2004-05-22 08:49:58 +00:00
|
|
|
} else {
|
2003-04-16 02:26:12 +00:00
|
|
|
path = null;
|
2004-05-22 08:49:58 +00:00
|
|
|
column = null;
|
|
|
|
}
|
2003-04-16 02:26:12 +00:00
|
|
|
|
|
|
|
return raw_ret;
|
|
|
|
}
|
|
|
|
|
2005-01-05 21:59:06 +00:00
|
|
|
public TreeViewColumn AppendColumn (string title, CellRenderer cell, 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;
|
|
|
|
}
|
|
|
|
|
2005-01-04 18:54:02 +00:00
|
|
|
public TreeViewColumn AppendColumn (string title, CellRenderer cell, CellLayoutDataFunc cell_data) {
|
2003-05-19 07:18:52 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2005-01-04 18:54:02 +00:00
|
|
|
public int InsertColumn (int pos, string title, CellRenderer cell, CellLayoutDataFunc cell_data)
|
2004-12-30 16:29:44 +00:00
|
|
|
{
|
|
|
|
TreeViewColumn col = new TreeViewColumn ();
|
|
|
|
col.Title = title;
|
|
|
|
col.PackStart (cell, true);
|
|
|
|
col.SetCellDataFunc (cell, cell_data);
|
|
|
|
return InsertColumn (col, pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int InsertColumn (int pos, string title, CellRenderer cell, params object[] attrs)
|
|
|
|
{
|
|
|
|
TreeViewColumn col = new TreeViewColumn (title, cell, attrs);
|
|
|
|
return InsertColumn (col, pos);
|
|
|
|
}
|
|
|
|
|
2005-05-04 11:47:25 +00:00
|
|
|
[Obsolete ("Replaced by SearchEqualFunc property.")]
|
2005-04-05 20:14:02 +00:00
|
|
|
public void SetSearchEqualFunc (TreeViewSearchEqualFunc search_equal_func, IntPtr search_user_data, DestroyNotify search_destroy)
|
|
|
|
{
|
2005-05-04 11:47:25 +00:00
|
|
|
SearchEqualFunc = search_equal_func;
|
2005-04-05 20:14:02 +00:00
|
|
|
}
|
|
|
|
|
2005-05-04 11:47:25 +00:00
|
|
|
[Obsolete ("Replaced by DestroyCountFunc property.")]
|
2005-04-05 20:14:02 +00:00
|
|
|
public void SetDestroyCountFunc (TreeDestroyCountFunc func, IntPtr data, DestroyNotify destroy)
|
|
|
|
{
|
2005-05-04 11:47:25 +00:00
|
|
|
DestroyCountFunc = func;
|
2005-04-05 20:14:02 +00:00
|
|
|
}
|
|
|
|
|
2005-05-04 11:47:25 +00:00
|
|
|
[Obsolete ("Replaced by ColumnDragFunction property.")]
|
2005-04-05 20:14:02 +00:00
|
|
|
public void SetColumnDragFunction (TreeViewColumnDropFunc func, IntPtr user_data, DestroyNotify destroy)
|
|
|
|
{
|
2005-05-04 11:47:25 +00:00
|
|
|
ColumnDragFunction = func;
|
2005-04-05 20:14:02 +00:00
|
|
|
}
|