CwTable
CwTable provides a great looking widget for row and column data. It implements the Windows Table Control for a native Windows look. CwTable collaborates with CwTableColumn and CwTableItem to display data in a grid format.
The CwTable can add and delete columns. It can add and delete rows represented by instances of CwTableItem. Several protocols exist to get and set the control’s value; the other group of protocols specify the appearance and behavior of the control.
 
Protocol
Value getters and setters
columnCount
Answer the number of columns in the receiver.
Answers:
<Integer>
 
columns
Answer the columns in the receiver.
Default setting: OrderedCollection new
Resource access: SG
Answers:
<OrderedCollection> of <CwTableColumn>
 
columns: aCollectionOfCwTableColumn
Set the columns in the receiver.
Default setting: Empty collection
Resource access: SG
Arguments:
aCollectionOfCwTableColumn - <OrderedCollection> of <CwTableColumn>
 
columnSelected
Answer the selected column in the receiver.
Answers:
<CwTableColumn>
 
focusedItem
Answer the item with focus in the receiver.
Arguments:
none
Answers:
<CwTableItem>
 
itemCount
Answer the number of items in the receiver.
Answers:
<Integer>
 
itemCount: aCount
Set the number of items in the receiver.
Arguments:
aCount - <Integer>
 
itemCountPerPage
Calculates the number of items that can fit vertically in the visible area
of a list-view control when in list or report view.
Answers:
<Integer>
 
selectedCount
Answer the number of selected columns in the receiver.
Answers:
<Integer>
 
selectedItems
Answer selected items in the receiver.
Answers:
<Integer>
 
topIndex
Answer index in the receiver of the topmost visible item.
Answers:
<Integer>
 
virtualItems
Answer the value of the XmNvirtualItems resource.
Answers:
< Boolean>
 
virtualItems: resourceValue
Set the value of the XmNvirtualItems resource to @resourceValue.
Answers:
< Boolean.>
 
Column creation
addColumn: theTableColumn
Add @theTableColumn as a child of the receiver.
Answer the new column widget.
Arguments:
theTableColumn - <CwTableColumn>
Answers:
<CwTableColumn>
 
addColumn: theCwTableColumn argBlock: argBlock
Add @theCwTableColumn as a child of the receiver. Initialize the column with @argBlock.
Answer the new column widget.
Arguments:
theCwTableColumn - <CwTableColumn>
argBlock - <Block> one argument is the CwTableColumn
Answers:
<CwTableColumn>
 
createColumn: theName argBlock: argBlock
Create a CwTableColumn as a child of the receiver. Initialize the column with @argBlock.
Answer the new column widget.
Arguments:
theName - A String specifying the name of the new widget.
argBlock - An optional 1-parameter block that may be used to
send resource setting messages to the widget being
created in order to initialize create-only resources,
or nil if no such initialization is required.
The widget being created is passed as the block
parameter.
Answers:
<CwTableColumn>
 
deleteColumn: aColumn
Delete the column from the receiver and release all OS resources associated with the item.
NOTE: #isDestroyed is the only valid message for a deleted item.
 
Row creation
addItem: theTableItem
Add @theItem as a child of the receiver.
Answer the new table item widget.
Arguments:
theTableItem - <CwTableItem> or an object conforming to the public API of CwTableItem.
Answers:
<CwTableItem>
 
addItem: theTableItem argBlock: argBlock
Add @theItem as a child of the receiver. Initialize the item with @argBlock.
Answer the new table item widget.
Arguments:
theTableItem - <CwTableItem> or an object conforming to the public API of CwTableItem.
argBlock - <Block> one argument is the CwTableItem
Answers:
<CwTableItem>
 
createItem: theName argBlock: argBlock
Create a CwTableItem as a child of the receiver.
Answer the new widget.
Arguments:
theName - A String specifying the name of the new widget.
argBlock
An optional 1-parameter block that may be used to send resource setting messages to the widget being created in order to initialize create-only resources, or nil if no such initialization is required. The widget being created is passed as the block parameter.
Answers:
<CwTableItem>
 
createTableItem: theName argBlock: argBlock
Create a CwTableItem as a child of the receiver.
Answer the new item.
Arguments:
theName
A String specifying the name of the new widget.
argBlock
An optional 1-parameter block that may be used to send resource setting messages to the widget being created in order to initialize create-only resources, or nil if no such initialization is required. The widget being created is passed as the block parameter.
Answers:
<CwTableItem>
 
deleteAllItems
Delete all the items from the receiver and release all OS resources associated with the items.
NOTE: #isDestroyed is the only valid message for a deleted item.
 
deleteItem: anItem
Delete the item from the receiver and release all OS resources associated with the item.
NOTE: #isDestroyed is the only valid message for a deleted item.
 
deleteItems: items
Delete the specified items from the receiver and release all OS resources associated with the items.
NOTE: #isDestroyed is the only valid message for a deleted item.
 
items
Answer the items in the receiver.
Default setting: OrderedCollection new
Resource access: SG
Answers:
<OrderedCollection> of <CwTableItem>
 
items: anItemCollection
Set the items displayed in the receiver.
Default setting: OrderedCollection new
Resource access: SG
Arguments:
anItemCollection - <OrderedCollection> of <CwTableItem>
 
Look and Feel
editLabels
Answer the value of the XmNeditLabels resource.
Default setting: false
Resource access: CSG
Description:
Whether the receiver allows editing its label column.
Answers:
<Boolean>
 
editLabels: resourceValue
Set the value of the XmNeditLabels resource to @resourceValue.
Default setting: false
Resource access: CSG
Description:
Whether the receiver allows editing its label column.
Arguments:
<Boolean>
 
findItem: aStartItem text: aText
Searches for a list-view item with the specified label text.
Answer a matching table item or nil.
Arguments:
aStartItem - <CwTableItem>
aText - <String>
Answers:
<CwTableItem>
 
fontList
Answer the value of the XmNfontList resource.
Default setting: dynamic
Resource access: CSG
Description:
Specifies the font list to be used for the widget.
Answers:
<CwFontList>
 
fontList: resourceValue
Set the value of the XmNfontList resource to @resourceValue.
Default setting: dynamic
Resource access: CSG
Description:
Specifies the font list to be used for the widget.
Arguments:
resourceValue - <CwFontList>
 
gridLines
Answer the value of the XmNgridLines resource.
Arguments:
none
Answers:
<Boolean>
 
gridLines: resourceValue
Set the value of the XmNgridLines resource to resourceValue.
Default setting: true
Resource access: CSG
Description:
Whether the receiver displays lines between its items and columns.
Arguments:
resourceValue - <Boolean>
 
noColumnHeader
Answer the value of the XmNoColumnHeader resource.
Default setting: false
Resource access: CSG
Description:
Whether the receiver displays a header at the top of each column.
Answers:
<Boolean>
 
noColumnHeader: resourceValue
Set the value of the XmNoColumnHeader resource to resourceValue.
Default setting: false
Resource access: CSG
Description:
Whether the receiver displays a header at the top of each column.
Argument:
resourceValue - <Boolean>
 
noScroll
Answer the value of the XmNoScroll resource.
Default setting: false
Resource access: CSG
Description:
Whether the receiver shows scroll bars. If the resource is true, scroll bars will appear if there are more columns or items than are visible.
Answers:
<Boolean>
 
noScroll: resourceValue
Set the value of the XmNoScroll resource to @resourceValue.
Default setting: false
Resource access: CSG
Description:
Whether the receiver shows scroll bars. If the resource is true, scroll bars will appear if there are more columns or items than are visible.
Arguments:
resourceValue - <Boolean>
 
noSortHeader
Answer the value of the XmNoSortHeader resource.
Default setting: true
Resource access: CSG
Description:
Whether the receiver allows columnar sorting.
Answers:
<Boolean>
 
noSortHeader: resourceValue
Set the value of the XmNoSortHeader resource to resourceValue.
Default setting: true
Resource access: CSG
Description:
Whether the receiver allows columnar sorting.
Arguments:
resourceValue - <Boolean>
 
selectionPolicy
Answer the value of the XmNselectionPolicy resource.
Default setting: XmEXTENDEDSELECT
Resource access: CSG
Description:
Defines the interpretation of the selection action.
Answers:
<Integer> - See CwTable>>#selectionPolicy:
 
selectionPolicy: resourceValue
Set the value of the XmNselectionPolicy resource to @resourceValue.
Default setting: XmEXTENDEDSELECT
Resource access: CSG
Description:
Defines the interpretation of the selection action.
This can be one of the following:
XmSINGLESELECT
allows only single selections of rows (items).
XmEXTENDEDSELECT
allows extended selections of rows (items).
XmCELLSINGLESELECT
allows single selection of cells. If the widget and the column
are editable, then selecting a cell causes it to be edited, and
fires the beginEditCallback.
Arguments:
<Integer>
 
showSelectAlways
Answer the value of the XmNshowSelectAlways resource.
Default setting: true
Resource access: CSG
Description:
Whether the receiver always shows selection.
Answers:
<Boolean>
 
showSelectAlways: resourceValue
Set the value of the XmNshowSelectAlways resource to @resourceValue.
Default setting: true
Resource access: CSG
Description:
Whether the receiver always shows selection.
Arguments:
resourceValue - <Boolean>
 
sort
Answer the value of the XmNsort resource.
Default setting: XmAscending
Resource access: CSG
Description:
Defines the interpretation of the sort action.
Values:
See CwTable>>#sort
Answers:
<Integer> - See CwTable>>#sort:
 
sort: resourceValue
Set the value of the XmNsort resource to @resourceValue.
Default setting: XmAscending
Resource access: CSG
Description:
Defines the interpretation of the sort action.
This can be one of the following:
o XmAscending.
o XmDescending.
Answers:
<Integer>
 
Callbacks and Events
drawCallback: resourceValue
Set the value of the XmNdrawCallback resource to @resourceValue.
Default setting: OrderedCollection new
Resource access: C
Callback reason: XmCRAPPLY,
Calldata structure: CwTableItemDrawCallbackData
Description:
Specifies the list of callbacks that is called when an item is selected.
Arguments:
<OrderedCollection> of< CwCallbackRec>
 
drawHeaderCallback: resourceValue
Set the value of the XmNdrawHeaderCallback resource to @resourceValue.
Default setting: OrderedCollection new
Resource access: C
Callback reason: XmCRAPPLY,
Calldata structure: CwTableItemDrawCallbackData
Description:
Specifies the list of callbacks that is called when an item is selected.
Arguments:
<OrderedCollection> of< CwCallbackRec>
 
editCallback: resourceValue
Set the value of the XmNeditCallback resource to @resourceValue.
Default setting: OrderedCollection new
Resource access: C
Callback reason: XmCRARM, XmCRDISARM,
Calldata structure: CwTableItemCallbackData
Description:
Specifies the list of callbacks that is called when an item is selected.
Arguments:
<OrderedCollection> of< CwCallbackRec>
 
findCallback: resourceValue
Set the value of the XmNfindCallback resource to @resourceValue.
Default setting: OrderedCollection new
Resource access: C
Callback reason: XmCRNOMATCH,
Calldata structure: CwTableItemCallbackData
Description:
Specifies the list of callbacks that is called when an item is selected.
Arguments:
<OrderedCollection> of< CwCallbackRec>
 
modifyVerifyCallback: resourceValue
Set the value of the XmNmodifyVerifyCallback resource to @resourceValue.
Default setting: OrderedCollection new
Resource access: C
Callback reason: XmCRVALUECHANGED, XmCRMODIFYINGTEXTVALUE
Calldata structure: CwTableItemCallbackData
Description:
Specifies the list of callbacks that is called before text is deleted from or inserted into the entry field. The object passed to this callback is CwTextVerifyCallbackData. The reason sent by the callback is XmCRMODIFYINGTEXTVALUE.
Arguments:
<OrderedCollection> of< CwCallbackRec>
 
multipleSelectionCallback: resourceValue
Set the value of the XmNmultipleSelectionCallback resource to @resourceValue.
Default setting: OrderedCollection new
Resource access: C
Callback reason: XmCRMULTISELECT
Calldata structure: CwAnyCallbackData, CwTableItemCallbackData
For range items call:
callData item - index of start item.
callData subItem - index of end item.
callData data = #()
Description:
Specifies the list of callbacks that is called
when an item is selected.
Arguments:
<OrderedCollection> of< CwCallbackRec>
 
virtualCallback: resourceValue
Set the value of the XmNvirtualCallback resource to @resourceValue.
Default setting: OrderedCollection new
Resource access: C
Callback reason: XmCRICONIFY, XmCRCASCADING
Calldata structure: CwTableItemCallbackData
callData item - index of start item.
callData subItem - index of end item.
Description:
Specifies the list of callbacks that is called
when an item is selected.
Arguments:
<OrderedCollection> of< CwCallbackRec>
 
Example
 
| widget |
widget := self form
createScrolledCwTable: 'data_table'
argBlock: [:w | w
selectionPolicy: XmSINGLESELECT;
fullRowSelect: true. ].
widget manageChild.
 
widget
columns: (OrderedCollection
with: (CwTableColumn new
labelString: 'Column0';
width: 120)
);
items: (OrderedCollection new
add: (CwTableListData new labelString: 'Item1') ;
yourself).
 
widget setValuesBlock: [:w |
w
leftAttachment: XmATTACHFORM;
rightAttachment: XmATTACHFORM;
rightOffset: 10;
topAttachment: XmATTACHFORM;
bottomAttachment: XmATTACHFORM;
bottomOffset: 10;
yourself].
 
Where
 
CwTableListData is any object conforming to the public API of CwTableItem.
Last modified date: 04/20/2022