- Sting
Canvas
ICanvas
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
None
See Also
Class Hierarchy, Frame, ChildFrame, Dialog, DrawEvent, Color, Pen, BitMap
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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