Picture Windows

 

The picture window is a special type of custom window that can display a combination of text, graphics, and pictures, and can trigger script events relating to mouse clicks and movements.

 

Once you have opened a picture window using the /window command, you can use the following commands and identifiers to draw and monitor activity in this window.

 

Drawing commands

 

/drawdot -ihnr @ <color> <size> <x y> [<x y>...]

Draws a dot using the specified color and size at the x,y co-ordinates. Multiple co-ordinates can be provided.

 

The -i switch draws in inverse mode.

 

The -h switch highlights the windows icon if it's minimized.

 

The -n switch prevents the display from being updated immediately. This allows you to make changes to the window in the background and then display the results only when you've finished. You can update the display by using any of the /draw commands with only the window name specified.

 

The -r switch indicates that the color is in RGB format. You can use $rgb(N,N,N) to create an RGB value.

 

The whole window can be cleared by using the /clear command, eg. /clear @name. You can also specify the -n switch in /clear to delay the effect as described above.

 

/drawline -ihnr @ <color> <size> <x y> <x y> [<x y>...]

Draws a line from the first <x y> co-ordinate to the second, if more co-ordinates are specified, the line is continued. The switches are the same as those in /drawdot.

 

/drawrect -ihnrfecd @ <color> <size> <x y w h> [<x y w h>...]

Draws a rectangle at the specified co-ordinates of the specified width and height. If more co-ordinates are specified these are also drawn as separate rectangles.

 

The -f switch fills the rectangle with the current color.

 

The -e switch draws an Ellipse instead of a rectangle. You can draw a filled ellipse if you also specify the -f switch.

 

The -c switch draws a focus rectangle.

 

The -d switch draws a rounded rectangle, using the format /drawrect -d x y w h [w h],  where w and h are the width and height of the ellipse used to draw the corners.

 

The remaining switches are the same as those in /drawdot.

 

/drawfill -ihnrs @ <color> <color> <x y> [filename] [<x y>...]

Fills an area with the specified color starting at the specified co-ordinates.

 

The -s switches indicates that the second color parameter is the color that should be filled (surface fill). If no -s is specified, the second color is the border color at which filling should stop (border fill).

 

The optional [filename] specifies a bitmap .BMP file that is 8 by 8 pixels in size and is used as a fill pattern.

 

The remaining switches are the same as those in /drawdot.

 

/drawtext -hnrpboc @ <color> [color] [fontname fontsize] <x y [w h]> <text>

Draws text at the specified co-ordinates.

 

The -p switch processes and interprets color/bold/etc. codes in the text.

 

The -b switch indicates that you have specified the second color parameter as the background color for the text.

 

The -o switch means the specified font should be in bold.

 

The -c switch means that you have specified the [w h] values as the rectangle in which text should be printed. Text will be clipped if it extends beyond this rectangle.

 

The remaining switches are the same as those in /drawdot.

 

Note: If you use a negative number for the font size, it will match the size of fonts in the font dialog.

 

/drawsave -bNqN @ <filename>

This saves the background picture of the specified picture @window to a .bmp filename.

 

The -bN switch allows you to specify the bit depth of the saved file, which can be 1, 4, 8, 16, 24, or 32.

 

The -qN switch allows you to specify the quality of the jpeg file that is being saved, where N is between 1 and 100.

 

/drawscroll -hn @ <x> <y> <x y w h> [<x> <y> <x y w h>...]

Scrolls the region inside the specified rectangle. The first <x> and <y> parameters represent the distance to scroll and can be positive or negative.

 

The remaining switches are the same as those in /drawdot.

 

/drawcopy -ihmnt @ [color] <x y w h> @ <x y [w h]>

Copies part of a picture to a different position in the same window or to another window. If the second [w h] parameters are specified, the picture is stretched/squeezed to fit.

 

The -t switch indicates that you have specified the [color] RGB value as a transparent color in the source bitmap.

 

The -m switch changes the stretch mode quality when the picture is resized.

 

The remaining switches are the same as those in /drawdot.

 

/drawpic -ihmnotsclgN @ [color] <x y [w h]> [x y w h] [N] <filename>

Loads and draws a picture at the specified co-ordinates. The picture can be a graphics file, or an ico/exe/dll file.

 

If the first [w h] are specified, it is stretched or squeezed to fit. The second [x y w h] rectangle specifies which portion of the loaded bitmap should be displayed ie. a bitmap could contain multiple pictures.

 

The -t switch indicates that you have specified the [color] RGB value as a transparent color in the specified bitmap.

 

The -s switch indicates that you have specified the first [w h] parameters (as explained above) to squeeze/stretch the bitmap.

 

The -c switch indicates that the bitmap should be cached. This greatly speeds up subsequent references to this bitmap. If you specify -c and the bitmap is already in the cache, it is loaded and used from the cache, otherwise it is reloaded from the file. You can clear the entire cache with /drawpic -c.

 

The -l switch tiles the picture.

 

The -m switch changes the stretch mode quality when the picture is resized.

 

The -o switch indicates that you have specified the [N] value before the filename represents the index of the icon in the file.

 

The -gN switch attempts to load the large icon in an icon file, if none exists, it loads the small icon. If N is specified, N = 0 loads the small icon, N = 1 loads the large icon, and N = 2 loads the actual icon.

 

If you try to load and cache a bitmap and there are already 30 bitmaps in the cache, the bitmap with the lowest reference count is freed and replaced by the new bitmap.

 

If you try to load a bitmap and there isn't enough memory, mIRC repeatedly frees the least referenced bitmap and tries to load again.

 

The remaining switches are the same as those in /drawdot.

 

/drawrot -hmnbfc @ [color] <angle> [x y w h]

Rotates an area of a bitmap by the specified angle.

 

The -b switch indicates that you've specified the background color value.

 

The -f switch fits the newly rotated bitmap into the original width/height.

 

The -c switch centers the rotated image if -f isn't specified.

 

The -m switch changes the stretch mode quality when the picture is resized.

 

The remaining switches are the same as those in /drawdot.

 

/drawreplace -nr @ <color1> <color2> [x y w h]

Replaces color1 with color2 in the specified picture window.

 

The remaining switches are the same as those in /drawdot.

 

Events and Identifiers

 

Mouse events can be defined in a scripts menu definition, where they must be placed first above all other menu items:

 

menu @test {

 mouse:/echo mouse moved at $mouse.x $mouse.y in $active $1

 sclick:/echo single click at $mouse.x $mouse.y

 dclick:/echo double click at $mouse.x $mouse.y

 uclick:/echo mouse released at $mouse.x $mouse.y

 rclick:/echo single right-click at $mouse.x $mouse.y in $active $1

 lbclick:/echo mouse selected $active $1

 leave:/echo mouse left $leftwin $leftwinwid

 drop:/echo drag and drop at $mouse.x $mouse.y

}

 

The mouse event is triggered when you move a mouse inside a picture window. You can use the $mouse identifier (see below) for the x and y position of the mouse.

 

The sclick event is triggered when you click once inside a picture  window. It will also trigger if you double-click.

 

The dclick event is triggered when you double-click inside a picture window.

 

The uclick event is triggered when a mouse button is released inside a picture window.

 

The lbclick event is triggered when an item is selected in a listbox, either with the mouse or the cursor keys.

 

The leave event is triggered when the mouse is moved outside the borders of a custom window.

 

The drop event is triggered if you clicked in the window, held the button down, moved the mouse, and then let go of the button.

 

$mouse

Returns the x, y position of the current mouse event, and whether the left mouse button, shift key, and/or control key are pressed.

 

Properties: win, x, y, mx, my, dx, dy, key, lb

 

The $mouse identifier can be used in the mouse/click events. For $mouse.key you can use the & bitwise operator to check if the left button, shift key, and/or control key are pressed:

 

if ($mouse.key & 1) echo left button is pressed.

if ($mouse.key & 2) echo control key is pressed.

if ($mouse.key & 4) echo shift key is pressed.

if ($mouse.key & 8) echo alt key is pressed.

if ($mouse.key & 16) echo right mouse button is pressed.

 

The following properties can also be used:

 

The .win property returns the name of the active window.

 

The .x/.y, .mx/.my, and .dx/.dy properties return the x and y position of the mouse relative to the active window, the main mIRC window, and the desktop respectively.

 

The .lb property returns $true if a mouse event occurred over a listbox, or $false if it didn't.

 

$click(@,N)

This stores a history of x,y clicks for a window.

 

Properties: x, y

 

You can use /clear -c @name to clear the history of clicks for a window. If you use $click() with no properties it returns x y.

 

$inellipse(x,y,x,y,w,h)

Returns $true if the point x y is inside the specified ellipse, and $false if it isn't.

 

$inrect(x,y,x,y,w,h)

Returns $true if the point x y is inside the specified rectangle, and $false if it isn't.

 

$inroundrect(x,y,x,y,w,h,w,h)

Returns $true if the point x y is inside the specified rounded rectangle, and $false if it isn't.

 

$inpoly(x,y,a1,a2,b1,b2,...)

Returns $true if the point x y is inside the polygon defined by the specified points, and $false if it isn't.

 

$onpoly(n1,n2,x,y,x,y,...)

Returns $true if two polygons overlap. n1 is the number of points in the first polygon, n2 in the second polygon.

 

$rgb(N,N,N)

Returns an RGB color value for use in /draw commands. If you use only one parameter, it assumes it is an actual RGB color value and returns N,N,N.

 

$getdot(@,x,y)

Returns the RGB color value of the dot at the specified position.

 

$height(text,font,size)

Returns height of text in pixels for the specified font.

 

Note: If you use a negative number for the font size, it will match the size of fonts in the font dialog.

 

$window

Returns the name of the window in the leave menu event which was just left.

 

$pic(filename)

Returns the size, width, and height of a bmp, jpg, or png file.

 

Properties: size, width, height

 

$width(text,font,size,B,C)

Returns width of text in pixels for the specified font.

 

If B is non-zero, the font is bold, if C is non-zero, control codes are processed. Both B and C are optional.

 

Note: If you use a negative number for the font size, it will match the size of fonts in the font dialog.