world.WindowRectOp

MUSHclient script function (Method) — introduced in version 4.34

Draws a rectangle in a miniwindow

Prototype

long WindowRectOp(BSTR WindowName, short Action, long Left, long Top, long Right, long Bottom, long Colour1, long Colour2);

Data type meanings

Description

This draws a rectangle in various styles, controlled by the Action parameter.

Note that changes to miniwindows will not become visible until the output window is redrawn. This happens when new (visible) lines arrive from the MUD, or if you call WindowShow, or Redraw.

Parameters:

WindowName - the name of an existing miniwindow.

Action - what sort of rectangle to draw, as follows:

1 = Frame by a single pixel wide line in Colour1
2 = Fill the entire rectangle by Colour1
3 = InvertRect - the colour on the miniwindow inside that rectangle is inverted
4 = Draw a "3D-style" rectangle in two colours, a single pixel wide (Colour1 is top and left edge colour, Colour2 is bottom and right edge colour)
5 = Draw Edge (draws a 3d-style edge with optional fill)
6 = Flood Fill Border (fills to border specified by Colour1) - the filling commences at the pixel designated by Left, Top and continues until it runs out of pixels that colour. The fill colour is specified by Colour2.
7 = Flood Fill Surface (fills while on surface specified by Colour1) - the filling commences at the pixel designated by Left, Top and continues until it is on pixels that colour. The fill colour is specified by Colour2.

Left, Top, Right, Bottom - describes the rectangle to be drawn.

Colour1 - the colour to draw the rectangle in (or fill it). For Action 5, this must be one of:

5 : Raised
6 : Etched
9 : Bump
10 : Sunken

Colour2 - the colour used by Action 4 for the bottom and right edge. Also it is the colour used for flood filling (Actions 6 and 7). For Action 5, this is:

0x03 (3) top left
0x06 (6) top right
0x09 (9) bottom left
0x0c (12) bottom right
0x0f (15) rect

Diagonal lines:

0x13 (19) diagonal - end top left
0x16 (22) diagonal - end top right
0x19 (25) diagonal - end bottom left
0x1c (28) diagonal - end bottom right

For Action 5 you can also add in the following values to modify the behaviour of the drawn rectangle:

0x0800 - Fill in the middle
0x1000 - For softer buttons
0x4000 - For flat rather than 3D borders
0x8000 - For monochrome borders

For more information, see:

http://www.gammon.com.au/mushclient/mw_shapes.htm

Lua example

WindowRectOp (win, 1, 20, 20, 70, 70, ColourNameToRGB("blue"))  -- outline

WindowRectOp (win, 2, 50, 20, 80, 80, ColourNameToRGB("green"))  -- filled

WindowRectOp (win, 3, 5, 5, 90, 90, 0)   -- invert 

WindowRectOp (win, 4, 50, 30, 70, 70, ColourNameToRGB("springgreen"), ColourNameToRGB("green"))

WindowRectOp (win, 5, 30, 30, 70, 70, 5, 15)  -- raised, not filled

WindowRectOp (win, 5, 30, 30, 70, 70, 5, 15 + 0x800)  -- raised, filled

WindowRectOp (win, 5, 30, 30, 70, 70, 5, 15 + 0x800 + 0x1000)  -- raised, filled, softer

WindowRectOp (win, 5, 30, 30, 70, 70, 5, 15 + 0x800 + 0x1000 + 0x4000)  -- raised, filled, softer, flat

WindowRectOp (win, 5, 30, 30, 70, 70, 6, 15 + 0x800)  -- etched, filled

Lua notes

You can use the following constants for the action:

miniwin.rect_frame = 1
miniwin.rect_fill = 2
miniwin.rect_invert = 3
miniwin.rect_3d_rect = 4
miniwin.rect_draw_edge = 5
miniwin.rect_flood_fill_border = 6
miniwin.rect_flood_fill_surface = 7

You can use the following constants for the Colour1 parameter (argument 7) for action 5 (rect_draw_edge):

miniwin.rect_edge_raised = 5
miniwin.rect_edge_etched = 6
miniwin.rect_edge_bump = 9
miniwin.rect_edge_sunken = 10

You can use the following constants for the Colour2 parameter (argument 8) for action 5 (rect_draw_edge):

miniwin.rect_edge_at_top_left = 3
miniwin.rect_edge_at_top_right = 6
miniwin.rect_edge_at_bottom_left = 9
miniwin.rect_edge_at_bottom_right = 12
miniwin.rect_edge_at_all = 15
miniwin.rect_diagonal_end_top_left = 19
miniwin.rect_diagonal_end_top_right = 22
miniwin.rect_diagonal_end_bottom_left = 25
miniwin.rect_diagonal_end_bottom_right = 28

You can add in these additional constants to the Colour2 parameter (argument 8) for action 5 (rect_draw_edge):

miniwin.rect_option_fill_middle = 2048
miniwin.rect_option_softer_buttons = 4096
miniwin.rect_option_flat_borders = 16384
miniwin.rect_option_monochrom_borders = 32768

Return value

eNoSuchWindow - no such miniwindow

eUnknownOption - Action not in list above

eBadParameter - edge parameter invalid

eOK - completed OK

Return code meanings

Related topic

MiniWindows

See also

FunctionDescription
WindowArcDraws an arc in a miniwindow
WindowBezierDraws a Bézier curve in a miniwindow
WindowCircleOpDraws ellipses, filled rectangles, round rectangles, chords, pies in a miniwindow
WindowCreateCreates a miniwindow
WindowDrawImageDraws an image into a miniwindow
WindowLineDraws a line in a miniwindow
WindowPolygonDraws a polygon in a miniwindow