How to handle the width of borders

For most of my widgets I use wx.SUNKEN_BORDER. I've noticed that
because of the border, the actual window size is a bit smaller, by
some set amount of pixels. I understand that any DC attached to the
window automatically knows not to touch the borders, and can only draw
in the are inside the borders. Is this true?

And the important question: Can I rely on the width of the borders to
be exactly the same across all OSes?

Ram.

Hi,

For most of my widgets I use wx.SUNKEN_BORDER. I've noticed that
because of the border, the actual window size is a bit smaller, by
some set amount of pixels. I understand that any DC attached to the
window automatically knows not to touch the borders, and can only draw
in the are inside the borders. Is this true?

The border should be part of the non client area of the window. If you are drawing with in the ClientRect it should be fine.

And the important question: Can I rely on the width of the borders to
be exactly the same across all OSes?

No, you shouldn't make assumptions like this.

Cody

···

On Apr 2, 2010, at 5:09 AM, cool-RR wrote:

Hi,

For most of my widgets I use wx.SUNKEN_BORDER. I’ve noticed that

because of the border, the actual window size is a bit smaller, by

some set amount of pixels. I understand that any DC attached to the

window automatically knows not to touch the borders, and can only draw

in the are inside the borders. Is this true?

The border should be part of the non client area of the window. If you are drawing with in the ClientRect it should be fine.

I have no idea what a ClientRect is. I draw on a DC, and I start my drawings from (0, 0). Is this okay? Does (0, 0) get mapped to the inner (0, 0), instead of on the border?

And the important question: Can I rely on the width of the borders to

be exactly the same across all OSes?

No, you shouldn’t make assumptions like this.

When I draw I must know the exact size of the drawable area, regardless of OS. How can I know this?

Ram.

···

On Fri, Apr 2, 2010 at 2:08 PM, Cody Precord codyprecord@gmail.com wrote:

On Apr 2, 2010, at 5:09 AM, cool-RR wrote:

    Hi,

        For most of my widgets I use wx.SUNKEN_BORDER. I've noticed that
        because of the border, the actual window size is a bit smaller, by
        some set amount of pixels. I understand that any DC attached to the
        window automatically knows not to touch the borders, and can
        only draw
        in the are inside the borders. Is this true?

    The border should be part of the non client area of the window. If
    you are drawing with in the ClientRect it should be fine.

I have no idea what a ClientRect is.

The client area of a window is the space inside of any decorations that is usable for drawing or placement of child widgets. The upper-left point of the client area has coordinant (0,0) and GetClientSize will let you know how much space you have to use inside that client area of the window. GetClientAreaOrigin can be used to know how much (0,0) is offset from the real upper-left of the window, or GetWindowBorderSize will give you the width of the top/bottom and left/right borders.

I draw on a DC, and I start my
drawings from (0, 0). Is this okay? Does (0, 0) get mapped to the inner
(0, 0), instead of on the border?

Yep. And if you just use the size that the DC reports itself to be then you should always be within the borders.

        And the important question: Can I rely on the width of the
        borders to
        be exactly the same across all OSes?

    No, you shouldn't make assumptions like this.

When I draw I must know the exact size of the drawable area, regardless
of OS. How can I know this?

See above.

···

On 4/2/10 5:14 AM, cool-RR wrote:

On Fri, Apr 2, 2010 at 2:08 PM, Cody Precord <codyprecord@gmail.com > <mailto:codyprecord@gmail.com>> wrote:
    On Apr 2, 2010, at 5:09 AM, cool-RR wrote:

--
Robin Dunn
Software Craftsman

Thanks, using GetWindowBorderSize will allow me to simplify my code a bit.

Also: Does GetClientSize give the same answer as ClientRect, but in a different format?

Ram.

···

On Fri, Apr 2, 2010 at 7:35 PM, Robin Dunn robin@alldunn.com wrote:

On 4/2/10 5:14 AM, cool-RR wrote:

On Fri, Apr 2, 2010 at 2:08 PM, Cody Precord <codyprecord@gmail.com > > mailto:codyprecord@gmail.com> wrote:

Hi,



On Apr 2, 2010, at 5:09 AM, cool-RR wrote:


The border should be part of the non client area of the window. If

you are drawing with in the ClientRect it should be fine.

I have no idea what a ClientRect is.

The client area of a window is the space inside of any decorations that is usable for drawing or placement of child widgets. The upper-left point of the client area has coordinant (0,0) and GetClientSize will let you know how much space you have to use inside that client area of the window. GetClientAreaOrigin can be used to know how much (0,0) is offset from the real upper-left of the window, or GetWindowBorderSize will give you the width of the top/bottom and left/right borders.

Hey, I used GetClientAreaOrigin and got wx.Point(0, 0) on a panel with SUNKEN_BORDER! What’s going on?

···

On Fri, Apr 2, 2010 at 7:40 PM, cool-RR cool-rr@cool-rr.com wrote:

On Fri, Apr 2, 2010 at 7:35 PM, Robin Dunn robin@alldunn.com wrote:

On 4/2/10 5:14 AM, cool-RR wrote:

On Fri, Apr 2, 2010 at 2:08 PM, Cody Precord <codyprecord@gmail.com > > > mailto:codyprecord@gmail.com> wrote:

Hi,



On Apr 2, 2010, at 5:09 AM, cool-RR wrote:

The border should be part of the non client area of the window. If

you are drawing with in the ClientRect it should be fine.

I have no idea what a ClientRect is.

The client area of a window is the space inside of any decorations that is usable for drawing or placement of child widgets. The upper-left point of the client area has coordinant (0,0) and GetClientSize will let you know how much space you have to use inside that client area of the window. GetClientAreaOrigin can be used to know how much (0,0) is offset from the real upper-left of the window, or GetWindowBorderSize will give you the width of the top/bottom and left/right borders.

Thanks, using GetWindowBorderSize will allow me to simplify my code a bit.

Also: Does GetClientSize give the same answer as ClientRect, but in a different format?

Ram.


Sincerely,
Ram Rachum