My Project
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
ParaScripting::ParaUIObject Class Reference

it represents a GUI object. More...

#include <ParaScriptingGUI.h>

Public Member Functions

 ParaUIObject (CGUIBase *obj)
 
bool IsValid () const
 check if the object is valid More...
 
void AddChild (ParaUIObject pChild)
 Attach a child GUI object to this object This function is only for container objects;. More...
 
ParaAttributeObject GetAttributeObject ()
 get the attribute object associated with an object. More...
 
void GetAttributeObject_ (ParaAttributeObject &output)
 for API exportation
 
void AddTextItem (const char *text)
 Add a text item for listbox. More...
 
void AttachToRoot ()
 Attach this object to the root of the screen GUI.
 
void SetName (const char *szName)
 
string GetName () const
 Get the name of this object.
 
ParaUIObject GetChild (const char *name)
 get child by name
 
ParaUIObject GetChildAt (int index)
 get child by index.Index start from 0. More...
 
int GetChildCount ()
 get the total number of child UI objects. More...
 
int GetID () const
 get id of this object. More...
 
void SetID (int nID)
 this function is used internally. More...
 
ParaUIObject GetChildByID (int nChildID)
 get a child node by its id More...
 
ParaUIObject GetChildByName (const char *name)
 get the first child node whose name is name. More...
 
void SetEnabled (bool bEnabled)
 Set if a control is enabled. More...
 
bool GetEnabled () const
 
void SetUseTextShadow (bool bUseTextShadow)
 Set/Get whether the use text shadow.
 
bool GetUseTextShadow () const
 
void SetTextScale (float fScale)
 set the text scale the text scale, default to 1.f. More...
 
float GetTextScale ()
 get the text scale the text scale, default to 1.f. More...
 
void SetHighlightStyle (const char *style)
 
const char * GetHighlightStyle () const
 
string GetColor () const
 Get the UI control color for the current state. More...
 
void SetColor (const char *strColor)
 set the UI control color for the current state. More...
 
void SetZDepth (float fDepth)
 set z depth in the range [0,1], where 0 is closest to screen. More...
 
float GetZDepth ()
 get z depth
 
void SetAutoSize (bool bAutosize)
 Set if a control is auto resize. More...
 
bool GetAutoSize () const
 
void GetTextLineSize (int *width, int *height)
 get the text line size in pixels, supposing the current font and text will be rendered in a single line. More...
 
void SetVisible (bool bVisible)
 Set if a control is visible. More...
 
bool GetVisible () const
 
bool GetScrollable () const
 
string GetType () const
 
void SetReceiveDrag (bool bReceiveDrag)
 Get the resource of this control.
 
bool GetReceiveDrag () const
 
ParaUIObject GetParent () const
 
void SetParent (ParaUIObject parent)
 
object GetField (const char *sFieldname, const object &output)
 get field by name.
 
void SetField (const char *sFieldname, const object &input)
 set field by name More...
 
void CallField (const char *sFieldname)
 call field by name. More...
 
void SetDefault (bool bDefaultButton)
 set as the default button of the container. More...
 
void SetLifeTime (int nSeconds)
 Set a count down timer in frames. More...
 
int GetLifeTime () const
 Get a count down timer in frames. More...
 
string GetText () const
 Get text of a control;.
 
void SetText3 (const char *strText, const char *strColor, const char *strFontAssetName)
 Show text in the window. More...
 
void SetText1 (const object &strText)
 
void SetText (const char *strText)
 
void SetTextAutoTranslate (const char *strText, const char *sConverter)
 basically this is the same as the SetText method, except that it will automatically translate the text from one language to another. More...
 
void SetPasswordChar (string PasswordChar)
 this function is only supported in the "editbox" control, not the "text" or "IMEEditbox" The PasswordChar property specifies the character displayed in the edit box. More...
 
string GetPasswordChar () const
 get password char
 
void SetTopLevel (bool value)
 Set a container to be a top-level control or set a top-level control back to normal container.
 
void SetBGImage1 (const object &szBackground)
 set the background image of the control. More...
 
void SetBGImageStr (const char *szBackground)
 szBackground can be filename[; left top width height][:left top toright to bottom], such as "texture/whitedot.png", "texture/whitedot.png;0 0 64 64", "texture/whitedot.png:10 10 10 10", "texture/whitedot.png;0 0 64 64;10 10 10 10" [:left top toright to bottom] is used to specify the inner rect of the center tile in a nine texture element UI object
 
void SetBGImage5 (const char *TextFilename, int left, int top, int width, int height)
 
void SetBGImage (ParaAssetObject pTextureEntity)
 
void SetBGImageAndRect (ParaAssetObject pTextureEntity, int left, int top, int width, int height)
 
void SetBGImage_ (TextureEntity *pTextureEntity, RECT *rect)
 
void SetBGImage2 (const char *TextFilename, RECT *rect)
 
string GetBGImage () const
 
void SetBtnImage2 (const char *TextFilename, RECT *rect)
 
void SetBtnImage1 (const object &szButton)
 
string GetBtnImage () const
 
void SetNineElementBG (const char *TextFilename, int left, int top, int toRight, int toBottom)
 drawing the background using nine element. More...
 
int GetFirstVisibleCharIndex ()
 this method is only valid if the control is edit box or imeedit box if the text is longer than the edit box, the returned value is the index of the first visible character in the edit box Normally, this is 0 if the text can be fully contained in the edit box.
 
int GetCaretPosition ()
 return Caret position in characters
 
void SetCaretPosition (int nCharacterPos)
 Set Caret position in characters. More...
 
int GetTextSize ()
 return the text size in Unicode character count.
 
void GetPriorWordPos (int nCP, int PriorIn, int &Prior)
 get the prior word position
 
void GetNextWordPos (int nCP, int NextIn, int &Next)
 get the next word position
 
void CPtoXY (int nCP, bool bTrail, int XIn, int YIn, int &X, int &Y)
 Character position to X,Y in pixel.
 
void XYtoCP (int nX, int nY, int CPIn, int nTrailIn, int &CP, int &nTrail)
 X,Y in pixel to character position.
 
void SetPageSize (int pagesize)
 Get the page size of the scroll bar Page size is the size of how many items a page contains. More...
 
void SetStep (int nDelta)
 how many pixels to scroll each step
 
int GetStep ()
 how many pixels to scroll each step
 
void SetTrackRange (int nBegin, int nEnd)
 set the page size of a container or a scroll bar More...
 
void GetTrackRange (int &nBegin, int &nEnd)
 
int GetAnimationStyle () const
 get the animation style of this object. More...
 
void SetAnimationStyle (int nStyle)
 set the animation style of this object. More...
 
void SetScrollable (bool bScrollable)
 Set if a container is scrollable. More...
 
void GetAbsPosition (float &x, float &y, float &width, float &height, float &z) const
 get the absolute position of the control in screen coordinate e.g. More...
 
void SetPosition (const char *pos)
 set rect position of the control. More...
 
string GetPosition () const
 get rect position of the control
 
void Reposition (const char *alignment, int left, int top, int width, int height)
 reposition the control using the same parameter definition used when control is created. More...
 
int GetValue () const
 Gets and Sets the value of a control Controls that have value are CGUIScrollBar, CGUISlider.
 
void SetValue (int value)
 
void OnClick (const object &strScriptName)
 When the user clicked on the window, the script file or function will be activated. More...
 
string GetOnClick () const
 
void OnSize (const object &strScriptName)
 called when the size of the window is changed. More...
 
string GetOnSize () const
 
void OnDestroy (const object &strScriptName)
 called when the window is destroyed. More...
 
string GetOnDestroy () const
 
void OnActivate (const object &strScriptName)
 The framework calls this member function when a window is being activated or deactivated. More...
 
string GetOnActivate () const
 
void OnDoubleClick (const object &strScriptName)
 The following parameters are passed as global variables. More...
 
string GetOnDoubleClick () const
 
void OnKeyDown (const object &strScriptName)
 When the user pressed a key while the mouse cursor is inside the window, a script file or function will be activated. More...
 
string GetOnKeyDown () const
 
void OnKeyUp (const object &strScriptName)
 
string GetOnKeyUp () const
 
void OnDragBegin (const object &strScriptName)
 
string GetOnDragBegin () const
 
void OnDragEnd (const object &strScriptName)
 
string GetOnDragEnd () const
 
void OnDragOver (const object &strScriptName)
 
string GetOnDragOver () const
 
void OnMouseMove (const object &strScriptName)
 
string GetOnMouseMove () const
 
void OnMouseHover (const object &strScriptName)
 
string GetOnMouseHover () const
 
void OnMouseEnter (const object &strScriptName)
 
string GetOnMouseEnter () const
 
void OnMouseLeave (const object &strScriptName)
 
string GetOnMouseLeave () const
 
void OnMouseDown (const object &strScriptName)
 
string GetOnMouseDown () const
 
void OnMouseUp (const object &strScriptName)
 
string GetOnMouseUp () const
 
void OnMouseWheel (const object &strScriptName)
 
string GetOnMouseWheel () const
 
void OnFrameMove (const object &strScriptName)
 
string GetOnFrameMove () const
 
void OnTouch (const object &strScriptName)
 
string GetOnTouch () const
 
void OnDraw (const object &strScriptName)
 
string GetOnDraw () const
 
void OnInputMethod (const object &strScriptName)
 
string GetOnInputMethod () const
 
void SetCursor (const object &szCursorFile)
 Set/Get cursor file when mouse is over it. More...
 
std::string GetCursor () const
 
void SetCursorEx (const char *szCursorFile, int nHotSpotX, int nHotSpotY)
 Set cursor by file and hot spot.
 
void OnChange (const object &strScriptName)
 usually the editbox will call this handle, "virtual_key" contains the last key stroke. More...
 
string GetOnChange () const
 
void OnSelect (const object &strScriptName)
 
string GetOnSelect () const
 
void OnModify (const object &strScriptName)
 
string GetOnModify () const
 
void SetCanDrag (bool bCanDrag)
 
bool GetCanDrag () const
 
void SetFontString (const char *font)
 
void SetFontString1 (const object &font)
 
void SetFontString3 (const char *fontname, DWORD fontsize, bool isbold)
 
string ToScript () const
 
string GetFontString () const
 
void Focus ()
 
void LostFocus ()
 
bool GetReadOnly () const
 
void SetReadOnly (bool readonly)
 
int GetX () const
 
int GetY () const
 
float GetDepth () const
 
void SetDepth (float depth)
 
void SetX (int x)
 
void SetY (int y)
 
void SetWidth (int width)
 
void SetHeight (int height)
 
int Width () const
 
int Height () const
 
void SetSize (int width, int height)
 
void SetRotation (float fRot)
 set the rotation of the control around the center of the UI plus rotation origin offset. More...
 
float GetRotation () const
 Get the rotation of the control around the center of the UI plus rotation origin offset. More...
 
void SetRotOriginOffset (float x, float y)
 rotation origin offset from the center of the UI object. More...
 
void GetRotOriginOffset (float *x, float *y) const
 rotation origin offset from the center of the UI object. More...
 
void SetScaling (float x, float y)
 set the scaling of the control around the center of the UI plus rotation origin offset. More...
 
void GetScaling (float *x, float *y) const
 Get the scaling of the control around the center of the UI plus rotation origin offset. More...
 
void SetScalingX (float x)
 
float GetScalingX () const
 
void SetScalingY (float y)
 
float GetScalingY () const
 
void SetTranslation (float x, float y)
 set the translation of the control around the center of the UI plus rotation origin offset. More...
 
void GetTranslation (float *x, float *y) const
 Get the translation of the control around the center of the UI plus rotation origin offset. More...
 
void SetTranslationX (float x)
 
float GetTranslationX () const
 
void SetTranslationY (float y)
 
float GetTranslationY () const
 
void SetColorMask (const char *strColor)
 color mask, no matter what state the control is in. More...
 
string GetColorMask () const
 
void ApplyAnim ()
 automatically animate the child nodes according to this object's rotation, scaling, translation and color mask values.
 
void SetSpacing (int nSpacing)
 Spacing between the text and the edge of border.
 
int GetSpacing () const
 Spacing between the text and the edge of border.
 
int GetScrollbarWidth () const
 
void SetScrollbarWidth (int width)
 
bool GetFixedThumb () const
 
void SetFixedThumb (bool bFixed)
 
int GetThumbSize () const
 
void SetThumbSize (int size)
 
void SetBindingObj (ParaUIObject obj)
 
void SetFastRender (bool fastrender)
 
bool GetFastRender () const
 
bool GetWordbreak () const
 
void SetWordbreak (bool wordbreak)
 
int GetItemHeight () const
 
void SetItemHeight (int itemheight)
 
bool GetMultipleSelect () const
 
void SetMultipleSelect (bool multiple)
 
void AttachTo3D (const ParaObject obj)
 Attach the control to the 3D object. More...
 
void AttachTo3D_ (const char *s3DObjectName)
 save as AttachTo3D, except that the 3D object's name is specified. More...
 
string GetToolTip () const
 
void SetToolTip (const object &tooltip)
 
void RemoveAll ()
 
void RemoveItem (int index)
 
void SetPopUp (int popup)
 
int GetPopUp () const
 
ParaUIFont CreateFont (const char *name, const char *fontname)
 
ParaUITexture CreateTexture (const char *name, const char *texturename)
 
ParaUIFont GetFont (const char *name)
 get font by name. More...
 
ParaUIFont GetFont_ (int nIndex)
 get font by index
 
void DoAutoSize ()
 try to automatically adjust the size of this object to contain all its content. More...
 
ParaUITexture GetTexture (const object &name)
 Get the texture object associated with the current control A control may be associated with multiple textures. More...
 
void BringToFront ()
 bring to front among the same z order
 
void BringToBack ()
 bring to back among the same z order
 
int GetZOrder () const
 z order affect the order of rendering. More...
 
void SetZOrder (int nOrder)
 z order affect the order of rendering. More...
 
bool IsModified () const
 
void SetActiveLayer (const char *layer)
 Set the active layer for setting resource;. More...
 
bool HasLayer (const char *layer)
 return whether a given layer exist in the resource. More...
 
void SetCurrentState (const char *statename)
 Set the current state for setting resource: More...
 
void CloneState (const char *statename)
 Clones a state to the current state. More...
 
void ActivateScript (const char *scripttype)
 
void InvalidateRect ()
 the window's client(child) area that must be recalculated and redrawn this function is obsoleted, call UpdateRect() instead
 
void UpdateRect ()
 recalculated the window's client rect
 

Public Attributes

CGUIBase::WeakPtr_type m_pObj
 

Protected Member Functions

string GenGetImage (int index) const
 
string GenGetFont (int index) const
 

Detailed Description

it represents a GUI object.

Class Properties

Member Function Documentation

§ AddChild()

void ParaScripting::ParaUIObject::AddChild ( ParaUIObject  pChild)

Attach a child GUI object to this object This function is only for container objects;.

Parameters
pChildthe child object to be attached

§ AddTextItem()

void ParaScripting::ParaUIObject::AddTextItem ( const char *  text)

Add a text item for listbox.

Parameters
textthe text string to be added.

§ AttachTo3D()

void ParaScripting::ParaUIObject::AttachTo3D ( const ParaObject  obj)

Attach the control to the 3D object.

This function will internally call AttachToRoot() if it has not been called previously One can call this function multiple times move the attached GUI object from one 3D object to another.

Parameters
objthis must be a global object
Remarks
: The visible property of this GUI object is controlled internally as below:
  • if the 3d object does not exist, the GUI object is invisible.
  • if the 3d object is not visible in the current camera frustum, the GUI object is invisible.
  • if the 3d object is visible in the current camera frustum, the GUI object is visible.

§ AttachTo3D_()

void ParaScripting::ParaUIObject::AttachTo3D_ ( const char *  s3DObjectName)

save as AttachTo3D, except that the 3D object's name is specified.

Parameters
s3DObjectNamethis must be the name of a global object.
Remarks
: The visible property of this GUI object is controlled internally as below:
  • if the 3d object does not exist, the GUI object is invisible.
  • if the 3d object is not visible in the current camera frustum, the GUI object is invisible.
  • if the 3d object is visible in the current camera frustum, the GUI object is visible.

§ CallField()

void ParaScripting::ParaUIObject::CallField ( const char *  sFieldname)

call field by name.

This function is only valid when The field type is void. It simply calls the function associated with the field name.

§ CloneState()

void ParaScripting::ParaUIObject::CloneState ( const char *  statename)

Clones a state to the current state.

Parameters
statenamename of the state We have four states "normal", "highlight", "pressed", "disabled" "normal" state is the default state. "highlight" state is the highlighted state. Some controls will change their state to "highlight" automatically when mouse enters them. "pressed" state is when a button or something else is pressed. "disabled" state is when a control is disabled.

§ DoAutoSize()

void ParaScripting::ParaUIObject::DoAutoSize ( )

try to automatically adjust the size of this object to contain all its content.

§ GetAbsPosition()

void ParaScripting::ParaUIObject::GetAbsPosition ( float &  x,
float &  y,
float &  width,
float &  height,
float &  z 
) const

get the absolute position of the control in screen coordinate e.g.

local x,y = obj:GetAbsPosition();

Parameters
&xscreen x
&yscreen y
&widthwidth
&heightheight
&zdepth, usually not used

§ GetAnimationStyle()

int ParaScripting::ParaUIObject::GetAnimationStyle ( ) const

get the animation style of this object.

Different GUI object may have different style definitions. for "button" object: 1 is gradually enlarge 5% when getting focus.2 is 10%, 3 is 15%, 4 is 20%, 5 is 25%

Returns
: 0 always means no animation. 1 is gradually enlarge 5% when getting focus.2 is 10%, 3 is 15%, 4 is 20%, 5 is 25% 11-15 means the same as 1-5, except that the normal state alpha is the same as the highlighted state. 21-25 means the same as 11-15, except that the button animation will not stop in the highlighted state. 31-39 is clock-wise rotation, the larger the faster 41-49 is counter-clock-wise rotation, the larger the faster

§ GetAttributeObject()

ParaAttributeObject ParaScripting::ParaUIObject::GetAttributeObject ( )

get the attribute object associated with an object.

§ GetChildAt()

ParaUIObject ParaScripting::ParaUIObject::GetChildAt ( int  index)

get child by index.Index start from 0.

Use GetChildCount() for total child count.

§ GetChildByID()

ParaScripting::ParaUIObject ParaScripting::ParaUIObject::GetChildByID ( int  nChildID)

get a child node by its id

Parameters
nChildIDchild ID usually obtained by GetID() method.
Returns
: return the child object found. it may return invalid object if not found.

§ GetChildByName()

ParaScripting::ParaUIObject ParaScripting::ParaUIObject::GetChildByName ( const char *  name)

get the first child node whose name is name.

Since a name may not be unique among its sibling children. One is advised to use GetChildByID() instead.

Parameters
namechild name usually obtained by GetName() method.
Returns
: return the child object found. it may return invalid object if not found.

§ GetChildCount()

int ParaScripting::ParaUIObject::GetChildCount ( )

get the total number of child UI objects.

§ GetColor()

string ParaScripting::ParaUIObject::GetColor ( ) const

Get the UI control color for the current state.

§ GetFont()

ParaUIFont ParaScripting::ParaUIObject::GetFont ( const char *  name)

get font by name.

The prefered way is to get by index.

Parameters
namethis is usually "text".

§ GetID()

int ParaScripting::ParaUIObject::GetID ( ) const

get id of this object.

please note that this is a child id, not a globally unique id. the id is only available when this object is attached to a parent. And the ID will change if this object changes its parent. In all other circumstances, the id uniquely identify this object in its parent. One can call GetChildByID() from its parent control to get this object. Note: ID is assigned by its parent when this control is attached to a parent control (or parent changes) it ensures that ChildID is unique among all sibling children of the parent control during the lifetime of the parent.

§ GetLifeTime()

int ParaScripting::ParaUIObject::GetLifeTime ( ) const

Get a count down timer in frames.

when it is zero, the object will be automatically deleted If LifeTime is negative, the object will be permanent.

Returns
: return how many seconds the window left to be alive.

§ GetRotation()

float ParaScripting::ParaUIObject::GetRotation ( ) const

Get the rotation of the control around the center of the UI plus rotation origin offset.

it only affects the drawing rect but not the mouse sensor rect. it is usually used for visual effect, so there is no need to update or calculate client rect.

§ GetRotOriginOffset()

void ParaScripting::ParaUIObject::GetRotOriginOffset ( float *  x,
float *  y 
) const

rotation origin offset from the center of the UI object.

§ GetScaling()

void ParaScripting::ParaUIObject::GetScaling ( float *  x,
float *  y 
) const

Get the scaling of the control around the center of the UI plus rotation origin offset.

it only affects the drawing rect but not the mouse sensor rect. it is usually used for visual effect, so there is no need to update or calculate client rect.

§ GetTextLineSize()

void ParaScripting::ParaUIObject::GetTextLineSize ( int *  width,
int *  height 
)

get the text line size in pixels, supposing the current font and text will be rendered in a single line.

§ GetTextScale()

float ParaScripting::ParaUIObject::GetTextScale ( )

get the text scale the text scale, default to 1.f.

if we have text scale between 1.1-1.5 and shadow to true, the text will have an alpha border. This is great for rendering text in 3d scene with a boarder using just normal system font.

§ GetTexture()

ParaUITexture ParaScripting::ParaUIObject::GetTexture ( const object name)

Get the texture object associated with the current control A control may be associated with multiple textures.

Parameters
namedifferent controls have set of textures. it can be one of the following predefined string.
  • "background": the background texture, this is the most commonly used texture and is available in all controls.
  • "track": the track texture in a scroll bar. it is available in "scrollbar" control.
  • "up_left": the up arrow texture in scroll bar. it is available in "scrollbar" control.
  • "down_left": the down arrow texture in scroll bar. it is available in "scrollbar" control.
  • "thumb": the thumb button texture in the scroll bar. it is available in "scrollbar" control.
Returns

§ GetTranslation()

void ParaScripting::ParaUIObject::GetTranslation ( float *  x,
float *  y 
) const

Get the translation of the control around the center of the UI plus rotation origin offset.

it only affects the drawing rect but not the mouse sensor rect. it is usually used for visual effect, so there is no need to update or calculate client rect.

§ GetZOrder()

int ParaScripting::ParaUIObject::GetZOrder ( ) const

z order affect the order of rendering.

The parent control sort and render child control from small z value to larger z value. default value is 0.

§ HasLayer()

bool ParaScripting::ParaUIObject::HasLayer ( const char *  layer)

return whether a given layer exist in the resource.

One needs to call SetActiveLayer() in order to create a layer.

Parameters
layerit can be one of the three layers "artwork", "background" and "overlay". Typically, all controls contains the "artwork" layer.

§ IsValid()

bool ParaScripting::ParaUIObject::IsValid ( ) const

check if the object is valid

Returns
: true is the object is a valid GUI object.

§ OnActivate()

void ParaScripting::ParaUIObject::OnActivate ( const object strScriptName)

The framework calls this member function when a window is being activated or deactivated.

id = int; – the id of the triggering GUI window param1: Specifies whether the window is being activated or deactivated. It can be one of the following values:

  • 0 The window is being deactivated.
  • 1 The window is being activated by a mouse click.
  • 2 The window is being activated through some method other than a mouse click.

§ OnChange()

void ParaScripting::ParaUIObject::OnChange ( const object strScriptName)

usually the editbox will call this handle, "virtual_key" contains the last key stroke.

Usually application may check if it is an enter key for special actions.

§ OnClick()

void ParaScripting::ParaUIObject::OnClick ( const object strScriptName)

When the user clicked on the window, the script file or function will be activated.

The following parameters are passed as global variables. id = int; – the id of the triggering GUI window mouse_button = ["left"|"right"|"middle"]; mouse_x = number; mouse_y = number;

Parameters
strScriptNamethe NPL script file to activate.

§ OnDestroy()

void ParaScripting::ParaUIObject::OnDestroy ( const object strScriptName)

called when the window is destroyed.

Please note that GetUIObject() will return invalid object.

§ OnDoubleClick()

void ParaScripting::ParaUIObject::OnDoubleClick ( const object strScriptName)

The following parameters are passed as global variables.

id = int; – the id of the triggering GUI window mouse_button = ["left"|"right"|"middle"]; mouse_x = number; mouse_y = number;

Parameters
strScriptName

§ OnKeyDown()

void ParaScripting::ParaUIObject::OnKeyDown ( const object strScriptName)

When the user pressed a key while the mouse cursor is inside the window, a script file or function will be activated.

The following parameters are passed as global variables. id = int; – the id of the triggering GUI window keystring = string;–it is filled with the key character. e.g. "\r", "a", etc. It may contain multiple characters, if the user is typing fast or Multi-byte such as Chinese Character is entered.

Parameters
strScriptNamethe NPL script file to activate.

§ OnSize()

void ParaScripting::ParaUIObject::OnSize ( const object strScriptName)

called when the size of the window is changed.

id = int; – the id of the triggering GUI window

§ Reposition()

void ParaScripting::ParaUIObject::Reposition ( const char *  alignment,
int  left,
int  top,
int  width,
int  height 
)

reposition the control using the same parameter definition used when control is created.

see ParaUI::CreateUIObject() for parameter definition.

§ SetActiveLayer()

void ParaScripting::ParaUIObject::SetActiveLayer ( const char *  layer)

Set the active layer for setting resource;.

Parameters
layername of the layer We have three layers "artwork", "background" and "overlay" "artwork" layer is the primary layer. By default, we render a control using this layer "overlay" layer is a layer on top of the "artwork" layer. "background" layer is on the bottom of the "artwork" layer. All three layers are the same. If not implicitly set, the default active layer is the "artwork" layer. But when a user wants to set something, remember to call this function to ensure that the active layer is correct.

§ SetAnimationStyle()

void ParaScripting::ParaUIObject::SetAnimationStyle ( int  nStyle)

set the animation style of this object.

Different GUI object may have different style definitions. for "button" object: 1 is gradually enlarge 5% when getting focus.2 is 10%, 3 is 15%, 4 is 20%, 5 is 25%

Parameters
nStyle0 always means no animation. 1 is gradually enlarge 5% when getting focus.2 is 10%, 3 is 15%, 4 is 20%, 5 is 25% 11-15 means the same as 1-5, except that the normal state alpha is the same as the highlighted state. 21-25 means the same as 11-15, except that the button animation will not stop in the highlighted state. 31-39 is clock-wise rotation, the larger the faster 41-49 is counter-clock-wise rotation, the larger the faster

§ SetAutoSize()

void ParaScripting::ParaUIObject::SetAutoSize ( bool  bAutosize)

Set if a control is auto resize.

Parameters
bAutosizethe new value

§ SetBGImage1()

void ParaScripting::ParaUIObject::SetBGImage1 ( const object szBackground)

set the background image of the control.

Parameters
szBackgroundthe texture asset file name with the rectangle information the format of szBackground is filename[; left top width height][:left top toright to bottom]. if it is "" or width or height is zero, the texture is not drawn or is fully transparent. e.g. "texture/whitedot.png", "texture/whitedot.png;0 0 64 64", "texture/whitedot.png:10 10 10 10", "texture/whitedot.png;0 0 64 64;10 10 10 10" [:left top toright to bottom] is used to specify the inner rect of the center tile in a nine texture element UI object
Note
: GUI also supports texture bound with dynamic width and height. such as "Texture/anyfile.dds;0 0 -1 -1", where -1 is replaced with the dynamic width or height when needed. This is specially useful for specifying width and height of a HTTP remote texture where the dimension is not known immediately. things in [] are optional input;if not specified, the rectangle contains the whole picture;

§ SetCaretPosition()

void ParaScripting::ParaUIObject::SetCaretPosition ( int  nCharacterPos)

Set Caret position in characters.

Parameters
nCharacterPosin characters

§ SetColor()

void ParaScripting::ParaUIObject::SetColor ( const char *  strColor)

set the UI control color for the current state.

Parameters
strColor:"2550 0" or "255 0 0 128"

§ SetColorMask()

void ParaScripting::ParaUIObject::SetColorMask ( const char *  strColor)

color mask, no matter what state the control is in.

"r g b a", such as "255 255 255 255"

§ SetCurrentState()

void ParaScripting::ParaUIObject::SetCurrentState ( const char *  statename)

Set the current state for setting resource:

Parameters
statenamename of the state We have four states "normal", "highlight", "pressed", "disabled" "normal" state is the default state. "highlight" state is the highlighted state. Some controls will change their state to "highlight" automatically when mouse enters them. "pressed" state is when a button or something else is pressed. "disabled" state is when a control is disabled. If not implicitly set, the default state is the "normal" state. But when a user wants to set something, remember to call this function to ensure that the current state is correct.

§ SetCursor()

void ParaScripting::ParaUIObject::SetCursor ( const object szCursorFile)

Set/Get cursor file when mouse is over it.

If empty, the parent cursor file is used.

§ SetDefault()

void ParaScripting::ParaUIObject::SetDefault ( bool  bDefaultButton)

set as the default button of the container.

please note each container can only have one default button. so as one set a default button, it will automatically unset old default button in the parent container. when enter key is pressed in an edit box, the default button will be clicked.

§ SetEnabled()

void ParaScripting::ParaUIObject::SetEnabled ( bool  bEnabled)

Set if a control is enabled.

Parameters
bEnabledthe new value

§ SetField()

void ParaScripting::ParaUIObject::SetField ( const char *  sFieldname,
const object input 
)

set field by name

Parameters
sFieldnamefield name
inputinput value. if field type is vectorN, input is a table with N items.

§ SetID()

void ParaScripting::ParaUIObject::SetID ( int  nID)

this function is used internally.

never call this unless you known why.

§ SetLifeTime()

void ParaScripting::ParaUIObject::SetLifeTime ( int  nSeconds)

Set a count down timer in frames.

when it is zero, the object will be automatically deleted If LifeTime is negative, the object will be permanent.

Parameters
nSecondshow many seconds the window left to be alive.

§ SetNineElementBG()

void ParaScripting::ParaUIObject::SetNineElementBG ( const char *  TextFilename,
int  left,
int  top,
int  toRight,
int  toBottom 
)

drawing the background using nine element.

Note
: Right now, this is only valid on container, but we will support it for all other controll.
Parameters
TextFilenamethe background texture to use. it will be divided into 3x3 tiles when drawing the control
left,top,toRight,toBottomthe inner tile position relative to the dimension of TextFilename texture. If all are 0, it will be set back to one element background

§ SetPageSize()

void ParaScripting::ParaUIObject::SetPageSize ( int  pagesize)

Get the page size of the scroll bar Page size is the size of how many items a page contains.

The control will scroll a page size if we click on the empty space of the track of the scroll bar

§ SetPasswordChar()

void ParaScripting::ParaUIObject::SetPasswordChar ( string  PasswordChar)

this function is only supported in the "editbox" control, not the "text" or "IMEEditbox" The PasswordChar property specifies the character displayed in the edit box.

For example, if you want asterisks displayed in the password box, specify * for the PasswordChar property in the Properties window. Then, regardless of what character a user types in the text box, an asterisk is displayed.

Remarks
: Security Note: Using the PasswordChar property on a text box can help ensure that other people will not be able to determine a user's password if they observe the user entering it. This security measure does not cover any sort of storage or transmission of the password that can occur due to your application logic. Because the text entered is not encrypted in any way, you should treat it as you would any other confidential data. Even though it does not appear as such, the password is still being treated as a plain-text string (unless you have implemented some additional security measure).
Parameters
PasswordCharsuch as '*'

§ SetPosition()

void ParaScripting::ParaUIObject::SetPosition ( const char *  pos)

set rect position of the control.

Parameters
posin format "x y width height"

§ SetRotation()

void ParaScripting::ParaUIObject::SetRotation ( float  fRot)

set the rotation of the control around the center of the UI plus rotation origin offset.

it only affects the drawing rect but not the mouse sensor rect. it is usually used for visual effect, so there is no need to update or calculate client rect.

§ SetRotOriginOffset()

void ParaScripting::ParaUIObject::SetRotOriginOffset ( float  x,
float  y 
)

rotation origin offset from the center of the UI object.

§ SetScaling()

void ParaScripting::ParaUIObject::SetScaling ( float  x,
float  y 
)

set the scaling of the control around the center of the UI plus rotation origin offset.

it only affects the drawing rect but not the mouse sensor rect. it is usually used for visual effect, so there is no need to update or calculate client rect.

§ SetScrollable()

void ParaScripting::ParaUIObject::SetScrollable ( bool  bScrollable)

Set if a container is scrollable.

Parameters
bScrollablethe new scrollable value

§ SetText3()

void ParaScripting::ParaUIObject::SetText3 ( const char *  strText,
const char *  strColor,
const char *  strFontAssetName 
)

Show text in the window.

The text will fill the entire window. If one want to position text in a window, it must create another window to contain the text, then use the window to position the text.

Parameters
strTexttext to display (must be in utf8)
strColorcolor of the object. such as "255 255 255".
strFontAssetNamethe font asset name, it can be "", in which case the default font will be used.

§ SetTextAutoTranslate()

void ParaScripting::ParaUIObject::SetTextAutoTranslate ( const char *  strText,
const char *  sConverter 
)

basically this is the same as the SetText method, except that it will automatically translate the text from one language to another.

please note that this method does not solve all localization problems, but it allows for quick machine translation .

Parameters
strTextutf8 encoded text
sConverterit should be one of the supported converter name. a most common usage is "c_S2T" where simplified Chinese character is translated to traditional Chinese. The asset file "locale/c_simpl_to_trad.txt" is used.

§ SetTextScale()

void ParaScripting::ParaUIObject::SetTextScale ( float  fScale)

set the text scale the text scale, default to 1.f.

if we have text scale between 1.1-1.5 and shadow to true, the text will have an alpha border. This is great for rendering text in 3d scene with a boarder using just normal system font.

§ SetTrackRange()

void ParaScripting::ParaUIObject::SetTrackRange ( int  nBegin,
int  nEnd 
)

set the page size of a container or a scroll bar

Parameters
nBeginthe start value of the range
nEndthe end value of the range

§ SetTranslation()

void ParaScripting::ParaUIObject::SetTranslation ( float  x,
float  y 
)

set the translation of the control around the center of the UI plus rotation origin offset.

it only affects the drawing rect but not the mouse sensor rect. it is usually used for visual effect, so there is no need to update or calculate client rect.

§ SetVisible()

void ParaScripting::ParaUIObject::SetVisible ( bool  bVisible)

Set if a control is visible.

Parameters
bVisiblethe new value

§ SetZDepth()

void ParaScripting::ParaUIObject::SetZDepth ( float  fDepth)

set z depth in the range [0,1], where 0 is closest to screen.

if this is -1(default), zdepth is automatically determined. Otherwise it will force the z depth.

§ SetZOrder()

void ParaScripting::ParaUIObject::SetZOrder ( int  nOrder)

z order affect the order of rendering.

The parent control sort and render child control from small z value to larger z value. default value is 0. if this control has a parent it will cause the parent to sort all children again.


The documentation for this class was generated from the following files: