Project

General

Profile

Scol standard library package  0.3.1
Common and usefull functions for all Scol applications

Classes

struct  Grid
 Opaque internal structure. You should not call it directly, use API instead ! More...

Functions

 _CRgridCreate (chn, iLines, iCols, iWidthCell, iHeightCell, iSpacing)
 Create an empty Grid object.
 _EXCHANGEgridCell (grid, iLineSrc, iColSrc, iLineDest, iColDest, iKeepCurSize)
 Exchange two cells.
 _GETgridCell (grid, iLine, iCol)
 Get the window object cell.
 _GETgridCellInitPos (grid, iLine, iCol)
 Return the initial positions of a cell.
 _GETgridCellPos (grid, iLine, iCol)
 Return the current positions of a cell.
 _MOVEgrid (grid, iPosX, iPosY)
 Move the grid.
 _MOVEgridCell (grid, iLine, iCol, iPosX, iPosY)
 Move a cell in a grid.
 _REMOVEgridCell (grid, iLine, iCol)
 Remove a cell from a grid.
 _RESETgridCell (grid, iLine, iCol)
 Reset the position and the size of a cell.
 _SETgridCellDragDrop (grid, iLine, iCol, iState, iMouse)
 Activate or Deacticate the drag & drop in a given cell.
 _SETgridCellFlag (grid, iLine, iCol, iFlags)
 Set the flags for a cell.
 _SETgridCellFlagForce (grid, iLine, iCol, iFlags)
 Force the flags for a cell.
 _SETgridFlag (grid, iFlags)
 Set the flags of cell when they created.
 _SETgridParent (grid, oParent)
 Set the current parent window.
 _SIZEgrid (grid, iWidthCell, iHeightCell)
 Resize a grid.
 _SIZEgridCell (grid, iLine, iCol, iWidth, iHeight)
 Resize a window cell in a grid.

Detailed Description

A Grid is a table of window objects which can be freely set

Package to load : lib/2dos/grid.pkg

grid.png

Function Documentation

_CRgridCreate ( chn  ,
iLines  ,
iCols  ,
iWidthCell  ,
iHeightCell  ,
iSpacing   
)

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.

Prototype : fun [Chn I I I I I] Grid

Parameters
Chn: the channel where the Grid is created
I: the number of lines (> 0)
I: the number of columns (> 0)
I: the cell width (>0)
I: the cell height (>0)
I: the spacing (the space between each cell, >= 0)
Returns
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 Also
_SETgridParent
_MOVEgrid
_GETgridCell
_SETgridParent ( grid  ,
oParent   
)

Set the current parent window.

See Also
_CRgridCreate for more informations about the parent window.

Prototype : fun [Grid ObjWin] Grid

Parameters
Grid: a Grid object
ObjWin: a window or nil (no parent window)
Returns
Grid : The same Grid object or nil if an error occurs
_GETgridCell ( grid  ,
iLine  ,
iCol   
)

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 Also
_REMOVEgridCell to remove the window object.
_SETgridFlag to set the creation's flags.

Prototype : fun [Grid I I] ObjWin

Parameters
Grid: a Grid object
I: a line (the first line is 0)
I: a column (the first column is 0)
Returns
ObjWin : The window object or nil if an error occurs
_MOVEgrid ( grid  ,
iPosX  ,
iPosY   
)

Move the grid.

Prototype : fun [Grid I I] Grid

Parameters
Grid: a Grid object
I: the new x coordinate
I: the new y coordinate
Returns
Grid : The same Grid object or nil if an error occurs
_MOVEgridCell ( grid  ,
iLine  ,
iCol  ,
iPosX  ,
iPosY   
)

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.

Prototype : fun [Grid I I I I] Grid

Parameters
Grid: a Grid object
I: a line (the first line is 0)
I: a column (the first column is 0)
I: the new x coordinate
I: the new y coordinate
Returns
Grid : The same Grid object or nil if an error occurs
See Also
_EXCHANGEgridCell to exhange two cells.
_SIZEgridCell ( grid  ,
iLine  ,
iCol  ,
iWidth  ,
iHeight   
)

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'.

Prototype : fun [Grid I I I I] Grid

Parameters
Grid: a Grid object
I: a line (the first line is 0)
I: a column (the first column is 0)
I: the new width
I: the new height
Returns
Grid : The same Grid object or nil if an error occurs
See Also
_RESETgridCell to reset the size.
_SETgridFlag ( grid  ,
iFlags   
)

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 Also
_GETgridCell to get/create the window object.
_SETgridCellFlag to set the cell flags.

Prototype : fun [Grid I] Grid

Parameters
Grid: a Grid object
I: flags
Returns
Grid : The same Grid object or nil if an error occurs
_SETgridCellFlag ( grid  ,
iLine  ,
iCol  ,
iFlags   
)

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 Also
_SETgridCellFlagForce to force some changes.
_GETgridCell to get/create the window object.
_SETgridCellFlag to set the cell flags.
_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.

Prototype : fun [Grid I I I] Grid

Parameters
Grid: a Grid object
I: a line (the first line is 0)
I: a column (the first column is 0)
I: flags
Returns
Grid : The same Grid object or nil if an error occurs
_SETgridCellFlagForce ( grid  ,
iLine  ,
iCol  ,
iFlags   
)

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.

Prototype : fun [Grid I I I] Grid

Parameters
Grid: a Grid object
I: a line (the first line is 0)
I: a column (the first column is 0)
I: flags
Returns
Grid : The same Grid object or nil if an error occurs
_REMOVEgridCell ( grid  ,
iLine  ,
iCol   
)

Remove a cell from a grid.

Warning
If a window object is present, it will be also destroyed. The cell settings are resetted.
See Also
_GETgridCell to recrate a window object.

Prototype : fun [Grid I I] Grid

Parameters
Grid: a Grid object
I: a line (the first line is 0)
I: a column (the first column is 0)
Returns
Grid : The same Grid object or nil if an error occurs
_SIZEgrid ( grid  ,
iWidthCell  ,
iHeightCell   
)

Resize a grid.

The included window objects are also resized.

Prototype : fun [Grid I I] Grid

Parameters
Grid: a Grid object
I: a new width (> 0)
I: a new height (> 0)
Returns
Grid : The same Grid object or nil if an error occurs
_SETgridCellDragDrop ( grid  ,
iLine  ,
iCol  ,
iState  ,
iMouse   
)

Activate or Deacticate the drag & drop in a given cell.

A such drag & drop allows to move a cell to another cell, like _EXCHANGEgridCell.

Prototype : fun [Grid I I I I] Grid

Parameters
Grid: a Grid object
I: a line (the first line is 0)
I: a column (the first column is 0)
I: the state : GRID_DRAGDROP to activate it, GRID_NODRAGDROP (default) to deactivate it. Another value is incorrect.
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
Returns
Grid : The same Grid object or nil if an error occurs
Todo:
To do ...!!
_EXCHANGEgridCell ( grid  ,
iLineSrc  ,
iColSrc  ,
iLineDest  ,
iColDest  ,
iKeepCurSize   
)

Exchange two cells.

Exactly, only the two windows are exchanged.

Prototype : fun [Grid I I I I I] Grid

Parameters
Grid: a Grid object
I: the number line of the first cell (the first line is 0)
I: the number column of the first cell (the first column is 0)
I: the number line of the second cell (the first line is 0)
I: the number column of the second cell (the first column is 0)
I: 1 to keep the current size (by default) else 0
Returns
Grid : The same Grid object or nil if an error occurs
Todo:
write the resize part !
_RESETgridCell ( grid  ,
iLine  ,
iCol   
)

Reset the position and the size of a cell.

Position and size are those defined at the beginning (when the cell has been created).

Prototype : fun [Grid I I] Grid

Parameters
Grid: a Grid object
I: the number line of the cell (the first line is 0)
I: the number column of the cell (the first column is 0)
Returns
Grid : The same Grid object or nil if an error occurs
_GETgridCellInitPos ( grid  ,
iLine  ,
iCol   
)

Return the initial positions of a cell.

Prototype : fun [Grid I I] [I I I I]

Parameters
Grid: a Grid object
I: the number line of the cell (the first line is 0)
I: the number column of the cell (the first column is 0)
Returns
[I I I I] : the top left corner initial coordinates and the bottom right corner initial coordinates or nil if an error occurs
_GETgridCellPos ( grid  ,
iLine  ,
iCol   
)

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 Also
_MOVEgridCell
_SIZEgridCell

Prototype : fun [Grid I I] [I I I I]

Parameters
Grid: a Grid object
I: the number line of the cell (the first line is 0)
I: the number column of the cell (the first column is 0)
Returns
[I I I I] : the top left corner coordinates and the bottom right corner coordinates or nil if an error occurs