---++!! !MCML Controls %TOC{title="Contents:"}% %STARTINCLUDE% ---++ 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 <input type="radio">) pe:editor-checkbox (same as <input type="checkbox">) HTML editor tags are implemented by editor: <input type="checkbox" name="option2" value="Butter" checked="true"/> <input type="radio" name="group1" value="Milk"/> <input type="radio" name="group1" value="Butter"/> <select name="select" size="3"> <option selected="selected">line1</option> <option>line2</option> </select> - control tags: pe:visible-to-owner - worlds tags:pe:world pe:world-ip pe:model pe:avatar - HTML tags:<text>, h1, h2,h3, h4, li, p, div, hr, a(href), img(attr: src,height, width, title), <form> 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: <text>, font,a(href) will float around previous control, allowing content to automatically wrap to the next line. %T% __Sample Code__ <verbatim> 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 </verbatim> ---++ 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. %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemApp/mcml/mcml_controls.lua"); Map3DSystem.mcml_controls.create(rootName, mcmlNode, bindingContext, _parent, left, top, width, height) </verbatim> ---+++ Member Functions ---++++ !mcml_controls.create <verbatim> 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, }</verbatim> 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__ <verbatim>function mcml_controls.create(rootName, mcmlNode, bindingContext, _parent, left, top, width, height, style, parentLayout)</verbatim> __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__ <verbatim>function mcml_controls.OnClickHRef(href)</verbatim> __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__ <verbatim>function mcml_controls.OnPageEvent(mcmlNode, callbackFunc, ...)</verbatim> __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 %T% __Sample Code__ <verbatim> 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(); </verbatim> ---+++ Member Functions ---++++ !layout:new <verbatim>--------------------------------------------- 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, }</verbatim> mcml_controls.layout = layout; __syntax__ <verbatim>function layout:new(o)</verbatim> __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__ <verbatim>function layout:clone()</verbatim> ---++++ !layout:reset reset with newline position (left, top) and container size (width and height). __syntax__ <verbatim>function layout:reset(left, top, width, height)</verbatim> __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__ <verbatim>function layout:GetPreferredSize()</verbatim> ---++++ !layout:GetMaxSize get the max available size __syntax__ <verbatim>function layout:GetMaxSize()</verbatim> ---++++ !layout:GetSize get the size __syntax__ <verbatim>function layout:GetSize()</verbatim> ---++++ !layout:GetUsedSize get used size __syntax__ <verbatim>function layout:GetUsedSize()</verbatim> ---++++ !layout:SetUsedSize set used size __syntax__ <verbatim>function layout:SetUsedSize(width, height)</verbatim> __parameters__ | *width* | | | *height* | | ---++++ !layout:GetAvailableRect get the available rect by left, top, right, bottom. __syntax__ <verbatim>function layout:GetAvailableRect()</verbatim> ---++++ !layout:GetAvailablePos get the available rect by left, top __syntax__ <verbatim>function layout:GetAvailablePos()</verbatim> ---++++ !layout:GetNewlinePos get the newline position (left, top) __syntax__ <verbatim>function layout:GetNewlinePos()</verbatim> ---++++ !layout:OffsetPos offset the new line and available position of this layout. __syntax__ <verbatim>function layout:OffsetPos(dx, dy)</verbatim> __parameters__ | *dx* | | | *dy* | | ---++++ !layout:AddChildLayout childLayout is usually cloned from this layout and this layout will expand to accommandate childLayout. __syntax__ <verbatim>function layout:AddChildLayout(childLayout)</verbatim> __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__ <verbatim>function layout:AddObject(width, height)</verbatim> __parameters__ | *width* | | | *height* | | ---++++ !layout:NewLine make a new line in the layout __syntax__ <verbatim>function layout:NewLine()</verbatim> ---++++ !layout:IncHeight increase preferred height of this layout __syntax__ <verbatim>function layout:IncHeight(dHeight)</verbatim> __parameters__ | *dHeight* | | ---++++ !layout:IncWidth increase preferred width of this layout __syntax__ <verbatim>function layout:IncWidth(dWidth)</verbatim> __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 %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemApp/mcml/mcml_base.lua"); local node = Map3DSystem.mcml.new("pe:profile", {}) local o = Map3DSystem.mcml.buildclass(o); </verbatim> ---+++ Member Functions ---++++ !mcml.GetNode get a node by a string name. * _param_ __name__ : string, __syntax__ <verbatim>function mcml.GetNode(name)</verbatim> __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__ <verbatim>function mcml.new(tagName, o)</verbatim> __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__ <verbatim>function mcml.buildclass(o)</verbatim> __parameters__ | *o* | | | *return* | input o is returned. | ---++++ !mcml.baseNode:clone <verbatim>---------------------------- base node class ---------------------------- base class for all nodes. mcml.baseNode = { name = nil, parent = nil, -- control index in its parent index = 1, }</verbatim> return a copy of this object, everything is cloned including the parent and index of its child node. __syntax__ <verbatim>function mcml.baseNode:clone()</verbatim> ---++++ !mcml.baseNode:SetAttribute set the value of an attribute of this node. This function is rarely used. __syntax__ <verbatim>function mcml.baseNode:SetAttribute(attrName, value)</verbatim> __parameters__ | *attrName* | | | *value* | | ---++++ !mcml.baseNode:GetAttribute get the value of an attribute of this node as its original format (usually string) __syntax__ <verbatim>function mcml.baseNode:GetAttribute(attrName,defaultValue)</verbatim> __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__ <verbatim>function mcml.baseNode:GetAttributeWithCode(attrName,defaultValue, bNoOverwrite)</verbatim> __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__ <verbatim>function mcml.baseNode:GetString(attrName,defaultValue)</verbatim> __parameters__ | *attrName* | | | *defaultValue* | | ---++++ !mcml.baseNode:GetNumber get an attribute as number __syntax__ <verbatim>function mcml.baseNode:GetNumber(attrName,defaultValue)</verbatim> __parameters__ | *attrName* | | | *defaultValue* | | ---++++ !mcml.baseNode:GetInt get an attribute as integer __syntax__ <verbatim>function mcml.baseNode:GetInt(attrName, defaultValue)</verbatim> __parameters__ | *attrName* | | | *defaultValue* | | ---++++ !mcml.baseNode:GetBool get an attribute as boolean __syntax__ <verbatim>function mcml.baseNode:GetBool(attrName, defaultValue)</verbatim> __parameters__ | *attrName* | | | *defaultValue* | | ---++++ !mcml.baseNode:GetPureText get all pure text of only text node __syntax__ <verbatim>function mcml.baseNode:GetPureText()</verbatim> ---++++ !mcml.baseNode:GetInnerText get all inner text recursively (i.e. without tags) as string. __syntax__ <verbatim>function mcml.baseNode:GetInnerText()</verbatim> ---++++ !mcml.baseNode:SetInnerText set inner text. It will replace all child nodes with a text node __syntax__ <verbatim>function mcml.baseNode:SetInnerText(text)</verbatim> __parameters__ | *text* | | ---++++ !mcml.baseNode:GetValue get value: it is usually one of the editor tag, such as <input> __syntax__ <verbatim>function mcml.baseNode:GetValue()</verbatim> ---++++ !mcml.baseNode:SetValue set value: it is usually one of the editor tag, such as <input> __syntax__ <verbatim>function mcml.baseNode:SetValue(value)</verbatim> __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__ <verbatim>function mcml.baseNode:GetUIValue(pageInstName)</verbatim> __parameters__ | *pageInstName* | | ---++++ !mcml.baseNode:SetUIValue set UI value: set the value on the UI object with current node __syntax__ <verbatim>function mcml.baseNode:SetUIValue(pageInstName, value)</verbatim> __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__ <verbatim>function mcml.baseNode:CallMethod(pageInstName, methodName, ...)</verbatim> __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__ <verbatim>function mcml.baseNode:GetControl(pageName)</verbatim> __parameters__ | *pageName* | | ---++++ !mcml.baseNode:printParents print information about the parent nodes __syntax__ <verbatim>function mcml.baseNode:printParents()</verbatim> ---++++ !mcml.baseNode:print print this node to log file for debugging purposes. __syntax__ <verbatim>function mcml.baseNode:print()</verbatim> ---++++ !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__ <verbatim>function mcml.baseNode:GetStyle(baseStyle, base_baseStyle)</verbatim> __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__ <verbatim>function mcml.baseNode:AddChild(child, index)</verbatim> __parameters__ | *child* | it can be mcmlNode or string node. | | *index* | | ---++++ !mcml.baseNode:Detach detach this node from its parent node. __syntax__ <verbatim>function mcml.baseNode:Detach()</verbatim> ---++++ !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__ <verbatim>function mcml.baseNode:GetParent(name)</verbatim> __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__ <verbatim>function mcml.baseNode:GetRoot()</verbatim> __parameters__ | *return* | node. | ---++++ !mcml.baseNode:GetPageCtrl Get the page control(PageCtrl) that loaded this mcml page. __syntax__ <verbatim>function mcml.baseNode:GetPageCtrl()</verbatim> ---++++ !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__ <verbatim>function mcml.baseNode:GetParentAttribute(attrName)</verbatim> __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__ <verbatim>function mcml.baseNode:GetRequestURL()</verbatim> __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__ <verbatim>function mcml.baseNode:GetRequestParam(paramName)</verbatim> __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__ <verbatim>function mcml.baseNode:GetAbsoluteURL(url)</verbatim> __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__ <verbatim>function mcml.baseNode:GetOwnerUserID()</verbatim> ---++++ !mcml.baseNode:GetChildCount Get child count __syntax__ <verbatim>function mcml.baseNode:GetChildCount()</verbatim> ---++++ !mcml.baseNode:ClearAllChildren Clear all child nodes __syntax__ <verbatim>function mcml.baseNode:ClearAllChildren()</verbatim> ---++++ !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__ <verbatim>function mcml.baseNode.GenerateLessCFByField(fieldName)</verbatim> __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__ <verbatim>function mcml.baseNode.GenerateGreaterCFByField(fieldName)</verbatim> __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__ <verbatim>function mcml.baseNode:SortChildren(compareFunc)</verbatim> __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__ <verbatim>function mcml.baseNode:GetNodePath()</verbatim> ---++++ !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__ <verbatim>function mcml.baseNode:GetInstanceName(rootName)</verbatim> __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__ <verbatim>function mcml.baseNode:GetChild(name)</verbatim> __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__ <verbatim>function mcml.baseNode:SearchChildByAttribute(name, value)</verbatim> __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__ <verbatim>function mcml.baseNode:next(name)</verbatim> __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__ <verbatim>function mcml.baseNode:GetAllChildWithName(name, output)</verbatim> __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__ <verbatim>function mcml.baseNode:GetAllChildWithAttribute(attrName, attrValue, output)</verbatim> __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__ <verbatim>function mcml.baseNode:TranslateMe(langTable, transName)</verbatim> __parameters__ | *langTable* | | | *transName* | the translation name of the langTable. | %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