CwTable
CwTable provides a great looking widget for row and column data. It implements the Windows Table Control for a native native Windows look. CwTable collaborates with CwTableColumn and CwTableItem to display data in a grid format.
The CwTable can add and delete columns represented by instances of CwTableColumn. It can add and delete rows represented by instances of CwTableItem.
Note:
The CwTable was designed to configure and add the columns before adding rows containing user data.
Configuring columns to have some idea about properties of the user data such as how to get a value to put in a cell (#attributeName) or how to format an object returned from that attribute into a string (using a column converter) makes it convenient to put complex user data into each row of the column. However, errors will result if the user data does not comport with the customized column.
Display oddities may result if the configuration of the column and its header, (including hiding and showing it) occur after the table has been rendered visible.
TableConstants pool dictionary
The Windows specific CwTable control uses pool dictionary called TableConstants to provide pool variables for constant values. For example, pool variables such as XmATTACHFORM and XmNactivateCallback are used as arguments to methods sent to these controls. These pool variable names should be used rather than directly using their constant values. All classes that require these pool variable names must include the relevant pool dictionary in their class definition.
Many use constants are also defined in the CwConstants and EwConstants pool dictionaries.
Protocol
Several protocols exist to get and set the control’s resources; another group of protocols specify functions which apply to the control once it is created Finally the table can register certain methods which can be sent to user data occupying a row to determine the text color of an icon to be displayed on the row.
Resources
The table can be configured through various resources which define the behavior and appearance of the widget.
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>
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.
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.
showColumnHeadings
Answer the whether column headings are visible.
Default setting: true
Resource access: CSG
Description:
Whether the receiver displays a header at the top of each column.
Answers: <Boolean>
showColumnHeadings: aBoolean
Set the whether column headings are visible to aBoolean.
Default setting: true
Resource access: CSG
Description:
Whether the receiver displays a header at the top of each column.
Arguments:
resourceValue - <Boolean>
showGridLines
Answer whether the horizontal and vertical grid lines are visible.
Answers: <Boolean>
showGridLines: aBoolean
Set whether the horizontal and vertical grid lines are visible to aBoolean.
Default setting: true
Resource access: CSG
Description:
Whether the receiver displays lines between its items and columns.
Arguments:
resourceValue - <Boolean>
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
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
These are the methods used to add a column to a table. It is possible to customize a column using a block or by passing a pre-customized column.
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>