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
This commit is contained in:
@@ -594,10 +594,15 @@ void wxComboBox::Delete(int n)
|
|||||||
|
|
||||||
void wxComboBox::Clear()
|
void wxComboBox::Clear()
|
||||||
{
|
{
|
||||||
#if USE_HICOMBOBOX
|
|
||||||
//TODO
|
|
||||||
#else
|
|
||||||
FreeData();
|
FreeData();
|
||||||
|
#if USE_HICOMBOBOX
|
||||||
|
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
|
||||||
m_choice->Clear();
|
m_choice->Clear();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -605,8 +610,7 @@ void wxComboBox::Clear()
|
|||||||
int wxComboBox::GetSelection() const
|
int wxComboBox::GetSelection() const
|
||||||
{
|
{
|
||||||
#if USE_HICOMBOBOX
|
#if USE_HICOMBOBOX
|
||||||
int result = GetControl32BitValue( (HIViewRef) m_macControl ) -1;
|
return FindString( GetStringSelection() ) ;
|
||||||
return result;
|
|
||||||
#else
|
#else
|
||||||
return m_choice->GetSelection();
|
return m_choice->GetSelection();
|
||||||
#endif
|
#endif
|
||||||
@@ -653,11 +657,20 @@ wxString wxComboBox::GetString(int n) const
|
|||||||
|
|
||||||
wxString wxComboBox::GetStringSelection() 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 ();
|
int sel = GetSelection ();
|
||||||
if (sel > -1)
|
if (sel > -1)
|
||||||
return wxString(this->GetString (sel));
|
return wxString(this->GetString (sel));
|
||||||
else
|
else
|
||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxComboBox::SetStringSelection(const wxString& sel)
|
bool wxComboBox::SetStringSelection(const wxString& sel)
|
||||||
@@ -675,7 +688,9 @@ bool wxComboBox::SetStringSelection(const wxString& sel)
|
|||||||
void wxComboBox::SetString(int n, const wxString& s)
|
void wxComboBox::SetString(int n, const wxString& s)
|
||||||
{
|
{
|
||||||
#if USE_HICOMBOBOX
|
#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
|
#else
|
||||||
m_choice->SetString( n , s ) ;
|
m_choice->SetString( n , s ) ;
|
||||||
#endif
|
#endif
|
||||||
@@ -684,14 +699,11 @@ void wxComboBox::SetString(int n, const wxString& s)
|
|||||||
|
|
||||||
wxInt32 wxComboBox::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
|
wxInt32 wxComboBox::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, m_windowId );
|
wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, m_windowId );
|
||||||
event.SetInt(GetSelection());
|
event.SetInt(GetSelection());
|
||||||
event.SetEventObject(this);
|
event.SetEventObject(this);
|
||||||
event.SetString(GetStringSelection());
|
event.SetString(GetStringSelection());
|
||||||
ProcessCommand(event);
|
ProcessCommand(event);
|
||||||
return noErr ;
|
return noErr ;
|
||||||
*/
|
|
||||||
return eventNotHandledErr ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user