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 Clipboard.cs, NO


From: Richard Baumann <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/System.Windows.Forms Clipboard.cs, NONE, 1.1 DataObject.cs, NONE, 1.1 DataFormats.cs, NONE, 1.1 StatusBar.cs, 1.2, 1.3
Date: Fri, 01 Aug 2003 13:53:10 -0400

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

Modified Files:
        StatusBar.cs 
Added Files:
        Clipboard.cs DataObject.cs DataFormats.cs 
Log Message:
Apply reviewed savannah patches.


--- NEW FILE ---
/*
 * Clipboard.cs - Implementation of the
 *                      "System.Windows.Forms.Clipboard" class.
 *
 * Copyright (C) 2003  Free Software Foundation, Inc.
 *
 * Contributions from Cecilio Pardo <address@hidden>
 *
 * 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
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.Windows.Forms
{

using System;
using System.Threading;

[TODO]
public sealed class Clipboard
{
        // TODO: This is a simple implementation that only
        //       works inside the same application.

        private static IDataObject obj = null;

        private Clipboard() {}

        [TODO]
        public static IDataObject GetDataObject()
        {
                Thread ct = Thread.CurrentThread;
                if (ct.ApartmentState != ApartmentState.STA)
                {
                        throw new ThreadStateException(/* TODO */);
                }
                return obj;
        }

        public static void SetDataObject(Object data)
        {
                SetDataObject(data, false);
        }

        [TODO]
        public static void SetDataObject(Object data, bool copy)
        {
                if (data == null)
                {
                        throw new ArgumentNullException("data");
                }
                if ((obj = (data as IDataObject)) == null)
                {
                        obj = new DataObject(data);
                }
        }

}; // class Clipboard

}; // namespace System.Windows.Forms

--- NEW FILE ---
/*
 * DataObject.cs - Implementation of the
 *                      "System.Windows.Forms.DataObject" class.
 *
 * Copyright (C) 2003  Free Software Foundation, Inc.
 *
 * Contributions from Cecilio Pardo <address@hidden>
 *
 * 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
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.Windows.Forms
{

using System;
using System.Collections;

[TODO]
//[ClassInterface(ClassInterfaceType.None)]
public class DataObject : IDataObject
{
        Hashtable objects = new Hashtable();

        public DataObject() {}

        public DataObject(Object o)
        {
                SetData(o);
        }

        public DataObject(String s, Object o)
        {
                SetData(s, o);
        }

        public virtual Object GetData(String s)
        {
                return GetData(s, true);
        }

        [TODO]
        public virtual Object GetData(Type t)
        {
                return null;
        }

        [TODO]
        // TODO: Format conversion
        public virtual Object GetData(String s, bool b)
        {
                if (s == null)
                {
                        return null;
                }
                if (objects.ContainsKey(s))
                {
                        return ((DataObjectElement)objects[s]).data;
                }
                return null;
        }

        public virtual bool GetDataPresent(String s)
        {
                return GetDataPresent(s, true);
        }

        [TODO]
        public virtual bool GetDataPresent(Type t)
        {
                return false;
        }

        [TODO]
        // TODO: Check if some other format is convertible
        public virtual bool GetDataPresent(String s, bool b)
        {
                return objects.ContainsKey(s);
        }

        public virtual String[] GetFormats()
        {
                return GetFormats(true);
        }

        [TODO]
        // TODO: Implement format convertibility
        public virtual String[] GetFormats(bool b)
        {
                String[] s;
                s = new String[objects.Count];
                int i = 0;
                foreach (DictionaryEntry d in objects)
                {
                        s[i++] = d.Key.ToString();
                }
                return s;
        }

        [TODO]
        // TODO: This method has to find the format from the class
        public virtual void SetData(Object o)
        {
                SetData(DataFormats.StringFormat, o.ToString()); 
        }

        public virtual void SetData(String s, Object o)
        {
                SetData(s, true, o);
        }

        [TODO]
        public virtual void SetData(Type t, Object o)
        {
        }

        public virtual void SetData(String s, bool b, Object o)
        {
                if (s == null)
                {
                        s = DataFormats.StringFormat;
                }
                objects.Remove(s);
                objects.Add(s, new DataObjectElement(s, o, true));
        }





















        internal class DataObjectElement
        {
                public String format;
                public Object data;
                public bool canConvert;

                public DataObjectElement(String format, Object data, bool 
canConvert)
                {
                        this.format = format;
                        this.data = data;
                        this.canConvert = canConvert;
                }

        }; // class DataObjectElement

}; // class DataObject

}; // namespace System.Windows.Forms

--- NEW FILE ---
/*
 * DataFormats.cs - Implementation of the
 *                      "System.Windows.Forms.DataFormats" class.
 *
 * Copyright (C) 2003  Free Software Foundation, Inc.
 *
 * Contributions from Cecilio Pardo <address@hidden>
 *
 * 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
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.Windows.Forms
{

using System.Collections;

[TODO]
public class DataFormats
{
        public static readonly String Bitmap = "Bitmap";
        public static readonly String CommaSeparatedValue = "Csv";
        public static readonly String Dib = "DeviceIndependentBitmap";
        public static readonly String Dif = "DataInterchangeFormat";
        public static readonly String EnhancedMetafile = "EnhancedMetafile";
        public static readonly String FileDrop = "FileDrop";
        public static readonly String Html = "HTML Format";
        public static readonly String Locale = "Locale";
        public static readonly String MetafilePict = "MetaFilePict";
        public static readonly String OemText = "OEMText";
        public static readonly String Palette = "Palette";
        public static readonly String PenData = "PenData";
        public static readonly String Riff = "RiffAudio";
        public static readonly String Rtf = "Rich Text Format";
        public static readonly String Serializable = 
"WindowsForms10PersistentObject";
        public static readonly String StringFormat = "System.String";
        public static readonly String SymbolicLink = "SymbolicLink";
        public static readonly String Text = "Text";
        public static readonly String Tiff = "TaggedImageFileFormat";
        public static readonly String UnicodeText = "UnicodeText";
        public static readonly String WaveAudio = "WaveAudio";

        private static ArrayList formats;

        [TODO]
        static DataFormats()
        {
                // TODO: On windows, load extra formats from the registry

                formats = new ArrayList();

                // Numbers taken from MinGW's winuser.h
                formats.Add(new Format(Text, 1));
                formats.Add(new Format(Bitmap, 2));
                formats.Add(new Format(MetafilePict, 3));
                formats.Add(new Format(SymbolicLink, 4));
                formats.Add(new Format(Dif, 5));
                formats.Add(new Format(Tiff, 6));
                formats.Add(new Format(OemText, 7));
                formats.Add(new Format(Dib, 8));
                formats.Add(new Format(Palette, 9));
                formats.Add(new Format(PenData, 10));
                formats.Add(new Format(Riff, 11));
                formats.Add(new Format(WaveAudio, 12));
                formats.Add(new Format(UnicodeText, 13));
                formats.Add(new Format(EnhancedMetafile, 14));
                formats.Add(new Format(FileDrop, 15));
                formats.Add(new Format(Locale, 16));

                // TODO: These values are not predefined, so they need
                //       to be registered with the system, and the id
                //       values obtained upon registering them. Faked
                //       id values are used for now.
                formats.Add(new Format(StringFormat, 1001));
                formats.Add(new Format(CommaSeparatedValue, 1002));
                formats.Add(new Format(Html, 1003));
                formats.Add(new Format(Rtf, 1004));
                formats.Add(new Format(Serializable, 1005));
        }

        private static int GetNextID()
        {
                int maxid = 0;

                foreach (Format f in formats)
                {
                        if (f.Id > maxid)
                        {
                                maxid = f.Id + 1;
                        }
                }

                return maxid;
        }

        [TODO]
        public static Format GetFormat(int id)
        {
                // TODO: On Windows, the registry should
                //       be watched for new formats.
                foreach (Format f in formats)
                {
                        if (f.Id == id)
                        {
                                return f;
                        }
                }
                return new Format("Format" + id.ToString(), id);
        }

        [TODO]
        public static Format GetFormat(String name)
        {
                // TODO: Add the format to the registry.
                //       The registry should also be
                //       watched for new formats.
                foreach (Format f in formats)
                {
                        if (f.Name.Equals(name))
                        {
                                return f;
                        }
                }
                Format f = new Format(name, GetNextID());
                formats.Add(f);

                return f;
        }











        public class Format
        {
                private String name;
                private int id;

                public Format(String name, int id) : base()
                {
                        this.id = id;
                        this.name = name;
                }

                public int Id
                {
                        get { return id; }
                }

                public String Name
                {
                        get { return name; }
                }
        }; // class Format

}; // class DataFormats

}; // namespace System.Windows.Forms

Index: StatusBar.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/StatusBar.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** StatusBar.cs        28 Jul 2003 18:38:04 -0000      1.2
--- StatusBar.cs        1 Aug 2003 17:53:07 -0000       1.3
***************
*** 31,42 ****
  namespace System.Windows.Forms
  {
-       //[Serializable]
-       //public delegate void StatusBarDrawItemEventHandler(object sender,
-       //StatusBarDrawItemEventArgs sbdevent);
- 
-       //[Serializable]
-       //public delegate void StatusBarPanelClickEventHandler(object sender,
-       //StatusBarPanelClickEventArgs e);
- 
        public class StatusBar : Control
        {
--- 31,34 ----
***************
*** 74,79 ****
                protected override void OnPaint(PaintEventArgs e)
                {
-                       //ControlPaint.DrawBorder3D(e.Graphics, 0, 0, Width, 
Height, Border3DStyle.SunkenInner, Border3DSide.Top);
-                       
                        if (showPanels == false)
                        {
--- 66,69 ----
***************
*** 84,107 ****
                                int left = 0;
                                Border3DStyle style = Border3DStyle.Sunken;
! 
!                               for (int i=0;i<panels.Count;i++)
                                {
!                                       switch (panels[i].BorderStyle)
                                        {
!                                               case 
StatusBarPanelBorderStyle.None:
!                                                       style = 
Border3DStyle.Flat;
!                                                       break;
!                                               case 
StatusBarPanelBorderStyle.Raised:
!                                                       style = 
Border3DStyle.Raised;
!                                                       break;
!                                               case 
StatusBarPanelBorderStyle.Sunken:
!                                                       style = 
Border3DStyle.SunkenOuter;
!                                                       break;
                                        }
-                                       ControlPaint.DrawBorder3D(e.Graphics, 
left, 0, panels[i].Width, Height, style, Border3DSide.All);
-                                       DrawSimpleText(e, left, 0, 
panels[i].Width, Height,  panels[i].Text);
-                                       left += panels[i].Width +2;
                                }
-                               
                        }
  
--- 74,133 ----
                                int left = 0;
                                Border3DStyle style = Border3DStyle.Sunken;
!                               if (panels.Count <1)
                                {
!                                       int panelWidth;
!                                       if (sizingGrip == true)
!                                       {
!                                               panelWidth = Width - 16;
!                                       }
!                                       else
                                        {
!                                               panelWidth = Width;
!                                       }
!                                       ControlPaint.DrawBorder3D(e.Graphics, 
0, 2, panelWidth, Height - 2, Border3DStyle.SunkenOuter, Border3DSide.All);
!                               }
!                               else
!                               {
!                                       for (int i=0;i<panels.Count;i++)
!                                       {
!                                               switch (panels[i].BorderStyle)
!                                               {
!                                                       case 
StatusBarPanelBorderStyle.None:
!                                                               style = 
Border3DStyle.Flat;
!                                                               break;
!                                                       case 
StatusBarPanelBorderStyle.Raised:
!                                                               style = 
Border3DStyle.Raised;
!                                                               break;
!                                                       case 
StatusBarPanelBorderStyle.Sunken:
!                                                               style = 
Border3DStyle.SunkenOuter;
!                                                               break;
!                                               }
!                                               
ControlPaint.DrawBorder3D(e.Graphics, left, 4, panels[i].Width, Height -4, 
style, Border3DSide.All);
!                                               if (panels[i].Style == 
StatusBarPanelStyle.Text)
!                                               {
!                                                       StringAlignment align;
!                                                       switch 
(panels[i].Alignment)
!                                                       {
!                                                               case 
HorizontalAlignment.Center:
!                                                                       align = 
StringAlignment.Center;
!                                                                       break;
!                                                               case 
HorizontalAlignment.Left:
!                                                                       align = 
StringAlignment.Near;
!                                                                       break;
!                                                               case 
HorizontalAlignment.Right:
!                                                                       align = 
StringAlignment.Far;
!                                                                       break;
!                                                       }
!                                                       DrawSimpleText(e, left, 
4, panels[i].Width, Height,  panels[i].Text, align);
!                                               }
!                                               else
!                                               {
!                                                       // Owner drawn
!                                                       
StatusBarDrawItemEventArgs args = new StatusBarDrawItemEventArgs(e.Graphics, 
this.Font, new Rectangle(0, 0, panels[i].Width, Height), i, DrawItemState.None, 
panels[i]);
!                                                       OnDrawItem(args);
!                                               }
!                                               left += panels[i].Width +2;
                                        }
                                }
                        }
  
***************
*** 115,124 ****
                private void DrawSimpleText(PaintEventArgs e, int left, int 
top, int right, int bottom, string text)
                {
!                       // Draw the text within the label.
                        Font font = Font;
                        RectangleF layout = 
(RectangleF)Rectangle.FromLTRB(left, top, right, bottom);
  
                        StringFormat format = new StringFormat();
!                       format.Alignment = StringAlignment.Near;
                        format.LineAlignment = StringAlignment.Center;
  
--- 141,155 ----
                private void DrawSimpleText(PaintEventArgs e, int left, int 
top, int right, int bottom, string text)
                {
!                       DrawSimpleText(e, left, top, right, bottom, text, 
StringAlignment.Near);
!               }
! 
!               private void DrawSimpleText(PaintEventArgs e, int left, int 
top, int right, int bottom, string text, StringAlignment align)
!               {
!                       // Draw the text within the statusbar.
                        Font font = Font;
                        RectangleF layout = 
(RectangleF)Rectangle.FromLTRB(left, top, right, bottom);
  
                        StringFormat format = new StringFormat();
!                       format.Alignment = align;
                        format.LineAlignment = StringAlignment.Center;
  
***************
*** 133,137 ****
                                else
                                {
!                                       
ControlPaint.DrawStringDisabled(e.Graphics, text, font, BackColor, layout, 
format);
                                }
                        }
--- 164,170 ----
                                else
                                {
!                                       Brush brush = new SolidBrush(ForeColor);
!                                       e.Graphics.DrawString(text, font, 
brush, layout, format);
!                                       brush.Dispose();
                                }
                        }
***************
*** 162,170 ****
                }
  
!               
//[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
                public StatusBarPanelCollection Panels 
                {
                        get { return panels; }
-                       //set { statusBarPanelCollection = value; }
                }
  
--- 195,202 ----
                }
  
!               
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
                public StatusBarPanelCollection Panels 
                {
                        get { return panels; }
                }
  
***************
*** 242,245 ****
--- 274,294 ----
                }
  
+               protected override void OnMouseUp(MouseEventArgs e)
+               {
+                       StatusBarPanel panel;
+                       int left = 0;
+ 
+                       for (int i=0;i < panels.Count;i++)
+                       {
+                               if (e.X >= left && e.X < left + panels[i].Width)
+                               {
+                                       StatusBarPanelClickEventArgs args = new 
StatusBarPanelClickEventArgs(panels[i], e.Button, e.Clicks, e.X, e.Y);
+                                       OnPanelClick(args);
+                               }
+                               left += panels[i].Width + 2;
+                       }
+                       base.OnMouseUp(e);
+               }
+ 
                protected override void OnMouseDown(MouseEventArgs e)
                {
***************
*** 269,287 ****
                #endif // !CONFIG_COMPACT_FORMS
  
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
                public class StatusBarPanelCollection : IList, ICollection, 
IEnumerable 
!               {
                        private StatusBar owner;
                        private ArrayList list;
--- 318,323 ----
                #endif // !CONFIG_COMPACT_FORMS
  
                public class StatusBarPanelCollection : IList, ICollection, 
IEnumerable 
!               {       
                        private StatusBar owner;
                        private ArrayList list;
***************
*** 430,457 ****
                }
        }
-       /*
-       public class StatusBarDrawItemEventArgs : DrawItemEventArgs
-       {
-               private StatusBarPanel panel;
- 
-               public StatusBarDrawItemEventArgs(Graphics g, Font font, 
Rectangle r, int itemId, DrawItemState itemState, StatusBarPanel panel) : 
base(g, font, r, itemId, itemState)
-               {
-                       this.panel = panel;
-               }
-               public StatusBarDrawItemEventArgs(Graphics g, Font font, 
Rectangle r, int itemId, DrawItemState itemState, StatusBarPanel panel, Color 
foreColor, Color backColor) : base(g, font, r, itemId, itemState, foreColor, 
backColor)
-               {
-                       this.panel = panel;
-               }
- 
-       }
- 
-       public class StatusBarPanelClickEventArgs : MouseEventArgs
-       {
-               private StatusBarPanel panel;
- 
-               public StatusBarPanelClickEventArgs(StatusBarPanel 
statusBarPanel, MouseButtons button, int clicks, int x, int y) : base(button, 
clicks, x, y, 0)
-               {
-                       panel = statusBarPanel;
-               }
-       }*/
  }
--- 466,468 ----





reply via email to

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