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> the number of columns in the receiver
 
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.
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: <CwTableItem>
 
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. This setting is intended for displaying large data sets. The user of the table is responsible for drawing the data in the table.
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.
Arguments:
aColumn - <CwTableColumn>
 
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.
Arguments:
items - <OrderedCollection> of <CwTableItem> or an object conforming to the public API of CwTableItem.
 
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
editable
Answer the value of the XmNeditLabels resource.
Default setting: false
Resource access: CSG
Description:
Indicates whether the receiver will accept entry from the user directly into its cells. A false value will prohibit the user from editing the receiver's cells.
Answers: <Boolean>
 
editable: aBoolean
Set the value of the XmNeditLabels resource to @aBoolean.
Default setting: false
Resource access: CSG
Description:
Indicates whether the receiver will accept entry from the user directly into its cells. A false value will prohibit the user from editing the receiver's cells.
Arguments:
<Boolean> - true if the cells in the table will accept entry from the user.
 
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>
 
findItem: aStartItem text: aText partial: aBoolean
Searches for a list-view item with the specified label text. Answer a matching table item or nil.
Arguments:
aStartItem - <CwTableItem>
aText - <String>
aBoolean - < Boolean >
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.
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.
Arguments:
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: XmCELLSINGLESELECT
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: XmCELLSINGLESELECT
Resource access: CSG
Description:
The selection policy defines the interpretation of the selection action.
Arguments:
<Integer> - 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.
 
 
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. This can be one of the following:
XmAscending.
XmDescending.
Answers:
<Integer> - XmAscending or XmDescending
 
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:
XmAscending.
XmDescending.
Arguments:
<Integer> XmAscending or XmDescending
 
Callbacks and Events
XmNactivateCallback
Callback reason: XmCRACTIVATE
Calldata structure: CwTableItemCallbackData
Description:
This is called when the table is activated.
 
XmNcolumnClickCallback
Callback reason: XmCRACTIVATE
Calldata structure: CwTableItemCallbackData
Description:
This is called when an column in the table is clicked .
 
XmNdrawCallback
Callback reason: XmCRAPPLY
Calldata structure: CwTableItemDrawCallbackData
Description:
This is called the table is exposed or or any cells are redrawing..
 
XmNdrawHeaderCallback
Callback reason: XmCRAPPLY
Calldata structure: CwTableItemDrawCallbackData
Description:
This is called when a header in the table or any cells are redrawn.
 
XmNeditCallback
Callback reason: XmCRARM, XmCRDISARM
Calldata structure: CwTableItemCallbackData
Description:
This is called when cell is edited. Reason for arming and disarming are beginEdit and endEdit respectively.
 
XmNfindCallback
Callback reason: XmCRNOMATCH
Calldata structure: CwTableItemCallbackData
Description:
This is called when in response to a CwTable>>#findItem:text or CwTable>>#findItem:text:partial: request.
 
XmNmodifyVerifyCallback
Callback reason: XmCRVALUECHANGED, XmCRMODIFYINGTEXTVALUE
Calldata structure: CwTableItemCallbackData, CwTextVerifyCallbackData
Description:
This 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.
 
XmNmultipleSelectionCallback
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:
This is called when an item is selected and the table’s selection policy is set to XmEXTENDEDSELECT.
 
XmNsingleSelectionCallback
Callback reason: XmCRSINGLESELECT, XmCRCELLSINGLESELECT
Calldata structure: CwAnyCallbackData, CwTableItemCallbackData
callData data at: 1 - point of action.
Description:
This is called when an item is selected and the table’s selection policy is set to XmSINGLESELECT or XmEXTENDEDSELECT.
 
XmNvirtualCallback
Callback reason: XmCRICONIFY, XmCRCASCADING
Calldata structure: CwTableItemCallbackData
callData item - index of start item.
callData subItem - index of end item.
Description:
This is called when the receiver has virtualItems set to true and an item is comes into view.
 
Example
 
| shell form widget |
shell := CwTopLevelShell
createApplicationShell: 'CwTableExample'
argBlock: nil.
shell realizeWidget.
form := CwForm createWidget: 'form'
parent: shell
argBlock: [:w | w yourself].
form manageChild.
widget := self form
createScrolledCwTable: 'data_table'
argBlock: [:w | w
selectionPolicy: XmSINGLESELECT. ].
widget manageChild.
 
widget
columns: (OrderedCollection
with: (CwTableColumn new
labelString: 'Column0';
width: 120)
with: (CwTableColumn new
labelString: 'Column1';
width: 120)
);
items: (OrderedCollection new
add: (CwTableItem new labelString: 'Item1') ;
add: (CwTableItem new labelString: 'Item2'; cells: #('sub2-1') );
yourself).
 
widget setValuesBlock: [:w |
w
leftAttachment: XmATTACHFORM;
rightAttachment: XmATTACHFORM;
rightOffset: 10;
topAttachment: XmATTACHFORM;
bottomAttachment: XmATTACHFORM;
bottomOffset: 10;
yourself].
 
 
Last modified date: 04/12/2023