---++!! !CommonCtrl.FileDialog %TOC{title="Contents:"}% %STARTINCLUDE% ---++ File and directory listing common control (dialog) | *Title* | File and directory listing common control (dialog) | | *Author(s)* | LiXizhi | | *Date* | 2006/3/6 | | *File* | script/ide/FileDialog.lua | ---+++ Description %T% __Sample Code__ <verbatim> NPL.load("(gl)script/ide/FileDialog.lua"); local ctl = CommonCtrl.GetControl("FileTreeView1"); if(ctl==nil)then local ctl = CommonCtrl.FileTreeView:new{ name = "FileTreeView1", alignment = "_lt", left=0, top=0, width = 200, height = 200, parent = nil, -- 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 DrawNodeHandler = nil, sInitDir = "temp/", sFilePattern = "*.*", nMaxFileLevels = 0, nMaxNumFiles = 300, }; else ctl.sInitDir = "temp/"; ctl.sFilePattern = "*.*"; ctl:SetModified(true); end ctl:Refresh(); ctl.RootNode:CollapseAll(); ctl.RootNode:Expand(); -- only show first level ctl:Show(); </verbatim> ---+++ Member Functions ---++++ !FileTreeView:new <verbatim> default member attributes local FileTreeView = { -- the top level control name name = "FileTreeView1", -- normal window size alignment = "_lt", left = 0, top = 0, width = 300, height = 400, -- the background of container container_bg = nil, -- The root tree node. containing all tree node data RootNode = nil, -- Default height of Tree Node DefaultNodeHeight = 24, -- default indentation DefaultIndentation = 10, -- 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 FileTreeView.DrawFileItemHandler 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, nodepathString) or nil. this function will be called for each menuitem onclick except the group node. onclick = nil, -- the initial directory. sInitDir = "", -- e.g."*.", "*.x" or it could be table like {"*.lua", "*.raw"} sFilePattern = "*.*", -- max file levels. 0 shows files in the current directory. nMaxFileLevels = 3, -- max number of files in file listbox. e.g. 150 nMaxNumFiles = 300, -- currently selected file path. SelectedFilePath = "", ------------------------------------------- -- private functions ------------------------------------------- IsModified = true, }</verbatim> CommonCtrl.FileTreeView = FileTreeView; constructor __syntax__ <verbatim>function FileTreeView:new (o)</verbatim> __parameters__ | *o* | | ---++++ !FileTreeView:Destroy Destroy the UI control __syntax__ <verbatim>function FileTreeView:Destroy ()</verbatim> ---++++ !FileTreeView.GetNodePath return the node path of the input node. directory is separated by '/' __syntax__ <verbatim>function FileTreeView.GetNodePath(node)</verbatim> __parameters__ | *node* | | ---++++ !FileTreeView.AddNewFile * _param_ __node__ : to which node the filepath is attached. It will create child node if necessary. this function is recursive. * _param_ __filepath__ : file name to add. __syntax__ <verbatim>function FileTreeView.AddNewFile(node, filepath)</verbatim> __parameters__ | *node* | to which node the filepath is attached. It will create child node if necessary. this function is recursive. | | *filepath* | | ---++++ !FileTreeView: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 FileTreeView:SetModified(bModified)</verbatim> __parameters__ | *bModified* | | ---++++ !FileTreeView:GetSelectedFilePath 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 FileTreeView:GetSelectedFilePath()</verbatim> ---++++ !FileTreeView:Show [[ display the file treeview control ]] __syntax__ <verbatim>function FileTreeView:Show(bShow)</verbatim> __parameters__ | *bShow* | | ---++++ !FileTreeView.OnToggleNode private function: called by default TreeNode UI __syntax__ <verbatim>function FileTreeView.OnToggleNode(sCtrlName, nodePath)</verbatim> __parameters__ | *sCtrlName* | | | *nodePath* | | ---++++ !FileTreeView.OnClickNode private function: called by default TreeNode UI __syntax__ <verbatim>function FileTreeView.OnClickNode(sCtrlName, nodePath)</verbatim> __parameters__ | *sCtrlName* | | | *nodePath* | | ---++++ !FileTreeView.DrawFileItemHandler default node renderer: it display a clickable check box for expandable node, followed by node text __syntax__ <verbatim>function FileTreeView.DrawFileItemHandler(_parent,treeNode)</verbatim> __parameters__ | *parent* | | | *treeNode* | | ---++++ !CommonCtrl.InitFileDialog [[ Initializes a set UI objects for directory and file listing. Users can override the default behaviors of the UI controls. the Default behavior is this: listbox_dir shows directories, and is initialized to display sub directories of sInitDir. single click an item will display files in that directory in listbox_file. double click an item will display sub directories in listbox_dir. * _param_ __sInitDir__ : the initial directory. * _param_ __sFilePattern__ : e.g."*.", "*.x" or it could be table like {"*.lua", "*.raw"} * _param_ __nMaxFileLevels__ : max file levels. 0 shows files in the current directory. * _param_ __nMaxNumFiles__ : max number of files in file listbox. e.g. 150 * _param_ __listbox__ :_file: a valid ParaUIObject of type listbox for file listing. This can be nil. * _param_ __listbox__ :_dir: a valid ParaUIObject of type listbox for directory listing. This can be nil. * _param_ __btn__ :_dir_uplevel: a valid ParaUIObject of type button for displaying the last directory. ]] __syntax__ <verbatim>function CommonCtrl.InitFileDialog(sInitDir, sFilePattern, nMaxFileLevels, nMaxNumFiles, listbox_file, listbox_dir, btn_dir_uplevel)</verbatim> __parameters__ | *sInitDir* | the initial directory. | | *sFilePattern* | | | *nMaxFileLevels* | max file levels. 0 shows files in the current directory. | | *nMaxNumFiles* | | | *listbox* | _file: a valid ParaUIObject of type listbox for file listing. This can be nil. | | *file* | | | *listbox* | _file: a valid ParaUIObject of type listbox for file listing. This can be nil. | | *dir* | | | *btn* | _dir_uplevel: a valid ParaUIObject of type button for displaying the last directory. ]] | | *dir* | | | *uplevel* | | %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