|
楼主 |
发表于 2010-7-23 01:58:23
|
显示全部楼层
function draw_line (iLine, sPrompt, iCurrent, iMax, sGoodColour, sBadColour, sOverColour)
-- draw the Text
local left1 = EDGE_WIDTH + 4
local left2 = left1 + 40
local left3 = left2 + 185
local top = (EDGE_WIDTH + 3) + (font_height+2)*(iLine-1)
local text_colour = WINDOW_TEXT_COLOUR
local text1 = sPrompt
--Note ( text1)
WindowText (win, "f1", text1, left1, top, 0, 0, text_colour, true)
-- adjust different font height in one line
local top1 = top - 1
-- draw the background colour of the bar
local back_colour = ColourNameToRGB("dimgray")
WindowText (win, "f2", "gggggggggggg", left2, top1, 0, 0, back_colour, true)
if iCurrent == "" or iMax == "" then
iCurrent = 0
iMax = 0
end -- if
percent = math.floor(iCurrent/(iMax/12))
-- Below 25% warn by using different colour, or above 100% using another different colour
if percent < 3 then
active_colour= ColourNameToRGB(sBadColour)
elseif percent > 12 then
percent = 12
active_colour = ColourNameToRGB(sOverColour)
else
active_colour = ColourNameToRGB(sGoodColour)
end -- if
-- Draw active part of gauge
for count = 0,percent do
if count == 0 then
bar = ""
else
bar = bar.. "g"
end -- if
end -- for
if bar == nil then
bar = ""
end -- if
WindowText (win, "f2", bar, left2, top1, 0, 0, active_colour, true)
local text3 = iCurrent.. " / ".. iMax
WindowText (win, "f3", text3, left3, top, 0, 0, active_colour, true)
-- end draw the Text Line
end -- draw line |
|