_gui_helper
| Title |
Movie libaray 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
function _guihelper.SetUIColor(uiobject, color)
parameters
_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
function _guihelper.SetFontColor(uiobject, color)
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
function _guihelper.GetTextWidth(text, fontName)
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
function _guihelper.SetUIFontFormat(uiobject, format)
parameters
| uiobject |
uiobject such as button |
| format |
|
_guihelper.RGBA_TO_DWORD
- param r :, g, b, a: each in [0,255]
syntax
function _guihelper.RGBA_TO_DWORD(r, g, b, a)
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
function _guihelper.DWORD_TO_RGBA(w)
parameters
_guihelper.SetVistaStyleButton
make a button Windows Vista Style buttons, like the left top menu item in MS Office 2007.
- param uiobject : button UI object
- param foregroundImage :
syntax
function _guihelper.SetVistaStyleButton(uiobject, foregroundImage, backgroundImage)
parameters
| uiobject |
button UI object |
| foregroundImage |
|
| backgroundImage |
|
_guihelper.SetVistaStyleButton2
NOTE: --WangTian: set background color visible when mouse not over
--texture.color="255 255 255 255";
--uiobject:SetCurrentState("disabled");
make a button Windows Vista Style buttons, like the left top menu item in MS Office 2007.
- param uiobject : button UI object
- param foregroundImage :
syntax
function _guihelper.SetVistaStyleButton2(uiobject, foregroundImage, backgroundImage)
parameters
| uiobject |
button UI object |
| foregroundImage |
|
| backgroundImage |
|
_guihelper.SetVistaStyleButton3
NOTE: --WangTian: buttons for main bar icons
- param uiobject : button UI object
- param normalImage : normal and pressed layer image
- param mouseoverImage : highlight layer image
- param disableImage : disabled layer image
syntax
function _guihelper.SetVistaStyleButton3(uiobject, normalImage, mouseoverImage, disableImage)
parameters
| uiobject |
button UI object |
| normalImage |
|
| mouseoverImage |
highlight layer image |
| disableImage |
|
_guihelper.SetVistaStyleButton4
NOTE: by andy: this is another solution of _guihelper.SetVistaStyleButton
the difference is this function swap the
SetVistaStyleButton2? background and foreground color behavior
make a button Windows Vista Style buttons, like the left top menu item in MS Office 2007.
- param uiobject : button UI object
- param foregroundImage :
syntax
function _guihelper.SetVistaStyleButton4(uiobject, foregroundImage, backgroundImage)
parameters
| uiobject |
button UI object |
| foregroundImage |
|
| backgroundImage |
|
_guihelper.SetVistaStyleButtonBright
NOTE: --WangTian: set background color bright
all status are colored "255 255 255"
make a button Windows Vista Style buttons, like the left top menu item in MS Office 2007.
- param uiobject : button UI object
- param foregroundImage :
syntax
function _guihelper.SetVistaStyleButtonBright(uiobject, foregroundImage, backgroundImage)
parameters
| uiobject |
button UI object |
| foregroundImage |
|
| backgroundImage |
|
_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
function _guihelper.SafeSetText(objName, newText)
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
function _guihelper.SafeGetNumber(objName)
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
function _guihelper.SafeGetText(objName)
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
function _guihelper.CheckRadioButtons(objList, selectedName, color, checked_bg, unchecked_bg)
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
function _guihelper.CheckRadioButtons2(objList, selectedName, color, checked_bg, unchecked_bg)
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
function _guihelper.CheckRadioButtonsByIndex(objList, nSelectedIndex, color, checked_bg, unchecked_bg)
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
function _guihelper.SwitchVizGroup(objList, selectedName)
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
function _guihelper.SwitchVizGroupByIndex(objList, nSelectedIndex)
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
function _guihelper.OnClick(ctrlName, comments)
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
function _guihelper.PrintTableStructure(t, filename)
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
function _guihelper.PrintUIObjectStructure(obj, filename)
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
function _guihelper.SetContainerEnabled(obj, bEnabled)
parameters
| obj |
|
| bEnabled |
true or false |