kClock2.dll v1.4
----------------
by pika
http://pika.shellscape.org/
_gingerfish_@yahoo.com



Introduction
------------
Some people may ask why I've created this module when we already have others
such as chronos, label, and lsxcommand. The simple answer is for two reasons.
I don't like using label for the sole purpose of a clock. I think it's just
overkill. I've had slight problems with Chronos, particularly with the newer
builds. LSXCommand is in the same boat as label.

And I just felt like coding a clock module. Deal with it.



Description
-----------
kClock is simply a digital clock module for LiteStep. This means it displays
the time and date in digit format (0-9), though it can certainly use characters
too. It draws a window and text using either colours you specify, or a bitmap
you specify. It has several possible settings to use in the step.rc file, but
not all of them are necessary for functional use of the module. Descriptions of
the settings follow. Type and default values can be found in kclock-1.4.rc.



Step Settings
-------------
kclockX                  x coordinate of the clock.

kclockY                  y coordnate of the clock.

kclockWidth              width of the clock.

kclockHeight             height of the clock.

kclockBorder             default border size of the clock.

kclockBorderLeft         left border size. defaults to Border.

kclockBorderTop          top border size. defaults to Border.

kclockBorderRight        right border size. defaults to Border.

kclockBorderBottom       bottom border size. defaults to Border.

kclockDispRect           display area for the text. defaults to (0,0) and the
                         width and height.

kclockBorderDrag         determines whether the user can drag the clock around
                         by the border.

kclockBack               bitmap to draw for the back of the clock.

kclockBmpTile            uses the dimensions specified in the step instead of
                         the bitmap dimensions. tiles the sections of the
                         bitmap needed. uses 'edge scaling'.

kclockBmpStretch         the same as kclockBmpTile but stretches the sections
                         of the bitmap needed.

kclockBg                 first bg color. used to paint the back of the clock

kclockBgTo               second bg color. if this is different than Bg,
                         gradient will be drawn

kclockHilight            the left and top border color. not used if bitmap is
                         specified.

kclockShadow             right and bottom border color. not used if bitmap is
                         specified.

kclockText               color of the text used for the clock display.

kclockTextShadowClr      color of the text's shadow.

kclockFont               font face used in the clock's display.

kclockFontSize           font size used in the clock's display.

kclockTextJustify        text justification within dispRect. Either "left",
                         "right", or "center"

kclockBold               determines if the text is displayed as bold.

kclockItalic             determines if the text is displayed as italic.

kclockTextShadow         determines whether a shadow is displayed under the
                         clock's text.

kclockTextShadowOff      offset of the shadow of the clock's text, if
                         displayed.

kclockGradType           gradient type. either "vertical", "horizontal", or
                         "diagonal".

kclockFormat             format of the time displayed on the clock. Detects
                         newline character '\n'.

kclockInterval           interval of update for the time displayed.

kclockTimeChange         integer to add to the hours to display. accepts
                         negative numbers. (Suggested by Mulvane).

kclockLeftClick          action performed on left clicking the face of the
                         clock.

kclockMiddleClick        action performed on middle clicking the face of the
                         clock.

kclockRightClick         action performed on right clicking the face of the
                         clock.

kclockMouseEnter         action performed when mouse cursor hovers over main
                         client area of the clock (any area not attributed to
                         the border).

kclockMouseExit          action performed when mouse cursor exits the main
                         client area of the clock.

kclockHidden             determines whether the clock is visible upon startup.

kclockOnTop              determines whether the clock is on top of other
                         windows.

kclockOnBottom           determines whether the clock is under all other
                         windows.

kclockInBox              set this to true if you're going to use kClock inside
                         an LsBox kClock does not currently read any settings
                         from the box file, so put all commands into the
                         step.rc file. also, make sure kClock2.dll is loaded
                         before creating the box you intend to hook it into.
                         see notes on hooking kClock into an LsBox.



Bang Commands
-------------
You can control most of the aspects of kClock via the bang commands. The only
commands that take parameters are !kclockMove and !kclockSet.

!kclockHide              Hides the kclock window.

!kclockShow              Shows the kclock window.

!kclockToggle            Toggles the visibility of the kclock window.

!kclockLeftClick         Executes the left click command.

!kclockMiddleClick       Executes the middle click command.

!kclockRightClick        Executes the right click command.

!kclockMove              String is in the format "x y w h". If you need to
                         change one parameter, set all previous to their
                         character, e.g. "!kclockMove x y 50 25". Recognizes
                         the '+' character and will increment the parameter by
                         the given number. Also recognizes '+-' in order to
                         decrement the parameter by the given number.
                         "!kclockMove +10 +-25 w 20"

!kclockExecute           This bang will execute the arguments given to it,
                         after replacing any time format codes with the
                         appropiate values. E.g.:
                         !kclockExecute !Alert "%A" "Weekday" will popup an
                         alert box with the current weekday name in it.
                         E-vars will be expaned. Intereting use:
                         !kclockExecute !Alert "$kclockFormat$" "time"
                         Note that kclockTimeChange affects the values
                         returned.

!kclockSet               String is in the format "setting value", e.g.
                         "!kclockSet bgcolor 444444". Possible settings: back,
                         bgcolor, bgcolorto, hilight, shadow, textcolor,
                         textshadow, textshadowclr, textshadowoff, format,
                         leftclick, rightclick, middleclick, ontop, onbottom,
                         mouseenter, mouseexit, and timechange. Possible values
                         are the same as the step command values. Exceptions:
                         "back" will accept ".none" to remove any bitmap
                         background, e.g. "!kclockSet back .none".

!kclockBoxHook           this should only be used within a .box file. see notes
                         on hooking kclock into an LsBox.


LsBox Hook
----------
As of version 1.6, kClock can now be "hooked" into an LsBox. This means the
kClock display will show up as it normally would, with background bitmaps,
colours, gradients, etc, but it will show up inside the box you hook it into.
It will also drag with the box.

First, make sure that kclock.dll is loaded BEFORE the LsBox you're hooking it
into is created. Then, you need two extra commands to do this, one inside the
step.rc file, and one inside the .box file you're planning to load. Put the
command:

kclockInBox    true

into the step.rc file, and the command:

*ModuleHook !kclockBoxHook

into the .box file. After doing this, when you create the LsBox, kClock will
appear inside it.

Please note a few things when doing this. Because of the nature of LsBox and
child windows, it would probably be a bad idea to turn "kclockBorderDrag" on if
you load it into an LsBox. Keep in mind that kClock is still loaded before you
create the box. When the box is created, it simply "catches" or "hooks" kClock.
This may cause problems in some instances. kClock does not currently read any
settings from the box file. All kClock specific settings need to be set inside
the step.rc file. Hopefully in a future version of kClock it will be able to
read settings from the .box file.



Time Formatting Codes
---------------------
Taken directly from MSDN


%a   Abbreviated weekday name

%A   Full weekday name

%b   Abbreviated month name

%B   Full month name

%c   Date and time representation appropriate for locale

%d   Day of month as decimal number (01  31)

%H   Hour in 24-hour format (00  23)

%I   Hour in 12-hour format (01  12)

%j   Day of year as decimal number (001  366)

%m   Month as decimal number (01  12)

%M   Minute as decimal number (00  59)

%p   Current locales A.M./P.M. indicator for 12-hour clock

%S   Second as decimal number (00  59)

%U   Week of year as decimal number, with Sunday as first day of week (00  53)

%w   Weekday as decimal number (0  6; Sunday is 0)

%W   Week of year as decimal number, with Monday as first day of week (00  53)

%x   Date representation for current locale

%X   Time representation for current locale

%y   Year without century, as decimal number (00  99)

%Y   Year with century, as decimal number

%z   Time zone name. No characters if time zone is unknown.

%Z   Time zone abbreviation. No characters if time zone is unknown.

%%   Percent sign



Future
------
-Add more parameters to !kclockSet.
-Add uptime parameters to format settings.



History
-------

kClock v1.1
-----------
2002-09-16
     -Released kclock v1.1. Unfinished, but looking for bug reports.


kClock v1.2
-----------
2002-09-20
     -kClock v1.2 finished and released.


kClock v1.4
-----------
2002-09-21
     -Added "+-" syntax to !kclockMove bang. Subtracts value from parameter.
     -Changed default format to "%I:%M:%S"
2002-09-30
     -Added the "kclockTimeChange" setting to step commands and "timechange"
      parameter to !kclockSet (a la Mulvane's request).
     -Switched from GetRCCoordinate to my own code, as GetRCCoordinate didn't
      seem to be working quite correctly. (I didn't actually do this today, but
      i've forgotten when exactly i did do it).
2002-10-06
     -Added "kclockBmpTile" and "kclockBmpStretch"
     -!kclockMove now reconfigures the kclockDispRect as well as moving and/or
      resizing the window.
     -I think I've solved a problem with the window "flashing" occasionally.


kClock v1.6
-----------
2002-10-22
     -Added "kclockMouseEnter" and "kclockMouseExit" to the step commands, and
      "mouseenter" and "mouseexit" to !kclockSet parameters.
     -Added functionality for hooking kClock into a box. Very simple.
     -kClock now sets two e-vars upon being dragged: $kclockX$ and $kclockY$.
2002-10-25
     -I believe I've fixed a bug with the text not displaying correctly under
      Win9x (Thanks to Maur and ArielMT for massive help).
2002-10-27
     -!kclockExecute is now functional.