SkinBox 1.0 beta 2 by RabidCow


This is meant to be a base for furthur module development, but it
might be somewhat useful as a module on its own.  This will create
(as it is compiled) any number of windows which can be drawn with
a bitmap and have a number of script actions assigned to them.
Nearly everything can be changed without recycling.

Supports lsbox, multiple monitors, true and simulated alpha (no
per-pixel alpha yet), and ^@variable^ replacement in script actions.

Source code is included and meant to be distributed under the terms
of the GNU GPL, version 2 or later, but I'm too lazy to add all the
notices just yet.  There are four options that can be switched on
and off independently: SINGLE_WINDOW, NO_SCRIPT_ACTIONS, NO_SKIN,
and standard ls vs. named-monitor/lstools litestep.  The included
dll has all these switched off, for standard ls, which produces
the largest file at 20.0k.


rabidcow@juno.com



Config options ------------------------------------------------

#### Module

SkinBoxInBox [bool]

  Tells single-window SkinBox to not create main window right away.
  (ignored for multi-window builds)


SkinBoxHoverTime <int>

  Module-wide hover time in msec, defaults to Windows setting.


SkinBoxOnInit <action>
SkinBoxOnQuit <action>

  Actions for module init and quit.

SkinBoxOnCreate <action>
SkinBoxOnDestroy <action>
SkinBoxOnMouseOver <action>
SkinBoxOnMouseOut <action>
SkinBoxOnMouseMove <action>
SkinBoxOnHover <action>
SkinBoxOnUnhover <action>
SkinBoxOnL/M/RButtonDown <action>
SkinBoxOnL/M/RButtonUp <action>

  Default actions for windows.


#### Window

*SkinBox <box name> [monitor name] [<x> [<y> [<width> [<height> [<#flags>]]]]]

  Creates a box.  For single-window builds, this is ignored, instead
  there is a default box named "SkinBox" Individual named parameters
  below take precedence over ones specified here.
  #flags are:
	T OnTop
	L TrueAlpha
	H hidden
  Also, any numbers in the #flags are interpreted as group.

<box name>OnMonitor <monitor>
<box name>X <x>
<box name>Y <y>
<box name>Width <width>
<box name>Height <height>

  Sets window position.

<box name>Alpha <amount>

  Sets fake or true alpha amount.  Can be 0-255, 0%-100%, -255 to -0, etc.

<box name>TrueAlpha [bool]

  Creates the window as a "layered" window to allow true "win2k"
  transparency.  This is ignored if not supported by the system.

<box name>OnTop [bool]
<box name>Hidden [bool]

  Set the initial show or ontop state.

<box name>HoverTime <int>

  Override default hover time for this window.
  (ignored for single-window builds)

<box name>OnCreate <action>
<box name>OnDestroy <action>
<box name>OnMouseOver <action>
<box name>OnMouseOut <action>
<box name>OnMouseMove <action>
<box name>OnHover <action>
<box name>OnUnhover <action>
<box name>OnL/M/RButtonDown <action>
<box name>OnL/M/RButtonUp <action>

  Override default actions for this window.
  (ignored for single-window builds)

<box name>Group <int>

  Sets window group number.  Group 0 is "no group"
  (ignored for single-window builds)

<box name>SkinBitmap <bitmap>
<box name>SkinEdge <left> [<top> <right> <bottom>]
<box name>SkinEdgeLeft <int>
<box name>SkinEdgeTop <int>
<box name>SkinEdgeRight <int>
<box name>SkinEdgeBottom <int>
<box name>SkinTile [bool]

  Set the skin.
  (ignored for NO_SKIN builds)


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

!SkinBoxMove <box name> [monitor] <x> <y>
!SkinBoxSize <box name> <width> <height>
!SkinBoxOnTop <box name> [state]
!SkinBoxAlpha <box name> <amount>
!SkinBoxShow <box name> [state]
!SkinBoxLoadBoxHook [params] <box filename> <box HWND>
!SkinBoxExec <box name> <action>
!SkinBoxAction <box name> <action type> [action]
!SkinBoxBitmap <box name> <bitmap>
!SkinBoxBitmap <box name> :<HBITMAP> [<left> <top> [<width> <height>]]
!SkinBoxEdge <box name> <left> [<top> <right> <bottom>]
!SkinBoxTile <box name> [state]

For LoadBoxHook [params]:
  One parameter is recognized, "name=" to set the name of the box:
  *ModuleHook !LoadBoxHook name=<box name>
  If not given, the name is taken from the box filename, without extension.

For <box name>:
  This is omitted for single window builds.  For multiple window
  builds, you can specify * for all windows or . for no window.
  (where applicable):
    !SkinBoxExec . !alert "^@_n^: ^@_b^"
  You may also specify a group number, or a
  name with wildcards, or a list of box names in brackets:
    [one tw* 3]
  (box one, all boxes with names starting with tw, and group 3)

For <HBITMAP>:
  You may specify an HBITMAP converted to a decimal number preceded
  by a colon ':'.  The box will create a copy of this bitmap, the
  caller must free the original.  You can follow the handle by up
  to 4 coordinates to specify a clipping rectangle.
  Setting the bitmap to :. will clear it.

For <action type>:
  Create, Destroy, MouseOver, MouseOut, MouseMove, Hover, Unhover,
  L/M/RButtonDown, L/M/RButtonUp

For <action type> on window .:
  Any of the above or Init, Quit

For [action]:
  The action is cleared if this is left out.  Note for windows this
  will cause them to use the actions for the . window if there area
  any.

For <x>, <y>, <width>, <height>, <amount>, etc:
  May be anything recognized by ParseCoordinate.


^@variables^ --------------------------------------------------


^@_n^ module name
^@_v^ module version
^@_a^ module author
^@_b^ module build type

^@#a^ apostrophe: '
^@#c^ caret: ^
^@#d^ dollar sign: $
^@#n^ newline
^@#q^ double quote: "

^@ka^ alt key status, true or false
^@kc^ ctrl key
^@km^ context menu key
^@ks^ shift key
^@kw^ windows key
^@kal^ left alt key
^@kar^ right alt key
(etc.)

^@mx^ mouse x pos, rel to window
^@my^ mouse t pos, rel to window
^@mxs^ mouse x pos, rel to screen
^@mys^ mouse y pos, rel to screen
(need to fix that and add a rel to desktop)

^@ix^ window x pos
^@iy^ window y pos
^@isx^ window width
^@isy^ window height
^@ih^ window handle
^@in^ window name
^@ig^ window group number
^@ib^ handle of window's display bitmap
^@ik^ handle of window's skin bitmap


Funky Tricks --------------------------------------------------


Change alpha on mouseover:

SkinBoxOnMouseOver !SkinBoxAlpha ^@in^ 100%
SkinBoxOnMouseOut !SkinBoxAlpha ^@in^ 33%

(works for single- or multi-window builds)



Use one box to cache images for mouseovers for other boxes:

*SkinBox cache 0 0 0 0 #h
cacheBitmap $img$image.png

*SkinBox one 0 0 16 16 #t
oneOnMouseOver !SkinBoxExec cache !SkinBoxBitmap one :^@#c^@ik^@#c^ 0 16 16 16
oneOnMouseOut !SkinBoxExec cache !SkinBoxBitmap one :^@#c^@ik^@#c^ 0 0 16 16
oneOnCreate !SkinBoxExec cache !SkinBoxBitmap one :^@#c^@ik^@#c^ 0 0 16 16

*SkinBox two 16 0 16 16 #t
twoOnMouseOver !SkinBoxExec cache !SkinBoxBitmap one :^@#c^@ik^@#c^ 16 16 16 16
twoOnMouseOut !SkinBoxExec cache !SkinBoxBitmap one :^@#c^@ik^@#c^ 16 0 16 16
twoOnCreate !SkinBoxExec cache !SkinBoxBitmap one :^@#c^@ik^@#c^ 16 0 16 16
;                                                 :   ^  @ik  ^

The ^@#c^@ik^@#c^ gets changed by the action trigger to ^@ik^,
then by !SkinBoxExec to the bitmap handle.



Display a picture of the current "mini" desktop from a horizontal
RabidVWM 1.0:

deskwidth $VWMWidth/VWMDesksX$
deskheight $VWMHeight/VWMDesksY$
!VWMExec !SkinBoxBitmap one :^@ib^ ^@#d^(^@cd^-1)*$deskwidth$^@#d^ 0 $deskwidth$ $deskheight$
;                           bitmap    $ deskno   *  width      $   0    width       height



If you want nice, easy to remember names instead of the ^@...^,
you can define $vars$ for them:
WindowPosX ^@ix^

!skinboxexec one !alert $WindowPosX$



Drag a box using the right mouse button:

SkinBoxOnRButtonDown !SkinBoxAction ^@in^ mousemove !SkinBoxMove ^@in^ ^@#c^@#d^@#c^^@#c^@mxs^@#c^-^@mx^^@#c^@#d^@#c^ ^@#c^@#d^@#c^^@#c^@mys^@#c^-^@my^^@#c^@#d^@#c^
SkinBoxOnRButtonUp !SkinBoxAction ^@in^ mousemove

This is a bit sloppy, but mostly works (only on primary monitor),
and will work the same with single- or multi-window builds.

This: ^@#c^@#d^@#c^^@#c^@mxs^@#c^-^@mx^^@#c^@#d^@#c^
In OnRButtonDown becomes this: ^@#d^^@mxs^-32^@#d^
(if the mouse is 32 pixels from the left edge of the box when the button is pressed)
Then, in OnMouseMove (set by !SkinBoxAction) becomes: $200-32/2$
(if the mouse is 200 pixels from the left edge of the screen while being dragged)
And when !SkinBoxMove is executed by LiteStep, that becomes: 184
which !SkinBoxMove can understand.

The only problem with this is when the calculated coordinate comes out being negative.

Another idea might be to use something like:
SkinBoxOnRButtonUp !execute [!SkinBoxAction ^@in^ mousemove][!textreplace "step.rc" "^@in^X .*" "^@in^X ^@ix^"][!textreplace "step.rc" "^@in^Y .*" "^@in^Y ^@iy^"]
to save the new position to step.rc (but don't expect it to be res. independent)
(For single-window builds, use "SkinBox" for the two ^@in^ in !textreplace)



