+ //
+ // Ignore height parameter because height doesn't mean 'initially
+ // displayed' height, it refers to the drop-down menu as well. The
+ // wxWidgets interpretation is different; also, getting the size returns
+ // the _displayed_ size (NOT the drop down menu size) so
+ // setting-getting-setting size would not work.
+ //
+ wxControl::DoSetSize( nX
+ ,nY
+ ,nWidth
+ ,wxDefaultCoord
+ ,nSizeFlags
+ );
+} // end of wxChoice::DoSetSize
+
+wxSize wxChoice::DoGetBestSize() const
+{
+ //
+ // Find the widest string
+ //
+ int nLineWidth;
+ int nChoiceWidth = 0;
+ int nCx;
+ int nCy;
+ wxFont vFont = (wxFont)GetFont();
+
+ const unsigned int nItems = GetCount();
+
+ for (unsigned int i = 0; i < nItems; i++)
+ {
+ wxString sStr(GetString(i));
+ GetTextExtent( sStr, &nLineWidth, NULL );
+ if (nLineWidth > nChoiceWidth)
+ nChoiceWidth = nLineWidth;
+ }
+
+ //
+ // Give it some reasonable default value if there are no strings in the
+ // list
+ //
+ if (nChoiceWidth == 0L)
+ nChoiceWidth = 100L;
+
+ //
+ // The combobox should be larger than the widest string
+ //
+ wxGetCharSize( GetHWND(), &nCx, &nCy, &vFont );
+ nChoiceWidth += 5 * nCx;
+
+ //
+ // Choice drop-down list depends on number of items (limited to 10)
+ //
+ size_t nStrings = nItems == 0 ? 10 : wxMin(10, nItems) + 1;
+ int nChoiceHeight = EDIT_HEIGHT_FROM_CHAR_HEIGHT(nCy) * nStrings;
+
+ return wxSize(nChoiceWidth, nChoiceHeight);
+} // end of wxChoice::DoGetBestSize
+
+MRESULT wxChoice::OS2WindowProc(
+ WXUINT uMsg
+, WXWPARAM wParam
+, WXLPARAM lParam
+)
+{
+ return wxWindow::OS2WindowProc( uMsg
+ ,wParam
+ ,lParam
+ );
+} // end of wxChoice::OS2WindowProc
+
+bool wxChoice::OS2Command(
+ WXUINT uParam
+, WXWORD WXUNUSED(wId)
+)
+{
+ if (uParam != LN_SELECT)
+ {
+ //
+ // "selection changed" is the only event we're after
+ //
+ return false;
+ }
+ int n = GetSelection();
+
+ if (n > -1)
+ {
+ wxCommandEvent vEvent( wxEVT_COMMAND_CHOICE_SELECTED
+ ,m_windowId
+ );
+
+ vEvent.SetInt(n);
+ vEvent.SetEventObject(this);
+ vEvent.SetString(GetStringSelection());
+ if (HasClientObjectData())
+ vEvent.SetClientObject(GetClientObject(n));
+ else if (HasClientUntypedData())
+ vEvent.SetClientData(GetClientData(n));
+ ProcessCommand(vEvent);
+ }
+ return true;
+} // end of wxChoice::OS2Command