Discussions related to Visual Prolog
Harrison Pratt
VIP Member
Posts: 439
Joined: 5 Nov 2000 0:01

Draw vertical text using GDI+ stringFormat

Unread post by Harrison Pratt »

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.
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Re: Draw vertical text using GDI+ stringFormat

Unread post by Thomas Linder Puls »

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: 439
Joined: 5 Nov 2000 0:01

Re: Draw vertical text using GDI+ stringFormat

Unread post by Harrison Pratt »

Ahhh ... thank you.

I searched high and low for that constant in all the wrong places! :D
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Re: Draw vertical text using GDI+ stringFormat

Unread post by Thomas Linder Puls »

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
Insert Qualification.png (4.85 KiB) Viewed 8560 times
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
completion.png (13.36 KiB) Viewed 8560 times
Now TAB will change the casing to match the declaration (including changing the first letter to lowercase).
Regards Thomas Linder Puls
PDC
Harrison Pratt
VIP Member
Posts: 439
Joined: 5 Nov 2000 0:01

Re: Draw vertical text using GDI+ stringFormat

Unread post by Harrison Pratt »

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.
Post Reply