Drawing directly in the document window

Can anybody provide sample code showing the basics of drawing directly in the document window? I'm thinking of something along the lines of the measure tool (pardon the pun).
It looks like I'm supposed to use either the Annotator Suite or the Document View Suite to "invalidate" a rectangle in the document, followed by doing the actual drawing with the ADMDrawer Suite. But the documentation in this area is pretty sparse (for example GetDocumentViewInvalidRect and SetDocumentViewInvalidRect refer to a "fudged" invalid rect without explaining what that is) and I don't see anything in the Sample Code folder that explains this feature.
Are the little text annotations ("path" "anchor") that pop up when using Smart Guides done using this method?
Thanks,
John

(Sound of crickets chirping...)
Boy, this forum is awfully dead in comparison to the InDesign SDK forum. Is no one writing Illustrator plug-ins anymore?
But hey, I'll keep posting, if only for my own amusement, about my saga of writing a plug-in.
I figured out some of the annotation stuff, but I'm still puzzled by some things.
I started by simply trying to create a tool which would carry a 100x100 box around with it when moved on the screen -- no clicking or dragging yet -- much as the symbol sprayer, for example, has a nice circle (albeit of varying size) around it. I created the tool and added it as an annotator. When it receives a kSelectorAITrackToolCursor message, it simply captures the cursor location in a global and sets the PlatformCursor. When the tool receives a kCallerAIAnnotation message, I have this code:
extern AIErr toolAnnotate( AIAnnotatorMessage *message ) {
    AIErr error = kNoErr;
    error = sView->ArtworkPointToViewPoint( message->view, &g->cursorPoint, &g->cursorPointScreen );
    g->annoBoundsScreen.top = g->cursorPointScreen.v - 50;
    g->annoBoundsScreen.bottom = g->cursorPointScreen.v + 50;
    g->annoBoundsScreen.left = g->cursorPointScreen.h - 50;
    g->annoBoundsScreen.right = g->cursorPointScreen.h + 50;
    ADMDrawerRef dr = sADMDrawer->Create(message->port, &g->annoBoundsScreen, kADMPaletteFont);
    ASRect myRect;
    myRect.top = 0;
    myRect.bottom = 100;
    myRect.left = 0;
    myRect.right = 100;
    sADMDrawer->SetDrawMode( dr, kADMXORMode );
    sADMDrawer->SetADMColor( dr, kADMBlackColor );
    sADMDrawer->DrawRect( dr, &myRect );
    sADMDrawer->Destroy( dr );
    sAnnotator->InvalAnnotationRect ( message->view, &g->annoBoundsScreen );
This (should) convert the cursor location (in artwork coordinates) to screen coordinates, set the annotation boundaries based on this location, create the drawer reference, and draw the 100x100 rectangle within this reference. Finally, it invalidates this rectangle as per the Annotation suite documentation.
I fired up the tool in Illy 10 and saw a single box created down at the 0, 0 point on the page. No box followed the cursor. Hmm. I added an sADMBasic->Beep() to the annotation code and realized what was happening -- my tool was getting an annotation message when first selected, but none when it was merely moved around the screen.
After some futzing around I discovered that if I added a call to sView->SetDocumentViewInvalidDocumentRect in the TrackToolCursor code, I got an annotate message every time the mouse was moved! I captured the previous cursor position and invalidated the rectangle 50 points on all sides from it. and tried again. Success -- partially.
At this point, the cursor could be moved around with the box following it. It suffers, however, from the following bugs:
1) The SetDocumentViewInvalidDocumentRect is in artwork coordinates and so only works at 100% or greater. If I zoom out, my little box leaves trails all over the screen. In addition, if I zoom in, the cursor stutters noticeably -- I assume because Illustrator is forcing a redraw on large portions of the document. I think I can fix both these bugs by recalculating the SetDocumentViewInvalidDocumentRect into screen coordinates. However I note that the circle of the symbol sprayer can be made huge -- as large as the screen -- and it still moves smoothly. So maybe calling sView->SetDocumentViewInvalidDocumentRect is not the way to force annotations. But I haven't been able to discover another way.
2) When the mouse moves into a palette, the square remains "hung up" at the last position where the cursor was in the document window. I think I can fix this by utilizing the Suspend and Resume notifiers and doing one last InvalAnnotationRect when I get the Suspend notification.
3) For fun I tried clicking and dragging. Bad news. If I do this, thereafter the entire Illustrator window only redraws iself in the small rectangle that was set when I created the drawer port. By chance I found that if I use another tool that annotates such as the pencil *before* I use my tool, then everything is fine (although of course the box doesn't follow the cursor around anymore because my toolMouseDrag code is empty). How is using a previous tool "fixing" my code? I don't understand this one at all.
Anyway, I suppose I could fork over a wad of cash and join the ADN and purchase a support case -- but hey, I'm just a hobbyist messing around at this point and facing some rather crappy documentation. Any tips will be much appreciated.
John

Similar Messages

  • Scroll the document window to a specified graphic object

    Hi,
    anyone knows  a way to scroll the document window to a specified graphic object?
    I've tried with F_ApiScrollToText() function, but it works only with object containing text, and a graphic object ( like a line) doesn't contain text...
    Thanks in advance.

    Hi Stemen82,
    I have dealt with this in the past and found it to be a bit complex. I've pasted below the functions I came up with to do it. Note that:
    - I'm not sure that it works in all cases. Because there is no direct FDK function to do this, you really have to monkey around with things to get it done.
    - The code I've pasted should handle both anchored frames and graphic objects, including "floating" graphics. Anchored frames are actually a bit more straightforward because you can get the text location of the anchor.
    - All the comments in the code are "notes to self." That is, I didn't write them for you   However, they should be of some use to you.
    - There may be plenty of other, better ways to do this... this is just what I slapped together to get the basic functionality to work.
    Russ
    //THIS IS REALLY ONLY GOOD FOR ONE LEVEL OF NESTING,
    // ie, one graphic in one anchored frame, in a text frame.
    // No testing or implementation for anything else at this point.
    //If you don't know whether the object is a graphic or an anchored
    //frame, you can send it as the graphic ID and the function will
    //figure it out.
    // So, either send a graphic ID as graphicId,
    // a frame ID as graphicId, or both graphic and frame IDs.
    // Don't sent just a frame ID as frameID.
    VoidT ws_SelectAndScrollToGraphic(F_ObjHandleT docId,
                                      F_ObjHandleT graphicId,
                                      F_ObjHandleT frameId)
      F_ObjHandleT aFrameId = 0,
        textFrameId,
        graphicPageId,
        currentPageId,
        tempGraphicId;
      IntT objectType,
        alreadySelected = False;
      F_TextRangeT tr;
      if(!docId || (!graphicId && !frameId)) return;
      //let's get the page. We might need it for scrolling and
      //maybe to switch to the correct page type
      graphicPageId = ws_GetPageForGraphic(docId, graphicId);
      //So far, two possibilities here, either an anchored frame somewhere in the object hierarchy or not.
      //If there is no anchored frame, we have to guess based on pages and paragraps.  If there is one,
      //we can jump to the anchor.
      //let's start by looking for an anchored frame if one was not sent
      if(graphicId && !frameId)
        objectType = F_ApiGetObjectType(docId, graphicId);
        //if we actually got an anchored frame, we will store the ID.
        if(objectType == FO_AFrame)
          aFrameId = graphicId;
        //otherwise, let's look above to see if there is an anchored frame
        else
          aFrameId = F_ApiGetId(docId, graphicId, FP_FrameParent);
          objectType = F_ApiGetObjectType(docId, aFrameId);
          if(objectType != FO_AFrame)
            aFrameId = 0;
      //at this point, if we have an anchored frame, scroll to it
      if(aFrameId)
        //let's switch to the appropriate page type, only if necessary
        //we'll do that by simply switching to the first page of that
        //type in the doc before the scroll action
        currentPageId = F_ApiGetId(FV_SessionId, docId, FP_CurrentPage);
        if(F_ApiGetObjectType(docId, graphicPageId) != F_ApiGetObjectType(docId, currentPageId))
          if(F_ApiGetObjectType(docId, graphicPageId) == FO_MasterPage)
            currentPageId = F_ApiGetId(FV_SessionId, docId, FP_FirstMasterPageInDoc);
          else if(F_ApiGetObjectType(docId, graphicPageId) == FO_RefPage)
            currentPageId = F_ApiGetId(FV_SessionId, docId, FP_FirstRefPageInDoc);
          else
            currentPageId = F_ApiGetId(FV_SessionId, docId, FP_FirstBodyPageInDoc);
          F_ApiSetId(FV_SessionId, docId, FP_CurrentPage, currentPageId);
        tr.beg = tr.end = F_ApiGetTextLoc(docId, aFrameId, FP_TextLoc);
        F_ApiScrollToText(docId, &tr);
      //if no anchored frame (ie, just a floating graphic),
      //let's finangle with some paragraphs and pages and try our
      //best. There might be a better way.
      else
        // We have the page that the graphic is on, let's at least jump
        // to that page, maybe we can get a little closer later
        F_ApiSetId(FV_SessionId, docId, FP_CurrentPage, graphicPageId);
        //get the parent frame of the graphic which is hopefully a text frame
        textFrameId = F_ApiGetId(docId, graphicId, FP_FrameParent);
        //let's see if we can find a paragraph and scroll to it.
        tr.beg.objId = tr.end.objId =
          F_ApiGetId(docId, textFrameId, FP_FirstPgf);
        F_ApiScrollToText(docId, &tr);
      //now, let's do the selection. We'll unselect everything
      //that is selected, unless our graphic is already selected.
      tempGraphicId = F_ApiGetId(FV_SessionId, docId, FP_FirstSelectedGraphicInDoc);
      while(tempGraphicId)
        if(tempGraphicId == graphicId || tempGraphicId == frameId)
          alreadySelected = True;
        else
          F_ApiSetInt(docId, tempGraphicId, FP_GraphicIsSelected, False);
        tempGraphicId = F_ApiGetId(docId, tempGraphicId, FP_NextSelectedGraphicInDoc);
      if(!alreadySelected)
        if(graphicId)
          F_ApiSetInt(docId, graphicId, FP_GraphicIsSelected, True);
        else
          F_ApiSetInt(docId, frameId, FP_GraphicIsSelected, True);
    //Returns the ID of the page that the graphic is on.
    F_ObjHandleT ws_GetPageForGraphic(F_ObjHandleT docId,
                                      F_ObjHandleT graphicId)
      F_ObjHandleT tempGraphicId = 0,
        pageId = 0;
      while(graphicId)
        tempGraphicId = graphicId;
        graphicId = F_ApiGetId(docId, graphicId, FP_FrameParent);
      if(tempGraphicId)
        pageId = F_ApiGetId(docId, tempGraphicId, FP_PageFramePage);
      return pageId;

  • Draw directly to the screen (win32)

    Hi,
    I am attempting to draw directly to the screen in win32. The goal is to draw four small objects in each corner of the screen that will be painted on top of any existing windows, desktop objects and remain painted even after screen is refreshed. A screenshot overlay is not possible, it has to be real-time.
    I've scoured for a java class to accomplish with little luck and haven't been able to find much in the way of win32 api options either.
    Any advice given to point me in the right direction would be greatly appreciated.
    Thanks!
    -squirrellyj

    In the windows API you can create a window and set it to be on top of all other windows
    SetWindowPos(hWnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
    I think that in J2SE 5 or 6 you can do it from java directly but I'm not sure.
    So just create 4 windows and put them in 4 corners of the screen.

  • Why does the document window in illustrator cs6 move to the far left when I reopen the file?

    why does the document window in illustrator cs6 move to the far left when I reopen the file?

    Hi John,
    thanks for the fast response.  cs5 remembered the window position.  I like having the window in the middle as I have a 27" monitor.  I just upgraded to cs6 yesterday and I'm sure it was remembering the window document position.  I think.  If i find out how to fix this, I'll post it here.
    And while I'm on the subject of cs6, why the f*** did adobe combine the stroke and swatches pallettes?  Now I forever have to click stroke and swatch tabs all day.  And I love the army and navy file icons of photoshop and illustrator.  I won't comment on Acrobat X.  ; (

  • Expand the Document Window's Page Name Area

    In FW CS4, the area for the page name is too small.  It truncates my page names so that I can't tell them apart like this:
    Is there any way to expand that are where the page name shows up on the right of the document window toolbar?
    Thanks!

    That won't work if other users are to recognize what the pages are designed to do.

  • Why doesn't the image show in the document window?

    I am a Photoshop CS5 begI have tried to look for what button I need to click. I can see the document name in the window but there is no image showing in the window. Getting bit frustrated. Please help.
    Thank you.

    Here's the shot of what I get.
    It will show in the layers. But nothing in the document window.

  • Is it possible to make the document window not to hide behind the palettes?

    Is it possible to make the document window not to hide behind the palettes (layers, paths etc) like in CS5? For instance if I want to make a correction in the right part of the image and zoom in, the window expand under the different palettes and I can no longer see the area which I want to correct without change the document window size. I don't want to use the Photoshop application fram because then I can't see stuff in other applications ID, mail an so on. 

    I have written about how to control various font sizes in Thunderbird here:
    http://www.ramsden.org.uk/9_Type_sizes.html
    Generally, you shouldn't need to zoom; you can pre-set the display of message text.
    To get straight to the point, you should probably try the https://addons.mozilla.org/en-us/thunderbird/addon/theme-font-size-changer/ add-on to address issues with the size of the message list font.

  • Is there any way to bring back the Documents window? [Android]

    I liked the Documents window in the previous version where all the PDFs of the phone was shown, plus theor source folder was indicated. Now, it's somehow troublesome to go through my phone's folders just to look for a certain file.

    Hi Leslie,
        Are you using an Android device or an iOS device? My understanding is that you are able to find local files on your device but it is painful without a consolidated list of PDF's. In addition, if you are using an Android device can you please share your Android OS version (Settings-> About Phone) with us.
    -Rahul

  • How to trap the document window activate event?

    Hi All,
    I am working with a plugin development application. My requirement is, at any time I may have more than one document opened. The plugin window what I have designed gets populated with data from the xml file attached with the current document. Therefore whenever I switch between the document window, I need the plugin window to be refreshed so that it will load/display the contents from the current xml file.
    For this I need to trap the activate document window event. So whenever a window is selected from the current list of opened windows, then the plugin should get refreshed automatically.
    Actually, I tried inheriting the CWindowEH class and I used the kDocWindowBoss class for the same. But the event is not firing as expected. Help/tips from anyone could be appreciated.
    Thanks in advance.
    JR.

    Hi, <br /><br />I don't think having observers on kDocBoss and kDocumentListBoss should be a problem. We do exactly that.<br /><br />Just running with a couple of break points in your code, do you hit the DocListObserver::AutoAttach and not the Update().<br /><br />If you don't hit the AutoAttach breakpoint then it's probably the resource is not set up right. Ours is like this..<br /><br />/** Observes document list actions.<br /> */<br />AddIn<br />{<br />     kDocumentListBoss,<br />     kInvalidClass,<br />     {<br />      IID_IMYDOCLISTOBSERVER, kMyDocListObserverImpl,<br />     }<br />},<br /><br />If you're getting to the AutoAttach but not the Update then it may be that you're not specifying what notifications you wish to receive.<br /><br />Our AutoAttach is like this..<br /><br />     do<br />     {<br />          InterfacePtr<ISubject> subject( this, UseDefaultIID());<br />          if (subject != nil)<br />          {<br />               if ( subject->IsAttached(this, IID_IDOCUMENTLIST, IID_IMYDOCLISTOBSERVER) == kFalse )<br />                    subject->AttachObserver(this, IID_IDOCUMENTLIST, IID_IMYDOCLISTOBSERVER);<br />          }<br />     }<br />     while ( kFalse );<br /><br />with equivalent DetachObserver code in the AutoDetach of course.

  • Resizing the Document window to predetermined size

    Hopefully this is just a quickie... Have just defined a site
    and am about to start afresh and wanted to change the page size to
    760 x 420 as reccomended. However, have gone to change this in the
    pop-up menu at the bottom and all the sizes are greyed-out (have
    even tried to determine my own size - but that's greyed out too.
    I am stuck on one size only (1018 x 497) Is this due to my
    own screen size??? Should I just continue working to the parameters
    I have set with guides?

    1. You cannot change those items at the bottom of the page
    until you have
    unmaximized the document pane in DW. But don't bother
    because,
    2. Changing that value does nothing to your page other than
    to show it in a
    reduced size window. It adds no code to the page.
    If you want your page to be 760px wide, then that's how wide
    you make the
    widest element on the page. Don't worry about trying to
    control the
    height - you cannot conveniently or reliably do that anyhow.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "mccoole1" <[email protected]> wrote in
    message
    news:g16l5k$28r$[email protected]..
    > Hopefully this is just a quickie... Have just defined a
    site and am about
    > to
    > start afresh and wanted to change the page size to 760 x
    420 as
    > reccomended.
    > However, have gone to change this in the pop-up menu at
    the bottom and all
    > the
    > sizes are greyed-out (have even tried to determine my
    own size - but
    > that's
    > greyed out too.
    > I am stuck on one size only (1018 x 497) Is this due to
    my own screen
    > size???
    > Should I just continue working to the parameters I have
    set with guides?
    >

  • With the latest Firefox update, the Firefox window stays in front of all other software windows until I directly minimize the Firefox window. Is this a bug?

    I can minimize the Firefox window, but *unless* I minimize it, I can't access other programs-- even if I click on a window behind the Firefox window or try clicking on the appropriate icon from the Windows taskbar. The Firefox window stays in front.
    I'm using Firefox 18.0; I am on the update release channel.
    My enabled add-ons are:
    Adblock Plus Pop-up Addon 0.5
    BetterPrivacy 1.68
    Flashblock 1.5.15.1
    RAMBack 1.0
    and I have no toolbars installed. The only other thing I've recently installed is Amazon Cloud Drive-- but again, this problem is specifically and only with the Firefox window.
    Thank you for any help you can give me!

    There is a bug in Adblock. If you disable, thing return to normal. In my experience, this only occurs after an ad is blocked.

  • The document window in Dreamweaver does not match the tutorial.

    There is no Document title box.

    I don't use the Extract workspace.  Have you tried changing to Code or Design workspace (upper right corner)?  In addition, you can create a custom workspace and save it. 
    Nancy O.

  • Switch between views in the Document window

    This question was posted in response to the following article: http://help.adobe.com/en_US/dreamweaver/cs/using/WScbb6b82af5544594822510a94ae8d65-7fb6a.h tml

    When using the Code/Design view, I am Unable to Split View vertically or change the design view to the left, as the options are greyed out on my version of CS5.5 Dreamweaver.
    I would be grateful if anybody has any suggestions.

  • The way SharePoint open office documents will differ if the user try to open them from the document library directly, or if users try to open the document from the search result page.

    I have a document library where I have uploaded an excel sheet to it. Now If I click on the excel sheet directly from the document library page , I will get the following error ““The webpage cannot be displayed””. While if I do a search and I open the excel
    sheet from the search result page , it will open the excel sheet using the excel services inside the browser !!.
    So can anyone advice on this ?
    Also if I have a PowerPoint document , and I try to open it from the document library I will get the following error “The webpage cannot be displayed” , and the URL will be prefix with the following “ms-powerpoint:ofv|u|”. while if i do a search and i open
    the PowerPoint from the search result page i will be prompted to either open or save the document ? So why SharePoint is reacting totally different when trying to open document library items from the document library Or from the search result page?

    Hi,
    The behavior in the document library could be probably because of the Documents handling setting. Please try setting it to default behavior (Open in browser) as i hear from you that the default behavior is to open from browser.
    Thanks, Suneetha
    Currently I have set the following;-
    1. On the library advance setting :- I define  “Open in the client application”
    2. On the web application setting:- I define stricked for Browser File Handling
    And I have noted if I delete the browser cache and I access the document , then I will be prompted with the download dialog. but if I re-click on the same document I will be redirected to the
    The webpage cannot be displayed
    And the ms-powerpoint:ofv|u| will be added to the beginning of the URL. So could this be a caching problem ?

  • How can I open a document with applescript without the doc. window opening.

    How can I open a document with applescript without opening the document window and speak the text of the document?  I can get it to open the file but the doc window always opens up. 

    try
              set pathToMyFolderOnDesktop to ("Macintosh HD:Users:jodyconnor:Desktop:") & "Dsource:" as alias
              set rnd to (random number from 1 to 6)
              set rndFileName to (rnd as text) & ".scpt"
              set FullPath to pathToMyFolderOnDesktop & rndFileName as text
              set myScript to load script (FullPath as alias)
      run script myScript
    on error the error_message number the error_number
              display dialog "Error: " & the error_number & ". " & the error_message buttons {"OK"} default button 1
              return
    end try
    This code answered my question:  Hats off to Digimonk from stackoverflow and Darrick Herewe from stackoverflow.

Maybe you are looking for