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.