---++!! !_gui_helper %TOC{title="Contents:"}% %STARTINCLUDE% ---++ GUI helper functions for ParaEngine | *Title* | GUI helper functions for ParaEngine | | *Author(s)* | LiXizhi, WangTian | | *Date* | 2005/10 | | *File* | script/ide/gui_helper.lua | ---+++ Description ---+++ Member Functions ---++++ !_guihelper.SetUIColor [[ Set all texture layers of an UI object to the specifed color if UIobject is nil or is an invalid UI object, this function does nothing. e.g. _guihelper.SetUIColor(uiobject, "255 0 0"); or _guihelper.SetUIColor(uiobject, "255 0 0 128"); ]] __syntax__ <verbatim>function _guihelper.SetUIColor(uiobject, color)</verbatim> __parameters__ | *uiobject* | | | *color* | | ---++++ !_guihelper.SetFontColor set the text font color of a UI control. * _param_ __color__ : it can be "255 255 255", "#FFFFFF", "255 255 255 100", alpha is supported. __syntax__ <verbatim>function _guihelper.SetFontColor(uiobject, color)</verbatim> __parameters__ | *uiobject* | | | *color* | it can be "255 255 255", "#FFFFFF", "255 255 255 100", alpha is supported. | ---++++ !_guihelper.SetButtonTextColor set the text font color of a UI control. * _param_ __color__ : it can be "255 255 255", "#FFFFFF", "255 255 255 100", alpha is supported. __syntax__ <verbatim>function _guihelper.SetButtonTextColor(uiobject, color)</verbatim> __parameters__ | *uiobject* | | | *color* | it can be "255 255 255", "#FFFFFF", "255 255 255 100", alpha is supported. | ---++++ !_guihelper.GetTextWidth get the width of text of a given font. It internally cache the font object and UI object on first call. * _param_ __text__ : text for which to determine the width * _param_ __fontName__ : font name, such as "System;12". If nil, it will use the default font of text control. * _return_ __the__ : width of text of a given font __syntax__ <verbatim>function _guihelper.GetTextWidth(text, fontName)</verbatim> __parameters__ | *text* | text for which to determine the width | | *fontName* | | | *return* | width of text of a given font | ---++++ !_guihelper.SetUIFontFormat * _param_ __uiobject__ : uiobject such as button * _param_ __format__ : 0 for left alignment; 1 for horizontal center alignment; 4 for vertical center aligntment; 5 for both vertical and horizontal; 32 for single-lined left bottom alignment, 36 for single-lined vertical center alignment DT_TOP 0x00000000 DT_LEFT 0x00000000 DT_CENTER 0x00000001 DT_RIGHT 0x00000002 DT_VCENTER 0x00000004 DT_BOTTOM 0x00000008 DT_SINGLELINE 0x00000020 DT_WORDBREAK 0x00000010 DT_NOCLIP 0x00000100 __syntax__ <verbatim>function _guihelper.SetUIFontFormat(uiobject, format)</verbatim> __parameters__ | *uiobject* | uiobject such as button | | *format* | | ---++++ !_guihelper.RGBA_TO_DWORD * _param_ __r__ :, g, b, a: each in [0,255] __syntax__ <verbatim>function _guihelper.RGBA_TO_DWORD(r, g, b, a)</verbatim> __parameters__ | *r* | , g, b, a: each in [0,255] | | *g* | | | *b* | | | *a* | | ---++++ !_guihelper.DWORD_TO_RGBA * _param_ __r__ :, g, b, a: each in [0,255] * _return_ __r__ :, g, b, a: each in [0,255] __syntax__ <verbatim>function _guihelper.DWORD_TO_RGBA(w)</verbatim> __parameters__ | *w* | | ---++++ !_guihelper.SafeSetText [[ set the text of a ui control by its name. * _param_ __objName__ :name of the object * _param_ __newText__ : string of the new text. ]] __syntax__ <verbatim>function _guihelper.SafeSetText(objName, newText)</verbatim> __parameters__ | *objName* | name of the object | | *newText* | | ---++++ !_guihelper.SafeGetNumber [[ get the text of a ui control as a number. return nil if invalid. * _param_ __objName__ :name of the object * _return_ ____ : number or nil ]] __syntax__ <verbatim>function _guihelper.SafeGetNumber(objName)</verbatim> __parameters__ | *objName* | name of the object | ---++++ !_guihelper.SafeGetText [[ get the text of a ui control as a number. return nil if invalid. * _param_ __objName__ :name of the object, such as {"name1", "name2"} * _return_ ____ : number or nil ]] __syntax__ <verbatim>function _guihelper.SafeGetText(objName)</verbatim> __parameters__ | *objName* | name of the object, such as {"name1", "name2"} | ---++++ !_guihelper.CheckRadioButtons [[ * _param_ __objList__ : an array of button names. * _param_ __selectedName__ : name of the selected button. If nil, nothing will be selected. * _param_ __color__ : color used for highlighting the checked button. * _param_ __checked__ :_bg, unchecked_bg: can be nil or the texture of the checked and unchecked state. ]] __syntax__ <verbatim>function _guihelper.CheckRadioButtons(objList, selectedName, color, checked_bg, unchecked_bg)</verbatim> __parameters__ | *objList* | an array of button names. | | *selectedName* | | | *color* | color used for highlighting the checked button. | | *checked* | | | *bg* | | | *unchecked* | | | *bg* | | ---++++ !_guihelper.CheckRadioButtons2 NOTE: --WangTian: change background for group of buttons [[ * _param_ __objList__ : an array of button names. * _param_ __selectedName__ : name of the selected button. If nil, nothing will be selected. * _param_ __color__ : color used for highlighting the checked button. * _param_ __checked__ :_bg, unchecked_bg: can be nil or the texture of the checked and unchecked state. ]] __syntax__ <verbatim>function _guihelper.CheckRadioButtons2(objList, selectedName, color, checked_bg, unchecked_bg)</verbatim> __parameters__ | *objList* | an array of button names. | | *selectedName* | | | *color* | color used for highlighting the checked button. | | *checked* | | | *bg* | | | *unchecked* | | | *bg* | | ---++++ !_guihelper.CheckRadioButtonsByIndex [[ * _param_ __objList__ : an array <index, button names>, such as {[1] = "name1", [2] ="name2",} * _param_ __nSelectedIndex__ : index of the selected button. If nil, nothing will be selected. * _param_ __color__ : color used for highlighting the checked button. * _param_ __checked__ :_bg, unchecked_bg: can be nil or the texture of the checked and unchecked state. ]] __syntax__ <verbatim>function _guihelper.CheckRadioButtonsByIndex(objList, nSelectedIndex, color, checked_bg, unchecked_bg)</verbatim> __parameters__ | *objList* | an array <index, button names>, such as {[1] = "name1", [2] ="name2",} | | *nSelectedIndex* | | | *color* | color used for highlighting the checked button. | | *checked* | | | *bg* | | | *unchecked* | | | *bg* | | ---++++ !_guihelper.SwitchVizGroup [[ for all objects in objList, only the selectedName is made visible. * _param_ __objList__ : an array of button names, such as {"name1", "name2"} * _param_ __selectedName__ : name of the selected button. If nil, nothing will be selected. ]] __syntax__ <verbatim>function _guihelper.SwitchVizGroup(objList, selectedName)</verbatim> __parameters__ | *objList* | an array of button names, such as {"name1", "name2"} | | *selectedName* | | ---++++ !_guihelper.SwitchVizGroupByIndex [[ for all objects in objList, only the selectedName is made visible. * _param_ __objList__ : an array <index, button names>, such as {[1] = "name1", [2] ="name2",} * _param_ __nSelectedIndex__ : index of the selected button. If nil, nothing will be selected. ]] __syntax__ <verbatim>function _guihelper.SwitchVizGroupByIndex(objList, nSelectedIndex)</verbatim> __parameters__ | *objList* | an array <index, button names>, such as {[1] = "name1", [2] ="name2",} | | *nSelectedIndex* | | ---++++ !_guihelper.OnClick [[this is a message handler for placeholder buttons,etc. it will display the name of control, the texture file path, etc in the messagebox * _param_ __ctrlName__ : control name * _param_ __comments__ : if not nil, it is additional text that will be displayed. ]] __syntax__ <verbatim>function _guihelper.OnClick(ctrlName, comments)</verbatim> __parameters__ | *ctrlName* | control name | | *comments* | | ---++++ !_guihelper.PrintTableStructure print out the table structure * _param_ __t__ : table to print * _param_ __filename__ : the file name to print out the table __syntax__ <verbatim>function _guihelper.PrintTableStructure(t, filename)</verbatim> __parameters__ | *t* | table to print | | *filename* | | ---++++ !_guihelper.PrintUIObjectStructure print out the ui object structure * _param_ __obj__ : ui object to print * _param_ __filename__ : the file name to print out the ui object __syntax__ <verbatim>function _guihelper.PrintUIObjectStructure(obj, filename)</verbatim> __parameters__ | *obj* | ui object to print | | *filename* | | ---++++ !_guihelper.SetContainerEnabled set the container enabled, this will iterately set the enabled attribute in the UI object child container * _param_ __bEnabled__ : true or false __syntax__ <verbatim>function _guihelper.SetContainerEnabled(obj, bEnabled)</verbatim> __parameters__ | *obj* | | | *bEnabled* | true or false | ---++++ !_guihelper.HSL2RGB Given H,S,L in range of 0-1 Returns a Color (RGB struct) in range of 0-255 __syntax__ <verbatim>function _guihelper.HSL2RGB(h, s, l)</verbatim> __parameters__ | *h* | | | *s* | | | *l* | | ---++++ !_guihelper.RGB2HSL Given a Color (RGB Struct) in range of 0-255 Return H,S,L in range of 0-1 __syntax__ <verbatim>function _guihelper.RGB2HSL(r, g, b)</verbatim> __parameters__ | *r* | | | *g* | | | *b* | | ---++++ !_guihelper.HSL2RGB2 Given H,S,L in range of 0-1 Returns a Color (RGB struct) in range of 0-255 __syntax__ <verbatim>function _guihelper.HSL2RGB2(H, S, L)</verbatim> __parameters__ | *H* | | | *S* | | | *L* | | %STOPINCLUDE%
E
dit
|
A
ttach
|
P
rint version
|
H
istory
: r1
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r1 - 2008-02-29
-
LiXizhi
Home
Site map
CCWeb web
HaqiTeen web
Main web
ParaEngine web
TWiki web
Main Web
Users
Groups
Index
Search
Changes
Notifications
RSS Feed
Statistics
导航页WebTopMenu
Preferences
开发指南
Getting Started
ParacraftSDK
NPL
MCML
NPL Reference Manual
美术Mod
Account
Log In
English
简体中文
簡體中文
E
dit
A
ttach
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback