Recent

Author Topic: [SOLVED] ATTabs resp. ExtTextOut(W), why that weird behaviour?  (Read 1760 times)

d7_2_laz

  • Hero Member
  • *****
  • Posts: 510
After sucessfully integrating ATTab for to solve missing functionalities of the Lazarus page control on windows (x64) lately i now encountered some strage behaviour that i cannot solve at all.

The first thing is, although OptVarWidth had been set to true, it is tried to truncate the string (putting ellipses in part of it).
I would have expected no truncation unless i define a maxlength of the caption (OptTabWidthMaximal, but it does not seem to have effect),

The second thing is:
In an easy test context (the compontent witin a panel within a Form) a test caption will look ok like  in sample_good.jpg (test caption text hre is: sample_ABCD_1234):

in the real app, with more complicated nested component structure (therefore not possible to elaborate a test case). it looks like it sample_bad.jpg
Obviously the character for the trancation ellipsis ("...", as unicode character) had not been painted correctly.  A vertical bar is painted instead.

That goes back to a call to the procedure DoTextOut (within attabs.pas) having the truncation routine  (made by CanvasCollapseStringByDots from atcanvasprimitives.pas)  as input parameter "AText" . And then:
Code: Pascal  [Select][+][-]
  1. DoTextOut(C: TCanvas; AX, AY: integer; const AClipRect: TRect; const AText: string);
does either (this depends on ifdefs)
Code: Pascal  [Select][+][-]
  1. var  Str: WideString;
  2.   Str:= UTF8Decode(AText);
  3.   ExtTextOutW(C.Handle, AX, AY, ETO_CLIPPED, @AClipRect, PWideChar(Str), Length(Str), nil);
resp. or:
Code: Pascal  [Select][+][-]
  1.   ExtTextOut(C.Handle, AX, AY, ETO_CLIPPED, @AClipRect,  PChar(AText), Length(AText), nil);

I tried both variants and they failed both.

Maybe the Canvas involved has (due to the context) not the right properties, but i really get no clue how to fix that problem. Any idea about possible causes would be very welcome
« Last Edit: March 05, 2021, 04:47:06 pm by d7_2_laz »
Lazarus 3.2  FPC 3.2.2 Win10 64bit

d7_2_laz

  • Hero Member
  • *****
  • Posts: 510
Re: ATTabs resp. ExtTextOut(W), why that weird behaviour?
« Reply #1 on: March 03, 2021, 12:08:12 pm »
It has something to do with "OptShowXButtons:=atbxShowNone" (vs. "atbxShowActive"), when only one tab is open. What i tried to achieve: to show the close button on the activve tab only - but not on the last tab opened. Probably i encountered a textwidth calculation side effect by that. I ended up to apply a small patch in atttabs.pas for to achieve it.
--
As to prohibit a closure of the last tab opened is not a very uncommonly usage, it would be nice to have a regular solution with an additional option. Somehiing like: disallow closure of the last opened tab; and then the close button shouldn't appear here of course.


Lazarus 3.2  FPC 3.2.2 Win10 64bit

AlexTP

  • Hero Member
  • *****
  • Posts: 2386
    • UVviewsoft
Re: ATTabs resp. ExtTextOut(W), why that weird behaviour?
« Reply #2 on: March 03, 2021, 12:40:05 pm »
Quote
>although OptVarWidth had been set to true, it is tried to truncate the string (putting ellipses in part of it).
Look at maximal tab width,
    property OptTabWidthNormal
    property OptTabWidthMinimal
    property OptTabWidthMaximal
    property OptTabWidthMinimalHidesX

set Maximal to e.g. 1200.
My demo shows that 1200 works. With OptVarWidth=true.

Quote
>Obviously the character for the trancation ellipsis ("...", as unicode character) had not been painted correctly.  A vertical bar is painted instead.
I fixed smth like this a week ago.
Try the last Github version.
a) If it don't help, try to make a demo project.
b) in attabs.pas, or atCanvasPrimitives.pas, replace that unicode char, with another char.


AlexTP

  • Hero Member
  • *****
  • Posts: 2386
    • UVviewsoft
Re: ATTabs resp. ExtTextOut(W), why that weird behaviour?
« Reply #3 on: March 03, 2021, 12:41:55 pm »
atCanvasPrimitives unit has code for '...' dots, can you fix it?

Code: Pascal  [Select][+][-]
  1. function CanvasCollapseStringByDots(C: TCanvas;
  2.   const Text: string;
  3.   Mode: TATCollapseStringMode;
  4.   Width: integer;
  5.   DotsString: string=''): string;
  6. ...
  7.   if DotsString='' then
  8.     DotsString:= {$ifdef fpc}UTF8Encode{$endif}(#$2026);
  9.  

d7_2_laz

  • Hero Member
  • *****
  • Posts: 510
Re: ATTabs resp. ExtTextOut(W), why that weird behaviour?
« Reply #4 on: March 03, 2021, 04:07:00 pm »
Alextp, thank you for your attention and congrats for your excellent component!

About the OptTabWidthMaximal etc., i checked it again, yes it works fine indeed. My error, sorry, but it has not been primarily in my focus at that stage.
About the mini dots (truncation indicator):I retested with the very recent github master and that doesn't change (still shows up vertical bar instead).
Need to underline that the caption basically is able to show Unicode chars correctly; tested that.
As told, it’s only occurring in a more complex nested structure (not in a simple Form-Panel-Attabs context, otherwise I already would have postede a test case here).
I already had played with variations in DotsString (within CanvasCollapseStringByDots), but none attempt did work .
If i substitute by ‘X’, then that works of course, but the given contents you provided is by far the best for the purpose.
My workaround after some hours of digging is to decomment two IFs (around line 2144) for to reserve space for the close button anyhow (unconditinoally) and to query for the Tabcount when deciding to paint the button or not. Somehow brute force, but at least i had a result.

Lazarus 3.2  FPC 3.2.2 Win10 64bit

AlexTP

  • Hero Member
  • *****
  • Posts: 2386
    • UVviewsoft
Re: ATTabs resp. ExtTextOut(W), why that weird behaviour?
« Reply #5 on: March 03, 2021, 04:37:16 pm »
Quote
>About the mini dots (truncation indicator):I retested with the very recent github master and that doesn't change (still shows up vertical bar instead).
1) what if you set in code- DotsString:= '...' (or 2 dots '..') ? does it work?
2) I still need the repro-demo.

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: ATTabs resp. ExtTextOut(W), why that weird behaviour?
« Reply #6 on: March 03, 2021, 05:10:35 pm »
The two images you have in your first post show two different fonts. What font did you use in the problematic image?

To me, it looks like a missing glyph in that font.
« Last Edit: March 03, 2021, 05:12:15 pm by engkin »

d7_2_laz

  • Hero Member
  • *****
  • Posts: 510
Re: ATTabs resp. ExtTextOut(W), why that weird behaviour?
« Reply #7 on: March 03, 2021, 07:23:18 pm »
Hello engkin,
the images were from different apps (a simple test, vs. from the more complex app), but, however,. different fonts had been nowhere set intentionally (i already did check the parentfont inheritence but could not find any effect).

Hello Alextp,
yes a test case, that's absolutely fair. I tried to shrink it down again as much as possible (attached; contains now nearly nothing, but should show up the issue, hopefully). - For Lazarus - use Project1.lpi)  - ATTabs files are from the recent github master as of yesterday;  they are locally stored within.
Hopefully it's a simple user error, i'm still a beginner here. So, if you find some unefficient usage of the control,, it's appreciated if you tell it

Yes: the double char'ed dots '..'  would do the job too.
Lazarus 3.2  FPC 3.2.2 Win10 64bit

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: ATTabs resp. ExtTextOut(W), why that weird behaviour?
« Reply #8 on: March 04, 2021, 07:12:09 am »
Your test project confirms my assumption. You are using "MS Sans Serif" font, which is not a True Type font. Try it with a simple Memo, and you'll see the same result. It has a very limited number of glyphs. The ellipsis (three dots glyph) is replaced with a simple glyph.

You can see the glyphs using CharMap utility, for instance.

d7_2_laz

  • Hero Member
  • *****
  • Posts: 510
[SOLVED] ATTabs resp. ExtTextOut(W), why that weird behaviour?
« Reply #9 on: March 04, 2021, 06:26:01 pm »
Oh yes, this makes sense, finally that's the reason why. Thank you!
A simple ParentFont := False within the container panel is enough to fix it.
Should be worthy to mention in the docs though (because the user of the component has a few chance to be concious about such a dependency).
Or, if the component depends on that for to draw all of its elements correctly, would it make sense to force a correct font setting internally (unless somebody wants to override intentionally) ?

Nevertheless, i have still two howto question in the pipeline. As somehow specific, i'll open them seperate from here.
Lazarus 3.2  FPC 3.2.2 Win10 64bit

d7_2_laz

  • Hero Member
  • *****
  • Posts: 510
Re: ATTabs resp. ExtTextOut(W), why that weird behaviour?
« Reply #10 on: March 05, 2021, 04:46:28 pm »
Update of the subject line only for to indicate that's not a problem anymore
Lazarus 3.2  FPC 3.2.2 Win10 64bit

 

TinyPortal © 2005-2018