Aztec® Programming Language
Version 1.1 Alpha 2

Copyright © 2010-2017, Aztec Development Group, All Rights Reserved

Download Aztec

Search        Contact Us

I see you've sent my letters back...

And my L.P. records and they're all scratched.

- Sting

 

aztec.ui.Canvas

public class Canvas from<Control>

Base

Window

Control

Canvas

aztec.ui.ICanvas

public abstract class ICanvas from<Base>

Base

ICanvas

The Canvas class provides a general purpose drawing window. A variety of methods are provided to draw lines, text, shapes and bitmaps. In order to properly use the drawing methods, the user of this class needs to provide a drawing event handler, and all drawing needs to be performed within the event handler.

 

The framework determines when the canvas window needs to be redrawn (based on a variety of situations including OS painting events) and the framework issues the DrawEvent. The event handler for the DrawEvent then gets invoked and the canvas is filled by calling one or more of the drawing methods in this class. In addition, the script/application can force the window to be redrawn at any time by calling the Canvas.Redraw() method, which causes the framework to issue a DrawEvent, which the registered event handler then processes. Either way, the drawing is always done as a result of the DrawEvent being processed.

 

The ICanvas class is an abstract interface class which contains a virtual event handler method for each of the events which the Canvas class supports.

Canvas Methods

Canvas() Constructor for the Canvas class
DrawText() Draws a text string on the canvas using a Color object
DrawPoint() Draws a single point (pixel) on the canvas using a Color object
DrawLine() Draws a single line on the canvas using a Color object
DrawLine() Draws a single line on the canvas using a Pen object
DrawRect() Draws a rectangle border on the canvas using a Color object
DrawRect() Draws a rectangle border on the canvas using a Pen object
FillRect() Fills in a rectangle on the canvas using a Color object
FillRect() Fills in a rectangle on the canvas using a Pen object
DrawBitMap() Draws a bitmap object into the canvas
Redraw() Redraws the canvas by sending a draw event to the control
AddDrawHandler() Registers an event handler for a draw event using a method reference
AddDrawHandler() Registers an event handler for a draw event using an ICanvas reference
OnDraw() Virtual method to handle Draw events - can be overridden

ICanvas Methods

OnDraw() Virtual method to handle Draw events

Derived Classes

See Also

 


Canvas()

public method Canvas(Window Parent, int XPos, int YPos, int Width, int Height)

Parameters

Parent

Parent window for the canvas control

XPos

One based X position of control relative to parent

YPos

One based Y position of control relative to parent

Width

Initial width of the control in pixels

Height

Initial height of the control in pixels

Return Value

None

Description

Constructor for the Canvas class.

 

Canvas Class


DrawText()

public method DrawText(int XPos, int YPos, string TextString, Color TextColor = null)

Parameters

XPos

One based X position of text within the canvas control

YPos

One based Y position of text within the canvas control

TextString

Text to be drawn into the canvas

TextColor

Color object to specify the text color

Return Value

None

Description

This method draws the specified text string into the canvas control at the specified location. The TextColor indicates what color to use for the text, and if null, the default foreground color for the canvas will be used.

 

Canvas Class


DrawPoint()

public method DrawPoint(int XPos, int YPos, Color PointColor)

Parameters

XPos

One based X position of point within the canvas control

YPos

One based Y position of point within the canvas control

PixelColor

Color object to specify the pixel color

Return Value

None

Description

This method draws a single point (pixel) into the canvas control at the specified location. The PixelColor indicates what color to use for the pixel.

 

Canvas Class


DrawLine()

public method DrawLine(int XPos1, int YPos1, int XPos2, int YPos2, Color LineColor)

Parameters

XPos1

One based X position of start of line within the canvas control

YPos1

One based Y position of start of line within the canvas control

XPos2

One based X position of end of line within the canvas control

YPos2

One based Y position of end of line within the canvas control

LineColor

Color object to specify the line color

Return Value

None

Description

This method draws a line from (XPos1,YPos1) to (XPos2,YPos2) within the canvas control. The LineColor indicates what color to use for drawing the line. It is drawn as a solid line with a width of one.

 

Canvas Class


DrawLine()

public method DrawLine(int XPos1, int YPos1, int XPos2, int YPos2, Pen LinePen)

Parameters

XPos1

One based X position of start of line within the canvas control

YPos1

One based Y position of start of line within the canvas control

XPos2

One based X position of end of line within the canvas control

YPos2

One based Y position of end of line within the canvas control

LinePen

Pen object to specify the line color, style and width

Return Value

None

Description

This method draws a line from (XPos1,YPos1) to (XPos2,YPos2) within the canvas control. The reference to the LinePen object indicates what color, style (solid, dashed, etc.) and width to use for drawing the line.

 

Canvas Class


DrawRect()

public method DrawRect(int XPos1, int YPos1, int XPos2, int YPos2, Color LineColor)

Parameters

XPos1

One based X position of rect top left corner in the canvas control

YPos1

One based Y position of rect top left corner in the canvas control

XPos2

One based X position of rect bottom right corner in the canvas control

YPos2

One based Y position of rect bottom right corner in the canvas control

LineColor

Color object to specify the border color

Return Value

None

Description

This method draws a border around a rectangle described by (XPos1,YPos1) and (XPos2,YPos2) within the canvas control. The LineColor indicates what color to use for drawing the border. It is drawn as a solid line with a width of one.

 

Canvas Class


DrawRect()

public method DrawRect(int XPos1, int YPos1, int XPos2, int YPos2, Pen LinePen)

Parameters

XPos1

One based X position of rect top left corner in the canvas control

YPos1

One based Y position of rect top left corner in the canvas control

XPos2

One based X position of rect bottom right corner in the canvas control

YPos2

One based Y position of rect bottom right corner in the canvas control

LinePen

Pen object to specify the line color, style and width

Return Value

None

Description

This method draws a border around a rectangle described by (XPos1,YPos1) and (XPos2,YPos2) within the canvas control. The reference to the LinePen object indicates what color, style (solid, dashed, etc.) and width to use for drawing the border.

 

Canvas Class


FillRect()

public method FillRect(int XPos1, int YPos1, int XPos2, int YPos2, Color RectColor)

Parameters

XPos1

One based X position of rect top left corner in the canvas control

YPos1

One based Y position of rect top left corner in the canvas control

XPos2

One based X position of rect bottom right corner in the canvas control

YPos2

One based Y position of rect bottom right corner in the canvas control

RectColor

Color object to specify the rectangle color

Return Value

None

Description

This method draws and fills a rectangle described by (XPos1,YPos1) and (XPos2,YPos2) within the canvas control. The RectColor indicates what color to use for drawing and filling the rectangle.

 

Canvas Class


FillRect()

public method FillRect(int XPos1, int YPos1, int XPos2, int YPos2, Pen FillPen)

Parameters

XPos1

One based X position of rect top left corner in the canvas control

YPos1

One based Y position of rect top left corner in the canvas control

XPos2

One based X position of rect bottom right corner in the canvas control

YPos2

One based Y position of rect bottom right corner in the canvas control

FillPen

Pen object to specify the line color, style and width

Return Value

None

Description

This method draws and fills a rectangle described by (XPos1,YPos1) and (XPos2,YPos2) within the canvas control. The reference to the FillPen object indicates what color, style (solid, dashed, etc.) and width to use for drawing the border and filling the rectangle.

 

Canvas Class


DrawBitMap()

public method DrawBitMap(int XPos1, int YPos1, BitMap Bitmap)

Parameters

XPos1

One based X position of top left corner of the Bitmap in the canvas control

YPos1

One based Y position of top left corner of the Bitmap in the canvas control

Bitmap

Bitmap to be drawn at the specified location

Return Value

None

Description

This method draws the specified Bitmap at the location described by (XPos1,YPos1) within the canvas control. The Bitmap must have been created within the Display object that contains the Canvas object.

 

Canvas Class


Redraw()

public method Redraw()

Parameters

None

Return Value

None

Description

This method initiates the drawing of the entire canvas. It does not do any drawing itself. Instead, it issues a DrawEvent for the canvas control, which in turn invokes the event handler(s) which have been set up to perform drawing within the canvas.

 

Canvas Class


AddDrawHandler()

public method AddDrawHandler(DrawHandler Handler, Base ExtraObject = null)

Parameters

Handler

Method reference to be executed when the event occurs

ExtraObject

Optional object which will be sent along to each event handler when it is executed

Return Value

NONE

Description

This method registers a method reference to be executed when a "draw" event occurs within the Canvas object. The internal framework monitors OS painting events for the window, and issues a Draw event whenever the window needs to be redrawn. The script can also force a redraw by calling the Canvas.Redraw() method, which causes the system to manually issue a Draw event.

 

As is true with all Aztec event handling, this method can be called by any thread. When the event occurs, each registered event handler is scheduled to execute within the thread that registered it. So an event sent to one thread can be handled by event handlers executing in one or more other threads.

 

The DrawHandler data type represents a method reference specific to a handler for DrawEvent. DrawHandler is defined as follows:

 

        public type<method<DrawEvent,Base>> DrawHandler

 

Given this definition, the method handler must be defined with the following signature (name can be anything):

 

        public method DrawMethod(DrawEvent event, Base Extra) { }.

 

Canvas Class


AddDrawHandler()

public method AddDrawHandler(ICanvas Interface, Base ExtraObject = null)

Parameters

Interface

Reference to an ICanvas object

ExtraObject

Optional object which will be sent along to each event handler when it is executed

Return Value

NONE

Description

This method registers an ICanvas interface object to be executed when a "draw" event occurs for this Canvas control. An optional object can also be registered which will be sent to each event handler as it is executed.

 

As is true with all Aztec event handling, this method can be called by any thread. When the event occurs, each registered event handler is scheduled to execute within the thread that registered it. So an event sent to one thread can be handled by event handlers executing in one or more other threads.

 

When the draw event is issued, the OnDraw() method within the ICanvas object will be executed.

 

Canvas Class


OnDraw()

public method virtual OnDraw(DrawEvent CanvasEvent, Base ExtraObject)

Parameters

CanvasEvent

DrawEvent object associated with the event

ExtraObject

Optional object sent along from when it was registered

Return Value

NONE

Description

This method is the default event handler for DrawEvent for the Canvas control. This method in turn executes every registered handler with the same argument list which comes in. Both implementations of the Canvas.AddDrawHandler() method register the event handlers which get invoked by this method.

 

If this method is overridden by a class derived from Canvas, it must call this implementation of the method if it needs to execute handlers registered with the Canvas.AddDrawHandler() methods.

 

Canvas Class


OnDraw()

public method virtual OnDraw(DrawEvent CanvasEvent, Base ExtraObject)

Parameters

CanvasEvent

DrawEvent object associated with the event

ExtraObject

Optional object sent along from when it was registered

Return Value

NONE

Description

This virtual method is the event handler for DrawEvent within the ICanvas interface class. The method which overrides it is invoked for DrawEvent within a Canvas object when the interface object is registered with the Canvas.AddDrawHandler() method.

 

ICanvas Class

 

Copyright © 2010-2017

Aztec Development Group

All Rights Reserved

Download Aztec