Recent

Author Topic: [SOLVED] VTV: can't make multiline text  (Read 2737 times)

zoltanleo

  • Hero Member
  • *****
  • Posts: 509
[SOLVED] VTV: can't make multiline text
« on: August 13, 2015, 02:10:15 pm »
VTV 4.8.7

I need help. I can't draw multiple lines of text in the cell means component. Here is the code:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3. RootNode, ChildNode: PVirtualNode;
  4. I: Integer;
  5. Data: PVSTRecord;
  6. begin
  7.   RootNode := VST.AddChild(VST.RootNode);
  8.   if not (vsInitialized in RootNode^.States) then
  9.      VST.ReinitNode(RootNode, False);
  10.   Data := VST.GetNodeData(RootNode);
  11.   Data^.ElementName := 'Rood Node with long, long, long, long, long, long, long, long, long, long, long, long, long, long string';
  12.   Data^.ElementNumber := 0;
  13.  
  14.   for I := 1 to 10 do
  15.     begin
  16.        ChildNode := VST.AddChild(RootNode);
  17.        if not (vsInitialized in ChildNode^.States) then
  18.          VST.ReinitNode(ChildNode, False);
  19.  
  20.        Data := VST.GetNodeData(ChildNode);
  21.        Data^.ElementName := 'Child Node with long, long, long, long, long, long, long, long, long, long, long, long, long, long string';
  22.        Data^.ElementNumber := I;
  23.     end;
  24. end;


Code: Pascal  [Select][+][-]
  1. procedure TForm1.VSTInitNode(Sender: TBaseVirtualTree; ParentNode,
  2.   Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates);
  3. begin
  4.   Include(InitialStates, ivsMultiline);
  5. end;    
           

Code: Pascal  [Select][+][-]
  1. procedure TForm1.VSTMeasureItem(Sender: TBaseVirtualTree;
  2.   TargetCanvas: TCanvas; Node: PVirtualNode; var NodeHeight: Integer);
  3. begin
  4.   if Sender.MultiLine[Node] then
  5. begin
  6.    TargetCanvas.Font := Sender.Font;
  7.    NodeHeight := VST.ComputeNodeHeight(TargetCanvas, Node, 0) + 18;
  8. end;
  9. end;  
             

What I did wrong?  :(

           
« Last Edit: June 07, 2017, 09:09:08 am by zoltanleo »
Win10 LTSC x64/Deb 12 amd64(gtk2)/Kubuntu(qt5)/Darwin Cocoa x86_64 (Sequoia):
Lazarus x32_64 (trunk); FPC(trunk), FireBird 3.0.11; IBX by TonyW

Sorry for my bad English, I'm using translator ;)

wp

  • Hero Member
  • *****
  • Posts: 12911
Re: VTV: can't make multiline text
« Reply #1 on: August 13, 2015, 02:35:21 pm »
Did you look at "multilinedemo.pas"which is called from the Advanced.lpi demo app in the "demos" folder? This shows multi-line text.

zoltanleo

  • Hero Member
  • *****
  • Posts: 509
Re: VTV: can't make multiline text
« Reply #2 on: August 13, 2015, 03:39:29 pm »
Thanks for the thought. Once again I carefully scanned the code in demos. Here explicitly specifies the height of the node.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.VSTInitNode(Sender: TBaseVirtualTree; ParentNode,
  2.   Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates);
  3. begin
  4.   VST.NodeHeight[Node] := 50;//Here it is necessary to specify the height of node
  5.   Include(InitialStates, ivsMultiline);
  6. end;
  7.  
If you make the height is not large enough, you can get a lot of rows, but the text will still be clipped. But in general the problem is solved.
« Last Edit: June 07, 2017, 09:08:00 am by zoltanleo »
Win10 LTSC x64/Deb 12 amd64(gtk2)/Kubuntu(qt5)/Darwin Cocoa x86_64 (Sequoia):
Lazarus x32_64 (trunk); FPC(trunk), FireBird 3.0.11; IBX by TonyW

Sorry for my bad English, I'm using translator ;)

LuizAmérico

  • Sr. Member
  • ****
  • Posts: 457
Re: [SOLVED] VTV: can't make multiline text
« Reply #3 on: August 13, 2015, 07:43:49 pm »

 

TinyPortal © 2005-2018