Table columns
The EwTableColumn objects in a table list have their own set of resources and callbacks. The cellValueCallbackmethod obtains the renderable object that represents the value of a column in a particular row.
Additional resources control the appearance of the column and its heading. The heading resource can be set to a renderable object that is to be displayed at the top of a particular column. The resizable resource controls whether users can resize the column to a different width by dragging the right side of the column heading. Other resources control the size, alignment, and visual style of the column.
The following code creates a table list with the subclasses of the class Object as its items. The first column displays an icon, the second displays the name of the class, and the third displays the class's comment.
Object subclass: #TableListExample
instanceVariableNames: 'icon'
classVariableNames: "
poolDictionaries: 'CwConstants EwConstants '
open
| shell tableList |
shell := CwTopLevelShell
createApplicationShell: 'shell'
argBlock: [:w | w title: 'Table List Example'].
tableList := shell
createScrolledTableList: 'scrolled list'
argBlock: [:w | w
columns: self columns;
items: Object subclasses;
selectionPolicy: XmSINGLESELECT].
"Note: The destroyCallback is not shown."
icon := shell screen
getIcon: 'default_xm_information' foregroundColor: CgRGBColor black.
tableList manageChild.
shell realizeWidget
columns
"Answer a collection of EwTableColumns."
^ OrderedCollection new
add: self iconColumn;
add: self nameColumn;
add: self commentColumn;
yourself
iconColumn
"Answer the column for the class' icon."
| col |
col := EwTableColumn new
editable: false;
resizable: false;
width: 36;
horizontalAlignment: XmALIGNMENTCENTER;
yourself.
col
addCallback: XmNcellValueCallback
receiver: self
selector: #iconCellValue:clientData:callData:
clientData: nil.
^col
nameColumn
"Answer the column for the class' name."
| col |
col := EwTableColumn new
editable: false;
heading: 'Class Name';
resizable: true;
width: (CgFontStruct default textWidth: 'Class Name');
horizontalHeadingAlignment: XmALIGNMENTCENTER;
yourself.
col
addCallback: XmNcellValueCallback
receiver: self
selector: #textCellValue:clientData:callData:
clientData: #name.
^ col
 
commentColumn
"Answer the column for the class' comment."
| col |
col := EwTableColumn new
editable: false;
heading: 'Comment';
resizable: true;
width: 512;
horizontalHeadingAlignment: XmALIGNMENTCENTER;
yourself.
col
addCallback: XmNcellValueCallback
receiver: self
selector: #textCellValue:clientData:callData:
clientData: #comment.
^ col
 
iconCellValue: widget clientData: clientData callData: callData
"Set the cell's value to the an icon."
callData value: icon
 
textCellValue: widget clientData: clientData callData: callData
"Set the cell's value to the string answered by the list
item when the clientData is sent to it as a message."
callData value: (callData item perform: clientData)
Last modified date: 01/29/2015