| DrawPaint | ||
| Contents | ||||||
|
||||||
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 | ||
![]()
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
Aligns the bottoms of all selected objects with one another on a common baseline.
Aligns all selected (highlighted) objects using the left hand side of each object to align it with the leftmost coordinate.
Aligns all selected (highlighted) objects using the right hand side of each object to align it with the rightmost coordinate.
Aligns all selected (highlighted) objects using the top of each object to align it with the topmost coordinate.
CalcStringDims (long pItem = 0)
Called when the object enters scope.
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.
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.
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.
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.
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.
Called to initialise the control, takes the handle to a particular image control to use for the display.
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.
Called when an item was clicked on. In graphics this is usually referred to as picking.
Called to dispose allocated memory can clean up when the control is no longer needed.
Makes all selected objects the same height.
Makes all selected objects the same size (width and height)
Makes all selected objects the same width.
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).
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.
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.
Sets the cursor based on the passed string, or reset it to the standard cursor if no parameter is pased
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.
Sorts the items in the queue based on their z-order, with the lowest z-order being the bottom-most item.
Spreads out all selected objects evenly based on their widths and positions.
Spreads out all selected objects evenly based on their heights and positions.
The user clicked on the control, handles object selection and highlighting.
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.
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.
Called when event occurs, such as an object on the canvas being clicked on
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.
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The canvas (background) color for the control.
Indicates that a select has been made and can be moved if the user drags the mouse.
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.
The colour used for the grid lines drawn over the canvas (if the grid is enabled)
Enables or disables (hide) the grid layer.
The style of the grid lines being drawn onto the grid layer, uses a standard Clarion line style.
The width of the grid lines drawn onto the grid layer, by default this is one pixel.
ItemQueue &DrawPaintItemQueueType
The queue that contains the items on the canvas. This stores each items that is created and drawn on the control.
Indicates that items are being moved in a drag operation.
Indicates that an item us being resized as the user drags the mouse.
Handle to the Image control that Draw is using to display the image
Internal store for calculating differences when objects are moved or resized.
Internal store for calculating differences when objects are moved or resized.
_HighlightQueue &HighlightQueueType
Stores all highlights (selected areas)
Internal store for the mouse coordinate at the start of an action.
Internal store for the mouse coordinate at the start of an action.
![]()
Copyright © 2008 CapeSoft Software (Pty) Ltd