This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
||||||||||||||||||||||||
|
4D v19
Handling pictures
|
Property (constant) | Standard action |
wk anchor layout | anchorLayout |
wk anchor horizontal offset | |
wk anchor horizontal align | anchorHorizontalAlign |
wk anchor vertical offset | |
wk anchor vertical align | anchorVerticalAlign |
wk anchor origin | anchorOrigin |
wk anchor page | anchorPage |
wk anchor section | anchorSection |
moveToBack | |
moveToFront |
All anchored pictures are displayed in the Page view mode only. They're not displayed if:
You can insert 4D expressions that return pictures in your 4D Write Pro areas. Expressions can be variables, fields, project methods, object attributes or collection elements.
You can see an expression's reference in the picture tip(*):
(*)As there is no text associated with an anchored image, its expression reference cannot be displayed.
All image attributes can be applied to picture expressions (wk image and wk image url attributes can only be read). Note however, that since pictures have specific attributes, 4D Write Pro must evaluate the expression at least once to detect that its result is a picture and handle it as a picture expression. It means that when a picture expression is inserted with WP INSERT FORMULA, WP COMPUTE FORMULAS must be called before setting any picture attributes.
If the image resulting from the expression could not be computed or loaded, 4D Write Pro displays the default black frame image:
Note: As with other expressions, picture expressions are also impacted by the WP COMPUTE FORMULAS and WP FREEZE FORMULAS commands.
Anchored picture expressions are added with the WP Add picture command (without the second parameter), followed by a call to the WP SET ATTRIBUTES command with the wk image formula selector.
Example:
obImage:=WP Add picture(myDoc)
WP SET ATTRIBUTES(obImage;wk image formula;Formula(m_buildPict))
You can also insert picture expressions using WP SET ATTRIBUTES and wk image formula on existing anchored pictures.
Compatibility Note: wk image expression can still be used to define picture expressions through text. However, it is recommended to use wk image formula and objects.
Calling the WP RESET ATTRIBUTES command with wk image formula is similar to calling WP FREEZE FORMULAS (on the entire document) in that the expression is cleared from the image attribute. However WP FREEZE FORMULAS computes the expression before clearing, whereas WP RESET ATTRIBUTES does not. If an expression has never been computed, the default black frame image will be displayed.
Inline picture expressions are added with the WP INSERT FORMULA command.
Examples:
//Insert a picture variable
WP INSERT FORMULA(wpRange;Formula($vpict);wk prepend)
//Insert a field
WP INSERT FORMULA(wpRange;Formula([DOC]SamplePict);wk prepend)
//Insert a 4D method
WP INSERT FORMULA(wpRange;Formula(M_ComputeChart);wk prepend)
All pictures have properties (attributes) such as height, width, borders, etc., that can be get or set via the 4D Write Pro language (WP GET ATTRIBUTES and WP SET ATTRIBUTES) or standard actions.
You can work with picture references (picture variables, fields, expressions) or picture URLs (text representing a local or network address of the picture).
Two sets of attributes allow you to define if you want to set or get picture reference or a picture URL:
Example:
$range:=WP Get selection(WPArea) //get the picture selected by user
$range:=WP Picture range($range) //create a range
$url:="http://doc.4d.com/image/logo/poweredby4D_web.png"
WP SET ATTRIBUTES($range;wk image;$url) //set an image reference from a URL
//get the image
C_PICTURE(vPictureGet)
WP GET ATTRIBUTES($range;wk image;vPictureGet) //vPictureGet contains an image
C_TEXT(vPictureURLGet)
WP GET ATTRIBUTES($range;wk image url;vPictureURLGet) //vPictureURLGet=$url
The following commands can be used to return pictures:
You can remove inline and anchored pictures with:
Pictures can be manipulated via the mouse or the keyboard. Available actions include:
Product: 4D
Theme: Handling pictures
Modified: 4D v16 R6
Modified: 4D v18 R2
4D Write Pro Reference ( 4D v19)