X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/aa61d3525370a9b9fa8c797d9b7f89d96994db5f..1c62bcbeeb1f0f7fafc72544acc7d9caf1d0df1d:/src/mac/carbon/combobox.cpp diff --git a/src/mac/carbon/combobox.cpp b/src/mac/carbon/combobox.cpp index 38ff2771cb..6a155d9636 100644 --- a/src/mac/carbon/combobox.cpp +++ b/src/mac/carbon/combobox.cpp @@ -14,14 +14,19 @@ #if wxUSE_COMBOBOX #include "wx/combobox.h" -#include "wx/button.h" -#include "wx/menu.h" -#include "wx/containr.h" + +#ifndef WX_PRECOMP + #include "wx/button.h" + #include "wx/menu.h" + #include "wx/containr.h" + #include "wx/toplevel.h" +#endif + #include "wx/mac/uma.h" IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl) -WX_DELEGATE_TO_CONTROL_CONTAINER(wxComboBox) +WX_DELEGATE_TO_CONTROL_CONTAINER(wxComboBox, wxControl) BEGIN_EVENT_TABLE(wxComboBox, wxControl) WX_EVENT_TABLE_CONTROL_CONTAINER(wxComboBox) @@ -32,7 +37,7 @@ static int nextPopUpMenuId = 1000 ; MenuHandle NewUniqueMenu() { - MenuHandle handle = NewMenu( nextPopUpMenuId , "\pMenu" ) ; + MenuHandle handle = UMANewMenu(nextPopUpMenuId, wxString(wxT("Menu")), wxFont::GetDefaultEncoding() ); nextPopUpMenuId++ ; return handle ; @@ -54,7 +59,6 @@ static const int TEXTFOCUSBORDER = 3 ; static const wxCoord MARGIN = 2; static const int TEXTFOCUSBORDER = 0 ; #endif -static const int POPUPHEIGHT = 23; // ---------------------------------------------------------------------------- @@ -68,6 +72,7 @@ public: : wxTextCtrl( cb , 1 ) { m_cb = cb; + SetTriggerOnSetValue( false ); } protected: @@ -104,19 +109,16 @@ protected: // such as the clicking the default button. if (!m_cb->GetEventHandler()->ProcessEvent( event )) { - wxWindow *parent = GetParent(); - while ( parent && !parent->IsTopLevel() && parent->GetDefaultItem() == NULL ) - parent = parent->GetParent() ; - - if ( parent && parent->GetDefaultItem() ) + wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow); + if ( tlw && tlw->GetDefaultItem() ) { - wxButton *def = wxDynamicCast(parent->GetDefaultItem(), wxButton); + wxButton *def = wxDynamicCast(tlw->GetDefaultItem(), wxButton); if ( def && def->IsEnabled() ) { wxCommandEvent event( wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() ); event.SetEventObject(def); def->Command(event); - } + } } return; @@ -160,7 +162,7 @@ BEGIN_EVENT_TABLE(wxComboBoxText, wxTextCtrl) EVT_KEY_DOWN(wxComboBoxText::OnKeyDown) EVT_CHAR(wxComboBoxText::OnChar) EVT_KEY_UP(wxComboBoxText::OnKeyUp) - EVT_TEXT(-1, wxComboBoxText::OnText) + EVT_TEXT(wxID_ANY, wxComboBoxText::OnText) END_EVENT_TABLE() class wxComboBoxChoice : public wxChoice @@ -223,7 +225,7 @@ private: }; BEGIN_EVENT_TABLE(wxComboBoxChoice, wxChoice) - EVT_CHOICE(-1, wxComboBoxChoice::OnChoice) + EVT_CHOICE(wxID_ANY, wxComboBoxChoice::OnChoice) END_EVENT_TABLE() wxComboBox::~wxComboBox() @@ -392,7 +394,7 @@ bool wxComboBox::Create(wxWindow *parent, } // Needed because it is a wxControlWithItems - SetBestSize(size); + SetInitialSize(size); SetStringSelection(value); return true; @@ -466,39 +468,46 @@ void wxComboBox::SetEditable(bool editable) void wxComboBox::SetInsertionPoint(long pos) { - // TODO + if ( m_text ) + m_text->SetInsertionPoint(pos); } void wxComboBox::SetInsertionPointEnd() { - // TODO + if ( m_text ) + m_text->SetInsertionPointEnd(); } long wxComboBox::GetInsertionPoint() const { - // TODO + if ( m_text ) + return m_text->GetInsertionPoint(); return 0; } wxTextPos wxComboBox::GetLastPosition() const { - // TODO + if ( m_text ) + return m_text->GetLastPosition(); return 0; } void wxComboBox::Replace(long from, long to, const wxString& value) { - // TODO + if ( m_text ) + m_text->Replace(from,to,value); } void wxComboBox::Remove(long from, long to) { - // TODO + if ( m_text ) + m_text->Remove(from,to); } void wxComboBox::SetSelection(long from, long to) { - // TODO + if ( m_text ) + m_text->SetSelection(from,to); } int wxComboBox::DoAppend(const wxString& item) @@ -671,4 +680,4 @@ wxInt32 wxComboBox::MacControlHit( WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENT return noErr ; } -#endif +#endif // wxUSE_COMBOBOX