---++!! !CommonCtrl.MainMenu %TOC{title="Contents:"}% %STARTINCLUDE% ---++ Main menu, using buttons with top level menu item, and a tree view internally for child level menus. It has a modern appearance. | *Title* | Main menu, using buttons with top level menu item, and a tree view internally for child level menus. It has a modern appearance. | | *Author(s)* | LiXizhi | | *Date* | 2007/12/30 | | *File* | script/ide/MainMenu.lua | ---+++ Description ---+++ Member Functions ---++++ !MainMenu:new <verbatim> common control library NPL.load("(gl)script/ide/common_control.lua"); NPL.load("(gl)script/ide/TreeView.lua"); define a new control in the common control libary default member attributes local MainMenu = { -- the top level control name name = "MainMenu1", -- normal window size left = 0, top = 0, width = 400, height = 22, -- popup menu default height popmenu_height = 22, parent = nil, -- 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, PopMenuWidth = 200, -- 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 menu container, default to null. container_bg = nil, -- popmenu background popmenu_container_bg = "Texture/3DMapSystem/ContextMenu/BG2.png:8 8 8 8", -- 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, -- half space between the text of top level menu item DefaultMenuTextMargin = 5, -- color of the main menu item text TextColor = "24 57 124", -- color of the selected main menu item text SelectedTextColor = nil, -- default menu item font font = nil, -- the background image to be displayed when mouse over an top level menu item. -- please note that: MouseOverItemBG does not support 9 tile ":" texture name yet. -- MouseOverItemBG = "Texture/3DMapSystem/common/ThemeLightBlue/menuitem_over.png: 2 2 2 2", UnSelectedMenuItemBG = "", SelectedMenuItemBG = "Texture/3DMapSystem/common/ThemeLightBlue/menuitem_selected.png: 2 2 2 2", -- top level menu item spacing. ItemSpacing = 0, -- 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 MainMenu.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, ------------------------------------------- -- private functions ------------------------------------------- IsModified = true, -- current selected top level menu item index SelectedIndex = nil, }</verbatim> CommonCtrl.MainMenu = MainMenu; constructor __syntax__ <verbatim>function MainMenu:new (o)</verbatim> __parameters__ | *o* | | ---++++ !MainMenu:Destroy Destroy the UI control __syntax__ <verbatim>function MainMenu:Destroy ()</verbatim> ---++++ !MainMenu:Show it will automatically update items if the mainmenu is shown for the first time. * _param_ __bShow__ : boolean to show or hide. if nil, it will toggle current setting. __syntax__ <verbatim>function MainMenu:Show(bShow)</verbatim> __parameters__ | *bShow* | boolean to show or hide. if nil, it will toggle current setting. | ---++++ !MainMenu:Update call this function when ever the top level menu item is changed. There is no need to call this function, if one only updated sub menu items. __syntax__ <verbatim>function MainMenu:Update()</verbatim> ---++++ !MainMenu:GetSelectedIndex get the selected first level menu item index __syntax__ <verbatim>function MainMenu:GetSelectedIndex()</verbatim> ---++++ !MainMenu:SetSelectedIndex set the selected first level menu item index. * _param_ __index__ : index of the item * _param_ __bNotRefreshUI__ : true to refresh the UI. __syntax__ <verbatim>function MainMenu:SetSelectedIndex(index, bNotRefreshUI)</verbatim> __parameters__ | *index* | index of the item | | *bNotRefreshUI* | | ---++++ !MainMenu:UpdateTopLevelMenu after the content of a tree node is changed, one may need to call this function at the root node __syntax__ <verbatim>function MainMenu:UpdateTopLevelMenu()</verbatim> ---++++ !MainMenu.OnClickTopLevelMenuItem handler to select a top level menu item. __syntax__ <verbatim>function MainMenu.OnClickTopLevelMenuItem(sCtrlName, index)</verbatim> __parameters__ | *sCtrlName* | | | *index* | | ---++++ !MainMenu.OnMouseUpCont this is a click outside the pop menu container, we will therefore close the container. __syntax__ <verbatim>function MainMenu.OnMouseUpCont(sCtrlName)</verbatim> __parameters__ | *sCtrlName* | | ---++++ !MainMenu.OnMouseMoveCont automatically switch to another menu item. __syntax__ <verbatim>function MainMenu.OnMouseMoveCont(sCtrlName)</verbatim> __parameters__ | *sCtrlName* | | ---++++ !MainMenu.OnClose close the given control __syntax__ <verbatim>function MainMenu.OnClose(sCtrlName)</verbatim> __parameters__ | *sCtrlName* | | ---++++ !MainMenu.OnToggleNode private function: called by default TreeNode UI __syntax__ <verbatim>function MainMenu.OnToggleNode(sCtrlName, nodePath)</verbatim> __parameters__ | *sCtrlName* | | | *nodePath* | | ---++++ !MainMenu.OnClickNode private function: called by default TreeNode UI __syntax__ <verbatim>function MainMenu.OnClickNode(sCtrlName, nodePath)</verbatim> __parameters__ | *sCtrlName* | | | *nodePath* | | ---++++ !MainMenu.DrawMenuItemHandler default node renderer: it display a clickable check box for expandable node, followed by node text __syntax__ <verbatim>function MainMenu.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