Page 1 of 1

Draw vertical text using GDI+ stringFormat

Posted: 12 Jul 2020 21:43
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: ... 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.

Re: Draw vertical text using GDI+ stringFormat

Posted: 12 Jul 2020 23:10
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).

Re: Draw vertical text using GDI+ stringFormat

Posted: 13 Jul 2020 1:57
by Harrison Pratt
Ahhh ... thank you.

I searched high and low for that constant in all the wrong places! :D

Re: Draw vertical text using GDI+ stringFormat

Posted: 13 Jul 2020 20:54
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 1764 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 (13.36 KiB) Viewed 1764 times
Now TAB will change the casing to match the declaration (including changing the first letter to lowercase).

Re: Draw vertical text using GDI+ stringFormat

Posted: 14 Jul 2020 12:03
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.