Article # 49, added by Geoworks, historical record
| first | previous | index | next | last |

How to add HINTs and ATTRs




You can dynamically add and remove HINTs and ATTRs to generic objects. 
MSG_GEN_ADD_GEOMETRY_HINT or MSG_META_ADD_VAR_DATA are used to add;
MSG_GEN_REMOVE_GEOMETRY_HINT or MSG_META_DELETE_VAR_DATA are used to 
remove the hint from the object.

MSG_META_ADD_VAR_DATA and MSG_META_DELETE_VAR_DATA are the more generic
message.  That is, they can properly add or remove any hint or attribute.
But they do not invalidate the object, so it will not redraw with the
new hint/attr settings.  You can send MSG_VIS_INVALIDATE to the object
to get it to redraw with the new hint/attr.

MSG_GEN_ADD_GEOMETRY_HINT and MSG_GEN_REMOVE_GEOMETRY_HINT are used
specifically for hints and attributes that would effect the object's
geometry.  There is a list of hints and attributes that this message
can handle in genC.def (in the Include directory of any Geos SDK).
The messages will automatically cause the object's geometry to
recalculate.  If you use these messages to add a hint or attribute that
they don't know about, they may try to add it (not guaranteed, though), 
but will not properly add any extra data that the hint/attr needs.

Here are two examples of how you add attributes to an object:

-----------------

@chunk TCHAR  helpContext[] = _TEXT("myHelp");

...

{
   TCHAR *ptrHelpContext;

   /* lock the helpContext chunk and get its pointer */
   MemLock(OptrToHandle(@helpContext));
   ptrHelpContext = LMemDeref(@helpContext);

   /* add the atttribute */
   @call ::MSG_META_ADD_VAR_DATA(
		(VDF_SAVE_TO_STATE | ATTR_GEN_HELP_CONTEXT),
		strlen(ptrHelpContext),
		ptrHelpContext);

   /* unlock the block that contains helpContext */
   MemUnlock(OptrToHandle(@helpContext));
}

-----------------

@chunk VisTextCustomFilterData FilterArray[] = {
		{C_SPACE, 0xffff} /* this filters out all text */
};

/* Then write a method that sends MSG_META_ADD_VAR_DATA like this: */
{
   ChunkHandle filterChunk[1];

   filterChunk[0] = @FilterArray;

   @call GetChildHandle(oself), textObj::MSG_META_ADD_VAR_DATA(
		(VDF_SAVE_TO_STATE|ATTR_VIS_TEXT_CUSTOM_FILTER),
		sizeof(ChunkHandle),
		filterChunk);
}