--------------------------------------------------------------------------
xLabel 2.1.1
Author: X <b01011000@hotmail.com>
Last Modified: August 3, 2003
--------------------------------------------------------------------------

Overview
--------

xLabel is a Litestep module that lets you create skinnable labels and place
them anywhere on your desktop. These labels can display both static text as
well as dynamically updating system information. xLabel is based on
Maduin's Label.dll.


Differences from Label.dll
--------------------------

For the most part xLabel is compatible with Label.dll, but there are a few
incompatible differences that you need to know about if you are used to
Label.dll.

The Label and Labels commands have been replaced by *Label. *Label takes
the name of a single label only. Example:

Labels FirstLabel, SecondLabel, ThirdLabel
- becomes -
*Label FirstLabel
*Label SecondLabel
*Label ThirdLabel

Instead of each label having its own set of bang commands, there is now
just one set. Each bang command now takes an additional first parameter
that is the name of label. Example:

!FirstLabelSetText "Some text"
- becomes -
!LabelSetText FirstLabel "Some text"

Hopefully the reasoning behind these changes is obvious.


Loading the Module
------------------

Add a new LoadModule line to the step.rc file, similar to the following
(this assumes that xLabel.dll resides in C:\Litestep):

LoadModule "C:\Litestep\xLabel.dll"

The following sections describe how to configure xLabel to actually do
something useful. Once you're done configuring, recycle Litestep.


How to Create a Label
---------------------

xLabel lets you create any number of labels. Each labels has its own unique
name which is used to refer to that label for configuration and bang
commands. There are two ways to create labels: automatically and manually.
A label that is created automatically is created when xLabel is loaded. You
declare that a label is automatic by placing a *Label command in the
step.rc:

*Label MyLabel

Alternatively you can create a label manually using the !LabelCreate bang
command. In that case the label is created if and when the bang command is
executed. Example:

!LabelCreate MyLabel

All labels are automatically destroyed when xLabel is unloaded, regardless
of how they were created.


Configuration
-------------

The following commands are typically placed in the step.rc. See the
Litestep documentation for help modifying this file. Parameters and their
types are denoted by angle brackets (<, >) and optional parameters are
enclosed in square brackets ([, ]).

All commands must be prefixed with the label's name. For example: to set
the Text of a label named MyLabel the actual command you would put in the
step.rc would be MyLabelText.

Text <text>
Sets the text displayed by the label. If no value is provided the label is
left blank. The value can contain both simple text and escape sequences.
Escape sequences are enclosed in square brackets ("Simple text [escape]").
See the discussion of text escape sequences below for more information.
You can assign multiple text items by separating them with semicolons
("Item 1;Item 2") then switch between them with !LabelPrevious and !LabelNext.

X <number>
Sets the horizontal position of the label in pixels. If the value is
positive then it is relative to the left side of the desktop, if negative
then the right side. Additionally you can make the position relative to
the center of the desktop by appending the character 'c' after the number
("32c", "-128c").

Y <number>
Sets the vertical position of the label in pixels. If the value is
positive then it is relative to the top of the desktop, if negative then
the bottom. Additionally you can make the position relative to the center
of the desktop by appending the character 'c' after the number ("32c",
"-128c").

Width <number>
Sets the horizontal size of the label. This can be an absolute value (in
pixels) or a percentage of the desktop width.

Height <number>
Sets the vertical size of the label. This can be an absolute value (in
pixels) or a percentage of the desktop height.

AlwaysOnTop
If this command is present then it makes the label "always on top", that
is, the label stays above all application windows.

StartHidden
If this command is present then the label will be initially invisible. It
can later be shown using bang commands.

Image <file>
Sets the name of the skin file. This file must be in Windows bitmap (BMP)
format. If no value is provided then the label is displayed with the a
default background.

ImageLeftEdge <number>
Sets the number of pixels on the left edge of the bitmap that will not be
stretched or tiled. If no value is provided then the default is 0.

ImageTopEdge <number>
Sets the number of pixels on the top edge of the bitmap that will not be
stretched or tiled. If no value is provided then the default is 0.

ImageRightEdge <number>
Sets the number of pixels on the right edge of the bitmap that will not be
stretched or tiled. If no value is provided then the default is 0.

ImageBottomEdge <number>
Sets the number of pixels on the bottom edge of the bitmap that will not
be stretched or tiled. If no value is provided then the default is 0.

ImageMode "stretch", "tile", "tile-horizontal", or "tile-vertical"
Sets the method used to scale the skin bitmap. If no value is provided
then the default is "stretch".

Transparent
If this command is present then it enables transparency. If a skin is also
in use then areas of the skin bitmap that are pink (RGB 255, 0, 255) will
allow the desktop wallpaper to show through. If no skin is in use and this
command is present then the entire label will be transparent.

TrueTransparency
The command makes pink (RGB 255, 0, 255) areas in the background bitmap really
transparent (eg you will see a window you drag below the label).
Caution: This won't work with a blank background!
Default is false.

Font <font>
Sets the name of the font used to display text. If no value is provided
then the default is "Arial".

FontHeight <number>
Sets the height of the font used to display the text in pixels. If no
value is provided then the default is 15.

FontBold
If this command is present then the font will be bold.

FontItalic
If this command is present then the font will be italic.

FontColor <color>
Sets the color of the font used to display the text. If no value is
provided then the default is black (RGB 0, 0, 0).

FontShadow
If this command is present then the font will be shadowed.

FontShadowColor <color>
Sets the color used to display the text shadow. If no value is provided
then the default is dark gray (RGB 128, 128, 128).

FontShadowX <number>
Sets the number of pixels in the horizontal direction that the shadow is
offset from the rest of the text; this can be negative. If no value is
provided then the default is 1.

FontShadowY <number>
Sets the number of pixels in the vertical direction that the shadow is
offset from the rest of the text; this can be negative. If no value is
provided then the default is 1.

Align "left", "center", or "right"
Sets the horizontal text alignment. If no value is provided then the
default is "center".

VertAlign "top", "center", or "bottom"
Sets the vertical text alignment. If no value is provided then the
default is "center".

LeftBorder <number>
Sets the number of pixels on the left edge to reserve as a border. If no
value is provided then the default is 0.

TopBorder <number>
Sets the number of pixels on the top edge to reserve as a border. If no
value is provided then the default is 0.

RightBorder <number>
Sets the number of pixels on the right edge to reserve as a border. If no
value is provided then the default is 0.

BottomBorder <number>
Sets the number of pixels on the bottom edge to reserve as a border. If no
value is provided then the default is 0.

UpdateInterval <number>
Sets the amount of time in milliseconds between updates for labels that
contain dynamically updated content. If no value is provided then the
default is 1000 (1 second).

UseFahrenheit
If this command is present, mbmTemperature (see below) is diplayed in
Fahrenheit instead of Celsius.

Scroll
If this command is present then the label scrolls its contents if the text
doesn't fit into the label. Note that the text might "jump" a bit if
LabelJustify is not set to "left".

ScrollInterval <number>
Sets the scrolling update interval in milliseconds. If no value is
provided then the default is 100.

ScrollSpeed <number>
Sets the number of pixels to scroll for each update. Negative values allow
you to scroll in the opposite direction. If no value is provided then the
default is 1.

ScrollPad <number>
Sets the the number of pixels between the start and end of the text when
scrolling. If no value is provided then the default is 10.


Bang Commands
-------------

Bang commands allow you to manipulate labels at run-time through scripts
or other modules. See the Litestep documentation for more information
about bang commands and how to invoke them.

!LabelAlwaysOnTop <label-name>
Makes the label "always on top", that is, it stays above all application
windows.

!LabelClipboardCopy <label-name> [<text>]
Copies the contents of the label to the clipboard. If the optional text
parameter is present, it will prefixed to the label's contents.

!LabelClipboardPaste <label-name> [<text>]
Sets the label's text to the current contents of the clipboard. If the
optional text parameter is present, it will be prefixed to the clipboard's
contents. Naturally, this only works if the clipboard contains text.

!LabelCreate <label-name>
Create the label manually.

!LabelDestroy <label-name>
Destroy the label.

!LabelHide <label-name>
Hides the label, making it invisible.

!LabelMove <label-name> <x-coordinate> <y-coordinate>
Moves the label.

!LabelNext <label-name>
Switch to the next text.

!LabelPinToDesktop <label-name>
Pins the label to the desktop so that it stays below all application
windows. This the default state and is the opposite of always on top.

!LabelPrevious <label-name>
Switch to the previous text.

!LabelRefresh <label-name>
Call this after !reload to reconfigure the label

!LabelReposition <label-name> <x-coordinate> <y-coordinate> <width> <height>
Repositions (moves and resizes) the label.

!LabelResize <label-name> <width> <height>
Resizes the label.

!LabelScroll <label-name> <number>, "on", "off", or "toggle"
Depending on the parameter this command toggles scrolling/turns it on or off.
If the parameter is a number the label scrolls the given number of times. If
the number is 0 and the label is already scrolling it'll finish the "current
scroll" and then stop.

!LabelSetFontColor <label-name> <color>
Changes the label's font color. You can specify the color as decimal
RGB (128 64 255) or as hexadecimal (8040FF).

!LabelSetText <label-name> [<text>]
Sets the text displayed in the label. If the parameter is not present then
the label will be cleared of any text.

!LabelShow <label-name>
Shows the label, making it visible.

!LabelShowHide <label-name> <seconds>
Shows the label for the specified number of seconds then hides it.

!LabelToggleAlwaysOnTop <label-name>
Switches the label back and forth between the always on top and pinned to
desktop states.

!LabelToggle <label-name>
Switches the label back and forth between the visible and invisible
states.

!LabelUpdate <label-name>
Forces the label to update its contents.


Events
------

Events allow you execute programs or bang commands based on user
interaction with the label. The following work the same as configuration
settings. Each of them takes the name of program or bang commands as their
value. When the event is triggered, the program or bang command is
executed. Note that in the case of mouse clicks, assigning an action to
both the click and the double click event will not work. As before, you must
prefix the command name with the label name.

OnDrop <action>
Sets an action to perform when a file or a folder is dropped on the label.
The full path to the file/folder is passed to the action as an argument.

OnEnter <action>
Sets an action to perform when the mouse cursor enters the label.

OnLeave <action>
Sets an action to perform when the mouse cursor leaves the label.

OnLeftClick <action>
Sets an action to perform when the user left clicks on the label.

OnLeftDoubleClick <action>
Sets an action to perform when the user double-clicks the label with the
left mouse button.

OnMiddleClick <action>
Sets an action to perform when the user middle clicks on the label.

OnMiddleDoubleClick <action>
Sets an action to perform when the user double-clicks the label with the
middle mouse button.

OnRightClick <action>
Sets an action to perform when the user right clicks on the label.

OnRightDoubleClick <action>
Sets an action to perform when the user double-clicks the label with the
right mouse button.

OnTextChange <action>
Sets an action to perform when the text in the label changes.

OnWheelDown <action>
Sets an action to perform when the mouse wheel scrolls down while the
mouse cursor hovers over the label.

OnWheelUp <action>
Sets an action to perform when the mouse wheel is scrolled up while the
mouse cursor hovers over the label.


Text Escape Sequences
---------------------

To include dynamic text in labels, such as system information, you can use
escape sequences mixed in with normal text in labels. Escapes sequences
consist of a data source names and any necessary parameters and possibly
one or more modifier functions all enclosed in square brackets:

LabelText "Just some test... [modifier(dataSource(parameter))]"
ClockLabelText "The time is: [time]"
QuoteLabelText "Quote of the Day: [trim(randomLine('C:\quotes.txt'))]"
SysLabelText "CPU: [cpu], RAM: [memInUse]"

As of version 1.5, labels can have text which spans multiple lines. To
create a line break in the text use the character sequence "\n". If you
need to include a literal backslash then use "\\".

MultiLineLabelText "This is on line 1\nThis is on line 2"
MemLabelText "Memory Info\n\nFree: [memAvailable]\nTotal: [memTotal]"

The following is a list of all the valid data sources and any parameters
they take:

activeTask
Title of the currently active task.

battery
Percentage of battery power remaining.

computerName
Name assigned to this computer.

cpu
Current total CPU usage percent.

date('format')
Current local date. Format is optional and is explained below.

diskAvailable('drive', units)
Amount of space currently available on given drive.

diskInUse('drive', units)
Amount of space currently in use on given drive.

diskTotal('drive', units)
Total amount of space on given drive.

hostName
Host name assigned to this computer.

ip
Internet Procotol (IP) address assigned to this computer.

iTime
Current time as Swatch internet time (beats).

line('file', number)
Retrieves the number'th line from the given file.

lineCount('file')
Number of lines in the given file.

mbmCPUUsage
CPU usage as reported by MBM5. Takes an optional numeric index as a
parameter. MBM5 supports 4 CPUs numbered 1 to 4.

mbmFanSpeed
Fan speed as reported by MBM5. Takes an optional numeric index as a
parameter. MBM5 supports 10 fans numbered 1 to 10.

mbmTemperature
Temperature as reported by MBM5. Takes an optional numeric index as a
parameter. MBM5 supports 10 temperature sensors numbered 1 to 10.

mbmVoltage
Voltage as reported by MBM5. Takes an optional numeric index as a
parameter. MBM5 supports 10 voltages numbered 1 to 10.

memAvailable(units)
Amount of physical memory currently available.

memInUse(units)
Amount of physical memory currently in use.

memTotal(units)
Total amount of physical memory in the system.

os
Name of the operating system running on this computer.

powerSource('AC', 'Battery')
Selects what text to display based on whether the system is running on AC
or battery power. Defaults are 'AC' and 'Battery'.

randomLine('file')
Retrieves a randomly selected line from the given file.

size('file', units)
Size of the given file. Units is optional.

swapAvailable(units)
Amount of swap space currently available.

swapInUse(units)
Amount of swap space currently in use.

swapTotal(units)
Total amount of swap space in the system.

time('format')
Current local time. Format is optional and is explained below.

uptime('format')
Current system uptime. Format is optional and is explained below.

userName
Name of the user currently logged on.

winampSong
Song currently loaded in Winamp. If Winamp is not running or there is not
song loaded this will be empty.

winampTime
Time elapsed on the current song in Winamp.

winampRemainTime
Time remaining on the current song in Winamp.

winampTotalTime
Length of the current song in Winamp.

winampStatus
Current status of Winamp. If Winamp is running this will be one of
"Playing", "Paused", or "Stopped". If Winamp is not running this will be
empty.

windowTitle('class')
Title of the window with the given class name.

The following is the list of all valid modifier functions. These functions
can be used to modify the output from any of the above data sources. For
instance, the computer name is usually reported in all uppercase letters,
so you could use lowerCase or capitalize to change that.

after(x, delim)
Extracts the part of x after the first occurance of delim.

afterLast(x, delim)
Extracts the part of x after the last occurance of delim.

before(x, delim)
Extracts the part of x before the first occurance of delim.

beforeLast(x, delim)
Extracts the part of x before the last occurance of delim.

between(x, delim1, delim2)
Extracts the part of x that lies between the first occurance of delim1 and
the last occurance of delim2.

capitalize(x)
Makes all characters lowercase except for the first which is uppercased.

hideIfEmpty(x)
If x evaluates to an empty string and the label is visible then it is
hidden. Otherwise if x evaluates to a non-empty string and the label
is hidden then it will be shown. The argument is passed through unchanged.

lowerCase(x)
Makes all characters lowercase.

trim(x)
Removes leading and trailing whitespace.

upperCase(x)
Makes all characters uppercase.

The [date], [time], and [uptime] data sources can optionally take a format
as a parameter. The following character sequences will be interpreted in
the format (anything else is included verbatim):

m			month (1-12)
mm			month with leading zero (01-12)
mmm			abbreviated month name (Jan, Feb, etc)
mmmm		full month name (January, February, etc)
d			day (1-31)
dd			day with leading zero (01-31)
ddd			abbreviated weekday name (Sun, Mon, etc)
dddd		full weekday name (Sunday, Monday, etc)
yy			2-digit year
yyyy		4-digit year
h			hour (1-12)
hh			hour with leading zero (01-12)
i			hour (0-23)
ii			hour with leading zero (00-23)
n			minute (0-59)
nn			minute with leading zero (00-59)
s			second (0-59)
ss			second with leading zero (00-59)
am/pm		am/pm indicator

For [uptime] only the day, hour, minute, and second values are valid. The
[date] and [time] data sources can also take a second parameter that
modifies the timezone used. Here are some examples:

[time('h:nn am/pm', '+4')]
[time('h:nn am/pm', '-2:30')]
[time('h:nn am/pm', 'UTC')]
[time('h:nn am/pm', 'UTC+1')]

UTC means coordinated universal time and is loosely defined as the current
date and time in Greenwich, England.

Data sources that return a size in bytes (mem, swap, etc) take an optional
parameter that specifies the units to use. Legal values are KB, MB, GB, and
% (percent). If no units are given then the units are automatically
selected based on the current value. For example, if 24 MB of memory are
free (out of 64 MB total):

[memAvailable(KB)] --> 24576
[memAvailable(MB)] --> 24
[memAvailable(GB)] --> 0.02
[memAvailable(%)]  --> 38

Note that when you use specific units, the unit labels are not added for
you, but when the units are implicit they are.

MotherBoard Monitor: As of version 1.9 of Label the MBM data sources
[mbm*] require MBM version 5.1 (or higher). Due to the nature of the
changes this makes Label 1.9 incompatible with earlier versions of MBM.

If you want to include [ or ] in your label's text, use [[ and ]].


Default Configurations using AllLabels
--------------------------------------

To help reduce redundant commads in the step.rc, label.dll now supports
default settings. By prepending "AllLabels" to the name of the setting you
can make defaults that apply to all labels. For example, the following
sets the a default font which will be used for LabelOne and LabelTwo but
which is overridden by LabelThree:

AllLabelsFont "Tahoma"
AllLabelsFontHeight 12
AllLabelsFontBold
AllLabelsFontColor 255 255 255
AllLabelsJustify left

LabelOneText "Hello!"
LabelOneX 100
LabelOneY 100
LabelOneJustify center

LabelTwoText "Hi!"
LabelTwoX 200
LabelTwoY 100

LabelThreeText "Greetings!"
LabelThreeX 300
LabelThreeY 100
LabelThreeFont "Arial"
LabelThreeFontHeight 11
LabelThreeFontColor 255 255 255


Using Labels inside LSBox
-------------------------

xLabel supports the *ModuleHook feature of LSBox. To create a label inside
of an LSBox, place the following command in the .box file:

*ModuleHook !LabelLSBoxHook <label-name>

All the settings for the label will still be in the step.rc. Make sure that
you do not put the same name in both a *ModuleHook and a *Label command.
Note that xLabel must be loaded before LSBox in order for this to work.

The following bang commands do not work for labels inside of an LSBox:
	!LabelAlwaysOnTop
	!LabelCreate
	!LabelDestroy
	!LabelPinToDesktop
	!LabelToggleAlwaysOnTop
