|
楼主 |
发表于 2009-4-2 08:39:35
|
显示全部楼层
function drawGauge(win, font, param, left, top, current, maxium)
local height = WindowFontInfo(win, font, 1)
local descent = WindowFontInfo(win, font, 3)
WindowText (win, font,
param, -- text
left, top, 0, 0, -- rectangle
ColourNameToRGB ("darkgreen"), -- colour
false) -- not Unicode
width = WindowTextWidth (win, font, param)
local seperate = 5
local barTop = top + descent
local barLeft = left + width + seperate
local barWidth = 200
local barHeight = height - 2 * descent
local percent = current / maxium
local barColor = getColorByPercent(percent)
if (percent > 1) then
percent = 1
end
WindowRectOp (win, 2, barLeft, barTop, barLeft + barWidth * percent, barTop + barHeight, ColourNameToRGB(barColor)) -- draw rectangle
WindowRectOp (win, 1, barLeft, barTop, barLeft + barWidth, barTop + barHeight, ColourNameToRGB("blue")) -- draw rectangle
WindowText (win, font,
current .. "/" .. maxium, -- text
barLeft + barWidth + seperate, top, 0, 0, -- rectangle
ColourNameToRGB (barColor), -- colour
false)
end |
|