IupColorDlg

2

IupColorDlg

@serial = 697

dialog

Description

Creates the Color Dialog element. It is a predefined dialog for selecting a color.

There are 3 versions of the dialog. One for Windows only, one for GTK only and one for all systems, but it is based on the IupColorBrowser control that depends on the CD library.

The Windows and GTK dialogs can be shown only with the IupPopup function. The IupColorBrowser based dialog is a IupDialog that can be shown as any regular IupDialog.

IMPORTANT: The IupColorBrowser based dialog is included in the Controls Library. When the Controls Library is initialized the Windows and GTK dialogs are not available anymore, i.e. before the Controls Library initialization only the Windows and GTK dialogs are available, after only the IupColorBrowser based dialog is available.

Include

iup.e

Namespace

iup

Signature

public function IupColorDlg()

Creation

Returns: the identifier of the created element, or NULL if an error occurs.

Attribute

ALPHA [ColorBrowser and GTK only]: if defined it will enable an alpha selection additional controls with its initial value. If the user pressed the Ok button contains the returned value. Default: no defined, or 255 if SHOWALPHA=YES.

COLORTABLE: list of colors separated by ";". In GTK and in the ColorBrowser based accepts 20 values and if not present the palette will not be visible. In Windows accepts 16 values and will be always visible, even if the colors are not defined (in this case are initialized with black). If a color is not specified then the default color is used. You can skip colors using ";;".

PARENTDIALOG (creation only): Name of a dialog to be used as parent. This dialog will be always in front of the parent dialog.

SHOWALPHA [ColorBrowser and GTK only]: if enabled will display the alpha selection controls, regardless if ALPHA is defined for the initial value or not.

SHOWCOLORTABLE: if enabled will display the color table, regardless if COLORTABLE is defined or not. The default colors in the color table are different in GTK and in the ColorBrowser based dialog. In Windows the default colors are all black.

SHOWHEX [ColorBrowser only]: if enabled will display the Hexadecimal notation of the color.

SHOWHELP [ColorBrowser only]: if enabled will display the Help button. In GTK and Windows, the Help button is shown only if the HELP_CB callback is defined.

STATUS (read-only): defined to "1" if the user pressed the Ok button, NULL if pressed the Cancel button.

TITLE: Dialog title.

VALUE: The color value in RGB coordinates and optionally alpha. It is used as the initial value and contains the selected value if the user pressed the Ok button. Format: "R G B" or "R G B A". Each component range from 0 to 255.

VALUEHSI [ColorBrowser only]: The color value in HSI coordinates. It is used as the initial value and contains the selected value if the user pressed the Ok button. Format: "H S I". Each component range from 0-359, 0-100 and 0-100 respectively.

VALUEHEX [ColorBrowser only]: The color value in RGB Hexadecimal notation. It is used as the initial value and contains the selected value if the user pressed the Ok button. Format: "#RRGGBB". Each component range from 0-255, but in hexadecimal notation.

Callback

COLORUPDATE_CB [ColorBrowser only]: Action generated when the color is updated in the dialog. It is also called when the color is updated programmatically. (since 3.11) int function(Ihandle* ih); [in C] elem:colorupdate_cb() -> (ret: number) [in Lua]

ih: identifier of the element that activated the event.

HELP_CB: Action generated when the Help button is pressed.

Notes

The GTK and Windows dialogs are native pre-defined dialogs that are not altered by IupSetLanguage. To show the dialog, use function IupPopup. In Lua, use the popup function. The dialog is mapped only inside IupPopup, IupMap does nothing.

Example

include iup/iup.e 
IupOpen(NULL) 
 
atom dlg = IupColorDlg() 
 
IupSetAttribute(dlg, "VALUE", "128 0 255") 
IupSetAttribute(dlg, "ALPHA", "142") 
IupSetAttribute(dlg, "SHOWHEX", "YES") 
IupSetAttribute(dlg, "SHOWCOLORTABLE", "YES") 
IupSetAttribute(dlg, "TITLE", "IupColorDlg Test") 
--IupSetCallback(dlg, "HELP_CB", (Icallback)help_cb) 
 
IupPopup(dlg, IUP_CURRENT, IUP_CURRENT) 
 
if (IupGetInt(dlg, "STATUS")) then 
 
  printf(1,"OK\n") 
  printf("  COLOR(%s)\n", IupGetAttribute(dlg, "COLOR")) 
  printf("  COLORTABLE(%s)\n", IupGetAttribute(dlg, "COLORTABLE")) 
 
else 
  printf(1,"CANCEL\n") 
end if 
 
IupDestroy(dlg) 
 
 IupMainLoop() IupClose() 

See Also

IupFileDlg IupMessageDlg IupFontDlg IupProgressDlg IupAlarm IupGetFile IupGetColor IupGetParam IupGetText IupListDialog IupMessage IupScanf IupLayoutDialog IupElementPropertiesDialog
Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu