Table colour clauses¶
colour_record = record_id
The record_id is the identifier of a !record structure with the following form:
N should be replaced by an integer value corresponding to the number of elements (cells) displayed in each line of the table. The name and type of the field Cell must be exactly as specified in the definition.
The Cell field contains 24-bit, RGB definitions of the foreground and background colours required for each cell. A wide selection of useful colour definitions are contained in the file rgb.h, which is automatically included in <sculptor.h>.
The value of Cell[N, 1] defines the foreground colour for cell N, the first cell in a line being cell 1.
The value of Cell[N, 2] defines the background colour for cell N.
The value of Cell[N, 3] defines the foreground colour for the text of a column heading button in column N. This and the next value are only applicable to columns where the heading_type is THCT_COLOURBUTTON. See Table cell properties.
The value of Cell[N, 4] defines the background colour for the text of a column heading button in column N.
The value of Cell[N, 5] defines the transparent colour for the column heading button in column N. It is only applicable to columns where the heading_type is THCT_IMAGEBUTTON or THCT_TEXTIMAGEBUTTON. See Table cell properties
The field Cell may be allocated a single dimension only:
Cell,,i4[N]
In this case only the cell foreground colours are defined; the default value for background colours is used. Note that Cell must have at least one dimension. Similarly, if the dimension is less than [N, 4], default foreground and background colours are used for coloured button heading text.
If all the lines in the table are to use the same colours, it is only necessary to initialise the colour record before the table is created.
If all lines are not to use the same colours, set the required colours in the Cell field in the event function for the EV_SUPPLY_COLOUR event, which is called as follows:
func_id(EV_SUPPLY_COLOUR, table_id, line)
This event is generated when the table is being created and scrolled. If the source object is a function, the EV_SUPPLY_COLOUR event is called after the EV_SUPPLY_VALUE event.
The line defines the line in the table which is to be filled. The function should assign the required colours to the elements of Cell.
RELATED TOPICS |
RGB values¶
An RGB value has the form 0x80bbrrgg, where bb is blue intensity, rr is red intensity and gg is green intensity. The top bit (0x80xxxxxx) must be set to activate the colour. This is a Sculptor feature that makes it possible to switch pre-defined colours on and off by setting or clearing the top bit. To switch a colour on or off, use the forms:
Cell[dims] = Cell[dims] | RGB_ACTIVATE |
switch a colour on |
Cell[dims] = Cell[dims] & RGB_INACTIVE |
switch a colour off |
If a colour is not active, the appropriate default colour is used for the display of data in that cell.
This feature also makes it possible to distinguish between the default colour (0x00000000) and black (0x80000000).
RELATED TOPICS |
NOTES
The compiler accepts the spelling “colour” or “color”.
When the EV_SUPPLY_COLOUR event is called, the display record contains the values for the current line. If the source object is a file, the file’s default record buffer contains the corresponding record from the file. This is a temporary assignment; the default record buffer is reset to its previous value when the EV_SUPPLY_COLOUR event function returns.
EXAMPLE
/* Define a colour record for a table with 2 columns */
!record CountryColour {
Cell,,i4[2,5]
}
/* cell property record, used here to define column heading type */
!record CountryProps {
heading_type,,u1[2]
}
+window winmain at 1,1 {
-table CountryTable at 20,4 {
colour_record = CountryColour
event = CountryEvent
other table clauses
}
}
/* Assign column heading type - colour button with text */
CountryProps.heading_type[1] = THCT_COLOURBUTTON
CountryProps.heading_type[2] = THCT_COLOURBUTTON
/* Foreground colour for text in first column heading */
CountryColour.Cell[1,3] = RGB_DARKORCHID
/* Background colour for text in first column heading */
CountryColour.Cell[1,4] = RGB_GHOSTWHITE
/* Foreground colour for text in second column heading */
CountryColour.Cell[2,3] = RGB_INDIGO
/* Background colour for text in first column heading */
CountryColour.Cell[2,4] = RGB_LIGHTCORAL
create wintask.CountryTable
dialog wintask
exit
!function CountryEvent(EventCode, Table, Line, State) {
switch (EventCode) {
case = EV_SUPPLY_COLOUR:
/* Set a special colour scheme for countries with name beginning "G" */
if (CountryDisplay.Name bw "G") {
CountryColour.Cell[1,1] = RBG_BLUE /* Foreground colour for the first cell */
CountryColour.Cell[1,2] = RBG_YELLOW /* Background colour for the first cell */
CountryColour.Cell[2,1] = RBG_RED /* Foreground colour for the second cell */
CountryColour.Cell[2,2] = RBG_BLACK /* Background colour for the second cell */
} else if (CountryDisplay.Name bw "H") {
/* And another for countries with name beginning "H" */
CountryColour.Cell[1,1] = RBG_WHITE
CountryColour.Cell[1,2] = RBG_CYAN
CountryColour.Cell[2,1] = RBG_CORNFLOWERBLUE
CountryColour.Cell[2,2] = RBG_LIGHTSALMON
} else {
/* Restore default colours if RGB colour control is not to be used for this line*/
CountryColour.Cell[1,1] = 0
CountryColour.Cell[1,2] = 0
CountryColour.Cell[2,1] = 0
CountryColour.Cell[2,2] = 0
}
break
}
other event codes
}
RELATED TOPICS |