dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/System.Windows.Forms ToolBar.cs,NONE


From: Richard Baumann <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/System.Windows.Forms ToolBar.cs,NONE,1.1 ToolBarButton.cs,1.1,1.2 EventId.cs,1.5,1.6 ImageList.cs,1.4,1.5
Date: Fri, 04 Jul 2003 01:50:02 -0400

Update of /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms
In directory subversions:/tmp/cvs-serv14510/System.Windows.Forms

Modified Files:
        ToolBarButton.cs EventId.cs ImageList.cs 
Added Files:
        ToolBar.cs 
Log Message:
Implement winforms ToolBar, add RecreateHandle event to ImageList.


--- NEW FILE ---
/*
 * ToolBar.cs - Implementation of the
 *                      "System.Windows.Forms.ToolBar" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 * Copyright (C) 2003  Free Software Foundation, Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
[...1985 lines suppressed...]
                                                );
                                        }
                                        else if(position < 0 || position >= 
count)
                                        {
                                                throw new 
InvalidOperationException
                                                (
                                                        
S._("Invalid_BadEnumeratorPosition")
                                                );
                                        }
                                        return tbbc[position];
                                }
                        }

                }; // class TBBCEnumerator

        }; // class ToolBarButtonCollection

}; // class ToolBar

}; // namespace System.Windows.Forms

Index: ToolBarButton.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/ToolBarButton.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** ToolBarButton.cs    11 Jun 2003 07:07:19 -0000      1.1
--- ToolBarButton.cs    4 Jul 2003 05:50:00 -0000       1.2
***************
*** 4,7 ****
--- 4,8 ----
   *
   * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
+  * Copyright (C) 2003  Free Software Foundation, Inc.
   *
   * This program is free software; you can redistribute it and/or modify
***************
*** 23,29 ****
  {
  
  public class ToolBarButton
  {
!       // TODO
  
  }; // class ToolBarButton
--- 24,315 ----
  {
  
+ using System;
+ using System.ComponentModel;
+ using System.Drawing;
+ 
  public class ToolBarButton
+ #if CONFIG_COMPONENT_MODEL
+       : Component
+ #endif
  {
!       // Variables
!       internal ToolBar parent;
!       internal int tbbcIndex; // index in ToolBarButtonCollection
!       internal int groupID; // index of last separator (used in wrapping)
!       internal Rectangle viewRectangle;
!       internal Rectangle dropRectangle;
!       private Menu dropDownMenu = null;
!       private bool enabled = true;
!       private int imageIndex = -1;
!       private bool partialPush = false;
!       private bool pushed = false;
!       private ToolBarButtonStyle style = ToolBarButtonStyle.PushButton;
!       private object tag = null;
!       private string text = "";
!       private string toolTipText = "";
!       private bool visible = true;
! 
! 
! 
!       // Constructors
!       public ToolBarButton() : base() {}
! #if !CONFIG_COMPACT_FORMS
!       public ToolBarButton(String s) : base() { text = s; }
! #endif
! 
! 
! 
!       // Properties
!       public Menu DropDownMenu
!       {
!               get { return dropDownMenu; }
!               set
!               {
!                       // this is called bad design
!                       // this is the compiler's job
!                       if (!(value is ContextMenu))
!                       {
!                               throw new ArgumentException(/* TODO */);
!                       }
!                       if (value == dropDownMenu) { return; }
!                       dropDownMenu = value;
!               }
!       }
!       public bool Enabled
!       {
!               get { return enabled; }
!               set
!               {
!                       if (value == enabled) { return; }
!                       enabled = value;
!                       if (visible && parent != null)
!                       {
!                               parent.TBBUpdate(tbbcIndex,true);
!                       }
!               }
!       }
!       public int ImageIndex
!       {
!               get { return imageIndex; }
!               set
!               {
!                       if (value < -1)
!                       {
!                               // ArgumentOutOfRangeException?
!                               throw new ArgumentException(/* TODO */);
!                       }
!                       if (value == imageIndex) { return; }
!                       imageIndex = value;
!                       if (visible && parent != null)
!                       {
!                               parent.TBBUpdate(tbbcIndex,true);
!                       }
!               }
!       }
! #if !CONFIG_COMPACT_FORMS
!       public ToolBar Parent { get { return parent; } }
!       public bool PartialPush
!       {
!               get { return partialPush; }
!               set
!               {
!                       if (value == partialPush) { return; }
!                       partialPush = value;
!                       if (style == ToolBarButtonStyle.ToggleButton)
!                       {
!                               if (visible && parent != null)
!                               {
!                                       parent.TBBUpdate(tbbcIndex,true);
!                               }
!                       }
!               }
!       }
! #endif
!       public bool Pushed
!       {
!               get { return pushed; }
!               set
!               {
!                       if (value == pushed) { return; }
!                       pushed = value;
!                       if (style == ToolBarButtonStyle.ToggleButton)
!                       {
!                               if (visible && parent != null)
!                               {
!                                       parent.TBBUpdate(tbbcIndex,true);
!                               }
!                       }
!               }
!       }
! #if !CONFIG_COMPACT_FORMS
!       public Rectangle Rectangle
!       {
!               get
!               {
!                       if (parent.Visible && Visible)
!                       {
!                               return 
Rectangle.Union(viewRectangle,dropRectangle);
!                       }
!                       return Rectangle.Empty;
!               }
!       }
! #endif
!       public ToolBarButtonStyle Style
!       {
!               get { return style; }
!               set
!               {
!                       if (value == style) { return; }
! 
!                       ToolBarButtonStyle oldStyle = style;
!                       style = value;
!                       if (visible && parent != null)
!                       {
!                               if (oldStyle == ToolBarButtonStyle.Separator)
!                               {
!                                       
parent.buttons.KillGroupQuiet(tbbcIndex);
!                               }
!                               else if (value == ToolBarButtonStyle.Separator)
!                               {
!                                       
parent.buttons.MakeGroupQuiet(tbbcIndex);
!                               }
!                               parent.TBBUpdate(tbbcIndex,false);
!                       }
!               }
!       }
! #if !CONFIG_COMPACT_FORMS
!       public object Tag
!       {
!               get { return tag; }
!               set { tag = value; }
!       }
!       public string Text
!       {
!               get { return text; }
!               set
!               {
!                       if (value == text) { return; }
!                       if (value == null) { value = ""; }
!                       text = value;
!                       if (visible && parent != null)
!                       {
!                               parent.TBBUpdate(tbbcIndex,false);
!                       }
!               }
!       }
!       public string ToolTipText
!       {
!               get { return toolTipText; }
!               set
!               {
!                       if (value == toolTipText) { return; }
!                       if (value == null) { value = ""; }
!                       toolTipText = value;
!               }
!       }
! #endif
!       public bool Visible
!       {
!               get { return visible; }
!               set
!               {
!                       if (value == visible) { return; }
!                       visible = value;
!                       if (!visible)
!                       {
!                               viewRectangle = Rectangle.Empty;
!                               dropRectangle = Rectangle.Empty;
!                       }
!                       if (parent != null)
!                       {
!                               if (style == ToolBarButtonStyle.Separator)
!                               {
!                                       if (visible)
!                                       {
!                                               // if the separator is visible
!                                               // it should act as a wrap point
!                                               
parent.buttons.MakeGroupQuiet(tbbcIndex);
!                                       }
!                                       else
!                                       {
!                                               // if the separator isn't 
visible
!                                               // it shouldn't act as a wrap 
point
!                                               
parent.buttons.KillGroupQuiet(tbbcIndex);
!                                       }
!                                       // no point in recalculating all the 
text
!                                       // and button sizing info for a group 
change
!                                       parent.TBBCUpdate(true);
!                               }
!                               else
!                               {
!                                       parent.TBBUpdate(tbbcIndex,false);
!                               }
!                       }
!               }
!       }
! 
! 
! 
!       // Methods
!       protected override void Dispose(bool disposing)
!       {
!               base.Dispose(disposing);
!       }
!       internal int Contains(int x, int y, bool dropDowns)
!       {
!               if (!visible)
!               {
!                       return 0;
!               }
!               else if (style == ToolBarButtonStyle.Separator)
!               {
!                       if (viewRectangle.Contains(x,y))
!                       {
!                               return -1;
!                       }
!                       return 0;
!               }
!               else if (dropDowns)
!               {
!                       if (viewRectangle.Contains(x,y))
!                       {
!                               return 1;
!                       }
!                       else if (dropRectangle.Contains(x,y))
!                       {
!                               return 2;
!                       }
!                       else
!                       {
!                               return 0;
!                       }
!               }
!               else if (style == ToolBarButtonStyle.DropDownButton)
!               {
!                       if (viewRectangle.Contains(x,y))
!                       {
!                               return 2;
!                       }
!                       else
!                       {
!                               return 0;
!                       }
!               }
!               return 0;
!       }
!       internal void Reset()
!       {
!               parent = null;
!               tbbcIndex = -1;
!               groupID = -1;
!               viewRectangle = Rectangle.Empty;
!               dropRectangle = Rectangle.Empty;
!       }
!       public override string ToString()
!       {
!               // TODO
!               return base.ToString();
!       }
! 
  
  }; // class ToolBarButton

Index: EventId.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/EventId.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** EventId.cs  21 Jun 2003 04:34:35 -0000      1.5
--- EventId.cs  4 Jul 2003 05:50:00 -0000       1.6
***************
*** 121,124 ****
--- 121,128 ----
        ReadOnlyChanged,
  
+       // "ToolBar" events.
+       ButtonClick,
+       ButtonDropDown,
+ 
  }; // enum EventId
  

Index: ImageList.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/ImageList.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** ImageList.cs        25 Jun 2003 00:45:31 -0000      1.4
--- ImageList.cs        4 Jul 2003 05:50:00 -0000       1.5
***************
*** 32,37 ****
  public sealed class ImageList : Component
  {
-       // TODO
- 
        // Variables
        private ColorDepth colorDepth = ColorDepth.Depth8Bit;
--- 32,35 ----
***************
*** 40,43 ****
--- 38,42 ----
        private ImageListStreamer imageStream = null;
        private Color transparentColor = Color.Transparent;
+       private Delegate rhHandler = null;
  
        // Constructor
***************
*** 55,62 ****
        {
                get { return colorDepth; }
!               set { colorDepth = value; /* TODO */ }
        }
        public IntPtr Handle { get { return IntPtr.Zero; } }
!       public bool HandleCreated { get { return false; } }
  #endif
        public ImageCollection Images { get { return images; } }
--- 54,65 ----
        {
                get { return colorDepth; }
!               set
!               {
!                       colorDepth = value;
!                       OnRecreateHandle();
!               }
        }
        public IntPtr Handle { get { return IntPtr.Zero; } }
!       public bool HandleCreated { get { return true; } }
  #endif
        public ImageCollection Images { get { return images; } }
***************
*** 72,83 ****
                        }
                        imageSize = value;
!                       // TODO
                }
        }
  #if !CONFIG_COMPACT_FORMS
        public ImageListStreamer ImageStream
        {
                get { return imageStream; }
!               set { imageStream = value; /* TODO */ }
        }
        public Color TransparentColor
--- 75,91 ----
                        }
                        imageSize = value;
!                       OnRecreateHandle();
                }
        }
  #if !CONFIG_COMPACT_FORMS
+       [TODO]
        public ImageListStreamer ImageStream
        {
                get { return imageStream; }
!               set
!               {
!                       imageStream = value;
!                       OnRecreateHandle();
!               }
        }
        public Color TransparentColor
***************
*** 104,107 ****
--- 112,123 ----
        }
  #endif
+       private void OnRecreateHandle()
+       {
+               EventHandler handler = (rhHandler as EventHandler);
+               if (handler != null)
+               {
+                       handler(this,EventArgs.Empty);
+               }
+       }
        public override string ToString()
        {
***************
*** 112,117 ****
        // Events
  #if !CONFIG_COMPACT_FORMS
!       public event EventHandler RecreateHandle;
  #endif
  
  
--- 128,146 ----
        // Events
  #if !CONFIG_COMPACT_FORMS
!       public
! #else
!       internal
  #endif
+       event EventHandler RecreateHandle
+       {
+               add
+               {
+                       rhHandler = Delegate.Combine(rhHandler,value);
+               }
+               remove
+               {
+                       rhHandler = Delegate.Remove(rhHandler,value);
+               }
+       }
  
  
***************
*** 139,147 ****
  
  
! 
!       public class ImageCollection : IList, ICollection, IEnumerable
        {
-               // TODO
- 
                // Variables
                private ImageList owner;
--- 168,174 ----
  
  
!       [TODO]
!       public sealed class ImageCollection : IList, ICollection, IEnumerable
        {
                // Variables
                private ImageList owner;
***************
*** 152,159 ****
  
                // Properties
!               public virtual int Count { get { return images.Count; } }
!               public virtual bool IsReadOnly { get { return false; } }
        #if !CONFIG_COMPACT_FORMS
!               public virtual bool Empty { get { return images.Count == 0; } }
                public Image this[int index]
                {
--- 179,186 ----
  
                // Properties
!               public int Count { get { return images.Count; } }
!               public bool IsReadOnly { get { return false; } }
        #if !CONFIG_COMPACT_FORMS
!               public bool Empty { get { return images.Count == 0; } }
                public Image this[int index]
                {
***************
*** 263,267 ****
                public bool Contains(Image image)
                {
!                       return images.Contains(image);
                }
        #endif
--- 290,294 ----
                public bool Contains(Image image)
                {
!                       throw new NotSupportedException(/* TODO */);
                }
        #endif
***************
*** 273,282 ****
                public int IndexOf(Image image)
                {
!                       return images.IndexOf(image);
                }
  
                public void Remove(Image image)
                {
!                       images.Remove(image);
                }
        #endif
--- 300,309 ----
                public int IndexOf(Image image)
                {
!                       throw new NotSupportedException(/* TODO */);
                }
  
                public void Remove(Image image)
                {
!                       throw new NotSupportedException(/* TODO */);
                }
        #endif
***************
*** 291,296 ****
  
                // Properties (Explicit IList Implementation)
!               bool IList.IsReadOnly { get { return images.IsReadOnly; } }
!               bool IList.IsFixedSize { get { return images.IsFixedSize; } }
        #if !CONFIG_COMPACT_FORMS
                object IList.this[int index]
--- 318,322 ----
  
                // Properties (Explicit IList Implementation)
!               bool IList.IsFixedSize { get { return false; } }
        #if !CONFIG_COMPACT_FORMS
                object IList.this[int index]
***************
*** 302,327 ****
  
                // Methods (Explicit IList Implementation)
-               void IList.Clear() { Clear(); }
                int IList.Add(object o)
                {
!                       if (!(o is Image))
                        {
                                throw new ArgumentException(/* TODO */);
                        }
!                       return Add((Image) o,owner.TransparentColor);
                }
                bool IList.Contains(object o)
                {
!                       if (!(o is Image)) { return false; }
!                       return Contains((Image) o);
                }
                int IList.IndexOf(object o)
                {
!                       if (!(o is Image)) { return -1; }
!                       return IndexOf((Image) o);
                }
                void IList.Insert(int index, object o)
                {
!                       if (!(o is Image))
                        {
                                throw new ArgumentException(/* TODO */);
--- 328,359 ----
  
                // Methods (Explicit IList Implementation)
                int IList.Add(object o)
                {
!                       if (o == null)
!                       {
!                               throw new ArgumentNullException(/* TODO */);
!                       }
!                       if (!(o is Bitmap))
                        {
                                throw new ArgumentException(/* TODO */);
                        }
!               #if !CONFIG_COMPACT_FORMS
!                       ((Bitmap) o).MakeTransparent(owner.TransparentColor);
!               #endif
!                       return images.Add(o);
                }
                bool IList.Contains(object o)
                {
!                       if (!(o is Bitmap)) { return false; }
!                       return images.Contains(o);
                }
                int IList.IndexOf(object o)
                {
!                       if (!(o is Bitmap)) { return -1; }
!                       return images.IndexOf(o);
                }
                void IList.Insert(int index, object o)
                {
!                       if (!(o is Bitmap))
                        {
                                throw new ArgumentException(/* TODO */);
***************
*** 331,349 ****
                void IList.Remove(object o)
                {
!                       if (!(o is Image))
                        {
                                throw new ArgumentException(/* TODO */);
                        }
!                       Remove((Image) o);
                }
-               void IList.RemoveAt(int index) { RemoveAt(index); }
  
                // Properties (Explicit ICollection Implementation)
!               int ICollection.Count { get { return images.Count; } }
!               bool ICollection.IsSynchronized { get { return 
images.IsSynchronized; } }
!               object ICollection.SyncRoot { get { return images.SyncRoot; } }
  
                // Methods (Explicit ICollection Implementation)
!               void ICollection.CopyTo(Array array, int index) { 
images.CopyTo(array,index); }
  
        }; // class ImageList.ImageCollection
--- 363,388 ----
                void IList.Remove(object o)
                {
!                       if (!(o is Bitmap))
                        {
                                throw new ArgumentException(/* TODO */);
                        }
!                       images.Remove(o);
                }
  
                // Properties (Explicit ICollection Implementation)
!               bool ICollection.IsSynchronized
!               {
!                       get { return images.IsSynchronized; }
!               }
!               object ICollection.SyncRoot
!               {
!                       get { return images.SyncRoot; }
!               }
  
                // Methods (Explicit ICollection Implementation)
!               void ICollection.CopyTo(Array array, int index)
!               {
!                       images.CopyTo(array,index);
!               }
  
        }; // class ImageList.ImageCollection





reply via email to

[Prev in Thread] Current Thread [Next in Thread]