File: TreeView.cs

package info (click to toggle)
gtk-sharp3 2.99.3-4.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 25,488 kB
  • sloc: xml: 308,885; cs: 38,796; sh: 11,336; perl: 1,295; makefile: 1,099; ansic: 903
file content (155 lines) | stat: -rw-r--r-- 4,888 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
// Gtk.TreeView.cs - Gtk TreeView class customizations
//
// Authors:
//	Kristian Rietveld <kris@gtk.org>
//	Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
// Copyright (c) 2002 Kristian Rietveld
// Copyright (c) 2003 Ximian, Inc. (http://www.ximian.com)
//
// 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.

namespace Gtk {

	using System;
	using System.Runtime.InteropServices;

	public partial class TreeView {

		public Gdk.Color OddRowColor {
			get {
				GLib.Value value = StyleGetPropertyValue ("odd-row-color");
				Gdk.Color ret = (Gdk.Color)value;
				value.Dispose ();
				return ret;
			}
		}

		public Gdk.Color EvenRowColor {
			get {
				GLib.Value value = StyleGetPropertyValue ("even-row-color");
				Gdk.Color ret = (Gdk.Color)value;
				value.Dispose ();
				return ret;
			}
		}

		[DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)]
		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 (Global.GtkNativeDll, EntryPoint="gtk_tree_view_get_path_at_pos", CallingConvention = CallingConvention.Cdecl)]
		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 = (Gtk.TreePath) GLib.Opaque.GetOpaque (pathHandle, typeof (Gtk.TreePath), true);
			} 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 = (Gtk.TreePath) GLib.Opaque.GetOpaque (pathHandle, typeof (Gtk.TreePath), true);
			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 = (Gtk.TreePath) GLib.Opaque.GetOpaque (pathHandle, typeof (Gtk.TreePath), true);
				column = (Gtk.TreeViewColumn) GLib.Object.GetObject (columnHandle, false);
			} else {
				path = null;
				column = null;
			}

			return raw_ret;
		}

		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;
		}
		
		public TreeViewColumn AppendColumn (string title, CellRenderer cell, CellLayoutDataFunc 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;
		}

		public int InsertColumn (int pos, string title, CellRenderer cell, CellLayoutDataFunc cell_data) 
		{
			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);
		}
	}
}