---++!! !CommonCtrl.GridView3D %TOC{title="Contents:"}% %STARTINCLUDE% ---+++ Member Functions ---++++ !GridCell3D:new <verbatim> common control library NPL.load("(gl)script/ide/common_control.lua"); ------------------------------------------------------------ Grid Cell 3D ------------------------------------------------------------ Represents a cell of a GridView3D. local GridCell3D = { ---- Gets the parent tree node of the current tree node. --parent = nil, -- Gets the ancister grid view that the grid cell is assigned to. GridView3D = nil, -- Gets or sets the name of the grid cell. name = nil, -- Gets or sets the text displayed in the label of the grid cell. text = nil, -- column index of this cell in the GridView3D, from 1 column = nil, -- row index of this cell in the GridView3D, from 1 row = nil, ------ Gets the zero-based depth of the tree node in the TreeView control ----Level = 0, ------ Gets the array of TreeNode objects assigned to the current tree node. ----Nodes = nil, ------ Gets a value indicating whether the tree node is in the expanded state. ----Expanded = true, ---- Gets a value indicating whether the grid cell is in the selected state. --Selected = nil, ---- if true, node is invisible. --Invisible = nil, ---- Gets or sets the URL to navigate to when the cell is clicked. --NavigateUrl = nil, ---- Gets or sets a non-displayed value used to store any additional data about the cell, such as data used for handling postback events. --Value = nil, ---- Gets or sets the object that contains data about the grid cell. --Tag = nil, ---- Gets or sets the text that appears when the mouse pointer hovers over a grid cell. --ToolTipText = nil, ---- icon texture file --Icon = nil, ------ Gets or sets the key for the image associated with this tree node when the node is in an unselected state. ------ this can be a index which index into TreeView.ImageList[ImageKey] or it can be a string of image file path or URL. ----ImageKey = nil, ------ Gets or sets the key of the image displayed in the tree node when it is in a selected state. ------ this can be a index which index into TreeView.ImageList[ImageKey] or it can be a string of image file path or URL. ----SelectedImageKey = nil, ------ Width of this grid cell, if this is nil, GridView3D.DefaultCellWidth will be used ----CellWidth = nil, ------ Height of this grid cell, if this is nil, GridView3D.DefaultCellHeight will be used ----CellHeight = nil, ---- string to be executed or a function of format function FuncName(gridCell) end --onclick = nil, -------------------------------- -- internal parameters, do not use externally -------------------------------- -- logical position of the node relative to the grid view container. logicalX = 0, logicalY = 0, ---- logical position for the right bottom corner of this cell --logicalRight = 0, --logicalBottom = 0, ---- internal column index of this cell. such that ... --indexColumn = 0, ---- internal row index of this cell. such that ... --indexRow = 0, ---- render column index --columnindex = 0, ---- render row index --rowindex = 0, }</verbatim> CommonCtrl.GridCell3D = GridCell3D; constructor __syntax__ <verbatim>function GridCell3D:new (o)</verbatim> __parameters__ | *o* | | ---++++ !GridCell3D:GetCellCoord get a string containing the cell coordinate as long as the GridView3D does not change, the cell coordinate uniquely identifies a GridCell. * _return_ ____ : row, column __syntax__ <verbatim>function GridCell3D:GetCellCoord()</verbatim> __parameters__ | *return* | row, column | ---++++ !GridCell3D:GetSiblingCellUp get the sibling Up/Down/Left/Right cell __syntax__ <verbatim>function GridCell3D:GetSiblingCellUp()</verbatim> ---++++ !GridView3D:new <verbatim>------------------------------------------------------------ GridView3D ------------------------------------------------------------ GridView3D is a container showing 2 dimensional array of data in matrix display form. local sampleGridView3D = { -- the top level control name name = "GridView3D1", -- normal window size alignment = "_lt", left = 0, top = 0, width = 300, height = 300, --buttonwidth = 20, -- the drop down button width --dropdownheight = 150, -- the drop down list box height. parent = nil, -- appearance container_bg = nil, -- the background of container main_bg = "", -- the background of container without scrollbar, default to full transparent ---- automatically display vertical scroll bar when content is large --AutoVerticalScrollBar = true, ---- automatically display horizontal scroll bar when content is large --AutoHorizontalScrollBar = true, ---- Vertical ScrollBar Width --VerticalScrollBarWidth = 15, ---- Horizontal ScrollBar Width --HorizontalScrollBarWidth = 15, ---- how many pixels to scroll each time --VerticalScrollBarStep = 3, ---- how many pixels to scroll each time --HorizontalScrollBarStep = 3, ---- how many pixels to scroll when user hit the empty space of the scroll bar. ---- this is usually same as DefaultCellHeight --VerticalScrollBarPageSize = 48, ---- how many pixels to scroll when user hit the empty space of the scroll bar. ---- this is usually same as DefaultCellWidth --HorizontalScrollBarPageSize = 48, ---- The root tree node. containing all tree node data --RootNode = nil, -- row data containing all the gridcell3ds organized in rows -- table indexed by rows -- each row table contains a subtable indexed by columns, each entry is a grid cell -- both index from 1 cells = {}; -- number of columns in the GridView3D columns = nil, -- number of rows in the GridView3D rows = nil, -- cell width and cell height -- NOTE: Current version only supports the same width and height GridCell3D defined in the GridView3D cellWidth = 36, cellHeight = 36, -- cell padding between neighbor cells cellPadding = 4, -- different with the tree view defaultCellWidth = 24, defaultCellHeight = 24, -- render target size specified for mini scene graph -- NOTE: some control width and height need to be adjusted on the fly, user can assign -- the render target size to the largest size -- must be power of two renderTargetSize = 256, -- Gets or sets a function by which the individual GridCell3D control is drawn. The function should be of the format: -- function DrawCellEventHandler(parent,gridcell3d) end, where parent is the parent container in side which contents should be drawn. -- And GridCell3D is the GridCell3D object to be drawn -- if DrawCellHandler is nil, the default GridView3D.DrawNormalCellHandler function will be used. DrawCellHandler = nil, -- function(_parent, cell, filename) ---- default icon size --defaultIconSize = 16, ---- whether to show icon on the left of each line. --showIcon = true, ---- default indentation --DefaultIndentation = 5, ---- 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 GridView3D.DrawNormalNodeHandler function will be used. --DrawNodeHandler = nil, ---- Cache size: The number of TreeNode controls to be cached. [N/A] --CacheSize = 30, ---- 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 format function FuncName(treeNode) end or nil --onclick = nil, ---------------------------------- ---- internal parameters, do not use externally ---------------------------------- ---- top left cell and bottom right cell mainly for the horizontal and vertical scroll bar available --TopLeftCell = nil, --BottomRightCell = nil, ---- the client area X, Y position in pixels relative to the logical tree view container. --ClientX = 0, --ClientY = 0, -- this is automatically set according to whether a scroll bar is available. clientWidth = 10, clientHeight = 10, ---- a mapping from node path to existing line control container index, the total number of mapping here does not exceed CacheSize --NodeUIContainers = {}, }</verbatim> local GridView3D = {}; CommonCtrl.GridView3D = GridView3D; constructor __syntax__ <verbatim>function GridView3D:new (o)</verbatim> __parameters__ | *o* | | ---++++ !GridView3D:Show * _param_ __bShow__ : boolean to show or hide. if nil, it will toggle current setting. __syntax__ <verbatim>function GridView3D:Show(bShow)</verbatim> __parameters__ | *bShow* | boolean to show or hide. if nil, it will toggle current setting. | ---++++ !GridView3D:GetMiniSceneGraph function GridView3D.Click2DGridView(secretName, row, column) --local s = string.find(secretName, "_GridView3D_SecretGridView"); --if(s ~= nil) then --local secret = string.sub(secret, 1, s-1); --secretName, row, column --end end --------------------------------------- use precomputer miniscenegraph --------------------------------------- if(not GridView3D.LastTimerID) then GridView3D.LastTimerID = 4521; end function GridView3D:SetMiniSceneTimer() ---- register a timer for GridView3D update --NPL.SetTimer(GridView3D.LastTimerID + 1, 0.05, ";CommonCtrl.GridView3D.OnMiniSceneTimer(\""..self.name.."\");"); --self.timerID = GridView3D.LastTimerID + 1; --GridView3D.LastTimerID = GridView3D.LastTimerID + 1; ----NPL.SetTimer(235, 0.05, ";Map3DSystem.UI.MiniMapWnd.OnMiniMapTimer();"); end --function GridView3D.OnMiniSceneTimer(name) --local ctl = CommonCtrl.GetControl(name); --if(ctl ~= nil) then --local scene = ctl:GetMiniSceneGraph(); --scene:Draw(0.05); --end end __syntax__ <verbatim>function GridView3D:GetMiniSceneGraph()</verbatim> ---++++ !GridView3D:InitMiniSceneGraphCanvas create and initialize the mini map mini scene graph NOTE: one time init __syntax__ <verbatim>function GridView3D:InitMiniSceneGraphCanvas()</verbatim> ---++++ !GridView3D:Update this function should be called whenever the layout of the grid view changed. internally, it will recalculate all cell logical positions. TODO: @param ShowCell: nil or a GridCell3D. It will automaticly scroll for the best show of the cell element. __syntax__ <verbatim>function GridView3D:Update()</verbatim> ---++++ !GridView3D:InsertCell insert the GridCell3D object into the grid view * _param_ __cell__ : GridCell3D object * _param_ __mode__ : where to place the newly added cell when cell on target position already exists according to Numpad, if the cell inserted at 5, and 5 already has a cell, then try to insert cell according to the sequence: "Up": 8 1 4 7 "Down": 2 9 6 3 "Left": 4 9 8 7 "Right": 6 1 2 3 if the sequence hit the topleft or rightbottom corner of a GridView3D, drop cell. __syntax__ <verbatim>function GridView3D:InsertCell(cell, mode)</verbatim> __parameters__ | *cell* | GridCell3D object | | *mode* | | ---++++ !GridView3D:GetCellByRowAndColumn get a GridCell3D object from the grid view by row and column index * _param_ __row__ : GridCell3D row index * _param_ __column__ : GridCell3D column index __syntax__ <verbatim>function GridView3D:GetCellByRowAndColumn(row, column)</verbatim> __parameters__ | *row* | GridCell3D row index | | *column* | | ---++++ !GridView3D:RemoveCellByPosition remove a GridCell3D object from the grid view by row and column index * _param_ __row__ : GridCell3D row index * _param_ __column__ : GridCell3D column index __syntax__ <verbatim>function GridView3D:RemoveCellByPosition(row, column)</verbatim> __parameters__ | *row* | GridCell3D row index | | *column* | | ---++++ !GridView3D:GetCellByName get the first occurance of GridCell3D object whose name is name __syntax__ <verbatim>function GridView3D:GetCellByName(name)</verbatim> __parameters__ | *name* | | ---++++ !GridView3D:RemoveCellByName remove all occurance of grid cell whose name is name __syntax__ <verbatim>function GridView3D:RemoveCellByName(name)</verbatim> __parameters__ | *name* | | ---++++ !GridView3D:GetCellByText get the first occurance of GridCell3D object whose text is text __syntax__ <verbatim>function GridView3D:GetCellByText(text)</verbatim> __parameters__ | *text* | | ---++++ !GridView3D:GetCellByPoint TODO: implement this funciton in the grid view -- get the best matched cell that contains the logical point x, y __syntax__ <verbatim>function GridView3D:GetCellByPoint(x, y)</verbatim> __parameters__ | *x* | | | *y* | | ---++++ !GridView3D:GetCellCount Get cell count __syntax__ <verbatim>function GridView3D:GetCellCount()</verbatim> ---++++ !GridView3D:ClearAllCells clear all GridCell3Ds __syntax__ <verbatim>function GridView3D:ClearAllCells()</verbatim> ---++++ !GridView3D:UpdateLogicalPosition update the logical positions of grid cells __syntax__ <verbatim>function GridView3D:UpdateLogicalPosition()</verbatim> %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