* Label.cs: fixes image drawing (image and imagelist)
authorJordi Mas i Hernandez <jordi@mono-cvs.ximian.com>
Mon, 21 Feb 2005 12:17:50 +0000 (12:17 -0000)
committerJordi Mas i Hernandez <jordi@mono-cvs.ximian.com>
Mon, 21 Feb 2005 12:17:50 +0000 (12:17 -0000)
* ThemeWin32Classic.cs: cache brushes

2005-02-19  Jordi Mas i Hernandez <jordi@ximian.com>

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

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/Label.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs

index c9e24b02e41a57a7508449201771200f39552e68..f73f6ebccb6b86e81a3383e32943d691efbeefdd 100644 (file)
@@ -1,3 +1,8 @@
+2005-02-19  Jordi Mas i Hernandez <jordi@ximian.com>
+
+       * Label.cs: fixes image drawing (image and imagelist)
+       * ThemeWin32Classic.cs: cache brushes
+       
 2005-02-19  Jordi Mas i Hernandez <jordi@ximian.com>
 
        * Form.cs: Move menu drawing code to Theme class
index 9ac87b027f9354d8bb26a2ce78d868a5ce3acb08..65187b2497230308d976d0f6127ffe4e486793cc 100644 (file)
@@ -17,7 +17,7 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
-// Copyright (c) 2004 Novell, Inc.
+// Copyright (c) 2004-2005 Novell, Inc.
 //
 // Authors:
 //     Jordi Mas i Hernandez, jordi@ximian.com
@@ -25,7 +25,7 @@
 //
 //
 
-// INCOMPLETE
+// COMPLETE
 
 using System.ComponentModel;
 using System.ComponentModel.Design;
@@ -108,8 +108,7 @@ namespace System.Windows.Forms
 
                        SetStyle (ControlStyles.ResizeRedraw, true);
                        SetStyle (ControlStyles.Selectable, false);
-
-                       Resize += new EventHandler (OnResizeLB);
+                       
                        HandleCreated += new EventHandler (OnHandleCreatedLB);
                }
 
@@ -201,7 +200,15 @@ namespace System.Windows.Forms
                [Localizable(true)]
                public Image Image {
                        get {
-                               return image;
+                               if (image != null) {
+                                       return image;
+                               }
+                               
+                               if (image_list != null && ImageIndex >= 0) {
+                                       return image_list.Images[ImageIndex];
+                               }
+                               
+                               return null;
                        }
                        set {
                                if (image == value)
@@ -235,11 +242,21 @@ namespace System.Windows.Forms
                [Localizable (true)]
                [TypeConverter (typeof (ImageIndexConverter))]
                public int ImageIndex {
-                       get { return image_index;}
+                       get { 
+                               if (ImageList == null) {
+                                       return -1;
+                               }
+                               
+                               if (image_index >= image_list.Images.Count) {
+                                       return image_list.Images.Count - 1;
+                               }
+                               
+                               return image_index;
+                       }
                        set {
 
-                               if (value < 0 || value>= image_list.Images.Count)
-                                       throw new ArgumentException();
+                               if (value < -1)
+                                       throw new ArgumentException ();
 
                                if (image_index == value)
                                        return;
@@ -259,8 +276,10 @@ namespace System.Windows.Forms
                        set {
                                if (image_list == value)
                                        return;
+                                       
+                               image_list = value;
 
-                               if (ImageList != null && image_index !=-1)
+                               if (image_list != null && image_index !=-1)
                                        Image = null;
 
                                Refresh ();
@@ -474,16 +493,13 @@ namespace System.Windows.Forms
                        Refresh ();
                }
 
-
                protected override void OnPaint (PaintEventArgs pevent)
                {
                        if (Width <= 0 || Height <=  0 || Visible == false)
                                return;
 
-                       Draw ();
-                       // TODO: Imagelist
+                       Draw ();                        
                        pevent.Graphics.DrawImage (ImageBuffer, 0, 0);
-
                }
 
                protected override void OnParentChanged (EventArgs e)
@@ -530,7 +546,7 @@ namespace System.Windows.Forms
 
                public override string ToString()
                {
-                       return base.ToString();
+                       return base.ToString () + "Text: " + Text;
                }
 
                protected override void WndProc(ref Message m)
@@ -590,8 +606,7 @@ namespace System.Windows.Forms
                internal void Draw ()
                {                       
                        ThemeEngine.Current.DrawLabel(DeviceContext, ClientRectangle, this);
-
-                       DrawImage (DeviceContext, Image, ClientRectangle, image_align);
+                       DrawImage (DeviceContext, Image, ClientRectangle, image_align);                 
                }
 
                private void OnHandleCreatedLB (Object o, EventArgs e)
@@ -600,13 +615,6 @@ namespace System.Windows.Forms
                                CalcAutoSize ();
                }
 
-               private void OnResizeLB (object o, EventArgs e)
-               {
-                       if (Width <= 0 || Height <= 0)
-                               return;
-               }
-
-
                private void SetUseMnemonic (bool use)
                {
                        if (use)
index bb82dc25d365f1d9a1623c9d413e7022f47888b5..ad4b2e2fadb5728847724569edc9caaf1f212aa0 100644 (file)
@@ -4584,19 +4584,13 @@ namespace System.Windows.Forms
 
 
                public  override void CPDrawStringDisabled (Graphics graphics, string s, Font font, Color color, RectangleF layoutRectangle,
-                       StringFormat format) {
-                       SolidBrush      brush;
-
-                       brush=new SolidBrush(ControlPaint.Light(color, 95));
+                       StringFormat format) {                  
 
                        layoutRectangle.Offset(1.0f, 1.0f);
-                       graphics.DrawString(s, font, brush, layoutRectangle, format);
-
-                       brush.Color=ControlPaint.Light(color, 50);
+                       graphics.DrawString(s, font, ResPool.GetSolidBrush (ControlPaint.Light(color, 95)), layoutRectangle, format);                   
                        layoutRectangle.Offset(-1.0f, -1.0f);
-                       graphics.DrawString(s, font, brush, layoutRectangle, format);
-
-                       brush.Dispose();
+                       graphics.DrawString(s, font, ResPool.GetSolidBrush (ControlPaint.Light(color, 50)), layoutRectangle, format);
+                       
                }
 
                private static void DrawBorderInternal(Graphics graphics, int startX, int startY, int endX, int endY,