* * *

Author Topic: VirtualTreeView shows Kanji characters half dissapeared on Ubuntu  (Read 718 times)

GetMem

  • Hero Member
  • *****
  • Posts: 2750
Re: VirtualTreeView shows Kanji characters half dissapeared on Ubuntu
« Reply #15 on: February 10, 2018, 09:18:42 pm »
Quote
I thought "That's it" But it did not affect...
I set DefaultNodeHeight to default this time. See the lines with Kanji are lower than other?
This is really hard  :). When you have a Kanji text and you're under linux, do something like this:
Code: Pascal  [Select]
  1. procedure TForm1.VirtualStringTree1PaintText(Sender: TBaseVirtualTree;
  2.   const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
  3.   TextType: TVSTTextType);
  4. var
  5.   Data: PNodeData;
  6.   R: TRect;
  7. begin
  8.   if TextType = ttNormal then
  9.   begin
  10.     Data := VirtualStringTree1.GetNodeData(Node);
  11.     SetBKMode(TargetCanvas.Handle, TRANSPARENT);
  12.     TargetCanvas.Font.Name := 'Sans Serif';
  13.     TargetCanvas.Font.Size := 12;
  14.     R := TBaseVirtualTree(Sender).GetDisplayRect(Node, Column, False);
  15.     {$IFDEF LclGtk2},
  16.     Dec(R.Top, 2); //only on linux and with Kanji
  17.     {$ENDIF};
  18.     DrawText(Canvas.Handle, PChar(Data^.Column0), Length(Data^.Column0), R, DT_LEFT or DT_VCENTER or DT_SINGLELINE);
  19.   end;
  20. end;
« Last Edit: February 10, 2018, 09:20:47 pm by GetMem »

torumyax

  • New member
  • *
  • Posts: 22
Re: VirtualTreeView shows Kanji characters half dissapeared on Ubuntu
« Reply #16 on: February 10, 2018, 09:27:16 pm »
No luck..
(BTW, I removed , after the compiler directive)


GetMem

  • Hero Member
  • *****
  • Posts: 2750
Re: VirtualTreeView shows Kanji characters half dissapeared on Ubuntu
« Reply #17 on: February 10, 2018, 09:30:07 pm »
Not R.Left, you need R.Top(I edited my post in the mean time), sorry for the confusion.
Code: Pascal  [Select]
  1.  
  2. //..
  3.  {$IFDEF LclGtk2},
  4.  Dec(R.Top, 2); //only on linux and with Kanji
  5.  {$ENDIF};
  6. //..

PS: But you need to detect somehow between Kanji and other text type.
« Last Edit: February 10, 2018, 09:32:04 pm by GetMem »

torumyax

  • New member
  • *
  • Posts: 22
Re: VirtualTreeView shows Kanji characters half dissapeared on Ubuntu
« Reply #18 on: February 10, 2018, 09:34:31 pm »
Oh, I got it.
But, it did not change. Even if I changed it to 
Dec(R.Top, 4);
or Dec(R.Top, 8);

GetMem

  • Hero Member
  • *****
  • Posts: 2750
Re: VirtualTreeView shows Kanji characters half dissapeared on Ubuntu
« Reply #19 on: February 10, 2018, 09:42:04 pm »
OMG torumyax. We did not see the mistake, it was a typo. Instead of:
Quote
DrawText(Canvas.Handle, PChar(Data^.Column0), Length(Data^.Column0), R, DT_LEFT or DT_VCENTER or DT_SINGLELINE);
we need:
Quote
DrawText(TargetCanvas.Handle, PChar(Data^.Column0), Length(Data^.Column0), R, DT_LEFT or DT_VCENTER or DT_SINGLELINE);

DT_VCENTER should work fine.

torumyax

  • New member
  • *
  • Posts: 22
Re: VirtualTreeView shows Kanji characters half dissapeared on Ubuntu
« Reply #20 on: February 10, 2018, 09:51:16 pm »
Aha. it happens. :D

Now something is happening.

GetMem

  • Hero Member
  • *****
  • Posts: 2750
Re: VirtualTreeView shows Kanji characters half dissapeared on Ubuntu
« Reply #21 on: February 10, 2018, 09:55:24 pm »
Now just remove the ifdef, you don't need it:
Code: Pascal  [Select]
  1. procedure TForm1.VirtualStringTree1PaintText(Sender: TBaseVirtualTree;
  2.   const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
  3.   TextType: TVSTTextType);
  4. var
  5.   Data: PNodeData;
  6.   R: TRect;
  7. begin
  8.   if TextType = ttNormal then
  9.   begin
  10.     Data := VirtualStringTree1.GetNodeData(Node);
  11.     SetBKMode(TargetCanvas.Handle, TRANSPARENT);
  12.     TargetCanvas.Font.Name := 'Sans Serif';
  13.     TargetCanvas.Font.Size := 10;
  14.     R := TBaseVirtualTree(Sender).GetDisplayRect(Node, Column, False);
  15.     DrawText(TargetCanvas.Handle, PChar(Data^.Column0), Length(Data^.Column0), R, DT_LEFT or DT_VCENTER or DT_SINGLELINE);
  16.   end;
  17. end;

torumyax

  • New member
  • *
  • Posts: 22
Just an update...

It seems this is a widgetset bug.
https://bugs.freepascal.org/view.php?id=33215

ps. thanks a lot @GetMem.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus