Article # 235, added by Geoworks, historical record
| first |
previous |
index |
next |
last |
How to make a simple terminal type text object
Q. For test/demo purposes we still would like to have a simple "stdio window" teletype console. Our test application would print text lines there and the window would scroll (like teletype screens usually do). A. You can use a GenTextClass object. There are several examples of using this type of object. If you look at SDK_C\Serial or SDK_C\Serial2 sample application, they use GenTextClass objects in ways like you would want to. I will provide you with an example that should fit your specific needs. The following will create a text object that allows scrolling and text input by the user (you can disable input by adding the line "GI_attrs = @default | GA_READ_ONLY;" and removing the HINT_DEFAULT_FOCUS). It also uses the TERMINAL font, which is a font on the Nokia 9000 Communictor that allows you to display 80 characters per line. @object GenTextClass TeleText = { GTXI_attrs = @default | GTA_INIT_SCROLLING; GTXI_text = ""; ATTR_GEN_TEXT_CHAR_ATTR = @TeleTextCharAttrs; HINT_EXPAND_WIDTH_TO_FIT_PARENT; HINT_EXPAND_HEIGHT_TO_FIT_PARENT; HINT_DEFAULT_FOCUS; } @chunk VisTextCharAttr TeleTextCharAttrs = CHAR_ATTR_FONT_SIZE( FID_TERMINAL, 16 ); To add text to this text object, you would send MSG_VIS_TEXT_APPEND_PTR (or MSG_VIS_TEXT_APPEND_OPTR if the text to append is in a block). Normally, GenText objects simply append text and wrap as it reaches the right side of the object. You can add hard returns to force text to start at the right hand side of the text object. GEOS uses the '\r' character (0x0D hex) for carriage returns. If you want to put a grey frame around the text object (on the Nokia 9000 Communicator), you will need to use the ComplexMonikerClass. Here is how you would do that: /* * We establish a grey rectangle around the text object to * make it stand out. */ @chunk TCHAR InputMoniker[] = "Input"; @object ComplexMonikerClass InputBox = { ComplexMoniker = GreyFrameClass; CMI_topText = @InputMoniker; CMI_textStyle = @default & ~TS_BOLD; GI_comp = @TeleText; /* Note this points to the above defined GenTextClass object. */ HINT_CENTER_MONIKER; HINT_PLACE_MONIKER_TO_LEFT; HINT_EXPAND_HEIGHT_TO_FIT_PARENT; HINT_EXPAND_WIDTH_TO_FIT_PARENT; }