Selaa lähdekoodia

Handle drawing picture boxes in the theme now. Draw picture box borders and obey sizing modes

svn path=/trunk/mcs/; revision=32761
Jackson Harper 21 vuotta sitten
vanhempi
sitoutus
e29d4e255c

+ 1 - 1
mcs/class/Managed.Windows.Forms/System.Windows.Forms/PictureBox.cs

@@ -208,7 +208,7 @@ namespace System.Windows.Forms {
 		private void Draw ()
 		{
 			if (redraw) {
-				DeviceContext.DrawImage (image, 0, 0, Width, Height);
+				ThemeEngine.Current.DrawPictureBox (DeviceContext, this);
 			}
 			redraw = false;
 		}

+ 6 - 2
mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs

@@ -23,9 +23,12 @@
 //	Jordi Mas i Hernandez, [email protected]
 //
 //
-// $Revision: 1.2 $
+// $Revision: 1.3 $
 // $Modtime: $
 // $Log: Theme.cs,v $
+// Revision 1.3  2004/08/24 16:16:46  jackson
+// Handle drawing picture boxes in the theme now. Draw picture box borders and obey sizing modes
+//
 // Revision 1.2  2004/08/20 00:12:51  jordi
 // fixes methods signature
 //
@@ -277,6 +280,7 @@ namespace System.Windows.Forms
 		public abstract void DrawStatusBarPanel (Graphics dc, Rectangle area, int index,
 			SolidBrush br_forecolor, StatusBarPanel panel);
 		
-
+		public abstract void DrawPictureBox (Graphics dc, PictureBox pb);
+		
 	}
 }

+ 34 - 1
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs

@@ -25,9 +25,12 @@
 //
 //
 //
-// $Revision: 1.26 $
+// $Revision: 1.27 $
 // $Modtime: $
 // $Log: ThemeWin32Classic.cs,v $
+// Revision 1.27  2004/08/24 16:16:46  jackson
+// Handle drawing picture boxes in the theme now. Draw picture box borders and obey sizing modes
+//
 // Revision 1.26  2004/08/21 01:52:08  ravindra
 // Improvments in mouse event handling in the ToolBar control.
 //
@@ -1635,6 +1638,36 @@ namespace System.Windows.Forms
 			dc.DrawString (text, panel.Parent.Font, br_forecolor, x, y, string_format);
 		}
 
+		public override void DrawPictureBox (Graphics dc, PictureBox pb)
+		{
+			Rectangle client = pb.ClientRectangle;
+			int x, y, width, height;
+
+			dc.FillRectangle (new SolidBrush (pb.BackColor), client);
+			DrawBorderStyle (dc, client, pb.BorderStyle);
+
+			x = y = 0;
+			switch (pb.SizeMode) {
+			case PictureBoxSizeMode.StretchImage:
+				width = client.Width;
+				height = client.Height;
+				break;
+			case PictureBoxSizeMode.CenterImage:
+				width = client.Width;
+				height = client.Height;
+				x = width / 2;
+				y = (height - pb.Image.Height) / 2;
+				break;
+			default:
+				// Normal, AutoSize
+				width = client.Width;
+				height = client.Height;
+				break;
+			}
+			dc.DrawImage (pb.Image, x, y, width, height);
+			
+		}
+
 		public  override void DrawOwnerDrawBackground (DrawItemEventArgs e)
 		{
 			if (e.State == DrawItemState.Selected) {