QG_SetCellPicture

QG_SetCellPicture(areaRef; pictExpression; rectLeft; rectTop; rectRight; rectBottom; displayFormat):errorCode
areaRef Longint QGrid area reference
pictExpression Text Expression returning picture
rectLeft Longint Left coordinate
rectTop Longint Top coordinate
rectRight Longint Right coordinate
rectBottom Longint Bottom coordinate
displayFormat Longint Picture format number
error Longint Error result

Set the picture object of area cells

Parameter areaRef is the QGrid area reference. If areaRef is not a valid QGrid area reference, qg_paramErr error is returned.

Parameter pictExpression specifies a 4D picture expression to be used for populating the picture object of each cell. QGrid calls this expression every time it needs to draw a cell's picture. Before calling the expression it sets the global variable gQGCurrentCell to the cell index it needs to display. This variable can then be used within the expression.

Parameters rectLeft, rectTop, rectRight and rectBottom specify the picture box coordinates in the cell's coordinate system. Picture box coordinates can fall outside the cell bounds and even have negative values. In these cases only the visible part of the picture object is drawn on the cell. If the passed coordinate values do not form a rectangle, error qg_paramErr is returned.

Long parameter displayFormat specifies the picture display format. QGrid defines the following constants:

qg_PictTruncCentered 1 Same as 4D's Truncated Centered (default)
qg_PictScaledToFit 2 Same as 4D's Scaled To Fit
qg_PictTruncNonCenter 4 Same as 4D's Truncated non Centered
qg_PictScaledToFitProp 5 Same as 4D's Scaled to fit proportional
qg_PictScaledToFitPropCenter 6 Same as 4D's Scaled to fit prop centered
qg_PictXScaledToFitProp 8 Same as 4D's Scaled to fit proportional, but scales up as well
qg_PictXScaledToFitPropCenter 9 Same as 4D's Scaled to fit prop centered, but scales up as well

NOTE To remove a picture object from the current cell definition, call QG_SetCellPicture with an empty pictExpression. The rest of the parameters are then ignored and can be omitted.

Examples

   // Set-up the cell picture for plug-in area xGrid.

C_TEXT($expression)
$expression:="DB_GetGridPicture(gQGCurrentCell)"

C_LONGINT($err;$pictLeft;$pictTop;$pictRight;$pictBottom;$display)
$pictLeft:=2
$pictTop:=2
$pictRight:=98
$pictBottom:=108

$display:=qg_PictXScaledToFitPropCenter

$err:=QG_SetCellPicture (xGrid;$expression;$pictLeft;$pictTop;$pictRight;$pictBottom;$display)
ASSERT($err=qg_noErr)
   // Method DB_GetGridPicture(cell index): cell picture
   // Simple routine used in the picture expression .

C_LONGINT($1)// Cell index
C_PICTURE($0)// Result picture

GOTO SELECTED RECORD([Photos];$1)

$0:=[Photos]Image

Related commands

QG_GetCellPicture Get the picture object properties
QG_SetCellCaption Set the caption object for area cells