Row creation
The CwTable provides several ways to populate the rows with data.
•The most primitive is to add instances of CwTableItem to the items in the table. You can configure the table items using blocks of code or by instantiation a CwTableItem, customizing it, and passing it to the table.
•A more sophisticate way is to add user data (data items) to the rows of a table using column attributes which match attributes in the user data. If any of these attributes represent non-string objects, converters in the columns with these attributes can accomplish the task of formatting the non-string object into a string.
addDataItem: theData
Add theData as a child of the receiver. Answer the new table item widget.
Arguments:
theData - <Object>.Data to be displayed in a row of the table.
Answers: <CwTableItem or nil> nil if no row of data could be created
addItem: theTableItem
Add theTableItem 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 theTableItem 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>
dataItems
Answer the user data in the receiver.
Default setting: OrderedCollection new
Resource access: SG
Answers: <OrderedCollection> of <Object>
Objects are user data which do one of the following and thereby provide information to populate cells in the table with CwTableItems:
•answer string to the attributeNames of the table or its columns or
•answer an object to the attributeNames which converters in the columns can format as strings or
•answer a CwTableItem in response to the message #asCwTableItem
dataItems: anItemCollection
Set the user data displayed in the receiver.
Default setting: OrderedCollection new
Resource access: SG
Arguments:
anItemCollection - <OrderedCollection> of <Object>
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>
Functions
The following function messages can only be sent to the widget after it has been created.
columnCount
Answer the number of columns in the receiver.
Answers: <Integer>
columnSelected
Answer the selected column in the receiver.
Answers: <CwTableColumn>
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>
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>
selectedDataItem
Answer user data object in the selected items in the receiver.
Answers: <Object>
selectedDataItems
Answer user data object in the selected items in the receiver.
Answers: <Ordered Collection of Object>
selectedItems
Answer selected items in the receiver.
Answers: <Ordered Collection of CwTableItem>
topIndex
Answer index in the receiver of the topmost visible item.
Answers: <Integer>
Data formatting
The text color of user data occupying a row or the icon appearing at the left of the row can be customized using the methods that follow.
iconSelector
Answer the unary selector sent to a user data item in the table to return its icon.
The return value of the selector, when sent to the user data can be CgIcon or CgPixmap or nil.
Answers: <Symbol>
iconSelector: aSymbol
Answer the unary selector sent to a user data item in the table to return its icon.
The return value of the selector, when sent to the user data can be CgIcon or CgPixmap or nil.
Arguments: <Symbol>
colorSelector
Answer the unary selector sent to a user data item in the table to return its text color.
The return value of the selector, when sent to the user data can be aColor or nil.
Answers: <Symbol>
colorSelector: aSymbol
Answer the unary selector sent to a user data item in the table to return its text color.
The return value of the selector, when sent to the user data can be aColor or nil.
Arguments: <Symbol>
Data Editing
If a CwTable is editable, and its columns are equipped with attributes, the changes to the table cells are propagated to the user data (model) which the table is displaying. If any attribute of user data is not a simple string, that the column with that attribute must also have a converter to handle transformation of the string to a suitable object.