Recent

Author Topic: How to make thinner lines of the table?  (Read 2135 times)

izumsasha

  • Newbie
  • Posts: 3
How to make thinner lines of the table?
« on: November 26, 2018, 07:17:09 am »
Hello!
Please tell me - is it possible to set the thickness of the lines of the table?
Thank!

wp

  • Hero Member
  • *****
  • Posts: 6007
Re: How to make thinner lines of the table?
« Reply #1 on: November 26, 2018, 09:32:32 am »
Please provide more information. fpvectorial supports many formats, and it is not clear which one you are using. Ideally you should post a compilable sample project which shows the issue (put .pas, .lfm, .lpr and .lpi files into a common .zip which you can upload here under "Attchments and other options"; don't add binaries and other compiler-generated files).
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

izumsasha

  • Newbie
  • Posts: 3
Re: How to make thinner lines of the table?
« Reply #2 on: November 26, 2018, 09:51:25 am »
Please provide more information. fpvectorial supports many formats, and it is not clear which one you are using. Ideally you should post a compilable sample project which shows the issue (put .pas, .lfm, .lpr and .lpi files into a common .zip which you can upload here under "Attchments and other options"; don't add binaries and other compiler-generated files).

I just took your example on creating a simple table and saving a document (http://wiki.freepascal.org/fpvectorial_-_Text_Document_Support). Also an example procedure in an application.

wp

  • Hero Member
  • *****
  • Posts: 6007
Re: How to make thinner lines of the table?
« Reply #3 on: November 26, 2018, 11:48:51 am »
Strange, this example does not compile for me. I had to modify setting of the col widths and some other places.

Anyway, after studying the source code I found that each cell has a field "Borders" which, in turn, contains elements "Left", "Right", "Top" and "Bottom"; and these have an element "Width" for the border width in millimeters. Unfortunately this is initialized with the value 1 mm which seems to be too large, in my eyes - 0.1 mm would be better.

You can do this: Whenever you create a cell call the following procedure: it changes the border widths to 0.1 mm and sets the LineType of the border to tbtSingle (this is necessary because borders with the standard line type, tbtDefault, are not written to the file).

Code: Pascal  [Select]
  1. procedure DefaultBorder(var ABorder: TvTableBorder);
  2. begin
  3.   ABorder.Width := 0.1;
  4.   ABorder.LineType := tbtSingle;
  5. end;
  6.  
  7. procedure DefaultCell(ACell: TvTableCell);
  8. begin
  9.   DefaultBorder(ACell.Borders.Left);
  10.   DefaultBorder(ACell.Borders.Right);
  11.   DefaultBorder(ACell.Borders.Top);
  12.   DefaultBorder(ACell.Borders.Bottom);
  13. end;
  14. ...
  15.       for iCol := 0 to 4 do
  16.       begin
  17.         Cell := Row.AddCell;
  18.         DefaultCell(Cell);     // <---- NEW
« Last Edit: November 26, 2018, 11:58:18 am by wp »
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

izumsasha

  • Newbie
  • Posts: 3
Re: How to make thinner lines of the table?
« Reply #4 on: November 26, 2018, 11:57:40 am »
Code: Pascal  [Select]
  1. procedure DefaultBorder(var ABorder: TvTableBorder);
  2. begin
  3.   ABorder.Width := 0.1;
  4.   ABorder.LineType := tbtSingle;
  5. end;
  6.  
  7. procedure DefaultCell(ACell: TvTableCell);
  8. begin
  9.   DefaultBorder(ACell.Borders.Left);
  10.   DefaultBorder(ACell.Borders.Right);
  11.   DefaultBorder(ACell.Borders.Top);
  12.   DefaultBorder(ACell.Borders.Bottom);
  13. end;
  14. ...
  15.       for iCol := 0 to 4 do
  16.       begin
  17.         Cell := Row.AddCell;
  18.         DefaultCell(Cell);     // <---- NEW

Works!
Lazarus forever!

wp

  • Hero Member
  • *****
  • Posts: 6007
Re: How to make thinner lines of the table?
« Reply #5 on: November 26, 2018, 12:22:25 pm »
I modified the sources of fpvectorial, the default value of cell border widths is now 0.5 pt. The fix will be contained in the upcoming version 2.0.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10