ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Blocks with dynamic width
Posted by Medic89 on Oct-12-2022 00:21
Attachments:
Hello Peter,

I'm trying to fit some text into a Textbox. The text contains of three blocks, where Block 1 has a fix width. The width of Block 2 and 3 is constant at 1000 pixels, however, Block 2 has a dynamic width. Is it possible to align all those blocks together, and setting a dynamic width for block 3, so the whole space of the line is used? Im also struggling to align all three blocks at the top line, as shown in my screenshot below.
Screenshot 2022-10-11 181900.png

  Re: Blocks with dynamic width
Posted by Peter Kwan on Oct-12-2022 05:08
Hi Medic89,

You can use CDMLTable to implement your table:

https://www.advsofteng.com/doc/cdcpp.htm#BaseChart.addTable.htm

The steps are:

(a) Add all contents to the table.

(b) Call CDMLTable.layout, then call CDMLTable.getColWidth(1) to determine the width of the second column as determined by ChartDirector. You can then compute the width of the last column.

(c) Use t.getColStyle(N).setWidth(XXX) to set the widths of the first and last columns. Then call CDMLTable.layout again to update the layout.

Hope this can help.

Regards
Peter Kwan

  Re: Blocks with dynamic width
Posted by Medic89 on Oct-12-2022 19:57
Hello Peter,

thanks for your approach, but unfortunately, the content of the second column has different widths, so row 1 can be longer than row 2, so each line has to be different. As I understand with the CDMLtable, I can only adjust the whole column like in an excel sheet. Thats why I wanted to use the block feature.

  Re: Blocks with dynamic width
Posted by Peter Kwan on Oct-12-2022 21:50
Hi Medic89,

Sorry for my misunderstanding. My current understanding is that the table width is fixed (since the first column has fixed width, and the sum of the second and third column is fixed at 1000). However, the width of the second column can be different depending on the row.

I can think of two methods:

(a) Treat each row as a separate table of 3 columns x 1 row. You can use the method is by previous message to create that table, and you can use multiple tables to create multiple rows.

(b) Measure the width of the content in the second column. If its width is known, we can combine the 2nd and 3rd column into one column using:

(Note: The following should be in one line)

<*block,bgcolor=EEEEEE,width=111*>2nd column here<*/*><*block,bgcolor=FFFFCC,width=899*>3rd column here<*/*>

So the whole table can be implemented as a table with 2 columns.

For measuring the width of some text, it can be done by using a TextBox object. See:

https://www.chartdir.com/forum/download_thread.php?bn=chartdir_support&thread=1484148023#N1484153975

Best Regards
Peter Kwan

  Re: Blocks with dynamic width
Posted by Medic89 on Oct-13-2022 00:44
Hello Peter,

I did some 'crafting', I put the content of Column 2 in a fake TextBox and then I subtract its width from the total length of Column 2 and 3 and so I get the actual length of Column 3.