CommonCtrl.GridView3D

Member Functions

GridCell3D:new

 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,
}
GridCell3D = GridCell3D;

constructor

syntax

function GridCell3D:new (o)

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

function GridCell3D:GetCellCoord()

parameters

return row, column

GridCell3D:GetSiblingCellUp

get the sibling Up/Down/Left/Right cell

syntax

function GridCell3D:GetSiblingCellUp()

GridView3D:new

------------------------------------------------------------
 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 = {},
}

local GridView3D = {}; GridView3D = GridView3D;

constructor

syntax

function GridView3D:new (o)

parameters

o  

GridView3D:Show

  • param bShow : boolean to show or hide. if nil, it will toggle current setting.

syntax

function GridView3D:Show(bShow)

parameters

bShow boolean to show or hide. if nil, it will toggle current setting.

GridView3D:GetMiniSceneGraph

function 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 LastTimerID) then LastTimerID = 4521; end function GridView3D:SetMiniSceneTimer() ---- register a timer for GridView3D update --NPL.SetTimer(LastTimerID + 1, 0.05, ";CommonCtrl.GridView3D.OnMiniSceneTimer(\""..self.name.."\");"); --self.timerID = LastTimerID + 1; --GridView3D.LastTimerID = LastTimerID + 1; ----NPL.SetTimer(235, 0.05, ";Map3DSystem.UI.MiniMapWnd.OnMiniMapTimer();"); end

--function OnMiniSceneTimer(name) --local ctl = GetControl(name); --if(ctl ~= nil) then --local scene = ctl:GetMiniSceneGraph(); --scene:Draw(0.05); --end end

syntax

function GridView3D:GetMiniSceneGraph()

GridView3D:InitMiniSceneGraphCanvas

create and initialize the mini map mini scene graph NOTE: one time init

syntax

function GridView3D:InitMiniSceneGraphCanvas()

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

function GridView3D:Update()

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

function GridView3D:InsertCell(cell, mode)

parameters

cell GridCell3D object
mode  

GridView3D:GetCellByRowAndColumn

get a GridCell3D object from the grid view by row and column index

syntax

function GridView3D:GetCellByRowAndColumn(row, column)

parameters

row GridCell3D row index
column  

GridView3D:RemoveCellByPosition

remove a GridCell3D object from the grid view by row and column index

syntax

function GridView3D:RemoveCellByPosition(row, column)

parameters

row GridCell3D row index
column  

GridView3D:GetCellByName

get the first occurance of GridCell3D object whose name is name

syntax

function GridView3D:GetCellByName(name)

parameters

name  

GridView3D:RemoveCellByName

remove all occurance of grid cell whose name is name

syntax

function GridView3D:RemoveCellByName(name)

parameters

name  

GridView3D:GetCellByText

get the first occurance of GridCell3D object whose text is text

syntax

function GridView3D:GetCellByText(text)

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

function GridView3D:GetCellByPoint(x, y)

parameters

x  
y  

GridView3D:GetCellCount

Get cell count

syntax

function GridView3D:GetCellCount()

GridView3D:ClearAllCells

clear all GridCell3Ds

syntax

function GridView3D:ClearAllCells()

GridView3D:UpdateLogicalPosition

update the logical positions of grid cells

syntax

function GridView3D:UpdateLogicalPosition()


This topic: Main > NPL > GridView3D
Topic revision: r1 - 2008-02-29 - LiXizhi
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 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