MCML Controls

Contents:

header file for all mcml tag node definitions and data binding controls

Title header file for all mcml tag node definitions and data binding controls
Author(s) LiXizhi, WangTian
Date 2008/2/14
File script/kids/3DMapSystemApp/MCML/mcml.lua

Description

mcml is an XML format describing profile box items and other display items in paraworld, such as task, quick action, action feed, tradableitem, etc. One can think of it as the HTML counterpart in 3D social networking world for describing renderable objects in 2D and 3D. it conforms with the ide/LuaXML conversion format, so that the script table defined here has a strict XML translation. mcml is a universal format defined by ParaEngine. and any thing in the name space "pe" is official mcml control node that can be data binded to NPL controls. mcml_controls for rendering mcml data is defined in mcml/mcml_controls and mcml/pe_* files.

tag overview: - social tags: pe:profile pe:userinfo pe:friends pe:app pe:name pe:profile-action pe:profile-box pe:app-home-button - map tags: pe:map-mark pe:map-mark2d pe:map-tile - design tags: pe:container pe:dialog pe:tabs pe:tab-item pe:treeview pe:treenode pe:image pe:flash - component tags:pe:roomhost pe:market pe:comments - editor display: pe:editor pe:editor-buttonset pe:editor-button pe:editor-text pe:editor-divider pe:editor-custom pe:editor-radiobox(same as ) pe:editor-checkbox (same as ) HTML editor tags are implemented by editor: - control tags: pe:visible-to-owner - worlds tags:pe:world pe:world-ip pe:model pe:avatar - HTML tags:, h1, h2,h3, h4, li, p, div, hr, a(href), img(attr: src,height, width, title),

anyTag(attr
style="float:left;color: #006699; left: -60px; position: relative; top: 30px;width: 100px;height: 100px;class:"box";margin:5;margin-top:5;padding:5;background:url;background-color:#FF0000"), By default: , font,a(href) will float around previous control, allowing content to automatically wrap to the next line.

TIP Sample Code

NPL.load("(gl)script/kids/3DMapSystemApp/mcml/mcml.lua");
-- to create a user defined tag
local node = Map3DSystem.mcml.new("pe:profile", {})
-- to deserialize from xml data or pure table. 
local node = Map3DSystem.mcml.buildclass(node);
-- to render(create) databinding controls for an mcml node. 
Map3DSystem.mcml_controls.create("me", node, bindingContext, _parent, left, top, right, bottom)
-- one can access a node via baseNode functions (see mcml/mcml_base) or using ide/Xpath

all officially bindable controls that renders mcml nodes (only for 2D UI controls).

Title all officially bindable controls that renders mcml nodes (only for 2D UI controls).
Author(s) LiXizhi, WangTian
Date 2008/2/15
File script/kids/3DMapSystemApp/MCML/mcml_controls.lua

Description

all control implementations are in the mcml/pe_* files.

TIP Sample Code

NPL.load("(gl)script/kids/3DMapSystemApp/mcml/mcml_controls.lua");
Map3DSystem.mcml_controls.create(rootName, mcmlNode, bindingContext, _parent, left, top, width, height)

Member Functions

mcml_controls.create

 default control mapping: from tag name to rendering controls
mcml_controls.control_mapping = {
   -- global
   ["pe:mcml"] = mcml_controls.pe_simple_styles,
   
   -- social tags
   ["pe:profile"] = mcml_controls.pe_profile,
   ["pe:profile-mini"] = mcml_controls.pe_profile_mini,
   ["pe:profile-photo"] = mcml_controls.pe_profile_photo,
   ["pe:friends"] = mcml_controls.pe_friends,
   ["pe:app"] = mcml_controls.pe_app,
   ["pe:name"] = mcml_controls.pe_name,
   ["pe:avatar"] = mcml_controls.pe_avatar,
   ["pe:quickaction"] = mcml_controls.pe_quickaction,
   ["pe:onlinestatus"] = mcml_controls.pe_onlinestatus,
   
   -- component tags
   ["pe:download"] = mcml_controls.pe_download,
   ["ready"] = mcml_controls.pe_simple_styles,
   ["notready"] = mcml_controls.pe_simple_styles,
   ["pe:custom"] = mcml_controls.pe_custom,
   ["pe:world"] = mcml_controls.pe_world,
   
   -- control tags
   ["pe:if-is-user"] = mcml_controls.pe_if_is_user,
   ["pe:if"] = mcml_controls.pe_if,
   ["pe:if-not"] = mcml_controls.if_not,
   
   -- map tags
   ["pe:map"] = mcml_controls.pe_map,
   ["pe:tile"] = mcml_controls.pe_land,
   ["pe:mapmark"] = mcml_controls.pe_mapmark,
   ["pe:minimap"] = mcml_controls.pe_minimap,
   
   -- design tags
   ["pe:treeview"] = mcml_controls.pe_treeview,
   ["pe:treenode"] = mcml_controls.pe_treenode,
   ["pe:tabs"] = mcml_controls.pe_tabs,
   ["pe:tab-item"] = mcml_controls.pe_tab_item,
   ["pe:image"] = mcml_controls.pe_image,
   ["pe:flash"] = mcml_controls.pe_flash,
   ["pe:container"] = mcml_controls.pe_editor,
   ["pe:slide"] = mcml_controls.pe_slide,
   ["pe:filebrowser"] = mcml_controls.pe_filebrowser,
   ["pe:canvas3d"] = mcml_controls.pe_canvas3d,
   ["pe:label"] = mcml_controls.pe_label,
   ["pe:fileupload"] = mcml_controls.pe_fileupload,
   ["pe:GridView"] = mcml_controls.pe_gridview,
   ["pe:gridview"] = mcml_controls.pe_gridview,
   ["pe:pager"] = mcml_controls.pe_pager,
   ["pe:bindingblock"] = mcml_controls.pe_bindingblock,
   ["pe:xmldatasource"] = mcml_controls.pe_xmldatasource,
   ["pe:mqldatasource"] = mcml_controls.pe_mqldatasource,
   ["pe:progressbar"] = mcml_controls.pe_progressbar,
   ["pe:sliderbar"] = mcml_controls.pe_sliderbar,
   ["pe:numericupdown"] = mcml_controls.pe_numericupdown,
   ["pe:colorpicker"] = mcml_controls.pe_colorpicker,
   ["pe:ribbonbar"] = mcml_controls.pe_ribbonbar,
   ["pe:command"] = mcml_controls.pe_command,
   ["pe:asset"] = mcml_controls.pe_asset,
   ["pe:bag"] = mcml_controls.pe_bag,
   
   -- motion tags
   ["pe:animgroup"] = mcml_controls.pe_animgroup,
   ["pe:animlayer"] = mcml_controls.pe_animlayer,
   ["pe:animator"] = mcml_controls.pe_animator,
   
   -- storyboard tags   
   ["pe:storyboards"] = mcml_controls.pe_storyboards,
      ["pe:storyboard"] = mcml_controls.pe_storyboard,
         ["pe:doubleAnimationUsingKeyFrames"] = mcml_controls.pe_doubleAnimationUsingKeyFrames,
            ["pe:linearDoubleKeyFrame"] = mcml_controls.pe_linearDoubleKeyFrame,
            ["pe:discreteDoubleKeyFrame"] = mcml_controls.pe_discreteDoubleKeyFrame,
         ["pe:stringAnimationUsingKeyFrames"] = mcml_controls.pe_stringAnimationUsingKeyFrames,
            ["pe:discreteStringKeyFrame"] = mcml_controls.pe_discreteStringKeyFrame,
         ["pe:point3DAnimationUsingKeyFrames"] = mcml_controls.pe_point3DAnimationUsingKeyFrames,
            ["pe:linearPoint3DKeyFrame"] = mcml_controls.pe_linearPoint3DKeyFrame,
            ["pe:discretePoint3DKeyFrame"] = mcml_controls.pe_discretePoint3DKeyFrame,
         ["pe:objectAnimationUsingKeyFrames"] = mcml_controls.pe_objectAnimationUsingKeyFrames,
            ["pe:discreteObjectKeyFrame"] = mcml_controls.pe_discreteObjectKeyFrame,
         
         
   
   -- editor tags
   ["pe:dialog"] = mcml_controls.pe_dialog,
   ["pe:editor"] = mcml_controls.pe_editor,
   ["pe:editor-button"] = mcml_controls.pe_editor_button,
   ["pe:editor-buttonset"] = mcml_controls.pe_editor_buttonset,
   ["pe:editor-text"] = mcml_controls.pe_editor_text,
   ["pe:editor-divider"] = mcml_controls.pe_editor_divider,
   ["pe:editor-custom"] = mcml_controls.pe_editor_custom,
   ["pe:editor-radiobox"] = mcml_controls.pe_editor_radiobox,
   ["pe:editor-checkbox"] = mcml_controls.pe_editor_checkbox,
   ["pe:editor-hidden"] = mcml_controls.pe_editor_hidden,
   
   -- supported html tags
   ["<text>"] = mcml_controls.pe_text, -- there is no node called <text>, but all inner xml text is mapped to this one. 
   ["h1"] = mcml_controls.pe_simple_styles,
   ["h2"] = mcml_controls.pe_simple_styles,
   ["h3"] = mcml_controls.pe_simple_styles,
   ["h4"] = mcml_controls.pe_simple_styles,
   ["ul"] = mcml_controls.pe_simple_styles,
   ["li"] = mcml_controls.pe_simple_styles,
   ["p"] = mcml_controls.pe_simple_styles,
   ["div"] = mcml_controls.pe_simple_styles,
   ["a"] = mcml_controls.pe_a,
   ["span"] = mcml_controls.pe_font,
   ["font"] = mcml_controls.pe_font,
   ["strong"] = mcml_controls.pe_font,
   ["b"] = mcml_controls.pe_font,
   ["br"] = mcml_controls.pe_br,
   ["hr"] = mcml_controls.pe_editor_divider,
   ["img"] = mcml_controls.pe_img,
   ["form"] = mcml_controls.pe_form,
   ["input"] = mcml_controls.pe_input,
   ["textarea"] = mcml_controls.pe_editor_text,
   ["select"] = mcml_controls.pe_select,
   ["button"] = mcml_controls.pe_editor_button,
   ["iframe"] = mcml_controls.pe_iframe,
   ["script"] = mcml_controls.pe_script,
   ["unknown"] = mcml_controls.pe_script, -- this will handle <%embeded code block%>
   ["label"] = mcml_controls.pe_label,
   
   -- HTML extension
   ["pe:a"] = mcml_controls.pe_pe_a,
   ["pe:script"] = mcml_controls.pe_script,
}

automatically create the appropriate controls that renders the mcmlNode. Controls are child of _parent, and use automatic databinding. this function is recursive. See default control mapping for which control a specifc mcmlNode is mapped to. If one wants to manually choose which control an mcmlNode should be bound to, he can call any of the create function of that specific control.

  • param rootName : a name that uniquely identifies this UI instance, usually the userID or app_key. The renderer will create sub control names by concartinating this rootname with relative baseNode path.
  • param mcmlNode : any supported mcml node defined in mcml/mcml.
  • param bindingContext : the bindingContext object to use. If nil, it is automatically used.
  • param __ :_parent: the parent paraUIObject inside which controls are rendered.
  • param left :, top: the next free renderable cursor position from which following controls should be appended. The idea is similar to HTML renderer.
  • param width :, height: desired width and height of the _parent (or desired right, bottom position of the control in parent). they can be nil, and result is dependent on controls.
  • param style : nil or a table containing css style, such as {color=string, href=string}. This is a style object to be associated with each node.
  • param parentLayout : optional in|out: type of mcml_controls.layout

syntax

function mcml_controls.create(rootName, mcmlNode, bindingContext, _parent, left, top, width, height, style, parentLayout)

parameters

rootName a name that uniquely identifies this UI instance, usually the userID or app_key. The renderer will create sub control names by concartinating this rootname with relative baseNode path.
mcmlNode  
bindingContext the bindingContext object to use. If nil, it is automatically used.
parent  
left , top: the next free renderable cursor position from which following controls should be appended. The idea is similar to HTML renderer.
top  
width  
height  
style nil or a table containing css style, such as {color=string, href=string}. This is a style object to be associated with each node.
parentLayout  

mcml_controls.OnClickHRef


event handler helper functions

use clicks to open an href URL.

  • param href : the url to open.

syntax

function mcml_controls.OnClickHRef(href)

parameters

href the url to open.

mcml_controls.OnPageEvent

call this when a pe:editor-button is clicked.

  • param mcmlNode : mcmlNode that is firing this event. Please note that, if this is nil, the DOM (document object) will not be valid within the callback script.
  • param callbackFunc : the call back script function name or function itself. the script function will be called with function(param1, param2, param3,...)
  • param param1 : param1 is usually the btnName
  • param param2 : param2 is usually values from the calling control.
  • param param3 : param3 is usually the binding context object
  • return function : result or nil.

syntax

function mcml_controls.OnPageEvent(mcmlNode, callbackFunc, ...)

parameters

mcmlNode mcmlNode that is firing this event. Please note that, if this is nil, the DOM (document object) will not be valid within the callback script.
callbackFunc  

a layout is used when positioning an mcml control. It emulate the standard HTML renderer bahaviors.

Title a layout is used when positioning an mcml control. It emulate the standard HTML renderer bahaviors.
Author(s) LiXizhi
Date 2008/2/15
File script/kids/3DMapSystemApp/MCML/mcml_controls_layout.lua

Description

TIP Sample Code

NPL.load("(gl)script/kids/3DMapSystemApp/mcml/mcml_controls_layout.lua");
-- clone child object
parentLayout:NewLine();
local myLayout = parentLayout:clone();
myLayout:SetUsedSize(0,0);

-- update parent
myLayout:NewLine();
local left, top = parentLayout:GetAvailablePos();
local width, height = myLayout:GetUsedSize();
width, height = width-left, height -top;
parentLayout:AddObject(width, height);
parentLayout:NewLine();
   
-- add full size
parentLayout:NewLine();
local left, top, width, height = parentLayout:GetPreferredRect();
parentLayout:AddObject(width-left, height-top);
parentLayout:NewLine();

Member Functions

layout:new

---------------------------------------------
 layout class: 
---------------------------------------------
local layout = {
   -- the next available renderable position 
   availableX = 0,
   availableY = 0,
   -- the next new line position
   newlineX = 0,
   newlineY = 0,
   -- the current preferred size of the container control. It may be enlarged by child controls. 
   width = 0,
   height = 0,
   -- the min region in the container control which is occupied by its child controls
   usedWidth = 0,
   usedHeight = 0,
}
mcml_controls.layout = layout;

syntax

function layout:new(o)

parameters

o  

layout:clone

return a clone of this layout object. in most cases, one also calls SetUsedSize(0,0) to make the copy useful for a child layout.

syntax

function layout:clone()

layout:reset

reset with newline position (left, top) and container size (width and height).

syntax

function layout:reset(left, top, width, height)

parameters

left  
top  
width  
height  

layout:GetPreferredSize

a control may call this function to check its preferred size. if the preferred size is big enough, it can use this size when calling AddObject, otherwise, it can either call NewLine() or AddObject with a bigger size. return preferred width, height

syntax

function layout:GetPreferredSize()

layout:GetMaxSize

get the max available size

syntax

function layout:GetMaxSize()

layout:GetSize

get the size

syntax

function layout:GetSize()

layout:GetUsedSize

get used size

syntax

function layout:GetUsedSize()

layout:SetUsedSize

set used size

syntax

function layout:SetUsedSize(width, height)

parameters

width  
height  

layout:GetAvailableRect

get the available rect by left, top, right, bottom.

syntax

function layout:GetAvailableRect()

layout:GetAvailablePos

get the available rect by left, top

syntax

function layout:GetAvailablePos()

layout:GetNewlinePos

get the newline position (left, top)

syntax

function layout:GetNewlinePos()

layout:OffsetPos

offset the new line and available position of this layout.

syntax

function layout:OffsetPos(dx, dy)

parameters

dx  
dy  

layout:AddChildLayout

childLayout is usually cloned from this layout and this layout will expand to accommandate childLayout.

syntax

function layout:AddChildLayout(childLayout)

parameters

childLayout  

layout:AddObject

add object at the current available position. if available position is not big enough, it will start a new line. object still can not fit in a newline, it will increase its container size. THIS IS A TRICKY FUNCTION return the left, top position of the added object.

syntax

function layout:AddObject(width, height)

parameters

width  
height  

layout:NewLine

make a new line in the layout

syntax

function layout:NewLine()

layout:IncHeight

increase preferred height of this layout

syntax

function layout:IncHeight(dHeight)

parameters

dHeight  

layout:IncWidth

increase preferred width of this layout

syntax

function layout:IncWidth(dWidth)

parameters

dWidth  

base mcml function and base Node implementation of mcml

Title base mcml function and base Node implementation of mcml
Author(s) LiXizhi
Date 2008/2/15
File script/kids/3DMapSystemApp/MCML/mcml_base.lua

Description

only included and used by mcml

TIP Sample Code

NPL.load("(gl)script/kids/3DMapSystemApp/mcml/mcml_base.lua");
local node = Map3DSystem.mcml.new("pe:profile", {})
local o = Map3DSystem.mcml.buildclass(o);

Member Functions

mcml.GetNode

get a node by a string name.

  • param name : string,

syntax

function mcml.GetNode(name)

parameters

name string,

mcml.new


base functions

create or init a new object o of tag. it will return the input object, if tag name is not found. e.g. mcml.new(nil, {name="div"})

  • param tagName : the tag (node) name to be created or initialized. if nil, the default "baseNode" is used.
  • param o : the tag object to be initialized. if nil, a new one will be created.
  • return __ : the tag (node) object is returned. methods of the object can be called thereafterwards.

syntax

function mcml.new(tagName, o)

parameters

tagName the tag (node) name to be created or initialized. if nil, the default "baseNode" is used.
o  
return the tag (node) object is returned. methods of the object can be called thereafterwards.

mcml.buildclass

o is a pure mcml table, after building class with it, it will be deserialized from pure data to a class contain all methods and parent|child relationships. o must be a pure table that does not contains cyclic table references. for unknown node in o, it will inherite from the baseNode.

  • return the : input o is returned.

syntax

function mcml.buildclass(o)

parameters

o  
return input o is returned.

mcml.baseNode:clone

----------------------------
 base node class
----------------------------

 base class for all nodes. 
mcml.baseNode = {
   name = nil,
   parent = nil,
   -- control index in its parent
   index = 1,
}

return a copy of this object, everything is cloned including the parent and index of its child node.

syntax

function mcml.baseNode:clone()

mcml.baseNode:SetAttribute

set the value of an attribute of this node. This function is rarely used.

syntax

function mcml.baseNode:SetAttribute(attrName, value)

parameters

attrName  
value  

mcml.baseNode:GetAttribute

get the value of an attribute of this node as its original format (usually string)

syntax

function mcml.baseNode:GetAttribute(attrName,defaultValue)

parameters

attrName  
defaultValue  

mcml.baseNode:GetAttributeWithCode

get the value of an attribute of this node (usually string) this differs from GetAttribute() in that the attribute string may contain embedded code block which may evaluates to a different string, table or even function. please note that only the first call of this method will evaluate embedded code block, subsequent calls simply return the previous evaluated result. in most cases the result is nil or string, but it can also be a table or function.

  • param bNoOverwrite : default to nil. if true, the code will be reevaluated the next time this is called, otherwise the evaluated value will be saved and returned the next time this is called. e.g. attrName='<%="string"+Eval("index")}%>' attrName1='<%={fieldname="table"}%>'

syntax

function mcml.baseNode:GetAttributeWithCode(attrName,defaultValue, bNoOverwrite)

parameters

attrName  
defaultValue  
| bNoOverwrite | default to nil. if true, the code will be reevaluated the next time this is called, otherwise the evaluated value will be saved and returned the next time this is called. e.g. attrName='<%="string"+Eval("index")}%>' attrName1='<%={fieldname="table"}%>' |

mcml.baseNode:GetString

get an attribute as string

syntax

function mcml.baseNode:GetString(attrName,defaultValue)

parameters

attrName  
defaultValue  

mcml.baseNode:GetNumber

get an attribute as number

syntax

function mcml.baseNode:GetNumber(attrName,defaultValue)

parameters

attrName  
defaultValue  

mcml.baseNode:GetInt

get an attribute as integer

syntax

function mcml.baseNode:GetInt(attrName, defaultValue)

parameters

attrName  
defaultValue  

mcml.baseNode:GetBool

get an attribute as boolean

syntax

function mcml.baseNode:GetBool(attrName, defaultValue)

parameters

attrName  
defaultValue  

mcml.baseNode:GetPureText

get all pure text of only text node

syntax

function mcml.baseNode:GetPureText()

mcml.baseNode:GetInnerText

get all inner text recursively (i.e. without tags) as string.

syntax

function mcml.baseNode:GetInnerText()

mcml.baseNode:SetInnerText

set inner text. It will replace all child nodes with a text node

syntax

function mcml.baseNode:SetInnerText(text)

parameters

text  

mcml.baseNode:GetValue

get value: it is usually one of the editor tag, such as

syntax

function mcml.baseNode:GetValue()

mcml.baseNode:SetValue

set value: it is usually one of the editor tag, such as

syntax

function mcml.baseNode:SetValue(value)

parameters

value  

mcml.baseNode:GetUIValue

get UI value: get the value on the UI object with current node

  • param instName : the page instance name.

syntax

function mcml.baseNode:GetUIValue(pageInstName)

parameters

pageInstName  

mcml.baseNode:SetUIValue

set UI value: set the value on the UI object with current node

syntax

function mcml.baseNode:SetUIValue(pageInstName, value)

parameters

pageInstName  
value  

mcml.baseNode:CallMethod

call a control method

  • param instName : the page instance name.
  • param methodName : name of the method.
  • return __ : the value from method is returned

syntax

function mcml.baseNode:CallMethod(pageInstName, methodName, ...)

parameters

pageInstName  
methodName  
return the value from method is returned

mcml.baseNode:GetControl

get the control associated with this node.

  • param instName : the page instance name.
  • return __ : It returns the ParaUIObject or CommonCtrl object depending on the type of the control found.

syntax

function mcml.baseNode:GetControl(pageName)

parameters

pageName  

mcml.baseNode:printParents

print information about the parent nodes

syntax

function mcml.baseNode:printParents()

mcml.baseNode:print

print this node to log file for debugging purposes.

syntax

function mcml.baseNode:print()

mcml.baseNode:GetStyle

get the css style object if any.

  • param baseStyle : nil or parent node's style object with which the current node's style is merged. if the class property of this node is not nil, it the class style is applied over baseStyle. The style property if any is applied above the class and baseStyle
  • param base :_baseStyle: this is optional. it is the base style of baseStyle
  • return __ : nil or the style table which is a table of name value pairs. such as {color=string, href=string}

syntax

function mcml.baseNode:GetStyle(baseStyle, base_baseStyle)

parameters

| baseStyle | nil or parent node's style object with which the current node's style is merged. if the class property of this node is not nil, it the class style is applied over baseStyle. The style property if any is applied above the class and baseStyle |

base  
| baseStyle | nil or parent node's style object with which the current node's style is merged. if the class property of this node is not nil, it the class style is applied over baseStyle. The style property if any is applied above the class and baseStyle |
return nil or the style table which is a table of name value pairs. such as {color=string, href=string}

mcml.baseNode:AddChild

  • param child : it can be mcmlNode or string node.
  • param index : 1 based index, at which to insert the item. if nil, it will be inserted to the end

syntax

function mcml.baseNode:AddChild(child, index)

parameters

child it can be mcmlNode or string node.
index  

mcml.baseNode:Detach

detach this node from its parent node.

syntax

function mcml.baseNode:Detach()

mcml.baseNode:GetParent

check whether this baseNode has a parent with the given name. It will search recursively for all ancesters.

  • param name : the parent name to search for. If nil, it will return parent regardless of its name.
  • return __ : the parent object is returned.

syntax

function mcml.baseNode:GetParent(name)

parameters

name the parent name to search for. If nil, it will return parent regardless of its name.

mcml.baseNode:GetRoot

get the root node, it will find in ancestor nodes until one without parent is found

  • return root : node.

syntax

function mcml.baseNode:GetRoot()

parameters

return node.

mcml.baseNode:GetPageCtrl

Get the page control(PageCtrl) that loaded this mcml page.

syntax

function mcml.baseNode:GetPageCtrl()

mcml.baseNode:GetParentAttribute

search all parent with a given attribute name. It will search recursively for all ancesters. this function is usually used for getting the "request_url" field which is inserted by MCML web browser to the top level node.

  • param attrName : the parent field name to search for
  • return __ : the nearest parent object field is returned. it may return, if no such parent is found.

syntax

function mcml.baseNode:GetParentAttribute(attrName)

parameters

attrName the parent field name to search for

mcml.baseNode:GetRequestURL

get the url request of the mcml node if any. It will search for "request_url" attribtue field in the ancestor of this node. PageCtrl and BrowserWnd will automatically insert "request_url" attribtue field to the root MCML node before instantiate them.

  • return __ : nil or the request_url is returned. we can extract requery string parameters using regular expressions or using GetRequestParam

syntax

function mcml.baseNode:GetRequestURL()

parameters

return nil or the request_url is returned. we can extract requery string parameters using regular expressions or using GetRequestParam

mcml.baseNode:GetRequestParam

get request url parameter by its name. for example if page url is "www.paraengine.com/user?id=10&time=20", then GetRequestParam("id") will be 10.

  • return __ : nil or string value.

syntax

function mcml.baseNode:GetRequestParam(paramName)

parameters

paramName  
return nil or string value.

mcml.baseNode:GetAbsoluteURL

convert a url to absolute path using "request_url" if present it will replace %NAME% with their values before processing next.

  • param url : it is any script, image or page url path which may be absolute, site root or relative path. relative to url path can not contain "/", anotherwise it is regarded as client side relative path. such as "Texture/whitedot.png"
  • return __ : it always returns absolute path. however, if path cannot be resolved, the input is returned unchanged.

syntax

function mcml.baseNode:GetAbsoluteURL(url)

parameters

| url | it is any script, image or page url path which may be absolute, site root or relative path. relative to url path can not contain "/", anotherwise it is regarded as client side relative path. such as "Texture/whitedot.png" |

mcml.baseNode:GetOwnerUserID

get the user ID of the owner of the profile.

syntax

function mcml.baseNode:GetOwnerUserID()

mcml.baseNode:GetChildCount

Get child count

syntax

function mcml.baseNode:GetChildCount()

mcml.baseNode:ClearAllChildren

Clear all child nodes

syntax

function mcml.baseNode:ClearAllChildren()

mcml.baseNode.GenerateLessCFByField

generate a less compare function according to a node field name.

  • param fieldName : the name of the field, such as "text", "name", etc

syntax

function mcml.baseNode.GenerateLessCFByField(fieldName)

parameters

fieldName the name of the field, such as "text", "name", etc

mcml.baseNode.GenerateGreaterCFByField

generate a greater compare function according to a node field name.

  • param fieldName : the name of the field, such as "text", "name", etc One can also build a compare function by calling mcml.baseNode.GenerateLessCFByField(fieldName) or mcml.baseNode.GenerateGreaterCFByField(fieldName)

syntax

function mcml.baseNode.GenerateGreaterCFByField(fieldName)

parameters

| fieldName | the name of the field, such as "text", "name", etc One can also build a compare function by calling mcml.baseNode.GenerateLessCFByField(fieldName) or mcml.baseNode.GenerateGreaterCFByField(fieldName) |

mcml.baseNode:SortChildren

sorting the children according to a compare function. Internally it uses table.sort(). Note: child indices are rebuilt and may cause UI binded controls to misbehave compareFunc: if nil, it will compare by node.name.

syntax

function mcml.baseNode:SortChildren(compareFunc)

parameters

compareFunc  

mcml.baseNode:GetNodePath

get a string containing the node path. such as "1/1/1/3" as long as the baseNode does not change, the node path uniquely identifies a baseNode.

syntax

function mcml.baseNode:GetNodePath()

mcml.baseNode:GetInstanceName

  • param rootName : a name that uniquely identifies a UI instance of this object, usually the userID or app_key. The function will generate a sub control name by concartinating this rootname with relative baseNode path.

syntax

function mcml.baseNode:GetInstanceName(rootName)

parameters

rootName a name that uniquely identifies a UI instance of this object, usually the userID or app_key. The function will generate a sub control name by concartinating this rootname with relative baseNode path.

mcml.baseNode:GetChild

get the first occurance of first level child node whose name is name

  • param name : if can be the name of the node, or it can be a interger index.

syntax

function mcml.baseNode:GetChild(name)

parameters

name if can be the name of the node, or it can be a interger index.

mcml.baseNode:SearchChildByAttribute

get the first occurance of child node whose attribute name is value. it will search for all child nodes recursively.

syntax

function mcml.baseNode:SearchChildByAttribute(name, value)

parameters

name  
value  

mcml.baseNode:next

return an iterator of all first level child nodes whose name is name a more advanced way to tranverse mcml tree is using ide/Xpath

  • param name : if name is nil, all child is returned.

syntax

function mcml.baseNode:next(name)

parameters

name if name is nil, all child is returned.

mcml.baseNode:GetAllChildWithName

return a table containing all child nodes whose name is name. (it will search recursively) a more advanced way to tranverse mcml tree is using ide/Xpath

  • param name : if name is nil, all child is returned.
  • param output : nil or a table to receive the result. child nodes with the name is saved to this table array. if nil, a new table will be created.
  • return output : the output table containing all children. It may be nil if no one is found and input "output" is also nil.

syntax

function mcml.baseNode:GetAllChildWithName(name, output)

parameters

name if name is nil, all child is returned.
output  
return the output table containing all children. It may be nil if no one is found and input "output" is also nil.

mcml.baseNode:GetAllChildWithAttribute

return an iterator of all child nodes whose attribtue attrName is attrValue. (it will search recursively) a more advanced way to tranverse mcml tree is using ide/Xpath

  • param name : if name is nil, all child is returned.
  • param output : nil or a table to receive the result. child nodes with the name is saved to this table array. if nil, a new table will be created.
  • return output : the output table containing all children. It may be nil if no one is found and input "output" is also nil.

syntax

function mcml.baseNode:GetAllChildWithAttribute(attrName, attrValue, output)

parameters

attrName  
attrValue  
output  
return the output table containing all children. It may be nil if no one is found and input "output" is also nil.

mcml.baseNode:TranslateMe

here we will translate current node and all of its child nodes recursively, using the given langTable unless any of the child attribute disables or specifies a different lang using the trans attribute

  • note __ : it will secretly mark an already translated node, so it will not be translated twice when the next time this method is called.
  • param langTable : this is a translation table from CommonCtrl.Locale(transName); if this is nil,
  • param transName : the translation name of the langTable.

syntax

function mcml.baseNode:TranslateMe(langTable, transName)

parameters

langTable  
transName the translation name of the langTable.
Topic revision: r1 - 2008-02-29 - LiXizhi
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback