Topic: APLX Help : System Classes : List of Classes : ChooseColor
[ Previous | Next | Contents | Index | APL Home ]

www.microapl.co.uk

ChooseColor


Alternative name: ChooseColour

Description

The ChooseColor class implements the pre-defined color-selection dialog. This is a top-level object (i.e. it should not be opened as the child of a window).

To use the dialog, you must first create it using ⎕NEW. (Alternatively, you can create it as a top-level object using the New or Create method of ⎕WI). It will remain hidden at this stage. You can optionally set the initial color selection as the first element of the color property (foreground color only).

The style property applies to Windows only (it is ignored under MacOS and Linux). It defines whether the user can select custom colors, by selecting one of:

 0 = Allow custom colours
 1 = Open with custom colours displayed
 2 = Disallow custom colors

You can also add the following to style:

 4 = Return nearest solid colour
 8 = Allow any colour, dither if necessary

Under Windows and Linux, you can pre-define up to 16 custom colors by setting the custom property, as a vector of 16 integers representing the RGB values of each color. (This property is ignored under MacOS).

To set the color which will be selected when the dialog is shown, you can assign a value to the color property.

When you are ready to show the dialog, call the Show method. This displays the modal dialog. The user can then select a color; if the Cancel button is pressed, the Show method returns 0. If the OK button is pressed, the Show method returns 1. You can then read the color property to retrieve the color selected by the user (only the first element is used); if this is ¯1, the user has selected an undefined custom color. Under Windows and Linux, you can also optionally read the custom property to retrieve the list of any custom colors which the user has defined, as a vector of up to 16 integers.

Example

     ∇DEMO_ChooseColor;DLG
[1]   ⍝ Sample function demonstrating use of the ChooseColor object
[2]   DLG←'⎕' ⎕NEW 'ChooseColor'
[3]   ⍝ Show the dialog. If user presses Cancel, quit
[4]   :If 1=DLG.Show
[5]     ⍝ He pressed OK.
[6]     'Color chosen: ',⍕1↑DLG.color
[7]   :EndIf
     ∇

Properties

children class color custom data events methods name opened properties self style tie

Methods

Close Create Delete New Open Send Set Show Trigger

Callbacks

onClose onDestroy onOpen onSend


Topic: APLX Help : System Classes : List of Classes : ChooseColor
[ Previous | Next | Contents | Index | APL Home ]