Menu

#237 TRichEditView: Support for justified text

8
open
API (105)
1
2023-09-20
2023-09-18
No

TRichEditView has built-in support for left-aligned, right-aligned and centered paragraphs, which correspond to the PFA_LEFT, PFA_RIGHT and PFA_CENTER values for the PFM_ALIGNMENT flag in the PARAFORMAT2 structure , but does not have support for PFA_JUSTIFY and PFA_FULL_INTERWORD.

Related

Wiki: OWLNext_Roadmap_and_Prereleases

Discussion

  • Ognyan Chernokozhev

    Afetr more research and experiments, it turned out that I am unable to successfully use PFA_JUSTIFY (and that PFA_FULL_INTERWORD is defined to be the same as PFA_JUSTIFY).

    An answer to a post on StackOverflow indicated that the message EM_SETTYPOGRAPHYOPTIONS needs to be sent to the rich edit control with the flag TO_ADVANCEDTYPOGRAPHY, but even with that I cannot get it to work. Maybe I am missing something ...

     
    • Ognyan Chernokozhev

      There is one more piece of the equation - to use justified text and word wrapping in a rich edit control, first EM_SETTARGETDEVICE must be sent to the control.
      But the second parameter for that message is the line width, and it is not clear in what units it should be, as it is not in pixels? If printing, then it can be set to the result of GetDeviceCaps(hdc, PHYSICALWIDTH). But when we simply want to justify on the screen, what is the relation between the window width and the line width?

       
      • Ognyan Chernokozhev

        Okay, it is very counter-intuitive, but calling SetTargetDevice(NULL, 0) enables word wrapping in TRichEdit control, and allows PFA_JUSTIFY to work correctly.

         
        👍
        1
  • Vidar Hasfjord

    Vidar Hasfjord - 2023-09-20

    Hi Ognyan, good work on this!

    Just looked at [r6604], and I see == TRUE. This is something code analysis tools will flag as a potential issue, since the underlying type is int. Although the EM_SETTYPOGRAPHYOPTIONS documentation is clear that it will definitely return TRUE (often the documentation says "return non-zero" or something to that effect), the fail-safe test is != FALSE.

    PS. There is also owl::ToBool (defined in "owl/private/defs.h"), which performs a fail-safe static_cast.

     

    Related

    Commit: [r6604]


    Last edit: Vidar Hasfjord 2023-09-20
  • Vidar Hasfjord

    Vidar Hasfjord - 2023-09-20

    Ognyan, I get a build error now. I think you forgot to add a file:

    1> ..\..\include\owl/richedv.rc(27): error RC2135: file not found: owl/res/parjust.bmp [C:\OWLNext\trunk\build\microsoft\owl.vcxproj]
    
     
    • Ognyan Chernokozhev

      Oh, right :-(
      Added now.

       
  • Vidar Hasfjord

    Vidar Hasfjord - 2023-09-20
    • summary: TRichEditView does not have built-in support for justified text --> TRichEditView: Support for justified text
     

Anonymous
Anonymous

Add attachments
Cancel