// Color the background behind the text
ACanvas->Brush->Color = MainMenuBackground;
ACanvas->FillRect(ARect);
if(Text == "")
return;
if(Selected)
{
// Draw the outline of the selection box
FocusRectBorder = ARect;
ACanvas->Brush->Color = BorderColor;
ACanvas->FrameRect(FocusRectBorder);
// Draw the inside of the selection box
// Make is a little smaller so it does not erase the outline
FocusRectFill = ARect;
FocusRectFill.Top += SideBuffer;
FocusRectFill.Right -= SideBuffer;
FocusRectFill.Left += SideBuffer;
FocusRectFill.Bottom -= SideBuffer;
ACanvas->Brush->Color = MainMenuHighlightColor;
ACanvas->FillRect(FocusRectFill);
// Set the color that we want our text drawn when the item is selected
ACanvas->Font->Color = MainMenuHighlightTextColor;
}
else
{
ACanvas->Font->Color = MainMenuTextColor;
}
int TextLength;
TRect TextRect;
TextLength = Text.Length();
TextRect = ARect;
// This determines where the text is drawn.
TextRect.Left += 5;
TextRect.Top += 1;
// Draw the text
DrawText(ACanvas->Handle,Text.c_str(), TextLength, &TextRect, 0);
// Draw the Background erases anything that was there before.
ACanvas->Brush->Color = MenuColor;
ACanvas->FillRect(ARect);
// Draw any seperator lines
if(Text==BLANK_LINE)
{
// Draw the Vertical Bar
VerticalRect = ARect;
VerticalRect.Top -= SideBuffer;
VerticalRect.Right = VerticalWidth;
VerticalRect.Bottom += SideBuffer;
ACanvas->Brush->Color = VerticalColor;
ACanvas->FillRect(VerticalRect);
// Draw the Blank Line
ACanvas->MoveTo(VerticalWidth,ARect.Top+ARect.Height()/2);
ACanvas->LineTo(ARect.Right,ARect.Top+ARect.Height()/2);
return;
}
// This is for non seperator lines
TextLength = Text.Length();
if(Selected)
{
// Have to draw the vertical bar section to fill in the area that is not
// covered by the selection rect
VerticalRect = ARect;
VerticalRect.Top -= SideBuffer;
VerticalRect.Right = VerticalWidth;
VerticalRect.Bottom += SideBuffer;
ACanvas->Brush->Color = VerticalColor;
ACanvas->FillRect(VerticalRect);
if(MenuItem->Enabled)
{
// The item is selected and enabled
// Fill in the focus rect. Making it a little smaller so as to not
// draw over the outline
FocusRectFill = ARect;
FocusRectFill.Right -= FocusRectRightIndent;
FocusRectFill.Left += FocusRectLeftIndent;
FocusRectFill.Bottom -= SideBuffer;
FocusRectFill.Top += SideBuffer;
ACanvas->Brush->Color = HighlightColor;
ACanvas->FillRect(FocusRectFill);
// Set the way we want to draw our text
ACanvas->Font->Color = HighlightTextColor;
ACanvas->Font->Style = TFontStyles() << fsBold;
}
else
{
// Menu item is not enabled so do not draw any selection
// rect and change the text color to reflect its unenabled state
// NOTE: The icon is still drawn normally and not disabled
ACanvas->Font->Style = TFontStyles();
ACanvas->Brush->Color = NormalTextBackground;
ACanvas->Font->Color = DisabledTextColor;
}
}
else
{
// Fill in the vertical area
VerticalRect = ARect;
VerticalRect.Top -= SideBuffer;
VerticalRect.Right = VerticalWidth;
VerticalRect.Bottom += SideBuffer;
ACanvas->Brush->Color = VerticalColor;
ACanvas->FillRect(VerticalRect);
// Set the text background color and font based on if it is enabled or not
if(MenuItem->Enabled)
{
ACanvas->Brush->Color = NormalTextBackground;
ACanvas->Font->Color = NormalTextColor;
}
else
{
ACanvas->Brush->Color = NormalTextBackground;
ACanvas->Font->Color = DisabledTextColor;
}
}
// Calculate out the Rect we want to draw our text in
TextRect = ARect;
TextRect.Left += LeftTextPos;
if(Offset > 0)
TextRect.Top += Offset/2 + SideBuffer;
else
TextRect.Top += 2 + SideBuffer;
TextRect.Top += SideBuffer;
// Draw any menu item icons
if(Menu->Images != NULL)
{
Icon = new TIcon();
Menu->Images->GetIcon(MenuItem->ImageIndex,Icon);
ACanvas->Draw(5,ARect.Top+ItemOffset+1,Icon);
delete Icon;
}
// Draw the text
DrawText(ACanvas->Handle,Text.c_str(), TextLength, &TextRect, 0);
}
//---------------------------------------------------------------------------