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


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/System.Windows.Forms StatusBar.cs,NONE,1.1 StatusBarPanelCollection.cs,NONE,1.1 StatusBarPanel.cs,1.1,1.2
Date: Fri, 20 Jun 2003 20:02:48 -0400

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

Modified Files:
        StatusBarPanel.cs 
Added Files:
        StatusBar.cs StatusBarPanelCollection.cs 
Log Message:


Begin the implementation of the StatusBar class.


--- NEW FILE ---
/*
 * Control.cs - Implementation of the
 *                      "System.Windows.Forms.StatusBar" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * Contributions from Simon Guindon
 *
 * 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
 */

using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Text;
using System.Windows.Forms;

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
        {
                public event StatusBarDrawItemEventHandler DrawItem;
                public event StatusBarPanelClickEventHandler PanelClick;
                
                private StatusBarPanelCollection panels;
                private bool showPanels;
                private bool sizingGrip;

                public StatusBar()
                {
                        Name = "StatusBar";
                        Height = 22;
                        Dock = DockStyle.Bottom;
                        showPanels = false;
                        sizingGrip = true;
                        panels = new StatusBarPanelCollection(this);
                }

                ~StatusBar()
                {
                        Dispose(false);
                }

                /// Clean up any resources being used.
                protected override void Dispose(bool disposing)
                {
                        if(disposing)
                        {
                        }
                        base.Dispose(disposing);
                }

                protected override void OnPaint(PaintEventArgs e)
                {
                        //ControlPaint.DrawBorder3D(e.Graphics, 0, 0, Width, 
Height, Border3DStyle.SunkenInner, Border3DSide.Top);
                        
                        if (showPanels == false)
                        {
                                DrawSimpleText(e, 0, 0, Width, Height, Text);
                        }
                        else
                        {
                                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;
                                }
                                
                        }

                        if (sizingGrip == true)
                        {
                                ControlPaint.DrawSizeGrip(e.Graphics, 
BackColor, Width - 15, Height - 13, 15, 13);
                        }
                        base.OnPaint(e);
                }

                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;

                        if(text != null && text != String.Empty)
                        {
                                if(Enabled)
                                {
                                        Brush brush = new SolidBrush(ForeColor);
                                        e.Graphics.DrawString(text, font, 
brush, layout, format);
                                        brush.Dispose();
                                }
                                else
                                {
                                        
ControlPaint.DrawStringDisabled(e.Graphics, text, font, BackColor, layout, 
format);
                                }
                        }
                }

                public override Color BackColor
                {
                        get { return base.BackColor; }
                        set { base.BackColor = value; }
                }

                public override Image BackgroundImage
                {
                        get { return base.BackgroundImage; }
                        set { base.BackgroundImage = value; }
                }

                public override DockStyle Dock 
                {
                        get { return base.Dock; }
                        set { base.Dock = value; }
                }

                public override Font Font 
                {
                        get { return base.Font; }
                        set { base.Font = value; }
                }

                
//[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
                public StatusBarPanelCollection Panels 
                {
                        get { return panels; }
                        //set { statusBarPanelCollection = value; }
                }

                public bool ShowPanels 
                {
                        get { return showPanels; }
                        set 
                        {
                                showPanels = value; 
                                Invalidate();
                        }
                }

                public bool SizingGrip 
                {
                        get { return sizingGrip; }
                        set 
                        { 
                                sizingGrip = value;
                                Invalidate();
                        }
                }

                public override string Text 
                {
                        get { return base.Text; }
                        set 
                        {
                                base.Text = value;
                                Invalidate();
                        }
                }

                protected override CreateParams CreateParams 
                {
                        get { return base.CreateParams; }
                }

                protected override ImeMode DefaultImeMode 
                {
                        get { return base.DefaultImeMode; }
                }

                protected override Size DefaultSize 
                {
                        get { return base.DefaultSize; }
                }

                protected override void CreateHandle()
                {
                        base.CreateHandle();
                }

                protected virtual void OnDrawItem(StatusBarDrawItemEventArgs e)
                {
                        if (DrawItem != null)
                        {
                                DrawItem(this, e);
                        }
                }

                protected override void OnHandleCreated(EventArgs e)
                {
                        base.OnHandleCreated(e);
                }

                protected override void OnHandleDestroyed(EventArgs e)
                {
                        base.OnHandleDestroyed(e);
                }

                protected override void OnLayout(LayoutEventArgs e)
                {
                        base.OnLayout(e);
                }

                protected override void OnMouseDown(MouseEventArgs e)
                {
                        base.OnMouseDown(e);
                }

                protected virtual void 
OnPanelClick(StatusBarPanelClickEventArgs e)
                {
                        if (PanelClick != null)
                        {
                                PanelClick(this, e);
                        }
                }

                protected override void OnResize(EventArgs e)
                {
                        Invalidate();
                        base.OnResize(e);
                }
                
                #if !CONFIG_COMPACT_FORMS
                // Process a message.
                protected override void WndProc(ref Message m)
                {
                        base.WndProc(ref m);
                }
                #endif // !CONFIG_COMPACT_FORMS
                
        }
        /*
        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;
                }
        }*/
}

--- NEW FILE ---
/*
 * Control.cs - Implementation of the
 *                      "System.Windows.Forms.StatusBarPanelCollection" 
 *                      class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * Contributions from Simon Guindon
 *
 * 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
 */

using System;
using System.Collections;

namespace System.Windows.Forms
{
        public class StatusBarPanelCollection : IList, ICollection, IEnumerable 
        {
                private StatusBar owner;
                private ArrayList list;

                public StatusBarPanelCollection(StatusBar owner)
                {
                        this.owner = owner;
                        list = new ArrayList();
                }

                // Implement the ICollection interface.
                void ICollection.CopyTo(Array array, int index)
                {
                        List.CopyTo(array, index);
                }

                public virtual int Count
                {
                        get { return List.Count; }
                }
                
                bool ICollection.IsSynchronized
                {
                        get { return false; }
                }

                Object ICollection.SyncRoot
                {
                        get { return this; }
                }

                // Implement the IEnumerable interface.
                public IEnumerator GetEnumerator()
                {
                        return List.GetEnumerator();
                }

                // Determine if the collection is read-only.
                public bool IsReadOnly
                {
                        get { return false; }
                }

                bool IList.IsFixedSize
                {
                        get { return false; }
                }

                // Get the array list that underlies this collection
                Object IList.this[int index]
                {
                        get { return List[index]; }
                        set { List[index] = value; }
                }

                public StatusBarPanel this[int index]
                {
                        get { return (StatusBarPanel)List[index]; }
                        set { List[index] = value; }
                }
        
                        protected virtual ArrayList List
                {
                        get { return list; }
                }
                
                int IList.Add(Object value)
                {
                        int result;
                        result =  List.Add(value);
                        owner.Invalidate();
                        return result;
                }

                public virtual int Add(StatusBarPanel value)
                {
                        return List.Add(value);
                }

                public virtual StatusBarPanel Add(string text)
                {
                        StatusBarPanel panel = new StatusBarPanel();
                        panel.Text = text;
                        List.Add(panel);
                        return panel;
                }

                public virtual void AddRange(StatusBarPanel[] panels)
                {
                        List.AddRange(panels);
                        owner.Invalidate();
                }

                public virtual void Clear()
                {
                        List.Clear();
                        owner.Invalidate();
                }

                bool IList.Contains(Object value)
                {
                        return List.Contains(value);
                }

                public bool Contains(StatusBarPanel panel)
                {
                        return List.Contains(panel);
                }

                int IList.IndexOf(Object value)
                {
                        return List.IndexOf(value);
                }

                public int IndexOf(StatusBarPanel panel)
                {
                        return List.IndexOf(panel);
                }

                void IList.Insert(int index, Object value)
                {
                        List.Insert(index, value);
                        owner.Invalidate();
                }

                public virtual void Insert(int index, StatusBarPanel value)
                {
                        List.Insert(index, value);
                }

                void IList.Remove(Object value)
                {
                        List.Remove(value);
                        owner.Invalidate();
                }

                public virtual void Remove(StatusBarPanel value)
                {
                        List.Remove(value);
                }

                void IList.RemoveAt(int index)
                {
                        List.RemoveAt(index);
                }
        }
}

Index: StatusBarPanel.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/StatusBarPanel.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** StatusBarPanel.cs   18 Jun 2003 09:46:49 -0000      1.1
--- StatusBarPanel.cs   21 Jun 2003 00:02:46 -0000      1.2
***************
*** 1,8 ****
  /*
!  * StatusBarPanel.cs - Implementation of the
!  *                    "System.Windows.Forms.StatusBarPanel" class.
   *
   * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
   *
   * 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
--- 1,10 ----
  /*
!  * Control.cs - Implementation of the
!  *                      "System.Windows.Forms.StatusBarPanel" class.
   *
   * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
   *
+  * Contributions from Simon Guindon
+  *
   * 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
***************
*** 20,31 ****
   */
  
  namespace System.Windows.Forms
  {
  
! public class StatusBarPanel
! {
!       // TODO
  
! }; // class StatusBarPanel
  
! }; // namespace System.Windows.Forms
--- 22,143 ----
   */
  
+ using System;
+ using System.Drawing;
+ using System.Windows.Forms;
+ using System.ComponentModel;
+ 
  namespace System.Windows.Forms
  {
+       public class StatusBarPanel : Component, ISupportInitialize
+       {
+               private HorizontalAlignment alignment;
+               private StatusBarPanelAutoSize autosize;
+               private StatusBarPanelBorderStyle borderStyle;
+               private Icon icon;
+               private int minWidth;
+               private StatusBar parent;
+               private StatusBarPanelStyle style;
+               private string text;
+               private string toolTipText;
+               private int width;
  
!               public StatusBarPanel()
!               {
!                       alignment = HorizontalAlignment.Left;
!                       autosize = StatusBarPanelAutoSize.None;
!                       borderStyle = StatusBarPanelBorderStyle.Sunken;
!                       minWidth = 10;
!                       style = StatusBarPanelStyle.Text;
!                       text = this.GetType().Name;
!                       toolTipText = string.Empty;
!                       width = 100;
!               }
! 
!               ~StatusBarPanel()
!               {
!                       Dispose(false);
!               }
! 
!               /// Clean up any resources being used.
!               protected override void Dispose( bool disposing )
!               {
!                       if( disposing )
!                       {
!                       }
!                       base.Dispose( disposing );
!               }
! 
!               public void BeginInit()
!               {
!               }
! 
!               public void EndInit()
!               {
!               }
! 
!               public HorizontalAlignment Alignment
!               {
!                       get { return alignment; }
!                       set { alignment = value; }
!               }
! 
!               public StatusBarPanelAutoSize AutoSize
!               {
!                       get { return autosize; }
!                       set { autosize = value; }
!               }
! 
!               public StatusBarPanelBorderStyle BorderStyle 
!               {
!                       get { return borderStyle; }
!                       set { borderStyle = value; }
!               }
! 
!               public Icon Icon 
!               {
!                       get { return icon; }
!                       set { icon = value; }
!               }
! 
!               public int MinWidth 
!               {
!                       get { return minWidth; }
!                       set { minWidth = value; }
!               }
! 
!               public StatusBar Parent 
!               {
!                       get { return parent; }
!               }
! 
!               public StatusBarPanelStyle Style 
!               {
!                       get { return style; }
!                       set { style = value; }
!               }
! 
!               public string Text
!               {
!                       get { return text; }
!                       set { text = value; }
!               }
! 
!               public string ToolTipText 
!               {
!                       get { return toolTipText; }
!                       set { toolTipText = value; }
!               }
! 
!               public int Width 
!               {
!                       get { return width; }
!                       set { width = value; }
!               }
  
!               public override string ToString()
!               {
!                       return text;
!               }
  
!       }
! }





reply via email to

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