protected void DrawHeaderImageAndText(Graphics g, Rectangle r, OLVColumn column, HeaderStateStyle stateStyle)
{
TextFormatFlags flags = this.TextFormatFlags;
flags |= TextFormatFlags.VerticalCenter;
if (column.HeaderTextAlign == HorizontalAlignment.Center)
flags |= TextFormatFlags.HorizontalCenter;
if (column.HeaderTextAlign == HorizontalAlignment.Right)
flags |= TextFormatFlags.Right;
Font f = this.ListView.HeaderUsesThemes ? this.ListView.Font : stateStyle.Font ?? this.ListView.Font;
Color color = this.ListView.HeaderUsesThemes ? Color.Black : stateStyle.ForeColor;
if (color.IsEmpty)
color = Color.Black;
// Tweak the text rectangle a little to improve aethestics
r.Inflate(-3, 0);
r.Y -= 2;
const int imageTextGap = 3;
if (column.IsHeaderVertical) {
DrawVerticalText(g, r, column, f, color);
} else {
// Does the column have a header image and is there space for it?
if (column.HasHeaderImage && r.Width > column.ImageList.ImageSize.Width * 2)
DrawImageAndText(g, r, column, flags, f, color, imageTextGap);
else
DrawText(g, r, column, flags, f, color);
}
}