Input Roll - simpler and more efficient code, with a decent speedup

This commit is contained in:
adelikat 2014-08-10 21:35:17 +00:00
parent 1de36a0e2f
commit 7f053fc007
2 changed files with 10 additions and 12 deletions

View File

@ -121,12 +121,12 @@ namespace BizHawk.Client.EmuHawk.CustomControls
/// <param name="font">the font to use to draw the string</param>
/// <param name="color">the text color to set</param>
/// <param name="point">the location to start string draw (top-left)</param>
public void DrawString(String str, Font font, Point point)
public void DrawString(String str, Point point)
{
TextOut(_hdc, point.X, point.Y, str, str.Length);
}
public void PrepDrawString(String str, Font font, Color color, Point point)
public void PrepDrawString(Font font, Color color)
{
SetFont(font);
SetTextColor(color);

View File

@ -166,7 +166,6 @@ namespace BizHawk.Client.EmuHawk
{
var colWidth = _horizontalOrientedColumnWidth;
gdi.DrawRectangle(0, 0, colWidth, Height);
gdi.FillRectangle(1, 1, colWidth - 3, Height - 3);
int start = 0;
foreach (var column in Columns)
@ -243,22 +242,22 @@ namespace BizHawk.Client.EmuHawk
if (HorizontalOrientation)
{
int start = 0;
gdi.PrepDrawString(this.Font, this.ForeColor);
foreach (var column in Columns)
{
var point = new Point(CellPadding, start + CellPadding);
gdi.PrepDrawString(column.Text, this.Font, this.ForeColor, point);
gdi.DrawString(column.Text, this.Font, point);
gdi.DrawString(column.Text, point);
start += CellHeight;
}
}
else
{
int start = CellPadding;
gdi.PrepDrawString(this.Font, this.ForeColor);
foreach(var column in Columns)
{
var point = new Point(start + CellPadding, CellPadding);
gdi.PrepDrawString(column.Text, this.Font, this.ForeColor, point);
gdi.DrawString(column.Text, this.Font, point);
gdi.DrawString(column.Text, point);
start += CalcWidth(column);
}
}
@ -271,6 +270,7 @@ namespace BizHawk.Client.EmuHawk
if (HorizontalOrientation)
{
var visibleRows = (Width - _horizontalOrientedColumnWidth) / CellWidth;
gdi.PrepDrawString(this.Font, this.ForeColor);
for (int i = 0; i < visibleRows; i++)
{
for (int j = 0; j < Columns.Count; j++)
@ -280,14 +280,14 @@ namespace BizHawk.Client.EmuHawk
int y = j * CellHeight;
var point = new Point(x, y);
QueryItemText(i, j, out text);
gdi.PrepDrawString(text, this.Font, this.ForeColor, point);
gdi.DrawString(text, this.Font, point);
gdi.DrawString(text, point);
}
}
}
else
{
var visibleRows = (Height / CellHeight) - 1;
gdi.PrepDrawString(this.Font, this.ForeColor);
for (int i = 1; i < visibleRows; i++)
{
int x = 1;
@ -296,9 +296,7 @@ namespace BizHawk.Client.EmuHawk
string text;
var point = new Point(x + CellPadding, i * CellHeight);
QueryItemText(i, j, out text);
gdi.PrepDrawString(text, this.Font, this.ForeColor, point);
gdi.DrawString(text, this.Font, point);
gdi.DrawString(text, point);
x += CalcWidth(Columns[j]);
}
}