Omnis Technical Note TNGI0025 July 2008
Using the style() function in Tree Lists
For Omnis Studio
By Götz Krija
You can use the style() function and the Text formatting constants (listed in the Catalog under Text escapes) to format text in several areas of Omnis. For example, you can format text in bold, italic or in colour in a headed list. You can apply a similar technique for text formatting in tree lists using the style() function.
The following window has a single tree list and the content has been
formatted when the data for the tree list is constructed (you can download
a library containing this window).
To do this, set the $styledtext property of the tree list to kTrue and
add the style() function directly to the definition of the tree list.
For example:
##### Method '$makeTreeList' #####
; create local vars lLevel0, lLevel1, lLevel2 (Char)
; lExpand, lIcon, lIdent, lTextcolor (Long Int)
; lEnterable (Boolean)
; and instance var iList (List)
Do iList.$define(lLevel0,lLevel1,lLevel2,lIcon,lIdent,lEnterable,lExpand,lTextcolor)
Do iList.$add(con(style(kEscStyle,kBold),'Germany'),'','',0,100,0,2,0)
Do iList.$add('Germany',con(style(kEscStyle,kItalic),'Manufacturer'),'',0,101,0,2,0)
Do iList.$add('Germany','Manufacturer',con(style(kEscStyle,kUnderline),'Porsche'),0,102,0,2,0)
Do iList.$add('Germany','Manufacturer',con(style(kEscLTab,100),'Mercedes'),0,103,0,2,0)
Do iList.$add('Germany','Manufacturer',con(style (kEscColor,kBlue),'BMW'),0,103,0,2,0)
The following code can be added to the $construct method of the window to initialise the list and set the tree list contents to the list data using the $setnodelist() method.
; $construct() method of window
Do method $makeTreeList
Do $cinst.$objs.treelist.$setnodelist(kFlatList,0,iList)
Note you cannot use the style() function in the web (remote form) tree component.
Download a library from Github: https://github.com/OmnisStudio/Omnis-StyleList (for Studio 8.1.2 or above)
(or an archive
style_list.zip
for Studio 4.3.1 or above)