#include "wx/clipbrd.h"
#include "wx/msw/private.h"
-#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl)
-#endif
bool wxComboBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
{
- if (param == CBN_SELCHANGE)
- {
- if (GetSelection() > -1)
+ switch ( param )
{
- wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, m_windowId);
- event.SetInt(GetSelection());
- event.SetEventObject(this);
- event.SetString(GetStringSelection());
- ProcessCommand(event);
+ case CBN_SELCHANGE:
+ if (GetSelection() > -1)
+ {
+ wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, GetId());
+ event.SetInt(GetSelection());
+ event.SetEventObject(this);
+ event.SetString(GetStringSelection());
+ ProcessCommand(event);
+ }
+ break;
+
+ case CBN_EDITCHANGE:
+ {
+ wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, GetId());
+ event.SetString(GetValue());
+ event.SetEventObject(this);
+ ProcessCommand(event);
+ }
+ break;
}
- return TRUE;
- }
- else if (param == CBN_EDITCHANGE)
- {
- wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId);
- event.SetString(GetValue());
- event.SetEventObject(this);
- ProcessCommand(event);
-
- return TRUE;
- }
- else
- return FALSE;
+ // there is no return value for the CBN_ notifications, so always return
+ // FALSE from here to pass the message to DefWindowProc()
+ return FALSE;
}
bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
const wxString& name)
{
SetName(name);
+#if wxUSE_VALIDATORS
SetValidator(validator);
+#endif // wxUSE_VALIDATORS
if (parent) parent->AddChild(this);
// SetBackgroundColour(parent->GetBackgroundColour()) ;
int width = size.x;
int height = size.y;
- long msStyle = WS_CHILD | WS_TABSTOP | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL |
- CBS_NOINTEGRALHEIGHT;
+ long msStyle = WS_CHILD | WS_TABSTOP | WS_VISIBLE |
+ WS_VSCROLL | WS_HSCROLL | CBS_AUTOHSCROLL | CBS_NOINTEGRALHEIGHT;
if (m_windowStyle & wxCB_READONLY)
msStyle |= CBS_DROPDOWNLIST;
#endif
}
-void wxComboBox::DoSetSize(int x, int y,
- int width, int height,
- int sizeFlags)
+void wxComboBox::DoMoveWindow(int x, int y, int width, int height)
{
- wxControl::DoSetSize(x, y, width, height, sizeFlags);
+ int cx, cy;
+ wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());
+
+ // what should the height of the drop down list be? we choose 10 items by
+ // default and also 10 items max (if we always use n, the list will never
+ // have vertical scrollbar)
+ int n = GetCount();
+ if ( !n )
+ n = 10;
+ else if ( n > 10 )
+ n = 10;
+
+ height = n * EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
+
+ wxControl::DoMoveWindow(x, y, width, height);
+}
+
+wxSize wxComboBox::DoGetBestSize() const
+{
+ // the choice calculates the horz size correctly, but not the vertical
+ // component: correct it
+ wxSize size = wxChoice::DoGetBestSize();
+
+ int cx, cy;
+ wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());
+ size.y = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
+
+ return size;
}
#endif