Watermarks and page relative WPObjects

  • 1. How do I get a WPObject descendent to be rendered on the current page at relx/rely position, i.e. use the wpotPage parameter in the call to ChangePositionMode? I have an object that was initialized using the wpotChar and wpwrAutomatic parameters. I can change it to be free floating relative to the current paragraph using the wpotPar and wpwrNone parameters. How do I get it to be relative to current page as is described in the help file? wpwrAutomatic, wpwrLeft, wpwrRight and wpwrNone don't work when used with wpotPage. If you try them the object simply vanishes.

    2. Is there a way to control the size and position of a WPObject descendent? I want to prevent the user from moving the WPObject descendent in certain areas of the page and also prevent them from making it smaller then a minimum width and height?

    3. Is there a way to know when the user has scrolled the page. There are no scroll related events that I can see. I'd like to add a refresh call because my WPObject descendent barcode objects get full of video dust when the page is scrolled. I've tried to double buffer my pain routine. While thise reduced the flickering, I still get a lot of video dust.

    Meat

    • Offizieller Beitrag

    Hi,

    thanks for the call - I tried to reproduce the problem with the
    watermaks and posted a demo here:
    https://www.wpcubed.com/ftp/ex/WaterMDemo3.zip
    The text looks fine ...???

    >1. How do I get a WPObject descendent to be rendered on the current page
    >at relx/rely position, i.e. use the wpotPage parameter in the call to
    >ChangePositionMode? I have an object that was initialized using the
    >wpotChar and wpwrAutomatic parameters. I can change it to be free
    >floating relative to the current paragraph using the wpotPar and wpwrNone
    >parameters. How do I get it to be relative to current page as is
    >described in the help file? wpwrAutomatic, wpwrLeft, wpwrRight and
    >wpwrNone don't work when used with wpotPage. If you try them the object
    >simply vanishes.

    wpotPage is reserved for future versions. However the engine renders
    them on each watermark, on the same buffer DrawPage uses.
    Please also see the demo above.

    Please note that the images will show on all pages. You can only avoid
    that with a small change in the RTF-Engine by selecting certain pages
    in WPrtfPA, procedure InternUpdatePageBackground, after "if
    TxtObjLst.GetPageGraphics" - the unit is part of WPTools PRO.

    >2. Is there a way to control the size and position of a WPObject
    >descendent? I want to prevent the user from moving the WPObject
    >descendent in certain areas of the page and also prevent them from making
    >it smaller then a minimum width and height?

    No, the objects in WPTools4 cannot do this. You can change the way how
    the user can size them in the EditOptions (but there are no
    constraints)

    >3. Is there a way to know when the user has scrolled the page. There are
    >no scroll related events that I can see. I'd like to add a refresh call
    >because my WPObject descendent barcode objects get full of video dust
    >when the page is scrolled. I've tried to double buffer my pain routine.
    >While thise reduced the flickering, I still get a lot of video dust.


    You can check for the property TopOffset (which does the scrolling) in
    even OnYPosChanged.

    Julian Ziersch

  • Zitat von wpsupport


    I tried to reproduce the problem with the
    watermaks and posted a demo here:
    https://www.wpcubed.com/ftp/ex/WaterMDemo3.zip
    The text looks fine ...???


    Well, almost. I found out that I had a background image assigned to the editor and was then painting my background image in the OnPaintPage event. Once I got rid of the background image some of my text problems went away but I still have some issues with text fields. I modified your demo program to kind of do what I want to do with the backgrounds, i.e. draw a different image on the background of each page. Then I added a button to insert a text field. When the textfield text is drawn, and selected, the selection color never goes away. Check you mail for the modified sample program to see for yourself.



    I'm trying to use this with WPObjects that were created using code similar to your code from another one of your example programs. If you create the WPObject using the code below,

    procedure TFrmDocTemplate.WPOShapeClick(Sender: TObject);
    var
    obj: TWPOShape;
    begin
    obj:= WPRichText.InsertGraphicObject('TWPOShape', 1000, 1000) as TWPOShape;
    with obj do begin
    obj.Caption:= 'Hello World!'
    end {with};
    WPRichText.CPMoveBack;
    WPRichText.TextObjects.ChangePositionMode(WPRichText.TextObjects.TextObjectGet(WPRichText.CPAttr^.tag),
    wpotPar, wpwrAutomatic);

    end;

    then select it and execute the folowing code:

    procedure TFrmDocTemplate.NoneFreeFloating1Click(Sender: TObject);
    begin
    if CurrentPTextObj<>nil then
    begin
    WPRichText.BeginUpdate;
    try
    WPRichText.TextObjects.ChangePositionMode(CurrentPTextObj, wpotPage, wpwrNone);
    CurrentPTextObj.relx := 0;
    CurrentPTextObj.rely := 0;
    finally
    WPRichText.EndUpdate;
    end;
    // Otherwise we do not see the image unless the cache is cleared
    WPRichText.Memo.InternUpdatePageBackground(true,0);
    WPRichText.Memo.RePaint;
    end;
    end;

    ala your new example program, the object still vanishes.


    Zitat von wpsupport


    You can check for the property TopOffset (which does the scrolling) in
    even OnYPosChanged.


    I can't use this to refresh the screen by calling ReformatAll because this event get fired way too much. The documentation says "This event will be triggered when the caret was moved vertically.". It looks like it gets called no matter if the caret moves vertically or horizontally. It's overkill to do it when the caret position changes because the user may have just clicked on a different line on the same screen or just type a single character. Calling ReformatAll in this case, with many objects on the page, causes things to slow down a lot. I only get video dust issues when the user scrolls...


    Jim

    • Offizieller Beitrag

    The V4 concept does not allow double buffering in this mode - there are too many bitmaps involved.

    According to the problem with the TextFieldObjects - I can reproduce them. You can fix this problem (since you have PRO version) in unit WPrtfPA, about line 7575 by inserting the marked line:

    Code
    if not (prOnlyPaintLine in FPaintMode) then TextOutMode := TextOutMode or ETO_CLIPPED;
                        DrawBackgr(toCanvas, r, 0, 0, par, lin); //<<---- V4.23
                        WPExtTextOut(toCanvas, 0, 0, TextOutMode, r, PChar(ts), Length(ts), nil);


    Scrollevent:
    >> You can check for the property TopOffset (which does the scrolling) in even OnYPosChanged.<<
    Yes, OnYPosChanged is fired very often. This is why I suggest to check TopOffset.

    in TForm: old_topoffset : Integetr;

    in the event:
    if WPRichText.TopOffset<>old_topoffset then
    begin
    old_topoffset := WPRichText.TopOffset;
    dosomething
    end;

    It might be still not a good idea to refresh the screen like this.

    Vanishing Objects:
    a different possibility to remove all page background buffer is to call function
    WPRichText1.Memo.procedure FreePageBackgrounds;

    BTW.: I would not worry about flickering too much. Any flickering has been removed from WPTools 5 by concept.


    Julian Ziersch

  • Zitat von wpsupport

    The V4 concept does not allow double buffering in this mode - there are too many bitmaps involved.


    OK Thanks.

    Zitat von wpsupport


    According to the problem with the TextFieldObjects - I can reproduce them. You can fix this problem (since you have PRO version) in unit WPrtfPA, about line 7575 by inserting the marked line:

    Code
    if not (prOnlyPaintLine in FPaintMode) then TextOutMode := TextOutMode or ETO_CLIPPED;
                        DrawBackgr(toCanvas, r, 0, 0, par, lin); //<<---- V4.23
                        WPExtTextOut(toCanvas, 0, 0, TextOutMode, r, PChar(ts), Length(ts), nil);


    This seems to fix the problem fine, thanks.


    I tried subclassing the WPRichText window proc to intercept the WM_VSCROLL message but your control doen't seem to like me sticking my fingers in its message loop... I coupled the above method along with a timer to make sure I don't call the RefreshAll within 300 ms of each other. It seems to work fine and doesn't get called all that much:-)

    Zitat von wpsupport


    Vanishing Objects:
    a different possibility to remove all page background buffer is to call function
    WPRichText1.Memo.procedure FreePageBackgrounds;

    BTW.: I would not worry about flickering too much. Any flickering has been removed from WPTools 5 by concept.


    I have another touchy situation with vanishing objects that Brett found yesterday and doesn't like. if I have an object (barcode object) that has CurrentPTextObj.typ = wpotPar and CurrentPTextObj.wrap = wpwrNone and the object is moved towards the bottom of the page (layout mode), when the user inserts text above the objects anchor, the object is pushed off the screen but since there isn't enought text for a second page, the object seems to "vanish" because there is no page for it to be drawn on. Is there a way to:

    1. Detect when the object isn't being drawn on a valid page.
    2. Move it more vertically, towards its anchor, so that it stays on the current page and does't vanish on the user.


    Thanks for you help,
    Jim