Skip to content

The RGBColorSystem Class

The RGBColorSystem (RGBColor.pkg) converts RGB color values to their respective color names, etc. This class is used in the Studio to display colors; you can use this class to provide a list to populate a combo form or popup menu. Consult the source code for this class to see the interface. The following sample code demonstrates its usage:

Use DFAllEnt.pkg
Use RgbColor.pkg

Object oRGBColorSystem is a RGBColorSystem
    // Create an instance to receive the colors
End_Object

Class cColorCombo is a ComboForm
    Procedure Construct_Object
        Forward Send Construct_Object
        Set Size To 100 100
        Set Entry_State 0 To False
    End_Procedure

    Procedure OnAddColor String sColorName Integer iColorId
        // This event is received once for each color to add
        Send Combo_Add_Item sColorName
    End_Procedure

    Procedure OnChange
        Integer iColor
        String sColor
        Get Value 0 To sColor
        // Now convert the name to its color-id
        Get ColorNameToColorId of oRGBColorSystem sColor To iColor
        Set Color To iColor
    End_Procedure
End_Class

Object oPanel is a Panel
    Set Size To 100 270
    Set Label To 'Using the RGB Color System'

    Object oStandard_cc is a cColorCombo
        Set Location To 10 100
        Set Label To 'Standard:'
        // Now enumerate the colors. This sends the OnAddColor
        // message to the current object (defined in the
        // class) passing a symbol representing the style
        // of colors that are required.
        Send DoEnumColorNames of oRGBColorSystem msg_OnAddColor Self csStandard
    End_Object

    Object oSystem_cc is a cColorCombo
        Set Location To 30 100
        Set Label To 'System:'
        Send DoEnumColorNames of oRGBColorSystem msg_OnAddColor Self csSystem
    End_Object

    Object oAllColors_cc is a cColorCombo
        Set Location To 50 100
        Set Label To 'All Colors:'
        // You may want to set the Combo_Sort_State
        // property to False to stop automatic sorting.
        Send DoEnumColorNames of oRGBColorSystem msg_OnAddColor Self csAnyStyle
    End_Object
End_Object

Start_Ui

See Also

Understanding RGB Colors