Using BColorControl

A BColorControl object displays an on-screen device that permits users to pick a color. It reports the color as its current value - an rgb_color data structure stored as a 32-bit integer. If a model message is provided, it announces each change in value by sending a copy of the message to a designated target.

When the screen is 8 bits deep, the BColorControl object presents users with a matrix of the 256 available colors. The user chooses a color by pressing the primary mouse button while the cursor is over one of the cells in the matrix. Dragging from cell to cell changes the selected color. The arrow keys can similarly change the selection when the object is the focus view. The BColorControl's value changes each time the selection does.

colorcontrol1.png

When the screen is 15, 16, or 32 bits deep, the BColorControl object displays ramps for each color component. The user changes the current color by modifying a red, green, or blue component value.

In addition to the color matrix and ramp, a BColorColor has three text fields where the user can set a color by typing in its red, green, and blue component values. The text fields (BTextControl objects) are children of the BColorControl.

Archived Fields

The Archive() function adds the following fields to its BMessage argument:
Field Type code Meaning
"_layout" B_INT32_TYPE The layout of the matrix of 256 color cells.
"_csize" B_FLOAT_TYPE Size of a single cell in the matrix of 256 color cells.
"_use_off" B_BOOL_TYPE Whether the control uses buffered drawing.
The following views are added to the "_views" field (deep copy only):
Name Level Meaning
"_red" 0 BTextControl for the "red" field.
"_green" 0 BTextControl for the "green" field.
"_blue" 0 BTextControl for the "blue" field.

Copyright 2005 by yellowTAB GmbH, Be Inc., Palm Source Inc. and their respective legal successors
All rights reserved.