Reverted wxChoice size fix due to problems in W2K and below

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38442 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2006-03-30 09:21:11 +00:00
parent ccd34c944d
commit d4445d24d3
2 changed files with 40 additions and 22 deletions

View File

@@ -155,7 +155,7 @@ wxMSW:
- wxDisplay doesn't require multimon.h now and is enabled by default (Olly Betts).
- Fixed wxChoice/wxComboBox slow appending and infinite recursion
if its size is set within a paint handler (for example when embedded in a
wxHtmlWindow).
wxHtmlWindow). [Now reverted due to problems in W2K and below.]
wxGTK:

View File

@@ -504,8 +504,46 @@ void wxChoice::DoSetSize(int x, int y,
int width, int height,
int sizeFlags)
{
int heightOrig = height;
// the height which we must pass to Windows should be the total height of
// 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
if ( height != wxDefaultCoord )
{
// don't make the drop down list too tall, arbitrarily limit it to 40
// items max and also don't leave it empty
size_t nItems = GetCount();
if ( !nItems )
nItems = 9;
else if ( nItems > 24 )
nItems = 24;
// add space for the drop down list
const int hItem = SendMessage(GetHwnd(), CB_GETITEMHEIGHT, 0, 0);
height += hItem*(nItems + 1);
}
else
{
// We cannot pass wxDefaultCoord as height to wxControl. wxControl uses
// wxGetWindowRect() to determine the current height of the combobox,
// and then again sets the combobox's height to that value. Unfortunately,
// wxGetWindowRect doesn't include the dropdown list's height (at least
// on Win2K), so this would result in a combobox with dropdown height of
// 1 pixel. We have to determine the default height ourselves and call
// wxControl with that value instead.
int w, h;
RECT r;
DoGetSize(&w, &h);
if (::SendMessage(GetHwnd(), CB_GETDROPPEDCONTROLRECT, 0, (LPARAM) &r) != 0)
{
height = h + r.bottom - r.top;
}
}
wxControl::DoSetSize(x, y, width, height, sizeFlags);
// This solution works on XP, but causes choice/combobox lists to be
// too short on W2K and earlier.
#if 0
int widthCurrent, heightCurrent;
DoGetSize(&widthCurrent, &heightCurrent);
@@ -568,26 +606,6 @@ void wxChoice::DoSetSize(int x, int y,
}
wxControl::DoSetSize(x, y, width, height, sizeFlags);
// I'm commenting this out since the code appears to make choices
// and comboxes too high when they have associated sizers. I'm sure this
// is not the end of the story, which is why I'm leaving it #if'ed out for
// now. JACS.
#if 0
// if the height specified for the visible part of the control is
// different from the current one, we need to change it separately
// as it is not affected by normal WM_SETSIZE
if ( height != wxDefaultCoord )
{
const int delta = heightOrig - GetSize().y;
if ( delta )
{
int h = ::SendMessage(GetHwnd(), CB_GETITEMHEIGHT, (WPARAM)-1, 0);
SendMessage(GetHwnd(), CB_SETITEMHEIGHT, (WPARAM)-1, h + delta);
}
}
#else
wxUnusedVar(heightOrig);
#endif
}