Skip navigation.
 
mlQuartz HIViewConvertRect() then to QuickDraw...
FROM : Gary Sommer
DATE : Sun Nov 28 08:21:43 2004

I am using compositing for a nib-based window in OS X 10.3.  I am
trying to convert the bounds of an HIView to QuickDraw coordinates so I
can use a Rect (as opposed to an HIRect) to tell a QuickTime component
where it's bounds are to display a movie (actually a sequence grabber's
channel bounds).  So, I want to do something like this:
  Get the bounds for the HIView
  Convert it's coordinates to be relative to the window it is in
  Convert that HIRect to a Quickdraw Rect

However, when I do, I end up with a Rect that is shifted right and
down.  Can anyone give me the piece I'm missing (which is why it is
shifted)?.  Here is some chopped up source to try to better explain:

   GetPort( &savePort );
   SetPort( GetWindowPort( myWindowRef ) );

   //Get bounds of HIView, origin will be 0, 0 (relative to itself)
   HIRect    myHIRect;
   (void) HIViewGetBounds( MyHIViewRef, &myHIRect );

   //Convert HIRect to be relative to the window
   (void) HIViewConvertRect( &myHIRect, MyHIViewRef, NULL );

   //Convert Quartz HIRect to Quickdraw Rect
   Rect    qdRect;
   SetRect( &qdRect, (short)myHIRect.origin.x, (short)myHIRect.origin.y,
           (short)(myHIRect.origin.x + myHIRect.size.width),
           (short)(myHIRect.origin.y + myHIRect.size.height) );

   //IF I DO SOMETHING LIKE THIS, RECT DRAWN TO THE RIGHT & LOWER THAN
EXPECTED
   FrameRect( & qdRect );

   SetPort( savePort );


Thank you,
Gary

Related mailsAuthorDate
mlQuartz HIViewConvertRect() then to QuickDraw... Gary Sommer Nov 28, 08:21
mlRe: Quartz HIViewConvertRect() then to QuickDraw... David Dunham Nov 29, 06:50