From d77646875cf6a56658308905e805b7a7f0e67157 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Tue, 4 Mar 2003 21:27:53 +0000 Subject: [PATCH] Add sample for the TreeView svn path=/trunk/gtk-sharp/; revision=12198 --- doc/en/Gtk/TreeView.xml | 116 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 114 insertions(+), 2 deletions(-) diff --git a/doc/en/Gtk/TreeView.xml b/doc/en/Gtk/TreeView.xml index 261f7a1ee..362525ee9 100644 --- a/doc/en/Gtk/TreeView.xml +++ b/doc/en/Gtk/TreeView.xml @@ -7,8 +7,120 @@ Gtk# is thread aware, but not thread safe; See the Gtk# Thread Programming for details. - To be added - To be added + A widget for displaying both trees and lists. + + + Widget that displays any object that implements the + interface. + + + To create a tree or list in GTK#, you need to use the interface, in conjunction with the + widget. This widget is designed around a + Model/View/Controller design and consists of four major parts: + + , the tree view widget + , the view column. + The cell renderers ( + and others). + , the model interface. + + + + The View is composed of the first three, while the last is the + Model. One of the prime benefits of the MVC design is that + multiple views can be created of a single model. For example, + a model mapping the file system could be created for a file + manager. Many views could be created to display various parts + of the file system, but only one copy need be kept in memory. + + + The purpose of the cell renderers is to provide extensibility + to the widget and to allow multiple ways of rendering the same + type of data. For example, consider how to render a boolean + variable. Should you render it as a string of "True" or + "False", "On" or "Off", or should you render it as a checkbox? + + + +namespace Samples { + using System; + using System.Drawing; + using GLib; + using Gtk; + using GtkSharp; + + + public class TreeView { + + public static void Main (string[] args) + { + TreeStore store = null; + + Application.Init (); + + + store = new TreeStore ((int)TypeFundamentals.TypeString, + (int)TypeFundamentals.TypeString); + + + TreeIter iter = new TreeIter (); + + for (int i=0; i<0; i++) + { + GLib.Value Name = new GLib.Value ("Demo " + i.ToString()); + GLib.Value Type = new GLib.Value ("Data " + i.ToString()); + store.Append (out iter); + store.SetValue (iter, 0, Name); + store.SetValue (iter, 1, Type); + } + + Window win = new Window ("TreeView List Demo"); + win.DeleteEvent += new DeleteEventHandler (delete_cb); + win.DefaultSize = new Size (400,250); + + + ScrolledWindow sw = new ScrolledWindow (); + win.Add (sw); + + + TreeView tv = new TreeView (store); + tv.HeadersVisible = true; + + + TreeViewColumn DemoCol = new TreeViewColumn (); + CellRenderer DemoRenderer = new CellRendererText (); + DemoCol.Title = "Demo"; + DemoCol.PackStart (DemoRenderer, true); + DemoCol.AddAttribute (DemoRenderer, "text", 0); + tv.AppendColumn (DemoCol); + + + TreeViewColumn DataCol = new TreeViewColumn (); + CellRenderer DataRenderer = new CellRendererText (); + DataCol.Title = "Data"; + DataCol.PackStart (DataRenderer, false); + DataCol.AddAttribute (DataRenderer, "text", 1); + tv.AppendColumn (DataCol); + + + sw.Add (tv); + sw.Show(); + win.ShowAll (); + Application.Run (); + } + + + private static void delete_cb (System.Object o, DeleteEventArgs args) + { + Application.Quit (); + args.RetVal = true; + } + } +} + + + Gtk.Container