/* *********************************************************************
This source file is a part of the standard library of Scol
For the latest info, see http://www.scolring.org
Copyright (c) 2014 Stephane Bisaro aka Iri.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA, or go to
http://www.gnu.org/copyleft/lesser.txt
********************************************************************* */
/*
* Functions for the widget named 'Grid'
* See http://redmine.scolring.org/projects/tutorials/wiki/Scol_usage
* for more informations
*/
/*! \file grid.pkg
* \author Scol team
* \version 0.1
* \copyright GNU Lesser General Public License 2.0 or later
* \brief New Grid widget API
*
* Dependancies :
* -
*
* \image html grid.png
*
**/
/*! \struct Grid
*
* \ingroup _2dos_grid
*
* \brief Opaque internal structure. You should not call it directly, use
* API instead !
*
**/
struct Grid = [
grid_oChn : Chn,
grid_sArray : tab tab GridCell,
grid_iNbLines : I, // first line is 0
grid_iNbCols : I, // first column is 0
grid_iPosX1 : I, // left top corner
grid_iPosY1 : I,
grid_iPosX2 : I, // right bottom corner
grid_iPosY2 : I,
grid_iSpacing : I,
grid_iFlags : I, // current window flags to set
grid_oParent : ObjWin // last parent set
] mkGrid;;
struct GridCell = [
gridc_iLine : I,
gridc_iCol : I,
gridc_oWin : ObjWin,
gridc_oParent : ObjWin,
gridc_iPosX1 : I, // left top corner
gridc_iPosY1 : I,
gridc_iPosX2 : I, // right bottom corner
gridc_iPosY2 : I,
gridc_iPosInitX1 : I,
gridc_iPosInitY1 : I,
gridc_iPosInitX2 : I,
gridc_iPosInitY2 : I,
gridc_iFlags : I, // current window flags
gridc_isDrag : I,
gridc_isDragButton : I, // mouse button : nil for all buttons
gridc_cbClick : fun [ObjWin Grid I I I] I
] mkGridCell;;
struct GridCellDrag = [
gridcd_iPosX : I,
gridcd_iPosY : I,
gridcd_iInitLine : I,
gridcd_iInitCol : I,
gridcd_iLine : I,
gridcd_iCol : I
] mkGridCellDrag;;
typeof gridCellDrag = GridCellDrag;;
proto grid_initLine = fun [I] tab GridCell;;
proto gridcell_create = fun [Grid I I] ObjWin;;
fun GRID_DRAGDROP ()= 1;;
fun GRID_NODRAGDROP ()= 0;;
fun GRID_MOUSELEFT ()= 1;;
fun GRID_MOUSERIGHT ()= 2;;
fun GRID_MOUSEMIDDLE ()= 4;;
fun GRID_MOUSEALL ()= 32;;
/*fun _print (grid)=
let grid.grid_sArray -> table in
let sizetab table -> nl in
let sizetab table.0 -> nc in
let 0 -> i in
while i < nl do
let 0 -> j in
let table.i -> line in
(
while j < nc do
let line.j -> cell in
(
_fooS sprintf "Line : %d Col : %d Y1 : %d Y2 : %d" [i j cell.gridc_iPosY1 cell.gridc_iPosY2];
set j = j+1
);
set i = i+1;
);
0;;*/
fun grid_init (nL, nC)=
mkGrid [
nil mktab nL nil
nil nil
nil nil nil nil
5 WN_NORMAL
nil
];;
fun grid_initLine (nC)=
mktab nC nil;;
fun gridcell_init (l, c, x1, y1, x2, y2)=
mkGridCell [
l c
nil nil
x1 y1 x2 y2
x1 y1 x2 y2
nil 0 nil
nil
];;
fun gridcd_init ()=
mkGridCellDrag [nil nil nil nil nil nil];;
fun gridcell_getStructure (grid, l, c)=
if (l > grid.grid_iNbLines) || (c > grid.grid_iNbCols) then
nil
else
let grid.grid_sArray -> cells in
cells.(l).c;;
fun grid_size (grid, newCellW, newCellH)=
if (grid == nil) || (newCellW < 1) || (newCellW == nil) ||
(newCellH < 1) || (newCellH == nil) then
nil
else
let 0 -> l in
(
while l <= grid.grid_iNbLines do
let 0 -> c in
(
while c <= grid.grid_iNbCols do
let gridcell_getStructure grid l c -> cell in
(
set cell.gridc_iPosX1 = (c*newCellW)+((c+1)*grid.grid_iSpacing);
set cell.gridc_iPosY1 = (l*newCellH)+((l+1)*grid.grid_iSpacing);
set cell.gridc_iPosX2 = cell.gridc_iPosX1 + newCellW;
set cell.gridc_iPosY2 = cell.gridc_iPosY1 + newCellH;
_SIZEwindow cell.gridc_oWin newCellW newCellH cell.gridc_iPosX1 cell.gridc_iPosY1;
set c = c+1;
);
set l = l+1;
);
grid
);;
fun gridcell_exchange (grid, l1, c1, l2, c2, keepCurSize)=
let gridcell_getStructure grid l1 c1 -> cell1 in
let gridcell_getStructure grid l2 c2 -> cell2 in
if (cell1 == nil) || (cell2 == nil) then
nil
else
//let cell1 -> cellTmp in
let gridcell_init l1 c1 cell1.gridc_iPosX1 cell1.gridc_iPosY1 cell1.gridc_iPosX2 cell1.gridc_iPosY2 -> cellTmp in
(
set keepCurSize = if keepCurSize == 0 then 0 else 1;
set cellTmp.gridc_iPosInitX1 = cell1.gridc_iPosInitX1;
set cellTmp.gridc_iPosInitY1 = cell1.gridc_iPosInitY1;
set cellTmp.gridc_iPosInitX2 = cell1.gridc_iPosInitX2;
set cellTmp.gridc_iPosInitY2 = cell1.gridc_iPosInitY2;
set cell1.gridc_iLine = cell2.gridc_iLine;
set cell1.gridc_iCol = cell2.gridc_iCol;
//set cell1.gridc_oWin = cell2.gridc_oWin;
//set cell1.gridc_oParent = cell2.gridc_oParent;
set cell1.gridc_iPosX1 = cell2.gridc_iPosX1;
set cell1.gridc_iPosY1 = cell2.gridc_iPosY1;
set cell1.gridc_iPosX2 = cell2.gridc_iPosX2;
set cell1.gridc_iPosY2 = cell2.gridc_iPosY2;
set cell1.gridc_iPosInitX1 = cell2.gridc_iPosInitX1;
set cell1.gridc_iPosInitY1 = cell2.gridc_iPosInitY1;
set cell1.gridc_iPosInitX2 = cell2.gridc_iPosInitX2;
set cell1.gridc_iPosInitY2 = cell2.gridc_iPosInitY2;
//set cell1.gridc_iFlags = cell2.gridc_iFlags;
//set cell1.gridc_isDrag = cell2.gridc_isDrag;
//set cell1.gridc_isDragButton = cell2.gridc_isDragButton;
//set cell1.gridc_cbClick = cell2.gridc_cbClick;
set cell2.gridc_iLine = cellTmp.gridc_iLine;
set cell2.gridc_iCol = cellTmp.gridc_iCol;
//set cell2.gridc_oWin = cellTmp.gridc_oWin;
//set cell2.gridc_oParent = cellTmp.gridc_oParent;
set cell2.gridc_iPosX1 = cellTmp.gridc_iPosX1;
set cell2.gridc_iPosY1 = cellTmp.gridc_iPosY1;
set cell2.gridc_iPosX2 = cellTmp.gridc_iPosX2;
set cell2.gridc_iPosY2 = cellTmp.gridc_iPosY2;
set cell2.gridc_iPosInitX1 = cellTmp.gridc_iPosInitX1;
set cell2.gridc_iPosInitY1 = cellTmp.gridc_iPosInitY1;
set cell2.gridc_iPosInitX2 = cellTmp.gridc_iPosInitX2;
set cell2.gridc_iPosInitY2 = cellTmp.gridc_iPosInitY2;
//set cell2.gridc_iFlags = cellTmp.gridc_iFlags;
//set cell2.gridc_isDrag = cellTmp.gridc_isDrag;
//set cell2.gridc_isDragButton = cellTmp.gridc_isDragButton;
//set cell2.gridc_cbClick = cellTmp.gridc_cbClick;
_SIZEwindow
cell1.gridc_oWin
cell1.gridc_iPosX2-cell1.gridc_iPosX1
cell1.gridc_iPosY2-cell1.gridc_iPosY1
cell1.gridc_iPosX1
cell1.gridc_iPosY1;
_SIZEwindow
cell2.gridc_oWin
cell2.gridc_iPosX2-cell2.gridc_iPosX1
cell2.gridc_iPosY2-cell2.gridc_iPosY1
cell2.gridc_iPosX1
cell2.gridc_iPosY1;
grid
);;
fun gridcell_reset (grid, l, c)=
let gridcell_getStructure grid l c -> cell in
if nil == cell then
nil
else
(
set cell.gridc_iPosX1 = cell.gridc_iPosInitX1;
set cell.gridc_iPosY1 = cell.gridc_iPosInitY1;
set cell.gridc_iPosX2 = cell.gridc_iPosInitX2;
set cell.gridc_iPosY2 = cell.gridc_iPosInitY2;
_SIZEwindow
cell.gridc_oWin
cell.gridc_iPosX2-cell.gridc_iPosX1
cell.gridc_iPosY2-cell.gridc_iPosY1
cell.gridc_iPosX1
cell.gridc_iPosY1;
grid
);;
fun gridcell_getInitPos (grid, l, c)=
let gridcell_getStructure grid l c -> cell in
if nil == cell then
nil
else
[cell.gridc_iPosInitX1 cell.gridc_iPosInitY1 cell.gridc_iPosInitX2 cell.gridc_iPosInitY2];;
fun gridcell_getPos (grid, l, c)=
let gridcell_getStructure grid l c -> cell in
if nil == cell then
nil
else
[cell.gridc_iPosX1 cell.gridc_iPosY1 cell.gridc_iPosX2 cell.gridc_iPosY2];;
fun gridcell_size (grid, l, c, w, h)=
let gridcell_getStructure grid l c -> cell in
if nil == cell then
nil
else
(
set cell.gridc_iPosX2 = w + cell.gridc_iPosX1;
set cell.gridc_iPosY2 = h + cell.gridc_iPosY1;
_SIZEwindow cell.gridc_oWin w h cell.gridc_iPosX1 cell.gridc_iPosY1;
grid
);;
fun gridcell_move (grid, l, c, dx, dy)=
let gridcell_getStructure grid l c -> cell in
if nil == cell then
nil
else
let _GETwindowPositionSize cell.gridc_oWin -> [sx sy _ _] in
(
set cell.gridc_iPosX1 = sx + dx;
set cell.gridc_iPosY1 = sy + dy;
_MVwindow cell.gridc_oWin cell.gridc_iPosX1 cell.gridc_iPosY1;
grid
);;
fun grid_move (grid, x, y)=
//set grid.grid_iPosX1 = x;
//set grid.grid_iPosY1 = y;
let 0 -> l in
let x-grid.grid_iPosX1 -> dx in
let y-grid.grid_iPosY1 -> dy in
while (l <= grid.grid_iNbLines) do
(
let 0 -> c in
while c <= grid.grid_iNbCols do
(
gridcell_move grid l c dx dy;
set c = c+1
);
set l = l+1
);
grid;;
fun grid_setCellDragDrop (grid, l, c, state, mouse)=
if (state != GRID_NODRAGDROP) && (state != GRID_DRAGDROP) then
nil
else
let gridcell_getStructure grid l c -> cell in
if nil == cell then
nil
else
(
set cell.gridc_isDrag = state;
set cell.gridc_isDragButton =
if (mouse == GRID_MOUSELEFT) || (mouse == GRID_MOUSERIGHT) ||
(mouse == GRID_MOUSEMIDDLE) || (mouse == GRID_MOUSEALL) then
mouse
else
GRID_MOUSEALL;
grid
);;
fun grid_removeCell (grid, l, c)=
let gridcell_getStructure grid l c -> cell in
if nil == cell then
nil
else
(
if nil != cell.gridc_oWin then
(
_DSwindow cell.gridc_oWin;
set cell.gridc_oWin = nil
)
else
nil;
set cell.gridc_oParent = nil;
set cell.gridc_iFlags = grid.grid_iFlags;
set cell.gridc_iPosX1 = cell.gridc_iPosInitX1;
set cell.gridc_iPosY1 = cell.gridc_iPosInitY1;
set cell.gridc_iPosX2 = cell.gridc_iPosInitX2;
set cell.gridc_iPosY2 = cell.gridc_iPosInitY2;
grid
);;
fun grid_cellFlag (grid, flags)=
set grid.grid_iFlags = flags;
grid;;
fun grid_cellGetWin (grid, l, c)=
let gridcell_getStructure grid l c -> cell in
if nil == cell then
nil
else
//if cell.gridc_oWin == nil then
// nil
//else
cell.gridc_oWin;;
fun grid_getCell (grid, l, c)=
let grid_cellGetWin grid l c -> win in
if win == nil then
gridcell_create grid l c
else
win;;
fun grid_moveCell (grid, l, c, x, y)=
let gridcell_getStructure grid l c -> cell in
if cell == nil then
nil
else
let cell.gridc_iPosX2-cell.gridc_iPosX1 -> w in
let cell.gridc_iPosY2-cell.gridc_iPosY1 -> h in
(
set cell.gridc_iPosX1 = x;
set cell.gridc_iPosY1 = y;
set cell.gridc_iPosX2 = cell.gridc_iPosX1 + w;
set cell.gridc_iPosY2 = cell.gridc_iPosY1 + h;
_MVwindow cell.gridc_oWin cell.gridc_iPosX1 cell.gridc_iPosY1;
grid
);;
fun grid_setparent (grid, mother)=
set grid.grid_oParent = mother;
grid;;
fun grid_cellSetFlags (grid, l, c, flags)=
let grid_cellGetWin grid l c -> win in
if win == nil then
nil
else
(
set win = _SETwindowStyle win flags;
if win == nil then
nil
else
let gridcell_getStructure grid l c -> cell in
(
set cell.gridc_iFlags = flags;
grid
)
);;
fun gridcell_checkDragMouse (mouse, dragmouse)=
if mouse == 0 then
0
else if (dragmouse == GRID_MOUSEALL) then
1
else if (mouse == LBUTTON) && (dragmouse == GRID_MOUSELEFT) then
1
else if (mouse == RBUTTON) && (dragmouse == GRID_MOUSERIGHT) then
1
else if (mouse == MBUTTON) && (dragmouse == GRID_MOUSEMIDDLE) then
1
else
0;;
fun gridcell_cbClick (win, u, x, y, btn)=
let u -> [grid cell] in
//if (cell.gridc_isDrag == GRID_DRAGDROP) && (btn != 0) then
if (cell.gridc_isDrag == GRID_DRAGDROP) && (gridcell_checkDragMouse btn cell.gridc_isDragButton) then
(
set gridCellDrag = gridcd_init;
set gridCellDrag.gridcd_iInitLine = cell.gridc_iLine;
set gridCellDrag.gridcd_iInitCol = cell.gridc_iCol;
set gridCellDrag.gridcd_iPosX = x;
set gridCellDrag.gridcd_iPosY = y;
exec cell.gridc_cbClick with [win grid x y btn]
)
else
exec cell.gridc_cbClick with [win grid x y btn];
0;;
fun gridcell_cbUnclick (win, u, x, y, btn)=
let u -> [grid cell] in
0;;
fun gridcell_setCB (grid, cell)=
_CBwinClick cell.gridc_oWin @gridcell_cbClick [grid cell];
_CBwinUnclick cell.gridc_oWin @gridcell_cbUnclick [grid cell];
grid;;
fun gridcell_create (grid, nline, ncol)=
let grid.grid_sArray -> cells in
let cells.(nline).ncol -> cell in
let _CRwindow
grid.grid_oChn
grid.grid_oParent
_fooId cell.gridc_iPosX1
_fooId cell.gridc_iPosY1
cell.gridc_iPosX2-cell.gridc_iPosX1
cell.gridc_iPosY2-cell.gridc_iPosY1
grid.grid_iFlags
strcatn (itoa nline) :: " - " :: (itoa ncol) :: nil
-> win in
(
set cell.gridc_oParent = grid.grid_oParent;
set cell.gridc_iFlags = grid.grid_iFlags;
set cell.gridc_oWin = win;
//grid
);;
fun grid_create (chn, wCell, hCell, iSpacing, iLines, iCols)=
if (chn == nil) || (wCell < 1) || (wCell == nil) || (hCell < 1) || (hCell == nil) ||
(iSpacing < 0) || (iSpacing == nil) || (iLines < 1) || (iLines == nil) ||
(iCols < 1) || (iCols == nil) then
nil
else
let 0 -> gx1 in
let 0 -> gy1 in
let gx1+(wCell*iCols) -> gx2 in
let gy1+(hCell*iLines) -> gy2 in
let grid_init iLines iCols -> grid in
let grid.grid_sArray -> table in
let 0 -> l in
let 0 -> c in
(
while l < iLines do
(
set c = 0;
set table.l = grid_initLine iCols;
let ((l+1)*iSpacing)+(l*hCell) -> y1 in
let y1+hCell -> y2 in
let table.l -> line in
while c < iCols do
(
let ((c+1)*iSpacing)+(c*wCell) -> x1 in
let x1+wCell -> x2 in
set line.c = gridcell_init l c x1 y1 x2 y2;
set c = c+1;
);
set l = l+1;
);
set grid.grid_oChn = chn;
set grid.grid_iSpacing = iSpacing;
set grid.grid_iPosX1 = 0;
set grid.grid_iPosY1 = 0;
set grid.grid_iNbLines = iLines-1;
set grid.grid_iNbCols = iCols-1;
grid
);;
/*! \brief Create an empty Grid object.
*
* It allows to create a grid of window object (ObjWin) with a customized
* settings. In fact, each cell can provide a window or keep empty. All
* cells have the same size.
*
* By default, no parent window is set. If needed, use _SETgridParent.
*
* You can change the parent window as you want : thus, on a same grid,
* you put the cells on several levels and keep an homogeneous interface.
*
* By default, the grid is at the position (0,0). Use _MOVEgrid to set it.
*
* \ingroup _2dos_grid
* Prototype : fun [Chn I I I I I] Grid
*
* \param Chn : the channel where the Grid is created
* \param I : the number of lines (> 0)
* \param I : the number of columns (> 0)
* \param I : the cell width (>0)
* \param I : the cell height (>0)
* \param I : the spacing (the space between each cell, >= 0)
*
* \return Grid : The new Grid object or nil if an error occurs
* (null channel or bad settings)
*
* \warning The 4th and 5th parameters : the width and the height of one
* CELL, not of the grid !
*
* \see _SETgridParent
* \see _MOVEgrid
* \see _GETgridCell
**/
fun _CRgridCreate (chn, iLines, iCols, iWidthCell, iHeightCell, iSpacing)=
grid_create chn iWidthCell iHeightCell iSpacing iLines iCols;;
/*! \brief Set the current parent window.
*
* \see _CRgridCreate for more informations about the parent window.
*
* \ingroup _2dos_grid
* Prototype : fun [Grid ObjWin] Grid
*
* \param Grid : a Grid object
* \param ObjWin : a window or nil (no parent window)
*
* \return Grid : The same Grid object or nil if an error occurs
**/
fun _SETgridParent (grid, oParent)=
grid_setparent grid oParent;;
/*! \brief Get the window object cell.
*
* Any 2d object can be added in this window object, as any window object.
*
* If no window is defined for this cell yet, it will be automatically created
* when this function is called.
*
* \see _REMOVEgridCell to remove the window object.
* \see _SETgridFlag to set the creation's flags.
*
* \ingroup _2dos_grid
* Prototype : fun [Grid I I] ObjWin
*
* \param Grid : a Grid object
* \param I : a line (the first line is 0)
* \param I : a column (the first column is 0)
*
* \return ObjWin : The window object or nil if an error occurs
**/
fun _GETgridCell (grid, iLine, iCol)=
grid_getCell grid iLine iCol;;
/*! \brief Move the grid.
*
* \ingroup _2dos_grid
* Prototype : fun [Grid I I] Grid
*
* \param Grid : a Grid object
* \param I : the new x coordinate
* \param I : the new y coordinate
*
* \return Grid : The same Grid object or nil if an error occurs
**/
fun _MOVEgrid (grid, iPosX, iPosY)=
grid_move grid iPosX iPosY;;
/*! \brief Move a cell in a grid.
*
* Even if the window object comes in another line or column, it keeps
* linked to its cell.
*
* Thus, you can do as you want but i don't recommend to move beyond the
* original cell.
*
* \ingroup _2dos_grid
* Prototype : fun [Grid I I I I] Grid
*
* \param Grid : a Grid object
* \param I : a line (the first line is 0)
* \param I : a column (the first column is 0)
* \param I : the new x coordinate
* \param I : the new y coordinate
*
* \return Grid : The same Grid object or nil if an error occurs
* \see _EXCHANGEgridCell to exhange two cells.
**/
fun _MOVEgridCell (grid, iLine, iCol, iPosX, iPosY)=
grid_moveCell grid iLine iCol iPosX iPosY;;
/*! \brief Resize a window cell in a grid.
*
* Even if the window object comes in another line or column, it keeps
* linked to its cell.
*
* It is recommended to perform a resize by this function than
* directly with _'SIZEwindow'.
*
* \ingroup _2dos_grid
* Prototype : fun [Grid I I I I] Grid
*
* \param Grid : a Grid object
* \param I : a line (the first line is 0)
* \param I : a column (the first column is 0)
* \param I : the new width
* \param I : the new height
*
* \return Grid : The same Grid object or nil if an error occurs
* \see _RESETgridCell to reset the size.
**/
fun _SIZEgridCell (grid, iLine, iCol, iWidth, iHeight)=
gridcell_size grid iLine iCol iWidth iHeight;;
/*! \brief Set the flags of cell when they created.
*
* They are the same flags than for the window :
* http://www.scolring.org/files/doc_html/_crwindow.html
*
* All created cell after this call will have these flags. By default,
* WN_NORMAL is used.
*
* This function can be called as often as needed.
*
* \see _GETgridCell to get/create the window object.
* \see _SETgridCellFlag to set the cell flags.
*
* \ingroup _2dos_grid
* Prototype : fun [Grid I] Grid
*
* \param Grid : a Grid object
* \param I : flags
*
* \return Grid : The same Grid object or nil if an error occurs
**/
fun _SETgridFlag (grid, iFlags)=
grid_cellFlag grid iFlags;;
/*! \brief Set the flags for a cell.
*
* They are the same flags than for the window :
* http://www.scolring.org/files/doc_html/_crwindow.html
*
* \warning Like _SETwindowStyle, all combinations can no work (by example,
* WN_NORMAL from the start can not be modified to WN_CHILDINSIDE).
*
* If no window defined in this cell, this function returns also nil.
*
* \see _SETgridCellFlagForce to force some changes.
* \see _GETgridCell to get/create the window object.
* \see _SETgridCellFlag to set the cell flags.
* \see _SETwindowStyle http://www.scolring.org/files/doc_html/_SETwindowStyle.html
* This is the same thing but it is strongly recommended to use _SETgridCellFlag
* instead of _SETwindowStyle.
*
* \ingroup _2dos_grid
* Prototype : fun [Grid I I I] Grid
*
* \param Grid : a Grid object
* \param I : a line (the first line is 0)
* \param I : a column (the first column is 0)
* \param I : flags
*
* \return Grid : The same Grid object or nil if an error occurs
**/
fun _SETgridCellFlag (grid, iLine, iCol, iFlags)=
grid_cellSetFlags grid iLine iCol iFlags;;
/*! \brief Force the flags for a cell.
*
* They are the same flags than for the window :
* http://www.scolring.org/files/doc_html/_crwindow.html
*
* \deprecated This function does nothing now and always returns the same
* given Grid object. Instead of this, use _REMOVEgridCell and _GETgridCell.
*
* \ingroup _2dos_grid
* Prototype : fun [Grid I I I] Grid
*
* \param Grid : a Grid object
* \param I : a line (the first line is 0)
* \param I : a column (the first column is 0)
* \param I : flags
*
* \return Grid : The same Grid object or nil if an error occurs
**/
fun _SETgridCellFlagForce (grid, iLine, iCol, iFlags)=
grid;;
/*! \brief Remove a cell from a grid.
*
* \warning If a window object is present, it will be also destroyed.
* The cell settings are resetted.
*
* \see _GETgridCell to recrate a window object.
*
* \ingroup _2dos_grid
* Prototype : fun [Grid I I] Grid
*
* \param Grid : a Grid object
* \param I : a line (the first line is 0)
* \param I : a column (the first column is 0)
*
* \return Grid : The same Grid object or nil if an error occurs
**/
fun _REMOVEgridCell (grid, iLine, iCol)=
grid_removeCell grid iLine iCol;;
/*! \brief Resize a grid.
*
* The included window objects are also resized.
*
* \ingroup _2dos_grid
* Prototype : fun [Grid I I] Grid
*
* \param Grid : a Grid object
* \param I : a new width (> 0)
* \param I : a new height (> 0)
*
* \return Grid : The same Grid object or nil if an error occurs
**/
fun _SIZEgrid (grid, iWidthCell, iHeightCell)=
grid_size grid iWidthCell iHeightCell;;
/*! \brief Activate or Deacticate the drag & drop in a given cell.
*
* A such drag & drop allows to move a cell to another cell, like
* _EXCHANGEgridCell.
*
* \ingroup _2dos_grid
* Prototype : fun [Grid I I I I] Grid
*
* \param Grid : a Grid object
* \param I : a line (the first line is 0)
* \param I : a column (the first column is 0)
* \param I : the state : GRID_DRAGDROP to activate it, GRID_NODRAGDROP
* (default) to deactivate it. Another value is incorrect.
* \param I : the mouse button : it is one of these following values :
* - GRID_MOUSELEFT : left button
* - GRID_MOUSERIGHT : right button
* - GRID_MOUSEMIDDLE : middle button
* - GRID_MOUSEALL : all buttons
* - other values : GRID_MOUSEALL
*
* \return Grid : The same Grid object or nil if an error occurs
* \todo To do ...!!
**/
fun _SETgridCellDragDrop (grid, iLine, iCol, iState, iMouse)=
grid_setCellDragDrop grid iLine iCol iState iMouse;;
/*! \brief Exchange two cells.
*
* Exactly, only the two windows are exchanged.
*
* \ingroup _2dos_grid
* Prototype : fun [Grid I I I I I] Grid
*
* \param Grid : a Grid object
* \param I : the number line of the first cell (the first line is 0)
* \param I : the number column of the first cell (the first column is 0)
* \param I : the number line of the second cell (the first line is 0)
* \param I : the number column of the second cell (the first column is 0)
* \param I : 1 to keep the current size (by default) else 0
*
* \return Grid : The same Grid object or nil if an error occurs
* \todo write the resize part !
**/
fun _EXCHANGEgridCell (grid, iLineSrc, iColSrc, iLineDest, iColDest, iKeepCurSize)=
gridcell_exchange grid iLineSrc iColSrc iLineDest iColDest iKeepCurSize;;
/*! \brief Reset the position and the size of a cell.
*
* Position and size are those defined at the beginning (when the cell
* has been created).
*
* \ingroup _2dos_grid
* Prototype : fun [Grid I I] Grid
*
* \param Grid : a Grid object
* \param I : the number line of the cell (the first line is 0)
* \param I : the number column of the cell (the first column is 0)
*
* \return Grid : The same Grid object or nil if an error occurs
**/
fun _RESETgridCell (grid, iLine, iCol)=
gridcell_reset grid iLine iCol;;
/*! \brief Return the initial positions of a cell.
*
* \ingroup _2dos_grid
* Prototype : fun [Grid I I] [I I I I]
*
* \param Grid : a Grid object
* \param I : the number line of the cell (the first line is 0)
* \param I : the number column of the cell (the first column is 0)
*
* \return [I I I I] : the top left corner initial coordinates and the bottom right corner initial coordinates or nil if an error occurs
**/
fun _GETgridCellInitPos (grid, iLine, iCol)=
gridcell_getInitPos grid iLine iCol;;
/*! \brief Return the current positions of a cell.
*
* These positions are also those of the window object only if the motion
* or the resize has been invoked by this API. Else, they are the last
* known positions by this API.
*
* \see _MOVEgridCell
* \see _SIZEgridCell
*
* \ingroup _2dos_grid
* Prototype : fun [Grid I I] [I I I I]
*
* \param Grid : a Grid object
* \param I : the number line of the cell (the first line is 0)
* \param I : the number column of the cell (the first column is 0)
*
* \return [I I I I] : the top left corner coordinates and the bottom right corner coordinates or nil if an error occurs
**/
fun _GETgridCellPos (grid, iLine, iCol)=
gridcell_getPos grid iLine iCol;;