Browse Source

2007-10-09 Jonathan Pobst <[email protected]>

	* LineTag.cs, RichTextBox.cs, TextBoxBase.cs, TextControl.cs: Refactor to
	store a Color structure and use the ResPool for back color instead of
	holding onto brushes.

svn path=/trunk/mcs/; revision=87224
Jonathan Pobst 18 years ago
parent
commit
455495da78

+ 6 - 0
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog

@@ -1,3 +1,9 @@
+2007-10-09  Jonathan Pobst  <[email protected]>
+
+	* LineTag.cs, RichTextBox.cs, TextBoxBase.cs, TextControl.cs: Refactor to
+	store a Color structure and use the ResPool for back color instead of
+	holding onto brushes.
+
 2007-10-09  Jonathan Pobst  <[email protected]>
 
 	* TextControl.cs: Fix how we calculate the end of the tag we are drawing.

+ 3 - 4
mcs/class/Managed.Windows.Forms/System.Windows.Forms/LineTag.cs

@@ -41,11 +41,10 @@ namespace System.Windows.Forms
 
 		// In 2.0 tags can have background colours.  I'm not going to #ifdef
 		// at this level though since I want to reduce code paths
-		internal SolidBrush	back_color;  
+		internal Color		back_color;  
 
 		// Payload; text
 		internal int		start;		// start, in chars; index into Line.text
-		internal bool		r_to_l;		// Which way is the font
 
 		// Drawing support
 		internal int		height;		// Height in pixels of the text this tag describes
@@ -244,7 +243,7 @@ namespace System.Windows.Forms
 		/// Removes any previous tags overlapping the same area; 
 		/// returns true if lineheight has changed</summary>
 		/// <param name="start">1-based character position on line</param>
-		internal static bool FormatText (Line line, int start, int length, Font font, SolidBrush color, SolidBrush back_color, FormatSpecified specified)
+		internal static bool FormatText (Line line, int start, int length, Font font, SolidBrush color, Color back_color, FormatSpecified specified)
 		{
 			LineTag tag;
 			LineTag start_tag;
@@ -329,7 +328,7 @@ namespace System.Windows.Forms
 			return true;
 		}
 
-		private static void SetFormat (LineTag tag, Font font, SolidBrush color, SolidBrush back_color, FormatSpecified specified)
+		private static void SetFormat (LineTag tag, Font font, SolidBrush color, Color back_color, FormatSpecified specified)
 		{
 			if ((FormatSpecified.Font & specified) == FormatSpecified.Font)
 				tag.font = font;

+ 4 - 4
mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs

@@ -254,7 +254,7 @@ namespace System.Windows.Forms {
 					// Font changes always set the whole doc to that font
 					start = document.GetLine(1);
 					end = document.GetLine(document.Lines);
-					document.FormatText(start, 1, end, end.text.Length + 1, base.Font, null, null, FormatSpecified.Font);
+					document.FormatText(start, 1, end, end.text.Length + 1, base.Font, null, Color.Empty, FormatSpecified.Font);
 				}
 			}
 		}
@@ -560,7 +560,7 @@ namespace System.Windows.Forms {
 
 				document.FormatText (document.selection_start.line, document.selection_start.pos + 1,
 						document.selection_end.line, document.selection_end.pos + 1, null,
-						new SolidBrush (value),	null, FormatSpecified.Color);
+						new SolidBrush (value),	Color.Empty, FormatSpecified.Color);
 
 				document.CharIndexToLineTag(sel_start, out document.selection_start.line, out document.selection_start.tag, out document.selection_start.pos);
 				document.CharIndexToLineTag(sel_end, out document.selection_end.line, out document.selection_end.tag, out document.selection_end.pos);
@@ -606,7 +606,7 @@ namespace System.Windows.Forms {
 
 				document.FormatText (document.selection_start.line, document.selection_start.pos + 1,
 						document.selection_end.line, document.selection_end.pos + 1, value,
-						null, null, FormatSpecified.Font);
+						null, Color.Empty, FormatSpecified.Font);
 
 				document.CharIndexToLineTag(sel_start, out document.selection_start.line, out document.selection_start.tag, out document.selection_start.pos);
 				document.CharIndexToLineTag(sel_end, out document.selection_end.line, out document.selection_end.tag, out document.selection_end.pos);
@@ -1650,7 +1650,7 @@ namespace System.Windows.Forms {
 				if (rtf_line.Length > 0) {
 					document.InsertString(line, rtf_cursor_x, rtf_line.ToString());
 					document.FormatText (line, rtf_cursor_x + 1, line, rtf_cursor_x + 1 + length,
-							font, rtf_color, null,
+							font, rtf_color, Color.Empty,
 							FormatSpecified.Font | FormatSpecified.Color);
 				}
 				if (newline) {

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

@@ -2045,7 +2045,7 @@ namespace System.Windows.Forms {
 					line = document.GetLine(i);
 					LineTag.FormatText(line, 1, line.text.Length, Font,
 							ThemeEngine.Current.ResPool.GetSolidBrush(ForeColor),
-							null, FormatSpecified.Font | FormatSpecified.Color);
+							Color.Empty, FormatSpecified.Font | FormatSpecified.Color);
 				}
 				document.ResumeRecalc (false);
 

+ 3 - 3
mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs

@@ -1466,8 +1466,8 @@ namespace System.Windows.Forms {
 						continue;
 					}
 
-					if (tag.back_color != null) {
-						g.FillRectangle (tag.back_color, tag.X + line.X - viewport_x,
+					if (tag.back_color != Color.Empty) {
+						g.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (tag.back_color), tag.X + line.X - viewport_x,
 								line_y + tag.shift, tag.Width, line.height);
 					}
 
@@ -3309,7 +3309,7 @@ namespace System.Windows.Forms {
 		/// <param name="start_pos">1-based start position on start_line</param>
 		/// <param name="end_pos">1-based end position on end_line </param>
 		internal void FormatText (Line start_line, int start_pos, Line end_line, int end_pos, Font font,
-				SolidBrush color, SolidBrush back_color, FormatSpecified specified)
+				SolidBrush color, Color back_color, FormatSpecified specified)
 		{
 			Line    l;