Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: HiView vs WindowRef and bitmaps



Hi Larry,

Using kHIViewWindowContentID didn't work, but to make a long story short, I have a solution.

I need a rectangle inside the window to draw on.  The window itself includes the title bar and the bit around the bottom where the edge isn't square.  So I made an HiView that sits inside the window, and this works nicely:  there's a window which has the metal finish with the bitmap inside it.  In the inspector, when i look at the HiView, x is set to 0 and y is set to 20.  Perhaps this explains the y offset.  The width and height seem to explain the top margin:  the width is the same as the window, and the height is 20 less than the enclosing window.  Apparently y in the inspector starts at the bottom, which seems to be true for some things but not others.

Then when I resize, (which I always do after creating it), it maintains the 'y' and the height difference in absolute pixels.

Solution:  Find out the difference in size of the view and the window, and resize accordingly

HIViewFindByID(HIViewGetRoot(window), kDartControlID, &dartView);


HIRect bounds;
Rect windContent;


HIViewGetBounds(dartView, &bounds);
GetWindowBounds (window, kWindowContentRgn, &windContent);


int heightDiff = (windContent.bottom - windContent.top) - (bounds.size.height);
r.bottom += heightDiff;
SetWindowBounds(window,kWindowContentRgn, &r);

The goal ws to get rid of the magic number 20 in my code, and this did it:  the heightDiff is 20.

--Daniel


On Jun 26, 2007, at 12:37 PM, Laurence Harris wrote:


On Jun 26, 2007, at 2:12 PM, Daniel Birns wrote:

HIViewFindByID( HIViewGetRoot(window), kHIViewWindowContentID, &contentView);

  As far as the dartview -- I believe what you're asking about is in the nib, and I believe it's bound to the edges.  All of this is new to me -- this is pretty much my only app, and this is all the graphics it does, so hence my uncertainties...

If dartView fills the content area of the window in the nib and is bound to the edges, then it should have the same dimensions as the content view. If that's not what you're seeing you might want to look at the nib to make sure it's set up the way you think it is.

Larry



Larry, this is great.  Sounds like I don't need dartview at all, no?

I can't give you a definitive answer without knowing exactly how you plan to use it, but probably not if all you're doing is using it to draw an image. An HIImageView might make more sense, though if you're using a CGImageRef. Still, if this is all the window has and you have to resize it after creation then creating it programmatically might make more sense that screwing around with a nib.

Larry


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden

References: 
 >HiView vs WindowRef and bitmaps (From: Daniel Birns <email@hidden>)
 >Re: HiView vs WindowRef and bitmaps (From: Laurence Harris <email@hidden>)
 >Re: HiView vs WindowRef and bitmaps (From: Daniel Birns <email@hidden>)
 >Re: HiView vs WindowRef and bitmaps (From: Laurence Harris <email@hidden>)
 >Re: HiView vs WindowRef and bitmaps (From: Daniel Birns <email@hidden>)
 >Re: HiView vs WindowRef and bitmaps (From: Laurence Harris <email@hidden>)
 >Re: HiView vs WindowRef and bitmaps (From: Daniel Birns <email@hidden>)
 >Re: HiView vs WindowRef and bitmaps (From: Laurence Harris <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.