2
* ToolboxNode.cs - Base class for holding tree in a NodeStore, with columns for TreeView.
3
* Shared functionality for ItemToolboxNodes and CategoryToolboxNodes.
6
* Michael Hutchinson <m.j.hutchinson@gmail.com>
8
* Copyright (C) 2006 Michael Hutchinson
10
* This sourcecode is licenced under The MIT License:
12
* Permission is hereby granted, free of charge, to any person obtaining
13
* a copy of this software and associated documentation files (the
14
* "Software"), to deal in the Software without restriction, including
15
* without limitation the rights to use, copy, modify, merge, publish,
16
* distribute, sublicense, and/or sell copies of the Software, and to permit
17
* persons to whom the Software is furnished to do so, subject to the
18
* following conditions:
20
* The above copyright notice and this permission notice shall be included in
21
* all copies or substantial portions of the Software.
23
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
26
* NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
27
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
28
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
29
* USE OR OTHER DEALINGS IN THE SOFTWARE.
33
using System.Drawing.Design;
36
namespace MonoDevelop.DesignerSupport.Toolbox
39
public abstract class BaseToolboxNode : Gtk.ITreeNode
41
private static Gdk.Pixbuf _defaultIcon;
42
private static Gdk.Color _defaultColor;
43
private static int nextId = int.MinValue;
47
private ITreeNode parent = null;
49
public BaseToolboxNode ()
53
if (nextId == int.MaxValue)
54
throw new InvalidOperationException ("Have run out of integer indices for ToolboxNodes");
58
private Gdk.Pixbuf defaultIcon {
60
if (_defaultIcon == null) {
61
Gtk.Label lab = new Gtk.Label ();
63
_defaultIcon = lab.RenderIcon (Stock.MissingImage, IconSize.SmallToolbar, string.Empty);
70
private Gdk.Color defaultColor {
72
if (_defaultIcon == null) {
73
Gtk.Label lab = new Gtk.Label ();
75
_defaultColor = lab.Style.Base (Gtk.StateType.Normal);
82
//return true if the search is successful
83
//should remove children if they fail test
84
public abstract bool Filter (string keyword);
88
[TreeNodeValue (Column=0)]
89
public virtual Gdk.Pixbuf ViewIcon {
90
get { return defaultIcon; }
93
[TreeNodeValue (Column=1)]
94
public abstract string Label {
98
[TreeNodeValue (Column=2)]
99
public virtual int FontWeight {
103
[TreeNodeValue (Column=3)]
104
public virtual Gdk.Color BackgroundColour {
105
get { return defaultColor; }
108
[TreeNodeValue (Column=4)]
109
public virtual bool IconVisible {
113
[TreeNodeValue (Column=5)]
114
public virtual bool ExpanderVisible {
115
get { return false; }
118
[TreeNodeValue (Column=6)]
119
public virtual bool CanDrag {
123
#endregion Tree columns
125
#region ITreeNode Members
127
public virtual int ChildCount {
131
public virtual int ID {
135
public virtual ITreeNode this [int i] {
136
get { throw new System.IndexOutOfRangeException (); }
139
public ITreeNode Parent {
140
get { return parent; }
143
internal void SetParent (ITreeNode parent)
145
this.parent = parent;
148
public virtual int IndexOf (object o)
153
[field:NonSerialized]
154
public event System.EventHandler Changed;
155
[field:NonSerialized]
156
public event TreeNodeAddedHandler ChildAdded;
157
[field:NonSerialized]
158
public event TreeNodeRemovedHandler ChildRemoved;
160
protected void OnChanged ()
163
Changed (this, new EventArgs ());
166
protected void OnChildAdded (ITreeNode node)
168
if (ChildAdded != null)
169
ChildAdded (this, node);
172
protected void OnChildRemoved (ITreeNode node, int oldPosition)
174
if (ChildRemoved != null)
175
ChildRemoved (this, node, oldPosition);
178
#endregion ITreeNode Members