DrawPaint

Capesoft Draw
Return to the main Draw documentation

     

Contents
Introduction to DrawPaint
DrawPaint Template
DrawPaint Methods
DrawPaint Properties
     

The DrawPaint Class

The Capesoft DrawPaint class allows the end user to place objects (such circles and boxes, images, text etc.) onto a Draw control, and then allow the user select and manipulate those object visually. For example a box can be placed on the control by clicking with the mouse, and the box can later be selected, resized, the properties changed etc. It allows the order of objects on the control to be change, and any object to be selected simply by clicking on the control with the mouse.

This provides a tremendous amount of functionality without doing a large mount of coding.

Please note that this documentation is under construction and is being expanded.


DrawPaint Methods
  AddItem Add an item to the queue of items  
AlignBottom Align selected items bottom
AlignLeft Align selected items left
AlignRight Align selected items right
AlignTop Align selected items top
CalcStringDims Calculates the width and height of a string
Construct Called when the object comes into scope
CopyItems Copies the selected items so that they can be pasted
DeleteItem Deletes an item
Destruct Called when the object leaves scope
DrawHighlightBox Draws a highlight (selection indicator)
DrawHighlights Draws the highlighting for all selected items
DrawItems Draws all the items in the queue
FindParent Find parent for the item
GetAltPicture Returns a display picture - embed code here to set returnvalue
HideHighlight Hides the highlight (selection) layer
Init Initialises the object and control
InResizeCorner Determines whether the cursor is over the resize area of a selected item
ItemClicked Called when an item was clicked on
Kill Cleans up frees allocated memory
MakeSameHeight Makes all selected items the same height
MakeSameSize Makes all selected items the same size
MakeSameWidth Makes all selected items the same width
MoveItems Moves all selected items by the amount specified
PasteItems Pastes a copy of any items that have been copied by calling CopyItems
PicExample Returns an example text (as seen while editing clarion reports - e.g. $$$$$$$$$$ for a string) for the supplied picture
RedrawHighlightBox Draws the highlight after an object has moved
Reset Reset the layers used for drawing
ResizeItem Resizes and item
SaveHighlightPos Saves a new highlight position for an item
SetCanvasSize Resizes and clears the canvas and all used layers
SetCursor Sets or resets the cursor
SetGrid Redraws or hides the grid layer
SortItems Sorts the items based on the z-order
SpreadHorizontally Spreads out the selected items evenly horizontally
SpreadVertically Spreads out the selected items evenly vertically
TakeClickEvent Called when the user clicks on the control
TakeDragEvent Called when the user clicks and drags
TakeDropEvent Called when the user releases the mouse button after clicking and dragging.
TakeEvent Called when the control receives an event
TakeResizeEvent Called to handle a resize event
WithItem Selects a particular item from the queue
 
     

 

DrawPaint Method Reference

Click on the (up) icon to go back to the layer Method Index.


 AddItem (Long zOrder = 0), long, proc

Adds an item to the internal queue of items (objects) on the canvas. The Itemqueue queue must be populated with the settings for the object before AddItem() is called to add the item. Entries should not be added to the queue manually.

Parameters

zOrder
Determines the order in which the object is drawn, object with a low z-order are drawn first, and object with a higher z-order are draw on top of them. The higher the z-order the higher up the "stack" the object is.

Return Values

Returns 1 for success and zero for failure. If the method fails it calls ErrorTrap() with an error description.

Remarks

Use the zOrder to specify an order other than the creation order for displaying the item. The zOrder determines which item is topmost and which is bottommost. All other settings should be done using the ItemQueue properties.

Examples

 

See Also

DeleteItem

 

 

AlignBottom ()

Aligns the bottoms of all selected objects with one another on a common baseline.

 

AlignLeft ()

Aligns all selected (highlighted) objects using the left hand side of each object to align it with the leftmost coordinate.

 

AlignRight ()

Aligns all selected (highlighted) objects using the right hand side of each object to align it with the rightmost coordinate.

 

AlignTop ()

Aligns all selected (highlighted) objects using the top of each object to align it with the topmost coordinate.

 

CalcStringDims (long pItem = 0)

 

 

Construct ()

Called when the object enters scope.

 

CopyItems ()

Copies all selected items to a queue. Duplicates of the items can then be created by calling PasteItems().

 

 

DeleteItem (long p_Item), long

Removes the item indicated by the p_Item parameter from te queue. Does not redraw the control.

 

Destruct ()

Called when the object goes out of scope. The Kill() method must have been called by the time that Destruct is called.

 

DrawHighlightBox (long pItem = 0)

Selects the item in the queue and highlights it.

 

DrawHighlights ()

Draws the highlight (selection indication) on all currently selected objects and displays the control.

 

DrawItem (long pTransColor = COLOR:None)

Draws the item to the buffer (does not actually display the item). This is used to actually draw each item in the queue before the control is displayed.

 

DrawItems ()

Loop through the queue and draws each item by calling DrawItem.

 

FindParent (long pItem=0),long

Returns the ParentID for the item, if it has a parent set.

 

GetAltPicture (String pTextValue)

Returns a display picture for the passed text - embed code here to set returnvalue.

 

HideHighLight ()

Hides the HighLight layer, so no selections will be visible.

 

HighlightBoxesMoved (long pDeltaX=0, long pDeltaY=0)

Redraws the highlighting of all selected items based on the the current movement indicated by the deltaX and deltaY parameters.

 

HighLightItem (long pItem=0, long pMulti=0)

Highlights (selects) a particular item. If pMulti is set then the item is added to the currently selected items, otherwise the current selection is cleared and the item becomes the only selected item. Typically the user will hold down the Shift or Control key to select multiple items.

 

Init (ulong controlHandle)

Called to initialise the control, takes the handle to a particular image control to use for the display.

 

InResizeCorner (), long

Determines whether the user has moused over the corner of a selected object, which allows the user to them click and drag to resize the object.

 

ItemClicked ()

Called when an item was clicked on. In graphics this is usually referred to as picking.

 

Kill ()

Called to dispose allocated memory can clean up when the control is no longer needed.

 

MakeSameHeight ()

Makes all selected objects the same height.

 

MakeSameSize ()

Makes all selected objects the same size (width and height)

 

MakeSameWidth ()

Makes all selected objects the same width.

 

MoveItems ()

Handles moving selected items as the user drags the items, and redraws the controls as the items are moved.

 

PasteItems (long pTopLeftX = -1, long pTopLeftY = -1)

Called after calling CopyItems() to create duplicates of the copied items at the position specified.

 

PicExample (string pPicture), string

Returns an example text (as seen while editing clarion reports - e.g. $$$$$$$$$$ for a string) for the supplied picture.

 

RedrawHighlightBox (long pItem=0, long dx=0, long dy=0, long dw=0, long dh=0)

Redraws the highlight (selection indication) when an item has been moved (dragged by the user for example).

 

Reset ()

Clears all layers of the rendered image data. This does not remove any items from the queue, and does not call Display or change what appears in the control.

 

ResizeItem ()

Called when the user clicks and drags to resize an item, it sets the new size on the item and updates the queue.

 

SaveHighlightPos (long pItem=0, long pXPos, long pYPos, long pWidth, long pHeight)

Updates the highlight position for the item using the passed parameters.

 

SetCanvasSize (long canvasWidth=0, long canvasHeight=0)

Resizes the canvas (drawing area) to the width and height specified, and resizes all the layers used. The grid layers are redrawn, but not displayed until Display is called, everything else is cleared.

 

SetCursor (<string pCursor>)

Sets the cursor based on the passed string, or reset it to the standard cursor if no parameter is pased

 

SetGrid (bool showGrid)

If the grid is enabled (DrawPaint.gridEnabled = 1) the the grid layer is redrawn and unhidden. If the grid is disabled then the grid layer is hidden.

 

SortItems ()

Sorts the items in the queue based on their z-order, with the lowest z-order being the bottom-most item.

 

SpreadHorizontally ()

Spreads out all selected objects evenly based on their widths and positions.

 

SpreadVertically ()

Spreads out all selected objects evenly based on their heights and positions.

 

TakeClickEvent ()

The user clicked on the control, handles object selection and highlighting.

 

TakeDragEvent ()

Handles when the user clicks and drags. If an object was dragged them it is moved (or resized if the corner of a selection object was clicked and dragged). If multiple objects are selected they are moved as the user moves the mouse.

 

TakeDropEvent ()

Handles ending a Drag event. Unlike a normal "drop" even this handles ending a drag by updating the positions of the selected items that were dragged, auto finding the parents as needed.

 

TakeEvent ()

Called when event occurs, such as an object on the canvas being clicked on

 

TakeResizeEvent ()

Called when a resize occurs so that an action can be taken (resizing and redrawing the control).

 

WithItem (long p_Item), long , proc

Selects a particular item from the queue so that the settings can be modified.

 


 



DrawPaint Properties

These are the Draw class properties that are useful when working with layers. You can access all these properties directly (they are not private and so you don't need accessor method). Properties that should be used with caution are indicated by an underscore preceding the name. Typically these properties should not be accessed directly.

DrawPaint Properties
 
CanMoveNow long
canvasColor long
CopyItemQueue &CopyItemQueueType
gridColor long
gridEnabled long
gridStyle long
gridWidth long
hDrawFactor decimal(20, 10)
HighLight group
ItemQueue &DrawPaintItemQueueType
LockParents long
Moving long
Resizing long
vDrawFactor decimal(20, 10)
ZoomFactor long
_control long
_DeltaX long
_DeltaY long
_highlighted long
_HighlightItems long
_HighlightQueue &HighlightQueueType
_items long
_MultiClickCount long
_nextId long
_StartMouseX long
_StartMouseY long
   

 
     

 

 canvasColor long

The canvas (background) color for the control.

 

CanMoveNow long

Indicates that a select has been made and can be moved if the user drags the mouse.

 

canvasColor long

The backrground (canvas) colour for the control.

 

CopyItemQueue &CopyItemQueueType

The queue used to store the item details when the CopyItems method is used to copy one of more items. The PasteItems() methods then uses this queue to created copies of the items at the chosen position.

 

gridColor long

The colour used for the grid lines drawn over the canvas (if the grid is enabled)

 

gridEnabled long

Enables or disables (hide) the grid layer.

 

gridStyle long

The style of the grid lines being drawn onto the grid layer, uses a standard Clarion line style.

 

gridWidth long

The width of the grid lines drawn onto the grid layer, by default this is one pixel.

 

hDrawFactor decimal(20, 10)

 

 

HighLight group,pre()

 

 

ItemQueue &DrawPaintItemQueueType

The queue that contains the items on the canvas. This stores each items that is created and drawn on the control.

 

LockParents long

 

 

Moving long

Indicates that items are being moved in a drag operation.

 

Resizing long

Indicates that an item us being resized as the user drags the mouse.

 

vDrawFactor decimal(20, 10)

 

 

ZoomFactor long

 

 

_control long

Handle to the Image control that Draw is using to display the image

 

_DeltaX long

Internal store for calculating differences when objects are moved or resized.

 

 _DeltaY long

Internal store for calculating differences when objects are moved or resized.

 

_highlighted long

 

 

_HighlightItems long

 

 

_HighlightQueue &HighlightQueueType

Stores all highlights (selected areas)

 

_items long

 

 

_MultiClickCount long

 

 

_nextId long

 

 

_StartMouseX long

Internal store for the mouse coordinate at the start of an action.

 

_StartMouseY long

Internal store for the mouse coordinate at the start of an action.

 

 

 

 

 

 

Copyright © 2008 CapeSoft Software (Pty) Ltd