Next Previous Contents

9. Drawing primitive

The protocol let you draw anything you want in a form. You record a sequence to draw and it will be drawn when a window update is requested.

9.1 Drawing context

A drawing context specify how a drawing primitive will be rendered. You define a drawing context first and reuse it with drawing primitive. Drawing context are global to the application, so may be reused with any form.

(54) Defdc ID

This defines a new drawing context. The drawing context may be used with drawing primitive as an extra parameter ($dc=ID) or with some widget such as labels. It is never used without some extra parameters:

(55) Deffont id pointsize fontid style weight underlined

This defines a font ID which may be used to define one or more drawing context. The parameters are:

(56) Defpen id color Thick Style

This defines a pen ID usable to define one or more drawing context. The parameters are:

(57) Defbrush id color style

This defines a brush ID usable to define one or more drawing context. The parameters are:

9.2 Drawing primitive

You find here the various drawing primitives normally found in a GUI toolkit. In general, you combine the primitive with a predefined drawing context using the $dc=name named parameter. The drawing context is identified with the parameter "dc".

Drawing primitives are recorded in a Form context, either at the form creation, or by using the Setcontext primitive. They are not drawn as they are defined. They are only recorded. They will be drawn either when the form is exposed, or when a Refresh primitive is sent.

(70) Blit

Move some area of a form. The move is done immediatly.

(67) Clear

Clear the form using the specified (generally) drawing context. This also forgets the previously recorded primitives.

(60) Drawarc x1 y1 x2 y2 xc yc

This draw a filled arc (depending on the drawing context choosen). x1,y1 and x2,y2 represents two points on the edge of the circle. xc,yc represents the center of the circle.

(68) Drawclip x1 y1 x2 y2

Refresh only an area of a form. It sets a clipping using the speficied coordinate and perform the drawing. It may be used instead of refresh. It will generally be used combined with blit below. When scrolling complex drawing, we use blit to move a large portion of the drawing we record the new drawing primitive and then we only perform the drawing on the "missing" area.

(58) Drawline startx starty endx endy

Draws a line between two points.

(59) Drawrect startx starty endx endy

Draw a rectangle. Not filled. The two points represent two opposite corners of the rectangle.

(71) Drawtext x y text

Draw some text at the x,y coordinate. The extra parameter dc is generally supplied (drawing context).

(62) Fillarc x1 y1 w h start_angle end_angle

Not used for now. To be reviewed.

(78) Fillpolygon x1 y1 x2 y2 x3 y3 ...

Draw a filled polygon. The last point is automatically connected to the first.

(61) Fillrect startx starty sizex sizey

Draw a filled rectangle. startx,starty represents the left top corner.

(72) Refresh

Draw the recorded primitives immediatly. This primitive is only useful on a dialog already visible.


Next Previous Contents