X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e94e2e952b3bde7f2d456e10a12589a80185407d..3c5487b14442ddbc6e43ee2f4475b5a6ba251fb1:/src/mac/carbon/combobox.cpp?ds=inline diff --git a/src/mac/carbon/combobox.cpp b/src/mac/carbon/combobox.cpp index 5a911361cf..f158ee702e 100644 --- a/src/mac/carbon/combobox.cpp +++ b/src/mac/carbon/combobox.cpp @@ -40,7 +40,11 @@ MenuHandle NewUniqueMenu() // the margin between the text control and the choice static const wxCoord MARGIN = 2; +#if TARGET_API_MAC_OSX +static const int POPUPWIDTH = 24; +#else static const int POPUPWIDTH = 18; +#endif static const int POPUPHEIGHT = 23; @@ -55,6 +59,9 @@ public: : wxTextCtrl( cb , 1 ) { m_cb = cb; + + // remove the default minsize, the combobox will have one instead + SetSizeHints(-1,-1); } protected: @@ -135,6 +142,9 @@ public: : wxChoice( cb , 1 ) { m_cb = cb; + + // remove the default minsize, the combobox will have one instead + SetSizeHints(-1,-1); } protected: @@ -149,6 +159,13 @@ protected: event2.SetString(m_cb->GetStringSelection()); m_cb->ProcessCommand(event2); } + virtual wxSize DoGetBestSize() const + { + wxSize sz = wxChoice::DoGetBestSize() ; + if (! m_cb->HasFlag(wxCB_READONLY) ) + sz.x = POPUPWIDTH; + return sz ; + } private: wxComboBox *m_cb; @@ -204,7 +221,9 @@ void wxComboBox::DoMoveWindow(int x, int y, int width, int height) { if ( m_text == NULL ) { - m_choice->SetSize(0, 0 , width, -1); + // we might not be fully constructed yet, therefore watch out... + if ( m_choice ) + m_choice->SetSize(0, 0 , width, -1); } else { @@ -256,6 +275,22 @@ void wxComboBox::DelegateChoice( const wxString& value ) } +bool wxComboBox::Create(wxWindow *parent, wxWindowID id, + const wxString& value, + const wxPoint& pos, + const wxSize& size, + const wxArrayString& choices, + long style, + const wxValidator& validator, + const wxString& name) +{ + wxCArrayString chs( choices ); + + return Create( parent, id, value, pos, size, chs.GetCount(), + chs.GetStrings(), style, validator, name ); +} + + bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value, const wxPoint& pos, @@ -272,7 +307,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, } m_choice = new wxComboBoxChoice(this, style ); - + m_choice->SetSizeHints( wxSize( POPUPWIDTH , POPUPHEIGHT ) ) ; wxSize csize = size; if ( style & wxCB_READONLY ) { @@ -293,6 +328,8 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, m_choice->DoAppend( choices[ i ] ); } + SetBestSize(csize); // Needed because it is a wxControlWithItems + return TRUE; } @@ -312,6 +349,11 @@ wxString wxComboBox::GetValue() const return result; } +int wxComboBox::GetCount() const +{ + return m_choice->GetCount() ; +} + void wxComboBox::SetValue(const wxString& value) { int s = FindString (value); @@ -513,12 +555,13 @@ void wxComboBox::SetString(int n, const wxString& s) } -void wxComboBox::MacHandleControlClick( WXWidget WXUNUSED(control) , wxInt16 WXUNUSED(controlpart) , bool WXUNUSED(mouseStillDown)) +wxInt32 wxComboBox::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) ) { wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, m_windowId ); event.SetInt(GetSelection()); event.SetEventObject(this); event.SetString(GetStringSelection()); ProcessCommand(event); + return noErr ; }