Protecting, Setting attributes, and drawing Paragraphs

  • Hi Julian,

    What I have setup:
    I have access to a single Paragraph called Par.
    Par is an empty paragraph and contains no text.

    Question 1:
    How do I go about setting up the font size for this paragraph?

    Question 2:
    How do I go about protecting the Par to make sure the user cannot alter it in anyway: Font size, Text, etc?

    Question 3:
    How does the font size on the canvas work when in the OnInternPaintPar.

    When using the canvas to draw in the OnInternPaintPar the default font size seems to be related to the font size of the paragraph. This is why I am trying to set the size of the paragraph in question 1.

    I noticed that if the text font around the empty paragraph is large the font of Canvas.Font.Size is large and if small then the font is small. However if I change the size of the font any text I render using TextOut gets drawn twice, once where I planned and one just below. What is the best way to control the text size here?

    • Offizieller Beitrag

    Hi,

    I you want to acces and protect the paragraph in whole it is best to use its own attributes, not the character attributes of its text.

    You can set a font, size, color using par.ASet( ... )

    Use the WPAT_.... attribute identifiere. See demo CrTable for an example.

    Protection can be done through

    WPAT_ParProtect, 1

    OnInternPaintPar is used to draw borders, background etc. It is not guaranteed that the font has been set previously in Canvas.

    Julian

  • To discuss the OnInternPaintPar...

    NOTE ON THE FORUMS: I have images linked here in this post and while they work when I preview the post, I am unable to see them on the submitted post. The pictures are vital to demonstrating the issue.

    if I run this code

    Code
    Canvas.RoundRect(LineData.x-79, Linedata.Y,Trunc(Par.TextAreaWidth / 1.965)+44,Linedata.Y+Par.Height,30,30);        Canvas.Brush.Style := bsClear;        Canvas.Font.Color := Darken(FSlideColor,64);        Canvas.Font.Name := 'Arial';        Canvas.TextOut(LineData.x,LineData.y+trunc(LineData.h / 1.25)+OffSet,'SLIDE ' + inttostr(Par.HotParID)+' : ');        iLeft := Trunc(Canvas.TextWidth(Par.Name)/2);        Canvas.TextOut(LineData.x+(LineData.w div 2)-iLeft,LineData.y+trunc(LineData.h / 1.25)+OffSet,Par.Name);

    And I do not change the canvas.font.size then it renders it once.

    [Blockierte Grafik: http://www.oilcreekoriginals.com/OverAwe/LinkedImages/One.PNG]
    http://www.oilcreekoriginals.com/OverAwe/LinkedImages/One.PNG

    if I run this code

    And I do change the canvas.font.size and restore it when done then it renders it twice, the second time just below.

    Interesting and possible important point: The second duplicate line of text if it is up close enough to the blue rectangle we draw, then it will appear behind it.

    [Blockierte Grafik: http://www.oilcreekoriginals.com/OverAwe/LinkedImages/Two.PNG]
    http://www.oilcreekoriginals.com/OverAwe/LinkedImages/Two.PNG

    • Offizieller Beitrag

    Hi,

    I do not allow automatically embedded images in this forum since this (a) can introduce security problems and was abused by spammers to show unwanted images (under edit window).

    It is possible to open Your images by simply copy and paste the URL into a new browser tab. It is also possible to see them when answering a post.

    You cannot really Font.Size to be working. You always need to change Font.Height according to the calculated height for a certain logical resolution.

    WPTools uses normally 600 as rendering resolution. (Thats the variable Memo.CurrentXPixelsPerInch and CurrentYPixelsPerInch.)

    It depends a lot on the text you work on how the paint event works. Most important if there are tables used, if the paragragraphs have multiple lines or both.

    It is hard to reproduce without a real example.

    Julian