Discussions related to Visual Prolog
Harrison Pratt
VIP Member
Posts: 458 Joined: 5 Nov 2000 0:01
Post
by Harrison Pratt » 12 Jul 2020 21:43
Is vertical text output supported in the
graphics class?
I cannot find ViP documentation on this feature, but it is defined in MSDN:
https://docs.microsoft.com/en-us/window ... g-text-use
Code: Select all
...
Formatter = stringFormat:: create ( ) ,
% ??? How to set a format flag in Formatter for vertical text here ???
G : drawString ( axisLabel, Font , CtrlRectF , Formatter , Brush ) ,
...
I can get the job done in a kludgy way by interleaving carriage returns between the characters of the string, but it would be more robust to use stringFormat.
Thomas Linder Puls
VIP Member
Posts: 1466 Joined: 28 Feb 2000 0:01
Post
by Thomas Linder Puls » 12 Jul 2020 23:10
This is more or less a direct translation of the code from the Microsoft example (however using a
rectF rather than a
pointF ):
Code: Select all
predicates
onPaint : window :: paintresponder .
clauses
onPaint( _ , _ , GDI ) :-
HDC = GDI : getNativeGraphicContext ( IsReleaseNeeded ) ,
Graphics = graphics:: createFromHDC ( HDC ) ,
FontFamily = fontFamily:: createFromName ( "Lucida Console" ) ,
Font = font:: createFromFontFamily ( FontFamily , 14 , gdiplus_native:: fontStyleRegular , gdiplus_native:: unitPoint ) ,
RectF = gdiplus:: rectF ( 40 , 10 , 50 , 110 ) ,
StringFormat = stringFormat:: create ( ) ,
StringFormat : formatFlags := gdiplus_native:: stringFormatFlagsDirectionVertical ,
SolidBrush = solidBrush:: create ( color:: create ( 255 , 0 , 0 , 255 ) ) ,
Graphics : drawString ( "Vertical text" , Font , RectF , StringFormat , SolidBrush ) ,
Graphics : delete ( ) ,
GDI : releaseNativeGraphicContext ( HDC , IsReleaseNeeded ) .
Regards Thomas Linder Puls
PDC
Harrison Pratt
VIP Member
Posts: 458 Joined: 5 Nov 2000 0:01
Post
by Harrison Pratt » 13 Jul 2020 1:57
Ahhh ... thank you.
I searched high and low for that constant in all the wrong places!
Thomas Linder Puls
VIP Member
Posts: 1466 Joined: 28 Feb 2000 0:01
Post
by Thomas Linder Puls » 13 Jul 2020 20:54
A little tip that would surely have found it for you.
Paste the constant from the example into the editor and use the menu
Insert -> Qualification (or Ctrl+Shift+S)
Insert Qualification.png
If the constant is known (the relevant package must have been compiled) then the qualification will turn up.
Next (with the caret after the constant) press Ctrl+Space to get the the completion window up:
completion.png
Now TAB will change the casing to match the declaration (including changing the first letter to lowercase).
You do not have the required permissions to view the files attached to this post.
Regards Thomas Linder Puls
PDC
Harrison Pratt
VIP Member
Posts: 458 Joined: 5 Nov 2000 0:01
Post
by Harrison Pratt » 14 Jul 2020 12:03
I use the very handy Ctrl-Shift-S approach often.
What happened when I was trying to find the constant (stringFormatFlagsDirectionVertical) was that I wrongly assumed I would find it in the pfc\gui directory tree and searched files there for the substring "vertical" using Ctrl-Shift-F.
The constant is defined in pfc\windowsApi\gdiplus_api folder so I didn't search the proper directory tree!
Moral to the story: Search the entire pfc directory tree when you don't find what you seek.