TWPTextObjectClasses - customize TWPTextObj

<< Click to Display Table of Contents >>

Navigation:  Programming > Objects >

TWPTextObjectClasses - customize TWPTextObj

As described here, the TWPTextObj class is used for various tasks. It is not possible to inherit a new class from TWPTextObj and insert it into the editor. But there are several means to add customized behavior. There always were numerous events which can be used for custom drawing.

Starting with WPTools 8.20 there are the TWPTextObjectClass items hosted by the collection TWPTextObjectClassCollection. This collection is maintained by the component TWPTextObjectClasses - one instance can be assigned to several editors.

 

TWPTextObjectClasses For certain tasks the items in the TWPTextObjectClasses object which has been assigned to an editor are searched for a matching TWPTextObjectClass instance. If one was found, the events which were referenced by it will be triggered. The search will be aborted after that and, unless the event set a provided boolean parameter (i.e. handled) to true, the default behavior will be executed.

 

The following properties are used to find a matching class object:

 

property ObjClassName  : String - this must be "" or match the ObjClass property of the TWPTextObj. (note: ObjClass is only saved in WPT format)

property ObjName  : String - this must be "" or match the Name property of the TWPTextObj. (note: The Name is saved in RTF format only for fields)

property ObjTypeRequired  : TWPTextObjTypes - this must contain all object types this class item should be valid for. If it is [], it is never used.

property ObjModesExcluded  : TWPTextObjModes - list all modes which MUST NOT be defined in a text object for a match.

 

Further more this event is triggered to let you control the match condition by your program logic:

property OnObjectClassCheckMatch : TWPTextObjectClassEventCheckMatch

 

If a matching class was found, this events will be executed:

 

For mouse events:

property OnObjectClassMouseDown  : TWPTextObjectClassEventMouse

property OnObjectClassMouseUp  : TWPTextObjectClassEventMouse

property OnObjectClassMouseMove  : TWPTextObjectClassEventMouse

 

To calculate the visible the size of an object instance in the editor:

property OnObjectClassCalcSize   : TWPTextObjectClassEventCalcSize

 

To paint the background and/or the text of an object:

property OnObjectClassPaintBackground : TWPTextObjectClassEventPaint

 

To paint anything else after the background/text was painted:

property OnObjectClassPaint      : TWPTextObjectClassEventPaint

 

Retrieve the display text for a certain object

property OnObjectClassGetText    : TWPTextObjectClassEventGetText

 

You can use this user properties for your logic: Tag and comment, and at runtime ObjTag which is of type TObject.