CommonCtrl.colorpicker
color-picker control
Title |
color-picker control |
Author(s) |
LiXizhi |
Date |
2008/6/8 |
File |
script/ide/colorpicker.lua |
Description
ColorPicker displays a color edit control with 3 sliderbars to adjust R,G,B value
Sample Code
NPL.load("(gl)script/ide/colorpicker.lua");
local ctl = CommonCtrl.ColorPicker:new({
name = "coloredit",
r = 255,
g = 255,
b = 255,
left = 0,
top = 0,
width = 182,
height = 72,
parent = nil,
onchange = nil,
background = nil,
});
ctl:Show();
Member Functions
ColorPicker:new
define a new control in the common control libary
default member attributes
local ColorPicker = {
-- normal window size
alignment = "_lt",
left = 0,
top = 0,
width = 182,
height = 72,
r = 255,
g = 255,
b = 255,
-- container background, default to nil.
background = nil,
-- parent UI object, nil will attach to root.
parent = nil,
-- the top level control name
name = "defaultcoloredit",
-- onchange event, it can be nil, a string to be executed or a function of type void ()(sCtrlName, r,g,b)
onchange= nil
}
ColorPicker =
ColorPicker;
constructor
syntax
function ColorPicker:new (o)
parameters
ColorPicker:Destroy
Destroy the UI control
syntax
function ColorPicker:Destroy ()
ColorPicker:SetRGB
set/get the rgb of the control.
syntax
function ColorPicker:SetRGB(r,g,b)
parameters
ColorPicker:SetRGBString
set/get the rgb of the control. such as "255 255 255"
- param silent : if true, no onchange or UI update is called.
syntax
function ColorPicker:SetRGBString(rgb, silent)
parameters
rgb |
|
silent |
if true, no onchange or UI update is called. |
ColorPicker:GetRGBString
- return color : such as "255 255 255"
syntax
function ColorPicker:GetRGBString()
parameters
return |
such as "255 255 255" |
ColorPicker:SetValue
- param value : such as "255 255 255" or "#FFFFFF"
- param silent : if true, no onchange or UI update is called.
syntax
function ColorPicker:SetValue(color, silent)
parameters
ColorPicker:GetValue
- return color : such as "255 255 255"
syntax
function ColorPicker:GetValue()
parameters
return |
such as "255 255 255" |
ColorPicker.Update
[[ update the r,g,b, values from the control.
- param sCtrlName : if nil, the current control will be used. if not the given control is updated. ]]
syntax
function ColorPicker.Update(sCtrlName)
parameters
sCtrlName |
if nil, the current control will be used. if not the given control is updated. ]] |