Topic: APLX Help : System Classes : Using the Draw method
[ Next | Contents | Index | APL Home ]

Using the Draw method

The Draw method allows you to draw text, lines, patterns, pictures and geometric shapes on windows, controls, and printer pages. It takes an argument which comprises one or more phrases which each start with a keyword indicating the operation to perform, followed by the arguments to that operation. (see the workspace 10 HELPDRAW for examples).

Drawing takes place using a current Pen (for foreground drawing) and Brush (for background drawing). You can also set the Mode which determines how drawing interacts with what is already on the screen.

Coordinates are interpreted according to the current Draw-method Scale for the object. The first time that the Draw method is used on a control, this is set to be the same as the scale property of the control. However, you can change it to be either one of the standard fixed scales, or to be proportional to the window size.

APLX automatically handles window refreshing for you if the window is uncovered or resized (you can switch this off using the autoredraw property). It does this by storing the sequence of Draw commands applicable to the window or control, and replaying them when an update is required. You can also group a series of commands together, and selectively enable or disable them (for example, to temporarily hide the labels on a graph), or delete them altogether from the saved sequence. This is useful for animation effects.

The general syntax of the Draw method is:

      Control.Draw '<Keyword>' Arg1 Arg2...

where Control is usually the a reference to the Window into which you want to draw, or a Printer, or a Frame, Picture or Image object, identified using dot notation (for example, Win.Pic.Image1). You can also supply multiple sequences of commands on one line:

      Control.Draw ('<Keyword1>' Arg1)  ('<Keyword2>' Arg1 Arg2)...

Alternatively, you can use the equivalent ⎕WI syntax:

      ControlName ⎕WI 'Draw' '<Keyword>' Arg1 Arg2...
      ControlName ⎕WI 'Draw' ('<Keyword1>' Arg1)  ('<Keyword2>' Arg1 Arg2)...

where ControlName is a character vector containing the name of the window or control (including parent if applicable), for example: 'Win' or 'Win.Pic.Image1'

The keywords are not case-sensitive, but it is recommended that you enter them in the case shown in the following sections.

The operations you can carry out using the Draw method fall into four categories:

  • Operations which set the state of the drawing sub-system for the current control, defining how subsequent drawing commands will work. These include commands to set the Pen, Brush, Font and Scale.
  • Operations which cause drawing to take place on the current control. These include commands to draw lines, rectangles, arcs, and polygons, and to draw text (and find out what size rendered text would require on the screen). You can also draw bitmaps and other images, either from file or directly as an array of color values held in an APL variable.
  • Operations which determine how drawing commands are replayed when a window update is required. These include commands to group graphic elements together, to enable and disable specific groups, and to delete commands from the saved list. You can also obtain a bitmap or Scalable Vector Graphics (SVG) representation of the drawing, or copy it to the Clipboard.

In the descriptions which follow, optional parameters are shown in square brackets.

Topic: APLX Help : System Classes : Using the Draw method
[ Next | Contents | Index | APL Home ]