From: Stefan Csomor Date: Mon, 17 May 2004 04:57:53 +0000 (+0000) Subject: adding a few methods for selection handling in native combobox X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/b310cebd711a5a616502012b64cdc37d8f6ab9d8?ds=sidebyside adding a few methods for selection handling in native combobox git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27315 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/mac/carbon/combobxc.cpp b/src/mac/carbon/combobxc.cpp index e0549c540a..853a335aa5 100644 --- a/src/mac/carbon/combobxc.cpp +++ b/src/mac/carbon/combobxc.cpp @@ -594,10 +594,15 @@ void wxComboBox::Delete(int n) void wxComboBox::Clear() { + FreeData(); #if USE_HICOMBOBOX - //TODO + for ( CFIndex i = GetCount() - 1 ; i >= 0 ; ++ i ) + verify_noerr( HIComboBoxRemoveItemAtIndex( (HIViewRef) m_macControl, i ) ); + wxMacCFStringHolder cf(wxEmptyString,m_font.GetEncoding()) ; + CFStringRef cfr = cf ; + SetControlData((ControlRef) m_macControl,kHIComboBoxEditTextPart,kControlEditTextCFStringTag, + sizeof(CFStringRef),(Ptr) &cfr); #else - FreeData(); m_choice->Clear(); #endif } @@ -605,8 +610,7 @@ void wxComboBox::Clear() int wxComboBox::GetSelection() const { #if USE_HICOMBOBOX - int result = GetControl32BitValue( (HIViewRef) m_macControl ) -1; - return result; + return FindString( GetStringSelection() ) ; #else return m_choice->GetSelection(); #endif @@ -653,11 +657,20 @@ wxString wxComboBox::GetString(int n) const wxString wxComboBox::GetStringSelection() const { +#if USE_HICOMBOBOX + CFStringRef cfr ; + verify_noerr(GetControlData((ControlRef) m_macControl,kHIComboBoxEditTextPart,kControlEditTextCFStringTag, + sizeof(CFStringRef),(Ptr) &cfr,NULL)); + // takes of release responsibility + wxMacCFStringHolder cf( cfr ) ; + return cf.AsString() ; +#else int sel = GetSelection (); if (sel > -1) return wxString(this->GetString (sel)); else return wxEmptyString; +#endif } bool wxComboBox::SetStringSelection(const wxString& sel) @@ -675,7 +688,9 @@ bool wxComboBox::SetStringSelection(const wxString& sel) void wxComboBox::SetString(int n, const wxString& s) { #if USE_HICOMBOBOX - + verify_noerr ( HIComboBoxInsertTextItemAtIndex( (HIViewRef) m_macControl, (CFIndex) n, + wxMacCFStringHolder(s, m_font.GetEncoding()) ) ); + verify_noerr ( HIComboBoxRemoveItemAtIndex( (HIViewRef) m_macControl, (CFIndex) n + 1 ) ); #else m_choice->SetString( n , s ) ; #endif @@ -684,14 +699,11 @@ void wxComboBox::SetString(int n, const wxString& s) 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 ; -*/ - return eventNotHandledErr ; }