Added an optimization that fixes a recursive paint problem when controls
are embedded in wxHTML (or other circumstances where the parent resizes the choice/combobox within a paint handler). This also speeds up addition of strings considerably (see "Add many strings" in widgets sample). Also added a check for silly values that can be returned from CB_GETDROPPEDCONTROLRECT. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38301 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -510,6 +510,16 @@ void wxChoice::DoSetSize(int x, int y,
|
|||||||
// the control including the drop down list while the height given to us
|
// the control including the drop down list while the height given to us
|
||||||
// is, of course, just the height of the permanently visible part of it
|
// is, of course, just the height of the permanently visible part of it
|
||||||
if ( height != wxDefaultCoord )
|
if ( height != wxDefaultCoord )
|
||||||
|
{
|
||||||
|
int w, h;
|
||||||
|
DoGetSize(&w, &h);
|
||||||
|
|
||||||
|
// Don't change the height if it's already this size
|
||||||
|
if (h == height)
|
||||||
|
{
|
||||||
|
height = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// don't make the drop down list too tall, arbitrarily limit it to 40
|
// don't make the drop down list too tall, arbitrarily limit it to 40
|
||||||
// items max and also don't leave it empty
|
// items max and also don't leave it empty
|
||||||
@@ -523,6 +533,7 @@ void wxChoice::DoSetSize(int x, int y,
|
|||||||
const int hItem = SendMessage(GetHwnd(), CB_GETITEMHEIGHT, 0, 0);
|
const int hItem = SendMessage(GetHwnd(), CB_GETITEMHEIGHT, 0, 0);
|
||||||
height += hItem*(nItems + 1);
|
height += hItem*(nItems + 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// We cannot pass wxDefaultCoord as height to wxControl. wxControl uses
|
// We cannot pass wxDefaultCoord as height to wxControl. wxControl uses
|
||||||
@@ -535,7 +546,7 @@ void wxChoice::DoSetSize(int x, int y,
|
|||||||
int w, h;
|
int w, h;
|
||||||
RECT r;
|
RECT r;
|
||||||
DoGetSize(&w, &h);
|
DoGetSize(&w, &h);
|
||||||
if (::SendMessage(GetHwnd(), CB_GETDROPPEDCONTROLRECT, 0, (LPARAM) &r) != 0)
|
if (::SendMessage(GetHwnd(), CB_GETDROPPEDCONTROLRECT, 0, (LPARAM) &r) != 0 && r.bottom < 30000)
|
||||||
{
|
{
|
||||||
height = h + r.bottom - r.top;
|
height = h + r.bottom - r.top;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user