+bool wxChoice::Create(wxWindow *parent,
+ wxWindowID id,
+ const wxPoint& pos,
+ const wxSize& size,
+ const wxArrayString& choices,
+ long style,
+ const wxValidator& validator,
+ const wxString& name)
+{
+ wxCArrayString chs(choices);
+ return Create(parent, id, pos, size, chs.GetCount(), chs.GetStrings(),
+ style, validator, name);
+}
+
+bool wxChoice::MSWShouldPreProcessMessage(WXMSG *pMsg)
+{
+ MSG *msg = (MSG *) pMsg;
+
+ // if the dropdown list is visible, don't preprocess certain keys
+ if ( msg->message == WM_KEYDOWN
+ && (msg->wParam == VK_ESCAPE || msg->wParam == VK_RETURN) )
+ {
+ if (::SendMessage(GetHwndOf(this), CB_GETDROPPEDSTATE, 0, 0))
+ {
+ return false;
+ }
+ }
+
+ return wxControl::MSWShouldPreProcessMessage(pMsg);
+}
+
+WXDWORD wxChoice::MSWGetStyle(long style, WXDWORD *exstyle) const
+{
+ // we never have an external border
+ WXDWORD msStyle = wxControl::MSWGetStyle
+ (
+ (style & ~wxBORDER_MASK) | wxBORDER_NONE, exstyle
+ );
+
+ // WS_CLIPSIBLINGS is useful with wxChoice and doesn't seem to result in
+ // any problems
+ msStyle |= WS_CLIPSIBLINGS;
+
+ // wxChoice-specific styles
+ msStyle |= CBS_DROPDOWNLIST | WS_HSCROLL | WS_VSCROLL;
+ if ( style & wxCB_SORT )
+ msStyle |= CBS_SORT;
+
+ return msStyle;
+}
+
+#ifndef EP_EDITTEXT
+ #define EP_EDITTEXT 1
+ #define ETS_NORMAL 1
+#endif
+
+wxVisualAttributes
+wxChoice::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+ // it is important to return valid values for all attributes from here,
+ // GetXXX() below rely on this
+ wxVisualAttributes attrs;
+
+ // FIXME: Use better dummy window?
+ wxWindow* wnd = wxTheApp->GetTopWindow();
+ if (!wnd)
+ return attrs;
+
+ attrs.font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
+
+ // there doesn't seem to be any way to get the text colour using themes
+ // API: TMT_TEXTCOLOR doesn't work neither for EDIT nor COMBOBOX
+ attrs.colFg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
+
+ // NB: use EDIT, not COMBOBOX (the latter works in XP but not Vista)
+ attrs.colBg = wnd->MSWGetThemeColour(L"EDIT",
+ EP_EDITTEXT,
+ ETS_NORMAL,
+ ThemeColourBackground,
+ wxSYS_COLOUR_WINDOW);
+
+ return attrs;