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




I see where you set the size of the window with SetWindowBounds. How is the size of dartView set? Is it bound to the edges of the window? Have you considered just using the content view directly instead of adding an additional view? You can install handlers for events like kEventControlDraw on the content view itself.


Larry,

This sounds like what I need. How do I get the content view? 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...

--Daniel

Larry

 Here's some code that shows it:

			HIViewGetBounds(dartView, &cgRect);
			Rect windContent;

if (GetWindowBounds (window, kWindowContentRgn, &windContent))
printf("GetWindowBounds failed\n");
printf("TESTING %f/%f == %d/%d\n",
cgRect.size.width, cgRect.size.height,
windContent.right - windContent.left, windContent.bottom - windContent.top);




And the output is:

	TESTING 340.000000/580.000000 == 340/600

To summarize the problem: I need to display a bitmap that's 340/600. I use SetWindowBounds() to do this, but I the View inside that window is 340/580.

We found the problem because of mouse events: everything seemed to work, because the HiView was scaling my 340/600 bitmap into the 340/580 view. The problem showed up with the mouse, which said I was at bit 580 when I was at the right-hand side, instead of bit 600.

--Daniel

On Jun 26, 2007, at 1:10 AM, Laurence Harris wrote:


On Jun 25, 2007, at 9:04 PM, Daniel Birns wrote:

Hi all,

Our product maintains its own bitmap of everything that appears to the screen.

So you have a screen capture? The bitmap is the size of the display?

Therefore the only functionality we need is to associate our bitmap with a screen, and have it update rectangles of that bitmap.

Currently we're doing this with (roughly)

CreateWindowFromNib(...)
SetWindowBounds(window,kWindowContentRgn, ...)

HIViewFindByID(HIViewGetRoot(window), ...)
HIViewSetNeedsDisplayInRect()

that is, there's an HiView control embedded in the main window, and we use that for the bitmap.

Why not just use the content view itself?

All that works great. There's one problem: we deal with pixels and must have the pixels of the screen "line up" with our bitmap. We don't want any scaling.

After creating the window, I size it depending on the bitmap size we're working with: it changes with each CreateWindow call we make.

If I give it a w/h of 400/400, the size of the HiView control is exactly 400/380: the height of the HiView is exactly 20 pixels smaller than the height of the containing ContentRgn window.

There is no "ContentRgn window." Every window has a content region. To what "HiView control" do you refer? (And for what it's worth, you can just call it a view. You don't need to call it a control, as an HIViewRef == ControlRef.)


There isn't enough information here (at least not for me) because you've left too much out of your code above. It sounds like you're confusing the structure and content regions, which for a standard document window in Mac OS X would be the same except for the title bar region, which I believe is 20 pixels high.

If I add 20 to the height of the original SetWindowBounds call, I get what I want, but this is surely not a good way to approach this.

I could use some advice.

The first thing I'd advise is that you provide complete statements from your code so we know exactly what you're doing. Empty parentheses and ellipses where there should be parameters may allow you to type faster, but I can't tell what you're doing.


Also, why are you using a nib instead of just creating the window programmatically the size you need it?

Larry

It seems like I could code it all without using the HiView, but there's so much there I rely on, including all the input events. And I also like the xxxNeedsDisplayxxx() interface, which makes our coding much simpler.

Any help is appreciated.

Thanks.



_______________________________________________ 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>)



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.