[...]
There's not an actual problem here with .NET. The only issue is that
you
need to comprehend the API differently. Once you understand that
coordinates you provide don't refer to pixels, but rather to the grid
between pixels, everything makes sense.
If you don't understand that, then yes...you'll continue to believe a
problem exists, even though none does.
Pete
I know there is a method DrawRectangle(), but I was talking about a
property that describe the ACTUAL painting region.
The relationship between ClientRectangle, DisplayRectangle, etc. and the
visible area of the control is very well defined. Because of the way the
_graphical_ API works, it's true that those rectangles can't be passed
directly to the graphical API if you want to draw a line that is contained
within that area. But they do exactly describe the actual painting region
itself.
In the same units,
or relationship, as the method is going to use it. What use have I for
a description of an area I have to adjust before using?
I'm sorry you don't see the use for ClientRectangle, etc. Suffice to say,
those properties are in fact very useful, and if they behaved differently,
they wouldn't be.
Why provide me
with measurements that are close to what I need, but don't finally
describe the area I want?
Because the rectangle you get _is_ an exact description of the Control
instance. It would be far worse to have a ClientRectangle return (for
example) a rectangle that's only 639 pixels wide by 479 pixels high when
the control is actually 640 pixels wide by 480 pixels high.
As things are now, the rectangle you get is exactly correct. You would
prefer that it be wrong just for your convenience in one specific scenario?
There are no fewer than four rectangles that
describe areas one pixel larger than the Displayed area of a control.
You're incorrect that they "describe areas one pixel larger than the
displayed area of a control". They describe an area _exactly_ the same
size as the displayed area of the control. It's just that the graphical
API always fills pixels to the right and left of whatever grid coordinates
you've specified.
If your control tells you that the ClientRectangle is 100 pixels wide,
then if you count the pixels on the screen you will find there are exactly
100 pixels of width there. Not 101. And definitely not 99. Exactly 100
pixels.
You mean to tell me they couldn't find it in their hearts to provide
one single property that depicts the ACTUAL area that methods like
DrawRectangle() are expecting? It doesn't seem like that big a deal.
Well, I'm sorry you aren't able to see that it's a big deal, but it is.
Those properties must describe the actual size of the Control precisely.
It would be wrong for them to return a rectangle that's one pixel smaller
in width and height than the control actually is.
At the same time, it's inappropriate for the graphical API to sometimes
fill pixels inside the description of a shape and sometimes fill pixels
outside the description of a shape. That API needs to be consistent, and
if it did what you apparently would prefer it did, it wouldn't be. For
example, you can think of a rectangle as four lines. But if a rectangle
got drawn inside the boundary specified by the rectangle, rather than just
following the lines defined by the rectangle and drawing it the same way
as any other line, you wouldn't be able to get the same results drawing
the individual lines as you get drawing the rectangle itself.
This would be really bad. It's critical that a graphical API not have
inconsistencies like this. There's a very good reason that all of the
major graphical APIs, including all of Apple's Quickdraw iterations along
with Carbon and Cocoa, all of the Windows graphical APIs, Java, etc.
behave exactly this way. It's a mathematically pure, consistent API that
allows a developer to produce reliable results.
Is it really that big of a deal to have to subtract your pen size (one
pixel by default, of course) from the width and height of the rectangle
you want to be visible? It seems to me that you could easily write a
short method that handles this for you, if you really find it that hard to
just do it explicitly when needed.
Pete