GEOS SDK TechDocs
|
|
2 GenGlyph Basics
You may wish at some point to change the text in a GenGlyph. Because a GenGlyph's text is entirely within its visual moniker, it is a simple matter to use
GenClass
messages to change the moniker dynamically. Use
MSG_GEN_GET_VIS_MONIKER
to return a GenGlyph's current moniker; use
MSG_GEN_USE_VIS_MONIKER
(or
MSG_GEN_REPLACE_VIS_MONIKER
) to set a new moniker for a GenGlyph. Doing so will ensure that the object is visually rebuilt with the new moniker.
Code Display 6-2 A Toggle On/Off Switch Dialog Box
@object GenInteractionClass MyDialogBox = {
GI_comp = @DialogText, @DialogButton;
GII_visibility = GIV_DIALOG;
}
/* Monikers for the Instructions (the GenGlyphs). */
@visMoniker OnTextMoniker = "Click the `ON' button"; @visMoniker OffTextMoniker = "Click the `OFF' button";
/* Monikers for the triggers. */
@visMoniker OnButtonMoniker = "ON"; @visMoniker OffButtonMoniker = "OFF";
/* The object begins in the "On" state. */
@object GenGlyphClass DialogText = {
GI_vismoniker = @OnTextMoniker;
}
/* Whenever the button is pressed, MSG_FLIP_THE_SWITCH will change both the glyph * and the trigger monikers. */
@object GenTriggerClass DialogButton = {
GI_visMoniker = @OnButtonMoniker;
GTI_actionMsg = MSG_FLIP_THE_SWITCH;
GTI_destination = process;
}
@method MyProcessClass, MSG_FLIP_THE_SWITCH {
ChunkHandle testMoniker; /* Stores the temporary moniker. */
testMoniker = @call DialogButton::MSG_GEN_GET_VIS_MONIKER;
/* If the moniker is "ON", turn both it and the glyph to the Off monikers. * Otherwise (the moniker is "OFF"), turn both it and the glyph to the On * monikers. Both visual updates are delayed via the UI queue (and will therefore * be updated at the same time rather than separately) to avoid flashing. */
if (testMoniker == "ON") {
@call DialogButton::MSG_GEN_USE_VIS_MONIKER(OptrToChunk(@OffButtonMoniker),
VUM_DELAYED_VIA_UI_QUEUE);
@call DialogText::MSG_GEN_USE_VIS_MONIKER(OptrToChunk(@OffTextMoniker),
VUM_DELAYED_VIA_UI_QUEUE);
}
else {
@call DialogButton::MSG_GEN_USE_VIS_MONIKER(OptrToChunk(@OnButtonMoniker),
VUM_DELAYED_VIA_UI_QUEUE);
@call DialogText::MSG_GEN_USE_VIS_MONIKER(OptrToChunk(@OnTextMoniker),
VUM_DELAYED_VIA_UI_QUEUE);
}
}
GEOS SDK TechDocs
|
|
2 GenGlyph Basics