[ wxwindows-Bugs-1730157 ] wxWindow::DoSetSize() not documented

SourceForge.net noreply at sourceforge.net
Sun Jun 3 07:58:19 PDT 2007


Bugs item #1730157, was opened at 2007-06-03 10:26
Message generated for change (Comment added) made by giles314
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1730157&group_id=9863

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: Must fix
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Giles (giles314)
Assigned to: Nobody/Anonymous (nobody)
Summary: wxWindow::DoSetSize() not documented

Initial Comment:
You need to redefine the virtual wxWindow::DoSetSize() when you are creating a custom control that is to be managed by a sizer. But it is not described in the documentation.

----------------------------------------------------------------------

>Comment By: Giles (giles314)
Date: 2007-06-03 16:58

Message:
Logged In: YES 
user_id=1675490
Originator: YES

GetBestSize may need also to be overloaded if it was a virtual method. But
it is not. The actual method to overload is DoGetBestSize. This time it is
clear as only one of the 2 is virtual. The fact that the SetSize and
DoSetSize are both virtual makes it more complex.

If I take a simple example of a control that is a wxTextCtrl you want to
display with an additional 2 pixels width border, you will overload the
DoGetBestSize by adding 4 pixels in both direction to the result of the
base class function.
And in DoSetSize you will offset by 2 the coordinates and reduce by 4 the
size you pass to the base class function (for the coordinates that are
different from wxDefaultCoor).

----------------------------------------------------------------------

Comment By: Robert Roebling (roebling)
Date: 2007-06-03 16:17

Message:
Logged In: YES 
user_id=77100
Originator: NO

> I was overloading SetSize as described by the documentation

That is probably an error in the docs. I don't see why you'd
have to overrride any SetSize() or DoSetSize() method. If
you really have to override any, then indeed DoSetSize().
What goes wrong if you don't overrride at all? BTW, what you
should override is GetBestSize()



----------------------------------------------------------------------

Comment By: Giles (giles314)
Date: 2007-06-03 11:35

Message:
Logged In: YES 
user_id=1675490
Originator: YES

I was overloading SetSize as described by the documentation and when the
sizer tries to place the object this function is not called. So my control
perform the resizing as defined by its subclass instead of doing the
customized resizing. The sizer calls DoSetSize. So I realize you need not
overload SetSize and instead overload DoSetSize to have a custom resizing.

I got a confirmation of my hypothesis in wx/windows.h. Below an extract of
this file:

    // this is the virtual function to be overriden in any derived class
which
    // wants to change how SetSize() or Move() works - it is called by
all
    // versions of these functions in the base class
    virtual void DoSetSize(int x, int y,
                           int width, int height,
                           int sizeFlags = wxSIZE_AUTO) = 0;


----------------------------------------------------------------------

Comment By: Robert Roebling (roebling)
Date: 2007-06-03 10:45

Message:
Logged In: YES 
user_id=77100
Originator: NO

There is no need to redefine wxWindow::DoSetSize(). What makes you think
it is?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1730157&group_id=9863




More information about the wx-dev mailing list