4D Write Pro (Question for Roland Lannuzel)

How do I calculate the entire horizontal width of a Write Pro table, from its left side to its right side?

From the https://doc.4d.com/4Dv17R6/4D/17-R6/4D-Write-Pro-Attributes.300-4433872.en.html#3936731documentation on margins>, I see:

I am getting the widths and padding with https://doc.4d.com/4Dv17R6/4D/17-R6/WP-GET-ATTRIBUTES.301-4433881.en.htmlWP GET ATTRIBUTES> using these constants:

  1. wk border width left
  2. wk padding left
  3. wk width (for content width)
  4. wk padding right
  5. wk border width right

All of the cell margins appear to be zero.

I notice that if I change a cell’s border style to “wk none”, the border disappears.

But WP GET ATTRIBUTES still returns a non-zero width. I expected the hidden border’s width would be zero.

QUESTION

So how do I obtain the displayed width of a table, where some of the table’s cells have vertical borders and other are without vertical borders?

Hello,

First of all, please stop considering I am the only one able to answer questions about 4D Write Pro.
I’m quite sure many guys on the forum could answer too, so do not discourage them to answer your question by naming me in the title.

(and believe it or not, sometimes i’m on vacation too :slight_smile:


To know the width and height of a table, you have to consider many things.

  • Each cell might have distinct settings so you have to loop in each cell.
  • A cell has two padding values (left and right) but has no margins
  • The borders overlap so if you have N cells in a row, you have N-1 border widths
  • By default a table has NO borders (only cells have) but if you create a border on the table, again the biggest wins.

In the example below

  • Table has thicker borders than cells so they will be taken into account (2*4mm) = 8mm
  • Table also has margins (2*10mm) = 20mm
  • Cells have left and right padding (4 cells * 2 * 3mm) = 24mm
  • Cells have 2mm borders ((4-1)cells * 2mm) = 6mm
  • Each cell is 25m (4x25mm) = 100mm

[]33261999;“Your comment here…”[/]


OK, now the easy answer…:slight_smile:

<code 4D>
// Get the table
$table:=WP Get element by ID(WParea;“t1”)

// Chose the unit
WP SET ATTRIBUTES(WParea;wk layout unit;wk unit mm)

// Get position
$o:=WP Get position($table;wk 4D Write Pro layout)

// Calculate size
$tableWidth:=$o.bounds.right-$o.bounds.left
$tableHeight:=$o.bounds.bottom-$o.bounds.top
ALERT(String($tableWidth)+" mm X “+String($tableHeight)+” mm")

</code 4D>

Regards,

Roland Lannuzel