-- START OF DISPLAY FUNCTION
function Display_Line (line, styles) -- display one line
local left = TEXT_INSET
local top = (line - 1) * font_height
for _, v in ipairs (styles) do
left = left + WindowText (win, "f", v.text, left, top, 0, 0, v.textcolour)
end -- for each style run
end -- Display_Line
function display_all (flags, name)
--
local first_visible = #lines - visible_lines - scrolling
if first_visible < 1 then
first_visible = 1
end -- if
local scroll_range = WINDOW_HEIGHT - 35
if #lines > visible_lines then
scroll_line_pool = #lines - visible_lines
scroll_per_line = scroll_range / scroll_line_pool
scroll_amount = scrolling * scroll_per_line
end -- if
local scroll_adjust = 0 + scroll_amount
local scroll_position = (WINDOW_HEIGHT - 20) - scroll_adjust
local scroll_bar_top = scroll_position - 5
local scroll_bar_bottom = scroll_position + 5
-- blank existing window contents
WindowRectOp (win, 2, 0, 0, 0, 0, WINDOW_BACKGROUND_COLOUR)
WindowRectOp (win, 5, 0, 0, 0, 0, 5, 15)
-- draw scroll buttons
WindowRectOp (win, 5,WINDOW_WIDTH - 15, 0, WINDOW_WIDTH, 15, 9, 15 + 0x0800 + 0x1000)
WindowRectOp (win, 5,WINDOW_WIDTH - 15, WINDOW_HEIGHT - 15, WINDOW_WIDTH, WINDOW_HEIGHT, 9, 15 + 0x0800 + 0x1000)
-- draw triangles on scroll buttons
WindowPolygon (win, "352, 5, 355, 10, 350, 10",
ColourNameToRGB("gray"), 0, 1,
ColourNameToRGB("lightgray"), 0,
true,
false)
WindowPolygon (win, "352, 145, 355, 140, 350, 140",
ColourNameToRGB("gray"), 0, 1,
ColourNameToRGB("lightgray"), 0,
true,
false)
-- draw scroll bar
WindowRectOp (win, 5, WINDOW_WIDTH - 15, scroll_bar_top, WINDOW_WIDTH, scroll_bar_bottom,
9, 15 + 0x0800 + 0x1000)
-- display lines
local count = 0
for i = first_visible, #lines do
count = count + 1
Display_Line (count, lines )
end -- for
-- force window redisplay
WindowShow (win, true) -- show it
end -- end function display_all
-- END OF DISPLAY FUNCTIONS
function OnPluginInstall ()
win = GetPluginID ()
local x, y, mode, flags =
tonumber (GetVariable ("x")) or 0,
tonumber (GetVariable ("y")) or 0,
tonumber (GetVariable ("mode")) or 10, -- bottom left
tonumber (GetVariable ("flags")) or 0
-- make the window
check (WindowCreate (win,
x, y, WINDOW_WIDTH, WINDOW_HEIGHT,
mode,
flags,
WINDOW_BACKGROUND_COLOUR) ) -- create window
check (WindowFont (win, "f", FONT_NAME, FONT_SIZE)) -- define font
font_height = WindowFontInfo (win, "f", 1) -- height of the font
visible_lines = math.floor (WINDOW_HEIGHT / font_height) - 1
scrolling = 0
scroll_amount = 0
-- make a hotspot
WindowAddHotspot(win, "hs1",
0, 0, WINDOW_WIDTH - 15, WINDOW_HEIGHT, -- whole window
"", -- MouseOver
"", -- CancelMouseOver
"mousedown",
"", -- CancelMouseDown
"", -- MouseUp
"Drag to move", -- tooltip text
1, 0) -- hand cursor
WindowAddHotspot(win, "hs2",
WINDOW_WIDTH - 15, 0, WINDOW_WIDTH, 15, -- top left corner
"", -- MouseOver
"", -- CancelMouseOver
"", -- MouseDown
"", -- CancelMouseDown
"scroll_up", -- MouseUp
"Click to scroll up", -- tooltip text
1, 0) -- hand cursor
WindowAddHotspot(win, "hs3",
WINDOW_WIDTH - 15, WINDOW_HEIGHT - 15, WINDOW_WIDTH, WINDOW_HEIGHT, -- bottom right corner
"", -- MouseOver
"", -- CancelMouseOver
"", -- MouseDown
"", -- CancelMouseDown
"scroll_down", -- MouseUp
"Click to scroll down", -- tooltip text
1, 0) -- hand cursor
WindowDragHandler(win, "hs1", "dragmove", "dragrelease", 0)
if GetVariable ("enabled") == "false" then
ColourNote ("yellow", "", "Warning: Plugin " .. GetPluginName ().. " is currently disabled.")
check (EnablePlugin(GetPluginID (), false))
return
end -- they didn't enable last time
end -- OnPluginInstall
function OnPluginDisable ()
WindowShow (win, false)
end -- OnPluginDisable
function OnPluginSaveState ()
SetVariable ("enabled", tostring (GetPluginInfo (GetPluginID (), 17)))
SetVariable ("x", tostring (WindowInfo (win, 10)))
SetVariable ("y", tostring (WindowInfo (win, 11)))
SetVariable ("mode", tostring (WindowInfo (win, 7)))
SetVariable ("flags", tostring (WindowInfo (win, 8)))
end -- OnPluginSaveState
]]>
</script>
</muclient>
|