Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: HiView vs WindowRef and bitmaps
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: HiView vs WindowRef and bitmaps




On Jun 27, 2007, at 2:38 PM, Daniel Birns wrote:


On Jun 27, 2007, at 11:28 AM, Laurence Harris wrote:


On Jun 27, 2007, at 1:46 PM, Daniel Birns wrote:

Hi Larry,

Using kHIViewWindowContentID didn't work,

What do you mean, it didn't work? It definitely works to get the content view.

Yes, but when I draw to it, I don't see it. Yes, that's probably because I'm not sure what I'm doing. But when I draw to the HiView that's in the nib, it shows.

The concept is valid, so I'm not sure why you aren't seeing the results. When are you drawing? In a kEventControlDraw handler you've installed on the content view?


There's almost certainly a good reason why this isn't showing, but I remembered that one reason I made the HiView in the first place is that it placed the graphics where I want them on the window.

I thought you wanted them to fill the content area.

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.

Which y? You really need to be more specific when you post. Vague statements are rarely useful.

Fair enough, though I've only seen one in the inspector. to find it, I click on the HiView, and then in the inspector, I choose Size at the top, and then Layout Rect, and then bottom/left, width/ height, and the bottom left are the y and x. Is there another X and Y in the inspector?

There's the popup's Top/Left option in IB, and values you can obtain programmatically. But if you want it to fill the window, all you need to do is drag it to the top left corner and let IB snap it to the corner, then do the same thing with the resize box in the lower right corner.


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.

This doesn't really seem like a good solution IMO, because, you don't really understand what you've solved, you just found something that works.



Criticism taken although I *think* I understand what I've solved: I need the HiView for a variety of reasons, and that view is a different size than the window.

Different size than the content view?

I need the window to be an appropriate size so that the HiView is the size I need for the image to have the original size and aspect ratio.

The content view is an HIViewRef. In the above code, what are the bounds of the content view? Are the height and width the same as the results of GetWindowBounds (window, kWindowContentRgn,...)?


BTW, it's old school, but have you tried SetWindowSize using the size of the image?

Larry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
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>)
 >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>)



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

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.