Author: jpobst
Date: 2007-10-09 18:06:49 -0400 (Tue, 09 Oct 2007)
New Revision: 87231
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Line.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LineTag.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxTextRenderer.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs
Log:
2007-10-09 Jonathan Pobst <[EMAIL PROTECTED]>
* TextBoxTextRenderer.cs: Draw takes a Color now instead of a Brush, as
the Win32 backend uses Color.
* Line.cs, LineTag.cs, RichTextBox.cs, TextBoxBase.cs, TextControl.cs:
Refactor to store a Color instead of a Brush for Color.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-10-09 22:01:03 UTC (rev 87230)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-10-09 22:06:49 UTC (rev 87231)
@@ -1,5 +1,12 @@
2007-10-09 Jonathan Pobst <[EMAIL PROTECTED]>
+ * TextBoxTextRenderer.cs: Draw takes a Color now instead of a Brush, as
+ the Win32 backend uses Color.
+ * Line.cs, LineTag.cs, RichTextBox.cs, TextBoxBase.cs, TextControl.cs:
+ Refactor to store a Color instead of a Brush for Color.
+
+2007-10-09 Jonathan Pobst <[EMAIL PROTECTED]>
+
* Line.cs, LineTag.cs: Override GetHashCode to make a compiler warning
go
away. I didn't realize I needed this when I refactored these earlier.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Line.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Line.cs
2007-10-09 22:01:03 UTC (rev 87230)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Line.cs
2007-10-09 22:06:49 UTC (rev 87231)
@@ -77,7 +77,7 @@
this.ending = ending;
}
- internal Line (Document document, int LineNo, string Text, Font
font, SolidBrush color, LineEnding ending) : this (document, ending)
+ internal Line (Document document, int LineNo, string Text, Font
font, Color color, LineEnding ending) : this (document, ending)
{
space = Text.Length > DEFAULT_TEXT_LEN ? Text.Length+1
: DEFAULT_TEXT_LEN;
@@ -93,7 +93,7 @@
tags.color = color;
}
- internal Line (Document document, int LineNo, string Text,
HorizontalAlignment align, Font font, SolidBrush color, LineEnding ending) :
this(document, ending)
+ internal Line (Document document, int LineNo, string Text,
HorizontalAlignment align, Font font, Color color, LineEnding ending) :
this(document, ending)
{
space = Text.Length > DEFAULT_TEXT_LEN ? Text.Length+1
: DEFAULT_TEXT_LEN;
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LineTag.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LineTag.cs
2007-10-09 22:01:03 UTC (rev 87230)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LineTag.cs
2007-10-09 22:06:49 UTC (rev 87231)
@@ -37,7 +37,7 @@
#region Local Variables;
// Payload; formatting
internal Font font; // System.Drawing.Font
object for this tag
- internal SolidBrush color; // The font color for
this tag
+ internal Color color; // The font color for
this tag
// 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
@@ -171,23 +171,23 @@
back_color = other.back_color;
}
- internal virtual void Draw (Graphics dc, Brush brush, float x,
float y, int start, int end)
+ internal virtual void Draw (Graphics dc, Color color, float x,
float y, int start, int end)
{
- TextBoxTextRenderer.DrawText (dc, line.text.ToString
(start, end), font, brush, x, y, false);
+ TextBoxTextRenderer.DrawText (dc, line.text.ToString
(start, end), font, color, x, y, false);
}
- internal virtual void Draw (Graphics dc, Brush brush, float
xoff, float y, int start, int end, string text)
+ internal virtual void Draw (Graphics dc, Color color, float
xoff, float y, int start, int end, string text)
{
while (start < end) {
int tab_index = text.IndexOf ("\t", start);
if (tab_index == -1)
tab_index = end;
- TextBoxTextRenderer.DrawText (dc,
text.Substring (start, tab_index - start), font, brush, xoff +
line.widths[start], y, false);
+ TextBoxTextRenderer.DrawText (dc,
text.Substring (start, tab_index - start), font, color, xoff +
line.widths[start], y, false);
// non multilines get the unknown char
if (!line.document.multiline && tab_index !=
end)
- TextBoxTextRenderer.DrawText (dc,
"\u0013", font, brush, xoff + line.widths[tab_index], y, true);
+ TextBoxTextRenderer.DrawText (dc,
"\u0013", font, color, xoff + line.widths[tab_index], y, true);
start = tab_index + 1;
}
@@ -243,7 +243,7 @@
/// 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, Color back_color, FormatSpecified
specified)
+ internal static bool FormatText (Line line, int start, int
length, Font font, Color color, Color back_color, FormatSpecified specified)
{
LineTag tag;
LineTag start_tag;
@@ -333,7 +333,7 @@
return true;
}
- private static void SetFormat (LineTag tag, Font font,
SolidBrush color, Color back_color, FormatSpecified specified)
+ private static void SetFormat (LineTag tag, Font font, Color
color, Color back_color, FormatSpecified specified)
{
if ((FormatSpecified.Font & specified) ==
FormatSpecified.Font)
tag.font = font;
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs
2007-10-09 22:01:03 UTC (rev 87230)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs
2007-10-09 22:06:49 UTC (rev 87231)
@@ -55,7 +55,7 @@
private int rtf_skip_width;
private int rtf_skip_count;
private StringBuilder rtf_line;
- private SolidBrush rtf_color;
+ private Color rtf_color;
private RTF.Font rtf_rtffont;
private int rtf_rtffont_size;
private FontStyle rtf_rtfstyle;
@@ -254,7 +254,7 @@
// 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, Color.Empty, FormatSpecified.Font);
+ document.FormatText(start, 1, end,
end.text.Length + 1, base.Font, Color.Empty, Color.Empty, FormatSpecified.Font);
}
}
}
@@ -534,12 +534,12 @@
start = document.selection_start.line.FindTag
(document.selection_start.pos);
end = document.selection_start.line.FindTag
(document.selection_end.pos);
- color = start.color.Color;
+ color = start.color;
tag = start;
while (tag != null && tag != end) {
- if (!color.Equals (tag.color.Color))
+ if (!color.Equals (tag.color))
return Color.Empty;
tag = document.NextTag (tag);
@@ -560,7 +560,7 @@
document.FormatText
(document.selection_start.line, document.selection_start.pos + 1,
document.selection_end.line,
document.selection_end.pos + 1, null,
- new SolidBrush (value),
Color.Empty, FormatSpecified.Color);
+ 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 @@
document.FormatText
(document.selection_start.line, document.selection_start.pos + 1,
document.selection_end.line,
document.selection_end.pos + 1, value,
- null, Color.Empty,
FormatSpecified.Font);
+ Color.Empty, 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);
@@ -1402,9 +1402,9 @@
if (color != null) {
FlushText(rtf,
false);
if (color.Red
== -1 && color.Green == -1 && color.Blue == -1) {
-
this.rtf_color = new SolidBrush(ForeColor);
+
this.rtf_color = ForeColor;
} else {
-
this.rtf_color = new SolidBrush(Color.FromArgb(color.Red, color.Green,
color.Blue));
+
this.rtf_color = Color.FromArgb(color.Red, color.Green, color.Blue);
}
FlushText (rtf,
false);
}
@@ -1617,16 +1617,16 @@
font = new Font(rtf_rtffont.Name, rtf_rtffont_size,
rtf_rtfstyle);
- if (rtf_color == null) {
+ if (rtf_color == Color.Empty) {
System.Windows.Forms.RTF.Color color;
// First color in table is default
color =
System.Windows.Forms.RTF.Color.GetColor(rtf, 0);
if ((color == null) || (color.Red == -1 &&
color.Green == -1 && color.Blue == -1)) {
- rtf_color = new SolidBrush(ForeColor);
+ rtf_color = ForeColor;
} else {
- rtf_color = new
SolidBrush(Color.FromArgb(color.Red, color.Green, color.Blue));
+ rtf_color = Color.FromArgb(color.Red,
color.Green, color.Blue);
}
}
@@ -1689,7 +1689,7 @@
rtf_skip_width = 0;
rtf_skip_count = 0;
rtf_line = new StringBuilder();
- rtf_color = null;
+ rtf_color = Color.Empty;
rtf_rtffont_size = (int)this.Font.Size;
rtf_rtfalign = HorizontalAlignment.Left;
rtf_rtfstyle = FontStyle.Regular;
@@ -1842,7 +1842,7 @@
// use this.Font and this.ForeColor but the font/color
from the first tag
tag = LineTag.FindTag(start_line, pos);
font = tag.font;
- color = ((SolidBrush)tag.color).Color;
+ color = tag.color;
fonts.Add(font.Name);
colors.Add(color);
@@ -1864,8 +1864,8 @@
}
}
- if (((SolidBrush)tag.color).Color !=
color) {
- color =
((SolidBrush)tag.color).Color;
+ if (tag.color != color) {
+ color = tag.color;
if (!colors.Contains(color)) {
colors.Add(color);
}
@@ -1942,8 +1942,8 @@
font = tag.font;
}
- if (((SolidBrush)tag.color).Color !=
color) {
- color =
((SolidBrush)tag.color).Color;
+ if (tag.color != color) {
+ color = tag.color;
sb.Append(String.Format("\\cf{0}", colors.IndexOf(color)));
}
if (length != sb.Length) {
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs
2007-10-09 22:01:03 UTC (rev 87230)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs
2007-10-09 22:06:49 UTC (rev 87231)
@@ -374,12 +374,10 @@
set {
int i;
int l;
- SolidBrush brush;
document.Empty();
l = value.Length;
- brush =
ThemeEngine.Current.ResPool.GetSolidBrush(this.ForeColor);
document.SuspendRecalc ();
for (i = 0; i < l; i++) {
@@ -393,7 +391,7 @@
if (value [i].EndsWith ("\r"))
ending = LineEnding.Hard;
- document.Add (i + 1, CaseAdjust (value
[i]), alignment, Font, brush, ending);
+ document.Add (i + 1, CaseAdjust
(value[i]), alignment, Font, this.ForeColor, ending);
}
document.ResumeRecalc (true);
@@ -2044,7 +2042,7 @@
for (int i = 1; i <= document.Lines; i++) {
line = document.GetLine(i);
LineTag.FormatText(line, 1,
line.text.Length, Font,
-
ThemeEngine.Current.ResPool.GetSolidBrush(ForeColor),
+ ForeColor,
Color.Empty,
FormatSpecified.Font | FormatSpecified.Color);
}
document.ResumeRecalc (false);
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxTextRenderer.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxTextRenderer.cs
2007-10-09 22:01:03 UTC (rev 87230)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxTextRenderer.cs
2007-10-09 22:06:49 UTC (rev 87231)
@@ -58,18 +58,18 @@
sf_nonprinting.FormatFlags =
StringFormatFlags.DisplayFormatControl;
}
- public static void DrawText (Graphics g, string text, Font
font, Brush brush, float x, float y, bool showNonPrint)
+ public static void DrawText (Graphics g, string text, Font
font, Color color, float x, float y, bool showNonPrint)
{
if (!use_textrenderer) {
if (showNonPrint)
- g.DrawString (text, font, brush, x, y,
sf_nonprinting);
+ g.DrawString (text, font,
ThemeEngine.Current.ResPool.GetSolidBrush (color), x, y, sf_nonprinting);
else
- g.DrawString (text, font, brush, x, y,
StringFormat.GenericTypographic);
+ g.DrawString (text, font,
ThemeEngine.Current.ResPool.GetSolidBrush (color), x, y,
StringFormat.GenericTypographic);
} else {
if (showNonPrint)
- TextRenderer.DrawTextInternal (g, text,
font, new Rectangle (new Point ((int)x, (int)y), max_size), (brush as
SolidBrush).Color, TextFormatFlags.NoPadding, false);
+ TextRenderer.DrawTextInternal (g, text,
font, new Rectangle (new Point ((int)x, (int)y), max_size), color,
TextFormatFlags.NoPadding, false);
else
- TextRenderer.DrawTextInternal (g, text,
font, new Rectangle (new Point ((int)x, (int)y), max_size), (brush as
SolidBrush).Color, TextFormatFlags.NoPadding, false);
+ TextRenderer.DrawTextInternal (g, text,
font, new Rectangle (new Point ((int)x, (int)y), max_size), color,
TextFormatFlags.NoPadding, false);
}
}
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs
2007-10-09 22:01:03 UTC (rev 87230)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs
2007-10-09 22:06:49 UTC (rev 87231)
@@ -263,7 +263,7 @@
owner.HandleCreated += new
EventHandler(owner_HandleCreated);
owner.VisibleChanged += new
EventHandler(owner_VisibleChanged);
- Add (1, String.Empty, owner.Font,
ThemeEngine.Current.ResPool.GetSolidBrush (owner.ForeColor), LineEnding.None);
+ Add (1, String.Empty, owner.Font, owner.ForeColor,
LineEnding.None);
undo = new UndoManager (this);
@@ -904,7 +904,7 @@
lines = 0;
// We always have a blank line
- Add (1, String.Empty, owner.Font,
ThemeEngine.Current.ResPool.GetSolidBrush (owner.ForeColor), LineEnding.None);
+ Add (1, String.Empty, owner.Font, owner.ForeColor,
LineEnding.None);
this.RecalculateDocument(owner.CreateGraphicsInternal());
PositionCaret(0, 0);
@@ -1335,7 +1335,7 @@
LineTag tag = line.tags;
while (tag != null) {
Console.Write ("\t<tag type='{0}'
span='{1}->{2}' font='{3}' color='{4}'>",
- tag.GetType (),
tag.start, tag.Length, tag.font, tag.color.Color);
+ tag.GetType (),
tag.start, tag.Length, tag.font, tag.color);
Console.Write (tag.Text ());
Console.WriteLine ("</tag>");
tag = tag.next;
@@ -1353,12 +1353,8 @@
int end; // Last line to draw
StringBuilder text; // String representing the
current line
int line_no;
- Brush tag_brush;
- Brush current_brush;
- Brush disabled_brush;
- Brush readonly_brush;
- Brush hilight;
- Brush hilight_text;
+ Color tag_color;
+ Color current_color;
// First, figure out from what line to what line we
need to draw
@@ -1392,14 +1388,9 @@
Console.WriteLine ("E: {0}", GetLine
(end).text);
#endif
- disabled_brush =
ThemeEngine.Current.ResPool.GetSolidBrush(ThemeEngine.Current.ColorGrayText);
- readonly_brush =
ThemeEngine.Current.ResPool.GetSolidBrush
(ThemeEngine.Current.ColorControlText);
- hilight =
ThemeEngine.Current.ResPool.GetSolidBrush(ThemeEngine.Current.ColorHighlight);
- hilight_text =
ThemeEngine.Current.ResPool.GetSolidBrush(ThemeEngine.Current.ColorHighlightText);
-
// Non multiline selection can be handled outside of
the loop
if (!multiline && selection_visible &&
owner.ShowSelection) {
- g.FillRectangle (hilight,
+ g.FillRectangle
(ThemeEngine.Current.ResPool.GetSolidBrush (ThemeEngine.Current.ColorHighlight),
selection_start.line.widths
[selection_start.pos] +
selection_start.line.X -
viewport_x,
selection_start.line.Y,
@@ -1445,14 +1436,14 @@
line_selection_end =
line_selection_start;
} else if (multiline) {
// lets draw some selection
baby!! (non multiline selection is drawn outside the loop)
- g.FillRectangle (hilight,
+ g.FillRectangle
(ThemeEngine.Current.ResPool.GetSolidBrush (ThemeEngine.Current.ColorHighlight),
line.widths
[line_selection_start - 1] + line.X - viewport_x,
line_y,
line.widths [line_selection_end - 1] - line.widths [line_selection_start - 1],
line.height);
}
}
- current_brush = line.tags.color;
+ current_color = line.tags.color;
while (tag != null) {
// Skip empty tags
@@ -1471,37 +1462,37 @@
line_y +
tag.shift, tag.Width, line.height);
}
- tag_brush = tag.color;
- current_brush = tag_brush;
+ tag_color = tag.color;
+ current_color = tag_color;
if (!owner.Enabled) {
- Color a = ((SolidBrush)
tag.color).Color;
+ Color a = tag.color;
Color b =
ThemeEngine.Current.ColorWindowText;
if ((a.R == b.R) && (a.G ==
b.G) && (a.B == b.B)) {
- tag_brush =
disabled_brush;
+ tag_color =
ThemeEngine.Current.ColorGrayText;
}
} else if (owner.read_only &&
!owner.backcolor_set) {
- tag_brush = readonly_brush;
+ tag_color =
ThemeEngine.Current.ColorControlText;
}
int tag_pos = tag.start;
- current_brush = tag_brush;
+ current_color = tag_color;
while (tag_pos < tag.start +
tag.Length) {
int old_tag_pos = tag_pos;
if (tag_pos >=
line_selection_start && tag_pos < line_selection_end) {
- current_brush =
hilight_text;
+ current_color =
ThemeEngine.Current.ColorHighlightText;
tag_pos = Math.Min
(tag.End, line_selection_end);
} else if (tag_pos <
line_selection_start) {
- current_brush =
tag_brush;
+ current_color =
tag_color;
tag_pos = Math.Min
(tag.End, line_selection_start);
} else {
- current_brush =
tag_brush;
+ current_color =
tag_color;
tag_pos = tag.End;
}
- tag.Draw (g, current_brush,
+ tag.Draw (g, current_color,
line.X -
viewport_x,
line_y +
tag.shift,
old_tag_pos -
1, Math.Min (tag.start + tag.Length, tag_pos) - 1,
@@ -2239,12 +2230,12 @@
// Adds a line of text, with given font.
// Bumps any line at that line number that already exists down
- internal void Add (int LineNo, string Text, Font font,
SolidBrush color, LineEnding ending)
+ internal void Add (int LineNo, string Text, Font font, Color
color, LineEnding ending)
{
Add (LineNo, Text, alignment, font, color, ending);
}
- internal void Add (int LineNo, string Text, HorizontalAlignment
align, Font font, SolidBrush color, LineEnding ending)
+ internal void Add (int LineNo, string Text, HorizontalAlignment
align, Font font, Color color, LineEnding ending)
{
Line add;
Line line;
@@ -3309,7 +3300,7 @@
/// <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, Color back_color,
FormatSpecified specified)
+ Color color, Color back_color, FormatSpecified
specified)
{
Line l;
@@ -3849,12 +3840,12 @@
return (int) (picture.Height + 0.5F);
}
- internal override void Draw (Graphics dc, Brush brush, float
xoff, float y, int start, int end)
+ internal override void Draw (Graphics dc, Color color, float
xoff, float y, int start, int end)
{
picture.DrawImage (dc, xoff + line.widths [start], y,
false);
}
- internal override void Draw (Graphics dc, Brush brush, float
xoff, float y, int start, int end, string text)
+ internal override void Draw (Graphics dc, Color color, float
xoff, float y, int start, int end, string text)
{
picture.DrawImage (dc, xoff + + line.widths [start], y,
false);
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches