Terrapin Resources

Widget (WIDGET)

All objects that can be moved around on the Graphics panel (widgets) have a common set of properties. You cannot create a WIDGET object, only objects that are also widgets.

A widget can move, it can be hidden or shown, enabled or disabled, and the size can be changed. Widgets include turtles, controls, and bitmaps.

If the command IS.A object “WIDGET outputs TRUE, the object has the properties listed below. If you for example, ask a BUTTON widget if it is a button or a widget, it would always respond with TRUE:

DECLARE “BUTTON “OK IS.A “OK “BUTTON Result: TRUE IS.A “OK “WIDGET Result: TRUE

This makes it easier to use the correct properties with a widget. A turtle, for example, does not have a TEXT property like a button has, but both share the POSITION property. This way, a Logo program can easily check if a property is OK to use with the help of the IS.A command.

ALIGN

Controls the alignment of a widget in a grid cell.

Description

This property is only present and available if the widget is part of a Grid control; if not, the property is not present, and setting it causes a “normal” property to be created. Its value is a two element list of alignment values. For horizontal alignment, legal values are LEFT, CENTER and RIGHT. For vertical alignments, legal values are TOP, MIDDLE and BOTTOM. Setting the property aligns the widget inside the table cell; not that for alignments to actually work, the widget must be smaller than the table cell itself. You can also use a single word like LEFT to set just one part of the alignment.

Example

PPROP “MY.BUTTON “ALIGN “CENTER

ANCHOR

Controls the anchoring of a widget.

Description

This property anchors the widget relative to the borders of the Graphics panel. For horizontal alignments, validvalues are LEFT, CENTER and RIGHT. For vertical alignments, valid values are TOP, MIDDLE and BOTTOM. Widgets often like to stay at the same position regardless of the size of the Graphics panel. If you anchor a widget at [LEFT TOP], for example, it will stay at the same position and not move if the panel is resized. An anchor of [RIGHT BOTTOM] would cause the widget to move with a constant distance to the right and bottom borders, so if it would be in the panel’s lower right corner, it would stay there.

Note that turtles cannot be anchored; they ignore the ANCHOR property.

Example

GPROP “BUTTON “ANCHOR Result: [CENTER MIDDLE] PPROP “BUTTON “ANCHOR [TOP LEFT]

AUTOWIDTH

Controls the auto-resizing of a widget in a grid cell.

Description

This property is only present and available if the widget is part of a Grid control; if not, the property is not present, and setting it causes a “normal” property to be created. Setting this property to TRUE causes the widget to auto-resize to the width of the cell that contains the widget; if the cell’s size grows, the widget’s width grows as well.

Example

PPROP “My.BITMAP “AUTOWIDTH TRUE

BORDER

Sets or reports the widget’s border color.

Description

Many widgets do not have a visible border by default. For these objects, their border color is returned as a fully transparent black [0 0 0 0]. Setting this property causes a border to appear, or changes a border’s color.

Example

PPROP 0 “BORDER “RED

BOUNDS

Reports the widget’s size, depending on the scale and rotation.

Description

The BOUNDS property reports the size that the widget occupies on screen after applying and scale and heading as a two-element list containing the width and height of the occupied screen area. Note that this is different from the SIZE property, which reports the size of the widget’s image. When a widget is rotated, the BOUNDS property has greater valuer than the SIZE property, because the rotated image takes up more screen space.

Note: In earlier Logo versions, the SIZE property contained the actual size of the widget.

Example

GPROP 0 “BOUNDS Result: [32 32] RT 45 GPROP 0 “BOUNDS Result: [45 45]

COLUMN

Sets or reports the widget’s column number if in a grid cell.

Description

This property is only present and available if the widget is part of a Grid control; if not, the property is not present, and setting it causes a “normal” property to be created. It contains the column number of the widget. Setting the property causes the widget to move to the given cell, where is removes the widget found there. The vacated cell is filled with a new STATICTEXT control. Note that the “PREFS property ARRAYBASE controls the value of the lowest possible index.

Example

PPROP MY.BUTTON “COLUMN 1

CRAWL

Sets or reports the widget’s crawl speed.

Description

CRAWL controls the speed at which the object moves when told to move. If set to a value less than 1, the object moves slower. The value of 0.9999 is about 200 pixels per second. The SETSPEED and SPEED commands work with this property.

Example

PPROP 0 “CRAWL 0.5 FORWARD 100

ENABLED

Enables or disables a widget.

Description

Setting the ENABLED property causes the widget to be disabled. Its appearance changes to indicate that is no longer available for input, and it cannot be edited or clicked.

Example

PPROP “BUTTON “ENABLED FALSE

FONT

Sets or reports the widget’s font.

Description

FONT controls the font that the widget uses to draw text. This is a three-element list of the font name, its size in pixels, and a combination of attribute flags. See the SETFONT command for details. For controls, the property controls the font that the widget uses to display text.

Example

GPROP “BUTTON “FONT Result: [HELVETICA 12 0] PPROP “BUTTON “FONT [TIMES 16 0]

GLOW

Determines whether the widget’s drop shadow appears as a glow effect.

Description

The GLOW property, together with the SHADOW property, sets the widget’s drop shadow to a glow effect.

Example

PPROP 0 “SHADOW 3 PPROP 0 “GLOW “TRUE

HEADING

Controls the widget’s heading.

Description

HEADING reports or sets the widget’s heading as a number between 0 and 359 as degrees. The HEADING and SETHEADING commands use this property.

To lock the heading, see the SHAPELOCK property.

Example

SETH 270 GPROP 0 “HEADING Result: 270

NAME

Sets or reports the object’s alias name.

Description

NAME sets or reports the alias name of the widget. Setting this property changes the object’s alias name, and also sets the TOOLTIP property. The TURTLENAME and SETTURTLENAME commands use this property.

Example

GPROP 0 “NAME Result: 0 PPROP 0 “NAME “JOE ASK “JOE [FD 100]

OPACITY

Controls the opacity value used for colors.

Description

The value of OPACITY is used for colors without any opacity value. The opacity value is a value between 0 (totally transparent, so it is invisible) and 1 (totally opaque). Setting a value lower than 1 makes a drawing, other widgets beneath the widget, or the background shine through.

Example

PPROP 0 “OPACITY 0.5 SETPC “red (STAMPRECT 100 100 TRUE)

ORIGIN

Controls the origin of the widget’s coordinate system.

Description

This property lets you change the home position of a widget (coordinates [0 0]). Usually, this is the center of the Graphics panel, but you can set this home position to anywhere on the Graphics panel.

Example

GPROP 0 “ORIGIN Result: [0 0] PPROP 0 “ORIGIN [100 100]

ORIGINALNAME

Reports the widget’s original name.

Description

The original name of the widget is the name it was given when it was created. For turtles, this is the turtle number; for other widgets, this is the name used in the DECLARE command, or the name that Logo assigned to the object during its creation. The property is read-only.

Example

GPROP 0 “ORIGINALNAME Result: 0

POSITION

Sets or reports the widget’s position.

Description

The position is the coordinate located directly underneath the center of the widget. Setting this property causes the widget to move. The reported values are always integer values.

Example

SETXYY [100 100] GPROP 0 “POSITION Result: [100 100] PPROP 0 “POSITION [0 0]

ROW

Sets or reports the widget’s row number in a grid.

Description

This property is only present and available if the widget is part of a Grid control; if not, the property is not present, and setting it causes a “normal” property to be created. It contains the row number of the widget. Setting the property causes the widget to move to the given cell, where is removes the widget found there. The vacated cell is filled with a new STATICTEXT control. Note that the “PREFS property ARRAYBASE controls the value of the lowest possible index.

Example

PPROP “BUTTON “ROW 0

RUN

Stores a runlist that Logo executes when the widget is clicked.

Description

RUN contains a list of instructions that Logo runs if the widget is clicked, or a control’s item was selected. This list is initially empty. Some controls, like the GRID control, ignore the RUN property.

Example

PPROP “BUTTON “RUN [PR [I HAVE BEEN CLICKED]] PPROP 0 “RUN [PLAY “BIGDOG]

SCALE

Controls the widget’s scaling.

Description

The SCALE property controls the scalling of a widget, which is the sizing factor. A scaling factor of 2, for example, makes a widget twice as big, and a factor of 0.5 makes its size shrink by half. The property value is either a number, or a two element list for different scaling values for the width and height.

The TURTLESIZE and SETTURTLESIZE commands use this property.

Example

PPROP 0 “SCALE 3 TURTLESIZE Result: 3

SHADOW

Controls the widget’s drop shadow.

Description

The SHADOW property sets the widget’s drop shadow. This is a value between 0 and 999, and describes the offset in pixels of the drop shadow. The drop shadow simulates a light source towards the upper left corner of the display. A value of 3, for example, creates a neat little shadow underneath the widget.

Also, you can select a glow effect rather than a shadow by setting the widget’s GLOW property to TRUE.

The SHADOW and SETSHADOW commands use this property.

Example

PPROP 0 “SHADOW 3

SHAPELOCK

Locks or unlocks a widget’s rotation.

Description

If this property is set to TRUE, the widget does not rotate, but keeps its current rotated view when its heading changes.

Example

SETH 45 PPROP 0 “SHAPELOCK TRUE SETH 90 PPROP 0 “SHAPELOCK FALSE

SIZE

Reports or sets the size of the widget’s image size.

Description

SIZE reports the size of the widget’s image size in pixels, without any scaling or rotation taken into account. When setting the size of a widget, scaling and rotation are applied after the size has been set. The SIZE property reports a two-element list, which is the widget’s width and height. If you use a value less that zero when setting the SIZE property, Logo picks the default value for the respective list element. If you, for example, set a button’s size to [100 -1], the button will be 100 pixels wide, and its height depends on the operating system.

Note: Before, the SIZE property returned the actual size of the widget after applying scale and rotation. The property BOUNDS now returns these values, and the SIZE property now reports the widget’s size before applying scaling and rotation.

Example

GPROP 0 “SIZE Result: [32 32] PPROP 0 “SIZE [100 20]

STARTANGLE

Contains the starting angle of a widget if dropped.

Description

STARTANGLE contains the starting angle of the widget if it is dropped from the Toolbox. Some images are, for example, faced to the left; the natural starting angle of such an image is, therefore, 270 degrees.

Example

GPROP “GOAT “STARTANGLE Result: 270

STEPSIZE

Controls the number of pixels per step that the widget moves forward or backwards.

Description

The multiplicand that FORWARD and BACK movements are multiplied with. If you set STEPSIZE to 20, for example, the command FD 1 would move the widget 20 pixels forward.

Example

PPROP 0 “STEPSIZE 20 FD 10 PROP 0 “STEPSIZE 1 FD 10

TOOLTIP

Controls the contents of the widget’s tool tip.

Description

The TOOLTIP property controls the text that Logo displays when the mouse cursor hovers over the widget. Initially, the tool tip is set to the widget’s name.

Example

PPROP 0 “TOOLTIP “|I am Joe|

VELOCITY

Controls the speed at which a widget moves independently.

Description

The value of the VELOCITY property controls the speed at which a widget moves on the screen independently. The permitted range of values is 0 to 500; 0 means that there si no independent movement, while any other value causes the widget to move at the given speed, which is appxorimately the number of pixels (dots) per second.

Example

PPROP 0 “VELOCITY 100

VISIBLE

Hides or shows the widget.

Description

Setting this property to FALSE hides the widget; set it to TRUE to display the widget.

Example

PPROP 0 “VISIBLE FALSE

WINDOW

Reports the name of the Graphics panel that this widget is attached to.

Description

WINDOW reports the name of the Graphics panel that this widget is attached to. Currently it outputs GRAPHICS, because there is only a single Graphics panel.

The property is read-only.

Example

GPROP 0 “WINDOW Result: GRAPHICS

WRAPMODE

Sets a widget’s individual wrap mode.

Description

The WRAPMODE property sets an individual wrap mode for a widget. The default value is DEFAULT, which means that the widget uses the Graphics panel’s wrap mode. It can be set to one of BOUNCE, FENCE, WRAP or WINDOW.

Example

Turtle 0 will bounce off the Graphics panel’s boundaries regardless of the global setting.

PPROP 0 “WRAPMODE “BOUNCE

Z.ORDER

Controls the sequence of widgets when displayed.

Description

The widget’s Z order determines which widget is in front of other widgets. Widgets with a higher Z order appear to be in front of turtles with a lower Z order. Each widget receives its own value when created.