Author: rolf
Date: 2007-01-25 07:41:38 -0500 (Thu, 25 Jan 2007)
New Revision: 71663

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBox.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs
   
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
Log:
2007-01-25  Rolf Bjarne Kvinge  <[EMAIL PROTECTED]>

        * ComboBox.cs: Implemented FlatStyle and DropDownHeight, and added
        a few other missing 2.0 properties.
        * Theme.cs: Added DrawFlatStyleComboBox.
        * ThemeWin32Classic.cs: Implemented DrawFlatStyleComboBox.



Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-01-25 12:41:01 UTC (rev 71662)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-01-25 12:41:38 UTC (rev 71663)
@@ -1,3 +1,10 @@
+2007-01-25  Rolf Bjarne Kvinge  <[EMAIL PROTECTED]>
+
+       * ComboBox.cs: Implemented FlatStyle and DropDownHeight, and added
+       a few other missing 2.0 properties.
+       * Theme.cs: Added DrawFlatStyleComboBox.
+       * ThemeWin32Classic.cs: Implemented DrawFlatStyleComboBox.
+
 2007-01-24  Chris Toshok  <[EMAIL PROTECTED]>
 
        * XplatUIX11.cs: fix the wake_waiting logic - we always clear the

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBox.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBox.cs      
2007-01-25 12:41:01 UTC (rev 71662)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBox.cs      
2007-01-25 12:41:38 UTC (rev 71663)
@@ -74,6 +74,8 @@
                private AutoCompleteStringCollection 
auto_complete_custom_source = null;
                private AutoCompleteMode auto_complete_mode = 
AutoCompleteMode.None;
                private AutoCompleteSource auto_complete_source = 
AutoCompleteSource.None;
+               private int drop_down_height;
+               private FlatStyle flat_style;
 #endif
 
                [ComVisible(true)]
@@ -99,6 +101,11 @@
                        BackColor = ThemeEngine.Current.ColorWindow;
                        border_style = BorderStyle.None;
 
+#if NET_2_0
+                       drop_down_height = 106;
+                       flat_style = FlatStyle.Standard;
+#endif
+
                        /* Events */
                        MouseDown += new MouseEventHandler (OnMouseDownCB);
                        MouseUp += new MouseEventHandler (OnMouseUpCB);
@@ -251,10 +258,28 @@
                        }
                }
 
+#if NET_2_0
+               [Browsable (false)]
+               [EditorBrowsable (EditorBrowsableState.Never)]
+               public override ImageLayout BackgroundImageLayout {
+                       get { return base.BackgroundImageLayout; }
+                       set { base.BackgroundImageLayout = value; }
+               }
+#endif
+
                protected override CreateParams CreateParams {
                        get { return base.CreateParams;}
                }
 
+#if NET_2_0
+               [DefaultValue ((string)null)]
+               [AttributeProvider (typeof (IListSource))]
+               [RefreshProperties (RefreshProperties.Repaint)]
+               public object DataSource {
+                       get { return base.DataSource; }
+                       set { base.DataSource = value; }
+               }
+#endif
                protected override Size DefaultSize {
                        get { return new Size (121, 21); }
                }
@@ -280,6 +305,24 @@
                        }
                }
 
+#if NET_2_0
+               [Browsable (true)]
+               [DefaultValue (106)]
+               [EditorBrowsable (EditorBrowsableState.Always)]
+               public int DropDownHeight {
+                       get {
+                               return drop_down_height;
+                       }
+                       set {
+                               if (value < 1)
+                                       throw new ArgumentOutOfRangeException 
("DropDownHeight", "DropDownHeight must be greater than 0.");
+                                       
+                               drop_down_height = value;
+                               IntegralHeight = false;
+                       }
+               }
+#endif
+
                [DefaultValue (ComboBoxStyle.DropDown)]
                [RefreshProperties(RefreshProperties.Repaint)]
                public ComboBoxStyle DropDownStyle {
@@ -391,6 +434,24 @@
                        }
                }               
 
+#if NET_2_0
+               [DefaultValue (FlatStyle.Standard)]
+               [Localizable (true)]
+               public FlatStyle FlatStyle {
+                       get { return flat_style; }
+                       set {
+                               if (!Enum.IsDefined (typeof (FlatStyle), value))
+                                       throw new InvalidEnumArgumentException 
("FlatStyle", (int) value, typeof (FlatStyle));
+                               
+                               flat_style = value;
+                               LayoutComboBox ();
+                               Invalidate ();
+                       }
+               }
+ 
+
+#endif
+
                public override bool Focused {
                        get { return base.Focused; }
                }
@@ -469,6 +530,14 @@
                        }
                }
 
+#if NET_2_0
+               public override Size MaximumSize {
+                       get { return base.MaximumSize; }
+                       set {
+                               base.MaximumSize = new Size (value.Width, 0);
+                       }
+               }
+#endif
                [DefaultValue (0)]
                [Localizable (true)]
                public int MaxLength {
@@ -490,7 +559,24 @@
                        }
                }
 
+#if NET_2_0
+               public override Size MinimumSize {
+                       get { return base.MinimumSize; }
+                       set {
+                               base.MinimumSize = new Size (value.Width, 0);
+                       }
+               }
+               
                [DesignerSerializationVisibility 
(DesignerSerializationVisibility.Hidden)]
+               [EditorBrowsable (EditorBrowsableState.Never)]
+               [Browsable (false)]
+               public Padding Padding  {
+                       get { return base.Padding; }
+                       set { base.Padding = value; }
+               }
+#endif
+
+               [DesignerSerializationVisibility 
(DesignerSerializationVisibility.Hidden)]
                [Browsable (false)]             
                public int PreferredHeight {
                        get {
@@ -1008,11 +1094,19 @@
 
                protected override void OnMouseLeave (EventArgs e)
                {
+#if NET_2_0
+                       if (flat_style == FlatStyle.Popup)
+                               Invalidate ();
+#endif
                        base.OnMouseLeave (e);
                }
                
                protected override void OnMouseEnter (EventArgs e)
                {
+#if NET_2_0
+                       if (flat_style == FlatStyle.Popup)
+                               Invalidate ();
+#endif
                        base.OnMouseEnter (e);
                }
 #endif
@@ -1149,6 +1243,13 @@
                                button_area.Y = text_area.Y + border;
                                button_area.Width = button_width;
                                button_area.Height = text_area.Height - 2 * 
border;
+#if NET_2_0
+                               if (flat_style == FlatStyle.Popup || flat_style 
== FlatStyle.Flat) {
+                                       button_area.Inflate (1, 1);
+                                       button_area.X += 2;
+                                       button_area.Width -= 2;
+                               }
+#endif
                        }
 
                        if (button_area != prev_button_area) {
@@ -1180,11 +1281,25 @@
                internal void Draw (Rectangle clip, Graphics dc)
                {                               
                        Theme theme = ThemeEngine.Current;
+                       FlatStyle style = FlatStyle.Standard;
+                       bool is_flat = false;
 
+#if NET_2_0
+                       style = this.FlatStyle;
+                       is_flat = style == FlatStyle.Flat || style == 
FlatStyle.Popup;
+#endif
+
                        if (DropDownStyle == ComboBoxStyle.Simple)
                                dc.FillRectangle (theme.ResPool.GetSolidBrush 
(Parent.BackColor), ClientRectangle);
 
-                       if (clip.IntersectsWith (text_area))
+                       if (style == FlatStyle.Popup && (is_entered || 
Focused)) {
+                               Rectangle area = text_area;
+                               area.Height -= 1;
+                               area.Width -= 1;
+                               dc.DrawRectangle (theme.ResPool.GetPen 
(SystemColors.ControlDark), area);
+                               dc.DrawLine (theme.ResPool.GetPen 
(SystemColors.ControlDark), button_area.X - 1, button_area.Top, button_area.X - 
1, button_area.Bottom);
+                       }
+                       if (!is_flat && clip.IntersectsWith (text_area))
                                ControlPaint.DrawBorder3D (dc, text_area, 
Border3DStyle.Sunken);
 
                        int border = theme.Border3DSize.Width;
@@ -1213,7 +1328,11 @@
                                if (!is_enabled)
                                        button_state = ButtonState.Inactive;
                                
-                               theme.CPDrawComboButton (dc, button_area, 
button_state);
+                               if (is_flat) {
+                                       theme.DrawFlatStyleComboButton (dc, 
button_area, button_state);
+                               } else {
+                                       theme.CPDrawComboButton (dc, 
button_area, button_state);
+                               }
                        }                       
                }
 
@@ -1813,7 +1932,11 @@
                                                }
                                                
                                        } else  {
+#if NET_2_0
+                                               height = owner.DropDownHeight;
+#else          
                                                height = owner.ItemHeight * 
count;
+#endif
                                        }
                                }
                                

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs 
2007-01-25 12:41:01 UTC (rev 71662)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs 
2007-01-25 12:41:38 UTC (rev 71663)
@@ -709,6 +709,7 @@
                #region ComboBox
                // Drawing
                public abstract void DrawComboBoxItem (ComboBox ctrl, 
DrawItemEventArgs e);
+               public abstract void DrawFlatStyleComboButton (Graphics 
graphics, Rectangle rectangle, ButtonState state);
                #endregion      // ComboBox
 
                #region Control

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
===================================================================
--- 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs 
    2007-01-25 12:41:01 UTC (rev 71662)
+++ 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs 
    2007-01-25 12:41:38 UTC (rev 71663)
@@ -825,6 +825,58 @@
 
                        string_format.Dispose ();
                }
+               
+               public override void DrawFlatStyleComboButton (Graphics 
graphics, Rectangle rectangle, ButtonState state)
+               {
+                       Point[]                 arrow = new Point[3];
+                       Point                           P1;
+                       Point                           P2;
+                       Point                           P3;
+                       int                             centerX;
+                       int                             centerY;
+                       int                             shiftX;
+                       int                             shiftY;
+                       Rectangle               rect;
+
+                       rect=new Rectangle(rectangle.X+rectangle.Width/4, 
rectangle.Y+rectangle.Height/4, rectangle.Width/2, rectangle.Height/2);
+                       centerX=rect.Left+rect.Width/2;
+                       centerY=rect.Top+rect.Height/2;
+                       shiftX=Math.Max(1, rect.Width/8);
+                       shiftY=Math.Max(1, rect.Height/8);
+
+                       if ((state & ButtonState.Pushed)!=0) {
+                               shiftX++;
+                               shiftY++;
+                       }
+
+                       rect.Y-=shiftY;
+                       centerY-=shiftY;
+                       P1=new Point(rect.Left + 1, centerY);
+                       P2=new Point(rect.Right - 1, centerY);
+                       P3=new Point(centerX, rect.Bottom - 1);
+
+                       arrow[0]=P1;
+                       arrow[1]=P2;
+                       arrow[2]=P3;
+                       
+                       /* Draw the arrow */
+                       if ((state & ButtonState.Inactive)!=0) {
+                               /* Move away from the shadow */
+                               arrow[0].X += 1;        arrow[0].Y += 1;
+                               arrow[1].X += 1;        arrow[1].Y += 1;
+                               arrow[2].X += 1;        arrow[2].Y += 1;
+                               
+                               
graphics.FillPolygon(SystemBrushes.ControlLightLight, arrow, FillMode.Winding);
+
+                               arrow[0]=P1;
+                               arrow[1]=P2;
+                               arrow[2]=P3;
+
+                               graphics.FillPolygon(SystemBrushes.ControlDark, 
arrow, FillMode.Winding);
+                       } else {
+                               graphics.FillPolygon(SystemBrushes.ControlText, 
arrow, FillMode.Winding);
+                       }               
+               }
                #endregion ComboBox
                
                #region Datagrid
@@ -3264,6 +3316,7 @@
                                DrawInnerFocusRectangle( dc, text_rectangle, 
radio_button.BackColor );
                }
                
+               
                // renders a radio button with the Flat and Popup FlatStyle
                protected virtual void DrawFlatStyleRadioButton (Graphics 
graphics, Rectangle rectangle, RadioButton radio_button)
                {

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to