[Monodevelop-patches-list] r408 - src/Libraries/MonoDevelop.Gui/System.Windows.Forms
commit-watcher at sevenl.net
commit-watcher at sevenl.net
Thu Jan 8 15:22:53 EST 2004
Author: pedro
Date: 2004-01-08 15:22:52 -0500 (Thu, 08 Jan 2004)
New Revision: 408
Modified:
src/Libraries/MonoDevelop.Gui/System.Windows.Forms/TreeNode.cs
src/Libraries/MonoDevelop.Gui/System.Windows.Forms/TreeNodeCollection.cs
src/Libraries/MonoDevelop.Gui/System.Windows.Forms/TreeView.cs
Log:
Implemented the tree a bit more properly
Modified: src/Libraries/MonoDevelop.Gui/System.Windows.Forms/TreeNode.cs
===================================================================
--- src/Libraries/MonoDevelop.Gui/System.Windows.Forms/TreeNode.cs 2004-01-08 05:14:30 UTC (rev 407)
+++ src/Libraries/MonoDevelop.Gui/System.Windows.Forms/TreeNode.cs 2004-01-08 20:22:52 UTC (rev 408)
@@ -3,8 +3,8 @@
namespace MonoDevelop.Gui {
public class TreeNode {
- private TreeView treeView = null;
- private TreeNode parent = null;
+ internal TreeView treeView = null;
+ internal TreeNode parent = null;
private TreeNodeCollection nodes;
private string text;
private Gdk.Pixbuf image;
@@ -108,9 +108,15 @@
private void OnNodeInserted(TreeNode node) {
node.parent = this;
+ if (TreeView != null) {
+ TreeView.AddNode(this, node);
+ }
}
private void OnNodeRemoved(TreeNode node) {
+ if (TreeView != null) {
+ TreeView.RemoveNode(node);
+ }
node.parent = null;
}
@@ -119,5 +125,27 @@
TreeView.OnTreeChanged();
}
}
+
+ private string TreePath {
+ get {
+ if (parent == null) {
+ return "0";
+ }
+
+ string ret = parent.TreePath + ":";
+ ret += parent.Nodes.IndexOf(this);
+ return ret;
+ }
+ }
+
+ internal Gtk.TreeIter TreeIter {
+ get {
+ Gtk.TreeIter iter;
+ if (TreeView.Model.GetIterFromString(out iter, TreePath) == false) {
+ throw new Exception("Error calculating iter");
+ }
+ return iter;
+ }
+ }
}
}
Modified: src/Libraries/MonoDevelop.Gui/System.Windows.Forms/TreeNodeCollection.cs
===================================================================
--- src/Libraries/MonoDevelop.Gui/System.Windows.Forms/TreeNodeCollection.cs 2004-01-08 05:14:30 UTC (rev 407)
+++ src/Libraries/MonoDevelop.Gui/System.Windows.Forms/TreeNodeCollection.cs 2004-01-08 20:22:52 UTC (rev 408)
@@ -22,7 +22,7 @@
return (TreeNode) list[index];
}
set {
- list[index] = value;
+ list[index] = value; //TODO
Changed();
}
}
@@ -40,10 +40,7 @@
throw new ArgumentNullException("value");
Inserted(node);
-
int index = list.Add(node);
- Changed();
-
return index;
}
@@ -64,7 +61,6 @@
}
list.Clear();
- Changed();
}
public bool Contains(TreeNode node)
@@ -97,17 +93,14 @@
list.Insert(index, node);
Inserted(node);
- Changed();
}
public void Remove(TreeNode node)
{
if ( node == null )
throw new ArgumentNullException( "node" );
-
- list.Remove(node);
Removed(node);
- Changed();
+ list.Remove(node);
}
public virtual void RemoveAt(int index)
@@ -116,9 +109,8 @@
throw new ArgumentOutOfRangeException( "index" );
TreeNode node = (TreeNode) list[ index ];
- list.RemoveAt(index);
Removed(node);
- Changed();
+ list.RemoveAt(index);
}
bool IList.IsReadOnly{
@@ -140,7 +132,7 @@
throw new NotImplementedException();
}
}
-
+
void IList.Clear(){
Clear();
}
@@ -162,13 +154,16 @@
}
void IList.Remove(object value){
- list.Remove(value);
+ if (value is TreeNode == false) {
+ throw new Exception ("Attempt to remove a non node from the tree");
+ }
+ Remove((TreeNode)value);
}
void IList.RemoveAt(int index){
- list.RemoveAt(index);
+ RemoveAt(index);
}
-
+
object ICollection.SyncRoot{
get{
throw new NotImplementedException ();
Modified: src/Libraries/MonoDevelop.Gui/System.Windows.Forms/TreeView.cs
===================================================================
--- src/Libraries/MonoDevelop.Gui/System.Windows.Forms/TreeView.cs 2004-01-08 05:14:30 UTC (rev 407)
+++ src/Libraries/MonoDevelop.Gui/System.Windows.Forms/TreeView.cs 2004-01-08 20:22:52 UTC (rev 408)
@@ -68,14 +68,15 @@
}
public void BeginUpdate() {
- updating = true;
+// updating = true;
}
public void EndUpdate() {
- if (updating == true) {
+/* if (updating == true) {
UpdateStore(store);
}
updating = false;
+*/
}
internal void OnTreeChanged() {
@@ -99,12 +100,33 @@
}
}
- private void OnNodeInserted(TreeNode node) {
- node.SetTreeView(this);
- }
-
- private void OnNodeRemoved(TreeNode node) {
- node.SetTreeView(null);
- }
+ internal void AddNode(TreeNode parent, TreeNode child) {
+ if (parent.TreeView != this) {
+ throw new Exception("Wrong tree");
+ }
+ Gtk.TreeIter i = store.AppendValues(parent.TreeIter, child.Text, child.Image, child);
+ AddNodesRecursively(store, i, child);
+ }
+
+ internal void RemoveNode(TreeNode node) {
+ if (node.TreeView != this) {
+ throw new Exception("Wrong tree");
+ }
+ Gtk.TreeIter iter = node.TreeIter;
+ store.Remove(ref iter);
+ }
+
+ private void OnNodeInserted(TreeNode node) {
+ node.treeView = this;
+ node.parent = null;
+ Gtk.TreeIter i = store.AppendValues(node.Text, node.Image, node);
+ AddNodesRecursively(store, i, node);
+ }
+
+ private void OnNodeRemoved(TreeNode node) {
+ RemoveNode(node);
+ node.parent = null;
+ node.treeView = null;
+ }
}
}
More information about the Monodevelop-patches-list
mailing list