---++!! !CommonCtrl.ContextMenu %TOC{title="Contents:"}% %STARTINCLUDE% ---++ Context menu, using a tree view internally for sub level menus. It has a modern appearance. | *Title* | Context menu, using a tree view internally for sub level menus. It has a modern appearance. | | *Author(s)* | LiXizhi | | *Date* | 2007/9/24 | | *File* | script/ide/ContextMenu.lua | ---+++ Description ---+++ Member Functions ---++++ !ContextMenu:new <verbatim> common control library NPL.load("(gl)script/ide/common_control.lua"); NPL.load("(gl)script/ide/TreeView.lua"); NPL.load("(gl)script/ide/WindowFrame.lua"); define a new control in the common control libary default member attributes local ContextMenu = { -- the top level control name name = "ContextMenu1", -- normal window size width = 400, height = 290, -- this is the maximum height, a scroll bar will be used if there are too many menu items. MaxHeight = 500, -- this is the minimum height of the content menu, unless there are so few items to display MinHeight = 40, -- auto positioning method: it can be -- "_lt": left top, where the mouse x, y will be the left top point of the menu container. This is the default mode. -- "_lb": left bottom, where the mouse x, y will be the left bottom point of the menu container. AutoPositionMode = "_lt", -- the background of container container_bg = nil, -- The root tree node. containing all tree node data RootNode = nil, -- Default height of Tree Node DefaultNodeHeight = 22, -- default icon size DefaultIconSize = 16, -- default indentation DefaultIndentation = 16, -- Gets or sets a function by which the individual TreeNode control is drawn. The function should be of the format: -- function DrawNodeEventHandler(parent,treeNode) end, where parent is the parent container in side which contents should be drawn. And treeNode is the TreeNode object to be drawn -- if DrawNode is nil, the default ContextMenu.DrawMenuItemHandler function will be used. DrawNodeHandler = nil, -- Force no clipping or always using fast render. Unless you know that the unit scroll step is interger times of all TreeNode height. You can disable clipping at your own risk. -- Software clipping is always used to clip all invisible TreeNodes. However, this option allows you to specify whether to use clipping for partially visible TreeNode. NoClipping = nil, -- a function of type function (MenuItem, param1) or nil. this function will be called for each menuitem onclick except the group node. onclick = nil, -- NOTE by Andy 2008/12/7: add a style to allow customized menu apperance -- define menu apperance style style = nil, ------------------------------------------- -- private functions ------------------------------------------- IsModified = true, } CommonCtrl.ContextMenu = ContextMenu; ContextMenu.DefaultStyle = { borderTop = 4, borderBottom = 4, borderLeft = 0, borderRight = 0, fillLeft = -20, fillTop = -15, fillWidth = -19, fillHeight = -24, menu_bg = "Texture/Aquarius/Common/ContextMenu_BG_32bits.png: 31 27 31 36", shadow_bg = nil, separator_bg = "Texture/Aquarius/Common/ContextMenu_Separator.png: 1 1 1 4", item_bg = "Texture/Aquarius/Common/ContextMenu_ItemBG_32bits.png: 1 1 1 1", expand_bg = "Texture/Aquarius/Common/ContextMenu_Expand.png", expand_bg_mouseover = "Texture/Aquarius/Common/ContextMenu_Expand_MouseOver.png", menuitemHeight = 22, separatorHeight = 8, titleHeight = 22, titleFont = "System;14;bold"; }</verbatim>; constructor __syntax__ <verbatim>function ContextMenu:new (o)</verbatim> __parameters__ | *o* | | ---++++ !ContextMenu:Destroy Destroy the UI control __syntax__ <verbatim>function ContextMenu:Destroy ()</verbatim> ---++++ !ContextMenu.ShowContainerWithAnimation show the container with animation __syntax__ <verbatim>function ContextMenu.ShowContainerWithAnimation(obj)</verbatim> __parameters__ | *obj* | | ---++++ !ContextMenu.HideContainerWithAnimation hide the container with animation __syntax__ <verbatim>function ContextMenu.HideContainerWithAnimation(obj)</verbatim> __parameters__ | *obj* | | ---++++ !ContextMenu:Show * _param_ __x__ : where to display. if nil, mouse_x is used * _param_ __y__ : where to display. if nil, mouse_y is used * _param_ __param1__ : a optional parameter object to be passed to onclick event __syntax__ <verbatim>function ContextMenu:Show(x, y, param1)</verbatim> __parameters__ | *x* | where to display. if nil, mouse_x is used | | *y* | | | *param1* | a optional parameter object to be passed to onclick event | ---++++ !ContextMenu:Hide hide the context menu * _return_ __true__ : if object is original shown, and is hidden now. if the control is already hidden prior to this call, the function return nil. __syntax__ <verbatim>function ContextMenu:Hide()</verbatim> __parameters__ | *return* | if object is original shown, and is hidden now. if the control is already hidden prior to this call, the function return nil. | ---++++ !ContextMenu.OnClose close the given control __syntax__ <verbatim>function ContextMenu.OnClose(sCtrlName)</verbatim> __parameters__ | *sCtrlName* | | ---++++ !ContextMenu.OnMouseClickCont this is a click outside the menu container, we will therefore hide the container. __syntax__ <verbatim>function ContextMenu.OnMouseClickCont(sCtrlName)</verbatim> __parameters__ | *sCtrlName* | | ---++++ !ContextMenu.OnMouseDownCont this is a click outside the menu container, we will therefore hide the container. __syntax__ <verbatim>function ContextMenu.OnMouseDownCont(sCtrlName)</verbatim> __parameters__ | *sCtrlName* | | ---++++ !ContextMenu.OnMouseUpCont this is a click outside the menu container, we will therefore close the container. __syntax__ <verbatim>function ContextMenu.OnMouseUpCont(sCtrlName)</verbatim> __parameters__ | *sCtrlName* | | ---++++ !ContextMenu.OnClickItem onclick event handler __syntax__ <verbatim>function ContextMenu.OnClickItem(sCtrlName, nodePath)</verbatim> __parameters__ | *sCtrlName* | | | *nodePath* | | ---++++ !ContextMenu.OnMouseEnterItem onmouseenter event handler __syntax__ <verbatim>function ContextMenu.OnMouseEnterItem(sCtrlName, index)</verbatim> __parameters__ | *sCtrlName* | | | *index* | | ---++++ !ContextMenu.OnMouseLeaveItem onmouseleave event handler __syntax__ <verbatim>function ContextMenu.OnMouseLeaveItem(sCtrlName, index)</verbatim> __parameters__ | *sCtrlName* | | | *index* | | ---++++ !ContextMenu:SetModified set modified, always call this function after you have changed the menu items. this will cause the content menu to redraw next time it shows up. __syntax__ <verbatim>function ContextMenu:SetModified(bModified)</verbatim> __parameters__ | *bModified* | | ---++++ !ContextMenu.OnToggleNode private function: called by default TreeNode UI __syntax__ <verbatim>function ContextMenu.OnToggleNode(sCtrlName, nodePath)</verbatim> __parameters__ | *sCtrlName* | | | *nodePath* | | ---++++ !ContextMenu.OnClickNode private function: called by default TreeNode UI __syntax__ <verbatim>function ContextMenu.OnClickNode(sCtrlName, nodePath)</verbatim> __parameters__ | *sCtrlName* | | | *nodePath* | | ---++++ !ContextMenu.DrawMenuItemHandler default node renderer: it display a clickable check box for expandable node, followed by node text __syntax__ <verbatim>function ContextMenu.DrawMenuItemHandler(_parent,treeNode)</verbatim> __parameters__ | *parent* | | | *treeNode* | | %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