#include <PalmOS.h>
#include "T-Suite.h"

#pragma mark ----------

/*static*/ void WbMtCmdBarKeyDownResDraw (Char **nameP, UInt8 numButtons)
{
	WinPushDrawState ();
	WinHandle PrevDrawWindowH = WinSetDrawWindow (WinGetDisplayWindow ());

	Coord DisplayExtentX;
	Coord DisplayExtentY;
	WinGetDisplayExtent (&DisplayExtentX, &DisplayExtentY);
	RectangleType CmdBarRect;

	CmdBarRect.topLeft.x = 0 + 1;
	CmdBarRect.topLeft.y = DisplayExtentY - 19 + 1;
	CmdBarRect.extent.x = DisplayExtentX - 3;
	CmdBarRect.extent.y = 19 - 3;

	UInt16 maxWidth = DisplayExtentX - 14 - (17 * numButtons);

	RectangleType CmdBarNameRect;
	CmdBarNameRect.topLeft.x = CmdBarRect.topLeft.x + 11;
	CmdBarNameRect.topLeft.y = CmdBarRect.topLeft.y;
	CmdBarNameRect.extent.x = maxWidth;
	CmdBarNameRect.extent.y = 16;
	
	WinSetForeColor (UIColorGetTableEntryIndex (UIMenuFill));
	WinDrawRectangle (&CmdBarNameRect, 0);

	WinSetForeColor (UIColorGetTableEntryIndex (UIFieldFepUnderline));
	WinSetBackColor (UIColorGetTableEntryIndex (UIMenuFill));
	WinSetUnderlineMode (grayUnderline);
	FntSetFont (boldFont);

	WinDrawTruncChars (*nameP, StrLen (*nameP),
			CmdBarRect.topLeft.x + 11, CmdBarRect.topLeft.y + 1, maxWidth);

	WinSetDrawWindow (PrevDrawWindowH);
	WinPopDrawState ();
	
	UInt32 prvTimeOut = TimGetTicks () + (SysTicksPerSecond () / 6);
	do
	{
	}while (prvTimeOut > TimGetTicks ());
}