Forgot to cvs add, mike :-)
svn path=/trunk/gtk-sharp/; revision=6577
This commit is contained in:
parent
8896672938
commit
db4c8f1c2d
6 changed files with 339 additions and 0 deletions
31
gtk/ListStore.custom
Normal file
31
gtk/ListStore.custom
Normal file
|
@ -0,0 +1,31 @@
|
|||
// Gtk.ListStore.Custom - Gtk ListStore class customizations
|
||||
//
|
||||
// Author: Kristian Rietveld <kris@gtk.org>
|
||||
//
|
||||
// (c) 2002 Kristian Rietveld
|
||||
//
|
||||
// This code is inserted after the automatically generated code.
|
||||
|
||||
[DllImport("gtk-x11-2.0")]
|
||||
static extern bool gtk_tree_model_iter_children (IntPtr raw, out Gtk.TreeIter iter, IntPtr parent);
|
||||
public bool IterChildren (out Gtk.TreeIter iter) {
|
||||
bool raw_ret = gtk_tree_model_iter_children (Handle, out iter, IntPtr.Zero);
|
||||
bool ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
[DllImport("gtk-x11-2.0")]
|
||||
static extern int gtk_tree_model_iter_n_children (IntPtr raw, IntPtr iter);
|
||||
public int IterNChildren () {
|
||||
int raw_ret = gtk_tree_model_iter_n_children (Handle, IntPtr.Zero);
|
||||
int ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
[DllImport("gtk-x11-2.0")]
|
||||
static extern bool gtk_tree_model_iter_nth_child (IntPtr raw, out Gtk.TreeIter iter, IntPtr parent, int n);
|
||||
public bool IterNthChild (out Gtk.TreeIter iter, int n) {
|
||||
bool raw_ret = gtk_tree_model_iter_nth_child (Handle, out iter, IntPtr.Zero, n);
|
||||
bool ret = raw_ret;
|
||||
return ret;
|
||||
}
|
20
gtk/TreeModel.custom
Normal file
20
gtk/TreeModel.custom
Normal file
|
@ -0,0 +1,20 @@
|
|||
// Gtk.TreeModel.Custom - Gtk TreeModel interface customizations
|
||||
//
|
||||
// Author: Kristian Rietveld <kris@gtk.org>
|
||||
//
|
||||
// (c) 2002 Kristian Rietveld
|
||||
//
|
||||
// This code is inserted after the automatically generated code.
|
||||
|
||||
/// <summary>IterChildren Method</summary>
|
||||
/// <remarks>To be completed</remarks>
|
||||
bool IterChildren (out Gtk.TreeIter iter);
|
||||
|
||||
/// <summary>IterNChildren Method</summary>
|
||||
/// <remarks>To be completed</remarks>
|
||||
int IterNChildren ();
|
||||
|
||||
/// <summary>IterNthChild Method</summary>
|
||||
/// <remarks>To be completed</remarks>
|
||||
bool IterNthChild (out Gtk.TreeIter iter, int n);
|
||||
|
31
gtk/TreeModelSort.custom
Normal file
31
gtk/TreeModelSort.custom
Normal file
|
@ -0,0 +1,31 @@
|
|||
// Gtk.TreeModelSort.Custom - Gtk TreeModelSort class customizations
|
||||
//
|
||||
// Author: Kristian Rietveld <kris@gtk.org>
|
||||
//
|
||||
// (c) 2002 Kristian Rietveld
|
||||
//
|
||||
// This code is inserted after the automatically generated code.
|
||||
|
||||
[DllImport("gtk-x11-2.0")]
|
||||
static extern bool gtk_tree_model_iter_children (IntPtr raw, out Gtk.TreeIter iter, IntPtr parent);
|
||||
public bool IterChildren (out Gtk.TreeIter iter) {
|
||||
bool raw_ret = gtk_tree_model_iter_children (Handle, out iter, IntPtr.Zero);
|
||||
bool ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
[DllImport("gtk-x11-2.0")]
|
||||
static extern int gtk_tree_model_iter_n_children (IntPtr raw, IntPtr iter);
|
||||
public int IterNChildren () {
|
||||
int raw_ret = gtk_tree_model_iter_n_children (Handle, IntPtr.Zero);
|
||||
int ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
[DllImport("gtk-x11-2.0")]
|
||||
static extern bool gtk_tree_model_iter_nth_child (IntPtr raw, out Gtk.TreeIter iter, IntPtr parent, int n);
|
||||
public bool IterNthChild (out Gtk.TreeIter iter, int n) {
|
||||
bool raw_ret = gtk_tree_model_iter_nth_child (Handle, out iter, IntPtr.Zero, n);
|
||||
bool ret = raw_ret;
|
||||
return ret;
|
||||
}
|
111
gtk/TreeStore.custom
Normal file
111
gtk/TreeStore.custom
Normal file
|
@ -0,0 +1,111 @@
|
|||
// Gtk.TreeStore.Custom - Gtk TreeStore class customizations
|
||||
//
|
||||
// Author: Kristian Rietveld <kris@gtk.org>
|
||||
//
|
||||
// (c) 2002 Kristian Rietveld
|
||||
//
|
||||
// This code is inserted after the automatically generated code.
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Appends a row.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Appends a row to the root level of the TreeStore.
|
||||
/// </remarks>
|
||||
|
||||
[DllImport ("gtk-x11-2.0")]
|
||||
static extern void gtk_tree_store_append (IntPtr raw, out Gtk.TreeIter iter, IntPtr parent);
|
||||
|
||||
public void Append (out Gtk.TreeIter iter) {
|
||||
gtk_tree_store_append (Handle, out iter, IntPtr.Zero);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts a row.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Inserts a row in the root level of the TreeStore at
|
||||
/// the given position.
|
||||
/// </remarks>
|
||||
|
||||
[DllImport ("gtk-x11-2.0")]
|
||||
static extern void gtk_tree_store_insert (IntPtr raw, out Gtk.TreeIter iter, IntPtr parent, int position);
|
||||
|
||||
public void Insert (out Gtk.TreeIter iter, int position) {
|
||||
gtk_tree_store_insert (Handle, out iter, IntPtr.Zero, position);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prepends a row.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Prepends a row to the root level of the TreeStore.
|
||||
/// </remarks>
|
||||
|
||||
[DllImport ("gtk-x11-2.0")]
|
||||
static extern void gtk_tree_store_prepend (IntPtr raw, out Gtk.TreeIter iter, IntPtr parent);
|
||||
|
||||
public void Prepend (out Gtk.TreeIter iter) {
|
||||
gtk_tree_store_append (Handle, out iter, IntPtr.Zero);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts a row.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Inserts a row in the root level of TreeStore before the
|
||||
/// given sibling.
|
||||
/// </remarks>
|
||||
|
||||
[DllImport ("gtk-x11-2.0")]
|
||||
static extern void gtk_tree_store_insert_before (IntPtr raw, out Gtk.TreeIter iter, IntPtr parent, ref Gtk.TreeIter sibling);
|
||||
|
||||
public void InsertBefore (out Gtk.TreeIter iter, Gtk.TreeIter sibling) {
|
||||
gtk_tree_store_insert_before (Handle, out iter, IntPtr.Zero, ref sibling);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts a row.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Inserts a row in the root level of TreeStore before the
|
||||
/// given sibling.
|
||||
/// </remarks>
|
||||
|
||||
[DllImport ("gtk-x11-2.0")]
|
||||
static extern void gtk_tree_store_insert_after (IntPtr raw, out Gtk.TreeIter iter, IntPtr parent, ref Gtk.TreeIter sibling);
|
||||
|
||||
public void InsertAfter (out Gtk.TreeIter iter, Gtk.TreeIter sibling) {
|
||||
gtk_tree_store_insert_after (Handle, out iter, IntPtr.Zero, ref sibling);
|
||||
}
|
||||
|
||||
|
||||
[DllImport("gtk-x11-2.0")]
|
||||
static extern bool gtk_tree_model_iter_children (IntPtr raw, out Gtk.TreeIter iter, IntPtr parent);
|
||||
public bool IterChildren (out Gtk.TreeIter iter) {
|
||||
bool raw_ret = gtk_tree_model_iter_children (Handle, out iter, IntPtr.Zero);
|
||||
bool ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
[DllImport("gtk-x11-2.0")]
|
||||
static extern int gtk_tree_model_iter_n_children (IntPtr raw, IntPtr iter);
|
||||
public int IterNChildren () {
|
||||
int raw_ret = gtk_tree_model_iter_n_children (Handle, IntPtr.Zero);
|
||||
int ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
[DllImport("gtk-x11-2.0")]
|
||||
static extern bool gtk_tree_model_iter_nth_child (IntPtr raw, out Gtk.TreeIter iter, IntPtr parent, int n);
|
||||
public bool IterNthChild (out Gtk.TreeIter iter, int n) {
|
||||
bool raw_ret = gtk_tree_model_iter_nth_child (Handle, out iter, IntPtr.Zero, n);
|
||||
bool ret = raw_ret;
|
||||
return ret;
|
||||
}
|
22
gtk/TreeView.custom
Normal file
22
gtk/TreeView.custom
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Gtk.TreeView.Custom - Gtk TreeView class customizations
|
||||
//
|
||||
// Author: Kristian Rietveld <kris@gtk.org>
|
||||
//
|
||||
// (c) 2002 Kristian Rietveld
|
||||
//
|
||||
// This code is inserted after the automatically generated code.
|
||||
|
||||
|
||||
[DllImport("gtk-x11-2.0")]
|
||||
static extern IntPtr gtk_tree_view_get_model (IntPtr raw);
|
||||
|
||||
/// <summary>Model Property</summary>
|
||||
/// <remarks>Gets the model being displayed by the TreeView
|
||||
/// </remarks>
|
||||
public Gtk.TreeModel Model {
|
||||
get {
|
||||
IntPtr raw_ret = gtk_tree_view_get_model (Handle);
|
||||
Gtk.TreeModel ret = (Gtk.TreeModel) GLib.Object.GetObject (raw_ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
124
sample/TreeViewDemo.cs
Normal file
124
sample/TreeViewDemo.cs
Normal file
|
@ -0,0 +1,124 @@
|
|||
// TreeView.cs - Fun TreeView demo
|
||||
//
|
||||
// Author: Kristian Rietveld <kris@gtk.org>
|
||||
//
|
||||
// (c) 2002 Kristian Rietveld
|
||||
|
||||
namespace GtkSamples {
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Reflection;
|
||||
using System.AppDomain;
|
||||
|
||||
using GLib;
|
||||
using Gtk;
|
||||
using GtkSharp;
|
||||
|
||||
public class TreeViewDemo {
|
||||
private static TreeStore store = null;
|
||||
|
||||
private static void ProcessType (TreeIter parent, Type t)
|
||||
{
|
||||
TreeIter iter = new TreeIter ();
|
||||
|
||||
// .GetMembers() won't work due to unimplemented
|
||||
// scary classes.
|
||||
foreach (MemberInfo mi in t.GetMethods ()) {
|
||||
GLib.Value Name = new GLib.Value (mi.Name);
|
||||
GLib.Value Type = new GLib.Value (mi.ToString ());
|
||||
|
||||
store.Append (out iter, parent);
|
||||
store.SetValue (iter, 0, Name);
|
||||
store.SetValue (iter, 1, Type);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ProcessAssembly (TreeIter parent, Assembly asm)
|
||||
{
|
||||
TreeIter iter = new TreeIter ();
|
||||
|
||||
foreach (Type t in asm.GetTypes ()) {
|
||||
GLib.Value Name = new GLib.Value (t.Name);
|
||||
GLib.Value Type = new GLib.Value (t.ToString ());
|
||||
|
||||
store.Append (out iter, parent);
|
||||
store.SetValue (iter, 0, Name);
|
||||
store.SetValue (iter, 1, Type);
|
||||
|
||||
ProcessType (iter, t);
|
||||
}
|
||||
}
|
||||
|
||||
private static void PopulateStore ()
|
||||
{
|
||||
if (store != null)
|
||||
return;
|
||||
|
||||
Console.WriteLine ("Loading data from assemblies...");
|
||||
|
||||
store = new TreeStore ((int)TypeFundamentals.TypeString,
|
||||
(int)TypeFundamentals.TypeString);
|
||||
|
||||
TreeIter iter = new TreeIter ();
|
||||
|
||||
foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies ()) {
|
||||
// we can't show corlib due to some unimplemented
|
||||
// stuff in some scary class.
|
||||
if (asm.GetName ().Name == "mscorlib") continue;
|
||||
|
||||
GLib.Value Name = new GLib.Value (asm.GetName ().Name);
|
||||
GLib.Value Type = new GLib.Value ("Assembly");
|
||||
|
||||
store.Append (out iter);
|
||||
store.SetValue (iter, 0, Name);
|
||||
store.SetValue (iter, 1, Type);
|
||||
|
||||
ProcessAssembly (iter, asm);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Main (string[] args)
|
||||
{
|
||||
Application.Init ();
|
||||
|
||||
Window win = new Window ("TreeView demo");
|
||||
win.DeleteEvent += new EventHandler (DeleteCB);
|
||||
win.DefaultSize = new Size (640,480);
|
||||
|
||||
ScrolledWindow sw = new ScrolledWindow ();
|
||||
win.Add (sw);
|
||||
|
||||
PopulateStore ();
|
||||
|
||||
TreeView tv = new TreeView (store);
|
||||
tv.HeadersVisible = true;
|
||||
|
||||
TreeViewColumn NameCol = new TreeViewColumn ();
|
||||
CellRenderer NameRenderer = new CellRendererText ();
|
||||
NameCol.Title = "Name";
|
||||
NameCol.PackStart (NameRenderer, true);
|
||||
NameCol.AddAttribute (NameRenderer, "text", 0);
|
||||
tv.AppendColumn (NameCol);
|
||||
|
||||
TreeViewColumn TypeCol = new TreeViewColumn ();
|
||||
CellRenderer TypeRenderer = new CellRendererText ();
|
||||
TypeCol.Title = "Type";
|
||||
TypeCol.PackStart (TypeRenderer, false);
|
||||
TypeCol.AddAttribute (TypeRenderer, "text", 1);
|
||||
tv.AppendColumn (TypeCol);
|
||||
|
||||
sw.Add (tv);
|
||||
|
||||
win.ShowAll ();
|
||||
|
||||
Application.Run ();
|
||||
}
|
||||
|
||||
private static void DeleteCB (Object o, EventArgs args)
|
||||
{
|
||||
SignalArgs sa = (SignalArgs) args;
|
||||
Application.Quit ();
|
||||
sa.RetVal = true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue