SkinBox 1.0 beta 4

by RabidCow

General purpose template module. This module will create any number of skinned windows. Any of these can have specific actions assigned to them, can have their skin, position, size, alpha, etc changed without recycling. You can also create and destroy windows while the module is running.

Contents



Config Options



*SkinBox <name> [<monitor>] [<x>] [<y>] [<width>] [<height>] [<#flags>]
Creates a window, giving its initial position, size, and flags:
T OnTop
L TrueAlpha
H Hidden
Any numbers in the #flags will be interpreted as Group.
<box name>OnMonitor <monitor>
<box name>X <x>
<box name>Y <y>
Sets the initial position of the window. This will override the value given in the *SkinBox line.
<box name>Width <width>
<box name>Height <height>
Sets the initialsize of the window. This will override the value given in the *SkinBox line.
<box name>Alpha <amount>
Sets fake or true alpha amount.
<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 [<ontop>]
<box name>Hidden [<hidden>]
Sets the initial z-position and visibility of the window. These override any flags given on the *SkinBox line.
<box name>Group <group>
Sets the group number for this window. Group 0 means no group.

Skin Config



<box name>Bitmap <bitmap>
Sets the initial skin bitmap.
<box name>Edge <edge>
<box name>Edge <left> <top> <right> <bottom>
Sets the edge of the bitmap that is not stretched or tiled.
<box name>EdgeLeft <edge>
<box name>EdgeTop <edge>
<box name>EdgeRight <edge>
<box name>EdgeBottom <edge>
Sets the edge for a specific side, useful to have one edge different from the rest.
<box name>Tile [<tile>]
Sets whether the center of the bitmap is stretched or tiled.
<box name>Color [<style>] [<face color>] [<highlight color>] [<shadow color>] [<highlight 2>] [<shadow 2>]
<box name>ColorStyle <style>
<box name>ColorFace <face color>
<box name>ColorLight <highlight color>
<box name>ColorDark <shadow color>
<box name>ColorBrLight <highlight 2>
<box name>ColorDkDark <shadow 2>
Sets the colors to paint with if no bitmap is assigned. The light color is used to draw the top and left borders, the dark to draw the right and bottom borders.

The style param can be any of: flat, raised, sunken, ridged, groove, raisedbutton, or sunkenbutton. The second highlight and shadow are only used for the button style.

Default values will draw the box like a regular system button.

Script Actions



SkinBoxOnInit <action>
SkinBoxOnQuit <action>
Actions to perform when the module finishes initialization or begins shutting down. These actions can contain variables to replace.
SkinBoxOnCreate <action>
SkinBoxOnDestroy <action>
Global action when any window is created or destroyed, any window-specific action will override this.
SkinBoxOnMouseOver <action>
SkinBoxOnMouseOut <action>
SkinBoxOnMouseMove <action>
Global action when the mouse enters, leaves, or moves over any window that does not have a specific action.
SkinBoxOnHover <action>
SkinBoxOnUnhover <action>
Global action when the mouse hovers or stops hovering over any window that does not have a specific action.
SkinBoxHoverTime <msecs>
Sets the module-wide delay for mouse hover, defaults to the system setting.
SkinBoxOnLButtonDown <action>
SkinBoxOnRButtonDown <action>
SkinBoxOnMButtonDown <action>
Global action when the left, right, or middle mouse button is pressed in any window that does not have a specific action.
SkinBoxOnLButtonUp <action>
SkinBoxOnRButtonUp <action>
SkinBoxOnMButtonUp <action>
Global action when the left, right, or middle mouse button is released in any window that does not have a specific action.
<box name>OnCreate <action>
<box name>OnDestroy <action>
Action to perform when the window is created or destroyed.
<box name>OnMouseOver <action>
<box name>OnMouseOut <action>
<box name>OnMouseMove <action>
Action to perform when the mouse enters, leaves, or moves over the window.
<box name>OnHover <action>
<box name>OnUnhover <action>
Action to perform when the mouse hovers or stops hovering over the window.
<box name>HoverTime <msecs>
Delay before the mouse is considered hovering.
<box name>OnLButtonDown <action>
<box name>OnRButtonDown <action>
<box name>OnMButtonDown <action>
Action to perform when the left, right, or middle mouse button is pressed.
<box name>OnLButtonUp <action>
<box name>OnRButtonUp <action>
<box name>OnMButtonUp <action>
Action to perform when the left, right, or middle mouse button is released.

Bang Commands



!SkinBoxMove <box name> [<monitor>] [<x>] [<y>] [<width>] [<height>]
Changes the position and size of the window.
!SkinBoxSize <box name> <width> <height>
Changes the size of the window.
!SkinBoxOnTop <box name> [<state>]
Sets or toggles whether the window floats above normal windows.
!SkinBoxAlpha <box name> <amount>
Changes the alpha transparency amount.
!SkinBoxShow <box name> [<state>]
Shows or hides the window.
!SkinBoxLoadBoxHook ... <name=> <box file> <box HWND>
Loads the window into an lsbox.
!SkinBoxExec <box name> <command>
Executes a command, replacing variables in this window's context.
!SkinBoxAction <box name> <action name> [<command>]
Sets the action for a triggered event.
!SkinBoxBitmap <box name> <bitmap>
Sets the bitmap to draw the window skin.
!SkinBoxEdge <box name> <edge>
!SkinBoxEdge <box name> <left> <top> <right> <bottom>
Sets the edges of the skin, this area is not stretched or tiled.
!SkinBoxTile <box name> [<state>]
Toggles whether the center part of the bitmap is stretched or tiled to cover the window.
Sets whether the center of the bitmap is stretched or tiled.
!SkinBoxColor <box name> [<style>] [<face color>] [<highlight color>] [<shadow color>] [<highlight 2>] [<shadow 2>]
Sets the colors to paint with if no bitmap is assigned. The light color is used to draw the top and left borders, the dark to draw the right and bottom borders.

The style param can be any of: flat, raised, sunken, ridged, groove, raisedbutton, or sunkenbutton. The second highlight and shadow are only used for the button style.
!SkinBoxCreate <name> [<monitor>] [<x>] [<y>] [<width>] [<height>] [<#flags>]
Create a new window, same syntax as *SkinBox lines.
!SkinBoxDestroy <box name>
Destroy a window.

Argument Types



Integer
A simple decimal integer.
Position, Size
A position, usually relative to the screen. This can be a simple integer, or it can be a negative number for relative to the right/bottom edge. If you add a C suffix, it will be relative to the center, or an R for relative to the current or default value. It can also be a percent, or a percent plus or minus some offset.

Examples, given a range of 0-255:
    50     value =           50
    50c    value = 50%+50 = 157
    50r    value = 50 more than it was before
    50%    value = 50%    = 127 (rounded down)
    50%-25 value = 50%-25 = 102
   -50     value = 255-50 = 205
   -50c    value = 50%-50 =  77
   -50%    value = 50%    = 128 (rounded up)
The difference between 50% and -50% is so you can create a box 5% wide that rests up against the right side of the screen. 95% would be off by a few pixels due to rounding, but -5% would put it exactly at the edge.

You can force a postion off screen with things like 0%-12 and 100%+15.
Monitor
The name of a monitor defined by MonitorNames. A monitor name must begin with a letter. If no monitor is given, the primary is taken by default on startup. The special name "all" is reserved and refers to the total combined desktop area.
Boolean
A true/false setting. Leaving this command out entirely will default to false, specifying the command with no parameters sets it to true. Other valid values are: true, false, on, off, yes, no, and toggle.
Color
A six to eight digit hex number specifying the red, green, and blue components and optionally alpha. (order is RRGGBBAA) These colors are the same as for HTML/CSS.

Other possibilities include a system color index preceded by a colon, or the special index :-1 to use the face color. Colors can also be scaled with a + or - value (in decimal):
                RED  GREEN  BLUE  ALPHA
  808080        128   128   128   255
  80808080      128   128   128   128
  808080+20     148   148   148   255
  80808080+20   148   148   148   128 (alpha does not scale)
  :13            56    88   137   255 (system "select" color)
  :13-20         36    68   117   255
  :13@80         56    88   137   128 (set alpha in hex)
  :-1+40          (face color + 40)
Note that colors preceded by : will automatically be recalculated (including scaling) when their base color changes, for example if you change the system colors.
Command
This can be any bang command or executable file, with or without parameters. If the filename contains spaces, you must put quotes around it. If you want to execute more than one action, either use a scripting module to bind them together into one bang command, or use !execute [command 1][command 2][etc].

You may include ^@vars^ anywhere in this and they will be substituded automatically.

Change Log




2002-12-03:

 - rewrote PremultiplyAlpha with MMX (probly could be paired better)
 - fixed premultiply for fake alpha

2002-12-01:

 - added enum parser and made colors use it

2002-11-2?:

 - made colors adapt to system color changes

2002-11-22:

 - added solid color painting if no bitmap is available
 - tweaked bool parser
 - readded !Size
 - added !Color
 - fixed LSTransEdgeBlt for cases where the center area was 0 wide/high
 - fixed starting on bottom with TrueAlpha

2002-11-17:

 - fished rewriting readconfig, started making bang commands use the same parsers
 - added logging to a file if you compile with #undef NDEBUG

2002-11-16:

 - more work on rewriting readconfig
 - perfect adjustment to changing screen dimensions:
   1. create skinbox at 50%+10 on primary monitor
   2. move it by -60r
   3. move it to the secondary monitor (different dimensions, whatever)
      it will be 50 pixels left of center
   4. go into control panel and detach the secondary monitor
      skinbox will move to 50 pixels left of center of primary monitor
   5. reattach secondary monitor
      skinbox will move to 50 pixels left of center of secondary monitor
   6. move secondary monitor, window stays in the right place
   boo. yah.

2002-11-15:

 - started rewriting readconfig to be easier to modify programmatically


***** beta 2 *****

2002-11-13:

 - added !Create and !Destroy (multiwindow only)
 - added auto-generated documentation

2002-11-12:

 - added optional width and height params to !Move so you can move and size
   in one command with no flicker.

2002-11-09:

 - added position vars relative to screen, monitor, desk, and parent
 - register bangs before creating windows so they can be called from OnCreate
   and unregister them after destroying windows, for OnDestroy


^@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 (0,0 on primary monitor)
^@mys^ mouse y pos, rel to screen
^@mxp^ mouse x pos, rel to parent (of skinbox)
^@myp^ mouse y pos, rel to parent
^@mxd^ mouse x pos, rel to desktop (0,0 on top,leftmost monitor)
^@myd^ mouse y pos, rel to desktop
^@mxm^ mouse x pos, rel to monitor (of skinbox)
^@mym^ mouse y pos, rel to monitor

^@ix^ window x pos
^@iy^ window y pos
^@ixs^ window x pos, rel to screen (0,0 on primary monitor)
^@iys^ window y pos, rel to screen
^@ixp^ window x pos, rel to parent (of skinbox)
^@iyp^ window y pos, rel to parent
^@ixd^ window x pos, rel to desktop (0,0 on top,leftmost monitor)
^@iyd^ window y pos, rel to desktop
^@ixm^ window x pos, rel to monitor (of skinbox)
^@iym^ window y pos, rel to monitor
^@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