NAME
IUP::ColorBar - [GUI element] color palette for color selection of 1 or 2 colors
DESCRIPTION
Creates a color palette to enable a color selection from several samples. It can select one or two colors. The primary color is selected with the left mouse button, and the secondary color is selected with the right mouse button. You can double click a cell to change its color and you can double click the preview area to switch between primary and secondary colors.
USAGE
CREATION - new() method
$colorbar = IUP::Colorbar->new( SIZE=>"300x300" );
Returns: the identifier of the created element, or undef
if an error occurs.
NOTE: You can pass to new()
other ATTRIBUTE=>'value'
or CALLBACKNAME=>\&func
pairs relevant to this element - see IUP::Manual::02_Elements.
ATTRIBUTES
For more info about concept of attributes (setting/getting values etc.) see IUP::Manual::03_Attributes. Attributes specific to this element:
- BUFFERIZE
-
(non inheritable)
Disables the automatic redrawing of the control, so many attributes can be changed without many redraws. Default: "NO". When set to "NO" the control is redrawn.
- CELn
-
Contains the color of the "n" cell. "n" can be from 0 to NUM_CELLS-1.
- NUM_CELLS
-
(non inheritable)
Contains the number of color cells. Default: "16". The maximum number of colors is 256. The default colors use the same set of IUP::Image.
- COUNT
-
(read-only) (non inheritable)
Same as NUM_CELLS but it is read-only. (since iup-3.3)
- NUM_PARTS
-
(non inheritable)
Contains the number of lines or columns. Default: "1".
- ORIENTATION
-
Controls the orientation. It can be "VERTICAL" or "HORIZONTAL". Default "VERTICAL".
- PREVIEW_SIZE
-
(non inheritable)
Fixes the size of the preview area in pixels. The default size is dynamically calculated from the size of the control. The size is reset to the default when SHOW_PREVIEW=NO.
- SHOW_PREVIEW
-
Controls the display of the preview area. Default "YES".
- SHOW_SECONDARY
-
Controls the existence of a secondary color selection. Default "NO".
- SIZE
-
there is no initial size. You must define SIZE or RASTERSIZE.
- PRIMARY_CELL
-
(non inheritable)
Contains the index of the primary color. Default "0" (black).
- SECONDARY_CELL
-
(non inheritable)
Contains the index of the secondary color. Default "15" (white).
- SQUARED
-
Controls the aspect ratio of the color cells. Non square cells expand equally to occupy all of the control area. Default: "YES".
- SHADOWED
-
Controls the 3D effect of the color cells. Default "YES".
- TRANSPARENCY
-
Contains a color that will be not rendered in the color palette. The color cell will have a white and gray chess pattern. It can be used to create a palette with less colors than the number of cells.
The following common attributes are also accepted:
ACTIVE, BGCOLOR, FONT, SCREENPOSITION, POSITION, MINSIZE, MAXSIZE, WID, TIP, EXPAND, SIZE, RASTERSIZE, ZORDER, VISIBLE
CALLBACKS
For more info about concept of callbacks (setting callback handlers etc.) see IUP::Manual::04_Callbacks. Callbacks specific to this element:
- CELL_CB
-
called when the user double clicks a color cell to change its value.
Callback handler prototype:
sub cell_cb_handler { my ($self, $cell) = @_; #... }
$self: reference to the element (IUP::ColorBar) that activated the event
$cell: index of the selected cell. If the user double click a preview cell, the respective index is returned.
Returns: a new color or
undef
to ignore the change. By default nothing is changed. - EXTENDED_CB
-
called when the user right click a cell with the Shift key pressed. It is independent of the SHOW_SECONDARY attribute.
Callback handler prototype:
sub extended_cb_handler { my ($self, $cell) = @_; #... }
$self: reference to the element (IUP::ColorBar) that activated the event
$cell: index of the selected cell.
Returns: If IUP_IGNORE the cell is not redrawn. By default the cell is always redrawn.
- SELECT_CB
-
called when a color is selected. The primary color is selected with the left mouse button, and if existent the secondary is selected with the right mouse button.
Callback handler prototype:
sub extended_cb_handler { my ($self, $cell, $type) = @_; #... }
$self: reference to the element (IUP::ColorBar) that activated the event
$cell: index of the selected cell.
$type: indicates if the user selected a primary or secondary color. In can be:
IUP_PRIMARY(-1)
orIUP_SECONDARY(-2)
.Returns: If IUP_IGNORE the selection is not accepted. By default the selection is always accepted.
- SWITCH_CB
-
called when the user double clicks the preview area outside the preview cells to switch the primary and secondary selections. It is only called if SHOW_SECONDARY=YES.
Callback handler prototype:
sub extended_cb_handler { my ($self, $prim_cell, $sec_cell) = @_; #... }
$self: reference to the element (IUP::ColorBar) that activated the event
$prim_cell: index of the actual primary cell.
$sec_cell: index of the actual secondary cell.
Returns: If IUP_IGNORE the switch is not accepted. By default the switch is always accepted.
The following common callbacks are also accepted:
NOTES
When the control has the focus the keyboard can be used to change the colors and activate the callbacks. Use the arrow keys to move from cell to cell, Home goes to the first cell, End goes to the last cell. Space will activate the SELECT_CB callback for the primary color, Ctrl+Space will activate the SELECT_CB callback for the secondary color. Shift+Space will activate the EXTENTED_CB callback. Shift+Enter will activate the CELL_CB callback.
EXAMPLES
The element IUP::ColorBar is used in the following sample scripts:
0-basic/colorbar.pl - IUP::ColorBar example
SEE ALSO
The original doc: iupcolorbar.html