2004-11-29 Marek Safar <marek.safar@seznam.cz>
authorMarek Safar <marek.safar@gmail.com>
Mon, 29 Nov 2004 17:16:26 +0000 (17:16 -0000)
committerMarek Safar <marek.safar@gmail.com>
Mon, 29 Nov 2004 17:16:26 +0000 (17:16 -0000)
* System.Windows.Forms.dll.sources: Added
TreeNode.cs, TreeNodeCollection.cs, TreeView.cs,
TreeViewAction.cs, TreeViewEventArgs.cs

* System.Windows.Forms_test.dll.sources: Added
TreeNodeTest.cs

svn path=/trunk/mcs/; revision=36785

14 files changed:
mcs/class/Managed.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/SWF.csproj
mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.sources
mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNode.cs [new file with mode: 0644]
mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNodeCollection.cs [new file with mode: 0644]
mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeView.cs [new file with mode: 0644]
mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewAction.cs [new file with mode: 0644]
mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewEventArgs.cs [new file with mode: 0644]
mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TreeNodeTest.cs [new file with mode: 0644]

index 00f49faa422c8df95636e5c7ded411ddf0fe5016..9c4ddb3906a36c4b32021b53629f51c21ab53dee 100644 (file)
@@ -1,3 +1,12 @@
+2004-11-29  Marek Safar  <marek.safar@seznam.cz>
+
+       * System.Windows.Forms.dll.sources: Added\r
+       TreeNode.cs, TreeNodeCollection.cs, TreeView.cs,\r
+       TreeViewAction.cs, TreeViewEventArgs.cs\r
+\r
+       * System.Windows.Forms_test.dll.sources: Added\r
+       TreeNodeTest.cs
+\r
 2004-11-24  Ravindra  <rkumar@novell.com>
 
        * SWF.csproj: Updated project.
index 14325c3652db486172e99def7c4fff406ea03b0d..5e87acf761c0d1e4420a0f310b7e95d14db85930 100644 (file)
@@ -18,7 +18,7 @@
                 OutputType = "Library"\r
                 PreBuildEvent = ""\r
                 PostBuildEvent = ""\r
-                RootNamespace = "System.Windows.Forms"\r
+                RootNamespace = ""\r
                 RunPostBuildEvent = "OnBuildSuccess"\r
                 StartupObject = ""\r
             >\r
                     SubType = "Component"\r
                     BuildAction = "Compile"\r
                 />\r
+                <File\r
+                    RelPath = "System.Windows.Forms\TreeNode.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "System.Windows.Forms\TreeNodeCollection.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "System.Windows.Forms\TreeView.cs"\r
+                    SubType = "Component"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "System.Windows.Forms\TreeViewAction.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
+                <File\r
+                    RelPath = "System.Windows.Forms\TreeViewEventArgs.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
                 <File\r
                     RelPath = "System.Windows.Forms\TreeViewImageIndexConverter.cs"\r
                     SubType = "Code"\r
index 217e6752c26b9017e6546c16f5995eb409444822..5d9ad416e3e1005876d3802281d49a2acc3952ea 100644 (file)
@@ -204,7 +204,12 @@ System.Windows.Forms/ToolBarButtonStyle.cs
 System.Windows.Forms/ToolBar.cs
 System.Windows.Forms/ToolBarTextAlign.cs
 System.Windows.Forms/ToolTip.cs
-System.Windows.Forms/TrackBar.cs
+System.Windows.Forms/TrackBar.cs\r
+System.Windows.Forms/TreeNode.cs\r
+System.Windows.Forms/TreeNodeCollection.cs\r
+System.Windows.Forms/TreeView.cs\r
+System.Windows.Forms/TreeViewAction.cs\r
+System.Windows.Forms/TreeViewEventArgs.cs\r
 System.Windows.Forms/TreeViewImageIndexConverter.cs
 System.Windows.Forms/UICues.cs
 System.Windows.Forms/UICuesEventArgs.cs
index ed17bd4c1a1f589b98d8ac6351afd169b41d4c2e..ba44889c98654616460669c6f7c290fde2eeb55a 100644 (file)
@@ -111,11 +111,7 @@ namespace System.Windows.Forms {
                                }
                        }
 
-                       while (!exiting && XplatUI.GetMessage(ref msg, IntPtr.Zero, 0, 0)) {
-                               if (form.end_modal) {
-                                       break;
-                               }
-
+                       while (!exiting && !form.end_modal && XplatUI.GetMessage(ref msg, IntPtr.Zero, 0, 0)) {
                                XplatUI.TranslateMessage(ref msg);
                                XplatUI.DispatchMessage(ref msg);
 
index 2a13cc74ce7b0328ea3a8165ade2f5e1df7ee1eb..8d737bf4e4c6bddc7d79d4a7d4bc7d0dd31178d2 100644 (file)
@@ -1,3 +1,16 @@
+2004-11-29  Marek Safar  <marek.safar@seznam.cz>
+
+       * Application.cs (ModalRun): Don't hang after exit.\r
+\r
+       * Theme.cs: New TreeViewDefaultSize property.\r
+\r
+       * ThemeWin32Classic.cs: Replaced hardcoded defaultWindowBackColor\r
+       with less hardcoded SystemColors constant.\r
+       Implemented TreeViewDefaultSize.\r
+\r
+       * TreeNode.cs, TreeNodeCollection.cs, TreeView.cs,\r
+       TreeViewAction.cs, TreeViewEventArgs.cs: New files.\r
+\r
 2004-11-29  John BouAntoun <jba-mono@optusnet.com.au>
 
        * MonthCalendar.cs: 
index fe462e57fec3409e24595facfb75a1c2bb8bde3c..8b63d13fb22fbfca4eb3e066a3f19b77a523df18 100644 (file)
@@ -467,6 +467,9 @@ namespace System.Windows.Forms
                public abstract Size VScrollBarDefaultSize{get;}        // Default size of the scrollbar
                #endregion      // VScrollBar
 
+               #region TreeView
+               public abstract Size TreeViewDefaultSize { get; }
+               #endregion
 
                #region ControlPaint Methods
                public abstract void CPDrawBorder (Graphics graphics, Rectangle bounds, Color leftColor, int leftWidth,
index 3c1b7c455bee20f4fa1cdceb2dadb09d1efed785..916c6388a97776ba42a56747b345f6dddc873e34 100644 (file)
@@ -343,7 +343,7 @@ namespace System.Windows.Forms
                        pen_arrow = new Pen (Color.Black);
                        br_progressbarblock = new SolidBrush (Color.FromArgb (255, 0, 0, 128));                 
 
-                       defaultWindowBackColor = Color.FromArgb (255, 10, 10, 10);
+                       defaultWindowBackColor = SystemColors.Window;
                        defaultWindowForeColor = ColorButtonText;
                        default_font =  new Font (FontFamily.GenericSansSerif, 8.25f);
                }       
@@ -3382,6 +3382,15 @@ namespace System.Windows.Forms
                }
                #endregion      // VScrollBar
 
+               #region TreeView
+               public override Size TreeViewDefaultSize {\r
+                       get {\r
+                               return new Size (121, 97);\r
+                       }\r
+               }\r
+
+               #endregion
+
                #region ControlPaint
                private enum DrawFrameControlStates {
                        ButtonCheck             = 0x0000,
@@ -4611,13 +4620,19 @@ namespace System.Windows.Forms
                
                public override void CPDrawBorderStyle (Graphics dc, Rectangle area, BorderStyle border_style) {
                        switch (border_style){
-                       case BorderStyle.Fixed3D:                               
+                       case BorderStyle.Fixed3D:
                                dc.DrawLine (ResPool.GetPen (ColorButtonShadow), area.X, area.Y, area.X +area.Width, area.Y);
                                dc.DrawLine (ResPool.GetPen (ColorButtonShadow), area.X, area.Y, area.X, area.Y + area.Height);
                                dc.DrawLine (ResPool.GetPen (ColorButtonHilight), area.X , area.Y + area.Height - 1, area.X + area.Width , 
                                        area.Y + area.Height - 1);
                                dc.DrawLine (ResPool.GetPen (ColorButtonHilight), area.X + area.Width -1 , area.Y, area.X + area.Width -1, 
                                        area.Y + area.Height);
+
+                               // FIXME: These colors are not correct. Microsoft uses different ones but I didn't find them.
+                               dc.DrawLine (ResPool.GetPen (ColorButtonLight), area.X + 1, area.Bottom - 2, area.Right - 2, area.Bottom - 2);
+                               dc.DrawLine (ResPool.GetPen (ColorButtonLight), area.Right - 2, area.Top + 1, area.Right - 2, area.Bottom - 2);
+                               dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), area.X + 1, area.Top + 1, area.X + 1, area.Bottom - 3);
+                               dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), area.X + 1, area.Top + 1, area.Right - 3, area.Top + 1);
                                break;
                        case BorderStyle.FixedSingle:
                                dc.DrawRectangle (ResPool.GetPen (ColorWindowFrame), area.X, area.Y, area.Width - 1, area.Height - 1);
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNode.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNode.cs
new file mode 100644 (file)
index 0000000..b74904e
--- /dev/null
@@ -0,0 +1,254 @@
+//
+// System.Windows.Forms.TreeNode.cs
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Autors:
+//             Marek Safar             marek.safar@seznam.cz
+//
+//
+//
+//
+
+// NOT COMPLETE
+
+using System;
+using System.Runtime.Serialization;
+
+namespace System.Windows.Forms
+{
+       [Serializable]
+       public class TreeNode: MarshalByRefObject, ICloneable, ISerializable
+       {
+               [Flags]
+               enum Flags {
+                       HasCheck        = 0x01,
+                       IsSelected      = 0x02,
+                       IsExpanded      = 0x04
+               }
+
+               Flags flags;
+               int index;
+               int imageIndex = -1;
+               TreeNodeCollection nodes;
+               TreeNode parent;
+               int selectedImageIndex = -1;
+               object tag;
+               string text = "";
+               TreeView treeView;
+
+               public TreeNode() {
+               }
+
+               public TreeNode (string text)
+               {
+                       if (text != null)
+                               this.text = text;
+               }
+
+               public TreeNode (string text, TreeNode[] children):
+                       this (text)
+               {
+                       Nodes.AddRange (children);
+               }
+
+
+               public TreeNode (string text, int imageIndex, int selectedImageIndex):
+                       this (text)
+               {
+                       this.imageIndex = imageIndex;
+                       this.selectedImageIndex = selectedImageIndex;
+               }
+
+               public TreeNode (string text, int imageIndex, int selectedImageIndex, TreeNode[] children):
+                       this (text, imageIndex, selectedImageIndex)
+               {
+                       Nodes.AddRange (children);
+               }
+
+
+               #region Properties
+
+               public bool Checked { 
+                       get {
+                               return (flags & Flags.HasCheck) != 0;
+                       }
+                       set {
+                               flags |= Flags.HasCheck;
+                       }
+               }       
+
+               public TreeNode FirstNode { 
+                       get {
+                               return (nodes == null || nodes.Count == 0) ? null : nodes [0];
+                       }
+               }
+
+               public string FullPath { 
+                       get {
+                               if (treeView == null)
+                                       throw new Exception ("No TreeView associated");
+
+                               return "";
+                       }
+               }
+
+               public int Index { 
+                       get {
+                               return index;
+                       }
+               }
+
+               public int ImageIndex { 
+                       get {
+                               return imageIndex;
+                       }
+                       set {
+                               imageIndex = value;
+                       }
+               }
+
+               public bool IsExpanded { 
+                       get {
+                               return (flags & Flags.IsExpanded) != 0;
+                       }
+               }
+
+               public bool IsSelected { 
+                       get {
+                               return (flags & Flags.IsSelected) != 0;
+                       }
+               }
+
+               [MonoTODO]
+               public bool IsVisible {
+                       get {
+                               throw new NotImplementedException ();
+                       }
+               }
+
+               public TreeNode LastNode { 
+                       get {
+                               return (nodes == null || nodes.Count == 0) ? null : nodes [nodes.Count - 1];
+                       }
+               }
+
+               public TreeNode NextNode { 
+                       get {
+                               if (parent.nodes == null || index == parent.nodes.Count - 1)
+                                       return null;
+
+                               return parent.nodes [index + 1];
+                       }
+               }
+
+               public TreeNodeCollection Nodes {
+                       get {
+                               if (nodes == null)
+                                       nodes = new TreeNodeCollection (this);
+                               return nodes;
+                       }
+               }
+
+               public TreeNode Parent { 
+                       get {
+                               return parent;
+                       }
+               }
+
+               public TreeNode PrevNode { 
+                       get {
+                               if (parent.nodes == null || index == 0)
+                                       return null;
+
+                               return parent.nodes [index - 1];
+                       }
+               }
+
+               public int SelectedImageIndex { 
+                       get {
+                               return selectedImageIndex;
+                       }
+                       set {
+                               selectedImageIndex = value;
+                       }
+               }
+
+               public object Tag { 
+                       get {
+                               return tag;
+                       }
+                       set {
+                               tag = value;
+                       }
+               }
+
+               public string Text {
+                       get {
+                               return text;
+                       }
+                       set {
+                               this.text = (value == null) ? "" : value;
+                       }
+               }
+
+               #endregion
+
+               #region ICloneable Members
+
+               [MonoTODO ("Copy drawing fields")]
+               public object Clone()
+               {
+                       TreeNode tn = new TreeNode (text, imageIndex, selectedImageIndex);
+                       if (nodes != null) {
+                               foreach (TreeNode child in nodes)
+                                       tn.Nodes.Add ((TreeNode)child.Clone ());
+                       }
+                       tn.Tag = tag;
+                       tn.Checked = Checked;
+                       return tn;
+               }
+
+               #endregion
+
+               #region ISerializable Members
+
+               [MonoTODO]
+               void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               #endregion
+
+               // Internal
+
+               internal void SetParent (TreeNode parent)
+               {
+                       this.parent = parent;
+               }
+
+               internal void SetIndex (int index)
+               {
+                       this.index = index;
+               }
+
+       }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNodeCollection.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNodeCollection.cs
new file mode 100644 (file)
index 0000000..e2761a2
--- /dev/null
@@ -0,0 +1,182 @@
+//
+// System.Windows.Forms.TreeNode.cs
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Autors:
+//             Marek Safar             marek.safar@seznam.cz
+//
+//
+//
+//
+
+// NOT COMPLETE
+
+using System;
+using System.Collections;
+
+namespace System.Windows.Forms
+{
+       public class TreeNodeCollection: ICollection, IEnumerable, IList
+       {
+               TreeNode owner;
+
+               ArrayList collection = new ArrayList ();
+
+               internal TreeNodeCollection (TreeNode owner)
+               {
+                       this.owner = owner;
+               }
+
+        [MonoTODO ("Check implementation")]
+               public virtual int Add (TreeNode node)
+               {
+                       if (node == null)
+                               throw new ArgumentNullException("value");
+
+                       if (node.Parent != null)
+                               throw new ArgumentException("Object already has a parent", "node");
+
+                       node.SetParent (owner);
+                       int index = collection.Add (node);
+                       node.SetIndex (index);
+                       return index;           
+               }
+
+               public virtual void AddRange (TreeNode[] nodes)
+               {
+                       if (nodes == null)
+                               throw new ArgumentNullException("nodes");
+
+                       foreach (TreeNode node in nodes) {
+                               Add (node);
+                       }
+               }
+
+               public int Count {
+                       get {
+                               return collection.Count;
+                       }
+               }
+
+               [MonoTODO ("set")]
+               public virtual TreeNode this [int index] {
+                       get {
+                               return (TreeNode)collection [index];
+                       }
+                       set {
+                               throw new NotImplementedException ();
+                       }
+               }
+       
+               #region IEnumerable Members
+
+               public IEnumerator GetEnumerator ()
+               {
+                       return collection.GetEnumerator ();
+               }
+
+               #endregion
+       
+               #region ICollection Members
+
+               bool ICollection.IsSynchronized {
+                       get {
+                               return false;
+                       }
+               }
+
+               public void CopyTo(Array array, int index)
+               {
+                       collection.CopyTo (array, index);
+               }
+
+               object ICollection.SyncRoot {
+                       get {
+                               return this;
+                       }
+               }
+
+               #endregion
+
+               #region IList Members
+
+               public bool IsReadOnly {
+                       get {
+                               return false;
+                       }
+               }
+
+               [MonoTODO]
+               object IList.this[int index] {
+                       get {
+                               return null;
+                       }
+                       set {
+                       }
+               }
+
+               public void RemoveAt (int index)
+               {
+                       collection.RemoveAt (index);
+               }
+
+               [MonoTODO]
+               void IList.Insert(int index, object value)
+        {
+               }
+
+               [MonoTODO]
+               void IList.Remove(object value)
+               {
+               }
+                
+               [MonoTODO]
+               bool IList.Contains(object value)
+               {
+                       return false;
+               }
+
+               public void Clear()
+               {
+                       collection.Clear ();
+               }
+
+               [MonoTODO]
+               int IList.IndexOf(object value)
+               {
+                       return 0;
+               }
+
+               [MonoTODO]
+               int IList.Add(object value)
+               {
+                       return 0;
+               }
+
+               public bool IsFixedSize {
+                       get {
+                               return false;
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeView.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeView.cs
new file mode 100644 (file)
index 0000000..0a2ee22
--- /dev/null
@@ -0,0 +1,104 @@
+//
+// System.Windows.Forms.TreeNode.cs
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Autors:
+//             Marek Safar             marek.safar@seznam.cz
+//
+//
+//
+//
+
+// NOT COMPLETE
+
+using System;
+using System.Drawing;
+using System.ComponentModel;
+
+namespace System.Windows.Forms
+{
+       public class TreeView: Control
+       {
+               BorderStyle border_style = BorderStyle.Fixed3D;
+
+               public TreeView()
+               {
+                       background_color = ThemeEngine.Current.DefaultWindowBackColor;
+
+                       base.Paint += new PaintEventHandler (TreeView_Paint);
+
+                       SetStyle (ControlStyles.ResizeRedraw, true);
+               }
+
+               #region Properties
+
+               public override Color BackColor {
+                       get {
+                               return background_color;
+                       }
+                       set {
+                               if (value == background_color)
+                                       return;
+
+                               background_color = value;
+//                             if (BackColorChanged != null)
+//                                     BackColorChanged (this, new EventArgs ());
+//                             Redraw (false);
+                       }
+               }
+
+               [DefaultValue (BorderStyle.Fixed3D)]
+               public BorderStyle BorderStyle {
+                       get { 
+                               return border_style;
+                       }
+                       set {
+                               if (border_style != value) {
+                                       border_style = value;
+                                       //this.Redraw (false);
+                               }
+                       }
+               }
+
+               protected override System.Drawing.Size DefaultSize {
+                       get {
+                               return ThemeEngine.Current.TreeViewDefaultSize;
+                       }
+               }
+
+               #endregion
+
+               void TreeView_Paint (object sender, PaintEventArgs pe)
+               {
+                       if (this.Width <= 0 || this.Height <=  0 ||
+                               this.Visible == false)
+                               return;
+
+                       DrawTreeView (pe.Graphics, this);
+                       ThemeEngine.Current.CPDrawBorderStyle (pe.Graphics, this.ClientRectangle, border_style);
+               }
+
+               void DrawTreeView (Graphics dc, Control control)
+               {
+                       dc.Clear (control.BackColor);
+               }
+       }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewAction.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewAction.cs
new file mode 100644 (file)
index 0000000..cb6b8dc
--- /dev/null
@@ -0,0 +1,43 @@
+//
+// System.Windows.Forms.TreeViewAction.cs
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Autors:
+//             Marek Safar             marek.safar@seznam.cz
+//
+// Copyright (C) Novell Inc., 2004
+//
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms
+{
+       public enum TreeViewAction
+       {
+               Unknown         = 0,
+               ByKeyboard      = 1,
+               ByMouse         = 2,
+               Collapse        = 3,
+               Expand          = 4
+       }
+}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewEventArgs.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewEventArgs.cs
new file mode 100644 (file)
index 0000000..49a3226
--- /dev/null
@@ -0,0 +1,64 @@
+//
+// System.Windows.Forms.TreeViewEventArgs.cs
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Autors:
+//             Marek Safar             marek.safar@seznam.cz
+//
+// Copyright (C) Novell Inc., 2004
+//
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms
+{
+       public class TreeViewEventArgs: EventArgs
+       {
+               TreeViewAction action;
+               TreeNode node;
+
+               public TreeViewEventArgs (TreeNode node):
+                       this (node, TreeViewAction.Unknown)
+               {
+               }
+
+               public TreeViewEventArgs (TreeNode node, TreeViewAction action)
+               {
+                       this.node = node;
+                       this.action = action;
+               }
+
+               public TreeViewAction Action { 
+                       get {
+                               return action;
+                       }
+               }
+
+               public TreeNode Node { 
+                       get {
+                               return node;
+                       }
+               }
+       }
+}
index 566978899669c432d33d4bfb580c8ea04a413fe5..d441e91258b89ebb70c2dbaf368f4dbd589f3b0f 100644 (file)
@@ -1 +1,2 @@
 System.Windows.Forms/TestImageIndexConverter.cs
+System.Windows.Forms/TreeNodeTest.cs
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TreeNodeTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TreeNodeTest.cs
new file mode 100644 (file)
index 0000000..6b0822c
--- /dev/null
@@ -0,0 +1,134 @@
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+
+[TestFixture]
+public class TreeNodeTest {
+
+       [Test]
+       public void EmptyCtorTest ()
+       {
+               TreeNode tn = new TreeNode ();
+               Assert.AreEqual ("", tn.Text, "#1");
+               Assert.AreEqual (0, tn.Nodes.Count, "#2");
+               Assert.AreEqual (-1, tn.ImageIndex, "#3");
+               Assert.AreEqual (-1, tn.SelectedImageIndex, "#4");
+
+               // Set simple properties
+               tn.Text = null;
+               Assert.AreEqual ("", tn.Text, "#5");
+               tn.ImageIndex = 67;
+               Assert.AreEqual (67, tn.ImageIndex, "#6");
+               tn.SelectedImageIndex = 99;
+               Assert.AreEqual (99, tn.SelectedImageIndex, "#7");
+       }
+
+       [Test]
+       public void CtorTest () {
+               TreeNode tn = new TreeNode ("label1");
+               
+               Assert.AreEqual ("label1", tn.Text);
+               Assert.AreEqual (0, tn.Nodes.Count);
+               Assert.AreEqual (-1, tn.ImageIndex, "II");
+               Assert.AreEqual (-1, tn.SelectedImageIndex, "SI");
+
+               Assert.IsNull (tn.FirstNode);
+               Assert.IsNull (tn.LastNode);
+               Assert.AreEqual ("", new TreeNode (null).Text);
+       }
+
+       [Test]
+       public void CtorTest2 ()
+       {
+               TreeNode tn = new TreeNode ("a1", new TreeNode[] { new TreeNode ("aa1"), new TreeNode ("aa2") } );
+
+               Assert.AreEqual ("a1", tn.Text);
+               Assert.AreEqual (-1, tn.ImageIndex, "II");
+               Assert.AreEqual (-1, tn.SelectedImageIndex, "SI");
+
+               Assert.AreEqual ("aa1", tn.Nodes [0].Text, "#1");
+               Assert.AreEqual ("aa2", tn.Nodes [1].Text, "#2");
+               Assert.AreSame (tn.FirstNode, tn.Nodes [0], "#3");
+               Assert.AreSame (tn.LastNode, tn.Nodes [1], "#4");
+       }
+
+       [Test]
+       public void CtorTest3 ()
+       {
+               TreeNode tn = new TreeNode ("a", 5, 9);
+
+               Assert.AreEqual ("a", tn.Text);
+               Assert.IsNotNull (tn.Nodes);
+               Assert.AreEqual (5, tn.ImageIndex);
+               Assert.AreEqual (9, tn.SelectedImageIndex);
+               Assert.AreEqual ("", new TreeNode (null, 0, 0).Text);
+       }
+
+       [Test, ExpectedException (typeof (ArgumentNullException))]
+       public void CtorException1 ()
+       {
+               new TreeNode ("", 1, 1, null);
+       }
+
+       [Test, ExpectedException (typeof (ArgumentNullException))]
+       public void CtorException2 () {
+               new TreeNode ("tt", null);
+       }
+
+       [Test]
+       public void Traverse ()
+       {
+               TreeNode tn_1 = new TreeNode ("1");
+               TreeNode tn_2 = new TreeNode ("2");
+               TreeNode tn_3 = new TreeNode ("3");
+               TreeNode tn = new TreeNode ("lev1");
+               tn.Nodes.Add (tn_1);
+               Assert.AreSame (tn, tn_1.Parent, "#1");
+               Assert.IsNull (tn_1.NextNode, "#2");
+               Assert.AreEqual (0, tn_1.Parent.Index, "#3");
+               tn.Nodes.Add (tn_2);
+               Assert.IsNull (tn_1.NextNode.NextNode, "#33");
+               tn.Nodes.Add (tn_3);
+               Assert.AreEqual (2, tn_3.Index, "#4");
+
+               Assert.AreEqual (3, tn.Nodes.Count, "#5");
+               Assert.AreSame (tn_2, tn_2.NextNode.PrevNode, "#6");
+               Assert.IsNull (tn_1.PrevNode, "#7");
+       }
+
+       [Test, ExpectedException (typeof (Exception))]
+       public void FullPathException ()
+       {
+               string s = new TreeNode ("").FullPath;
+       }
+
+       [Test, Ignore ("TODO")]
+       public void FullPathTest ()
+       {
+               TreeNode tn_1 = new TreeNode ("A");
+               TreeNode tn_2 = new TreeNode ("B");
+               tn_2.Nodes.Add (tn_1);
+               Assert.AreEqual (@"A\B", tn_1.FullPath);
+
+       }
+
+       [Test]
+       public void CloneTest ()
+       {
+               // TODO: Add draw oriented fields will be implemented
+
+               TreeNode orig = new TreeNode ("text", 2, 3, new TreeNode [] { new TreeNode ("child", 22, 33) });
+               orig.Tag = FlatStyle.Flat;
+               orig.Checked = true;
+               TreeNode clone = (TreeNode)orig.Clone ();
+               Assert.AreEqual ("text", clone.Text, "#1");
+               Assert.AreEqual (2, clone.ImageIndex, "#2");
+               Assert.AreEqual (3, clone.SelectedImageIndex, "#3");
+               Assert.AreEqual (1, clone.Nodes.Count, "#4");
+               Assert.AreEqual (FlatStyle.Flat, clone.Tag, "#5");
+               Assert.IsTrue (clone.Checked, "#6");
+               Assert.AreEqual ("child", clone.Nodes [0].Text, "#10");
+               Assert.AreEqual (22, clone.Nodes [0].ImageIndex, "#11");
+       }
+
+}
\ No newline at end of file