X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6646ca90e801375fa3ce36206e02f76f202e13c6..bbd92d1dbea02db8c28e9c17bfacc0563d855b25:/src/mac/carbon/srchctrl.cpp diff --git a/src/mac/carbon/srchctrl.cpp b/src/mac/carbon/srchctrl.cpp index 3fcb8d7d66..4a78629391 100644 --- a/src/mac/carbon/srchctrl.cpp +++ b/src/mac/carbon/srchctrl.cpp @@ -37,15 +37,10 @@ IMPLEMENT_DYNAMIC_CLASS(wxSearchCtrl, wxSearchCtrlBase) // wxMacSearchFieldControl // ============================================================================ -#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2 - - static const EventTypeSpec eventList[] = { { kEventClassSearchField, kEventSearchFieldCancelClicked } , -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 { kEventClassSearchField, kEventSearchFieldSearchClicked } , -#endif }; class wxMacSearchFieldControl : public wxMacUnicodeTextControl @@ -71,7 +66,7 @@ public : virtual void SetDescriptiveText(const wxString& text); virtual wxString GetDescriptiveText() const; - + protected : virtual void CreateControl( wxTextCtrl* peer, const Rect* bounds, CFStringRef crf ); @@ -79,15 +74,12 @@ private: wxMenu* m_menu; } ; -void wxMacSearchFieldControl::CreateControl( wxTextCtrl* /*peer*/, const Rect* bounds, CFStringRef crf ) +void wxMacSearchFieldControl::CreateControl(wxTextCtrl* WXUNUSED(peer), + const Rect* bounds, + CFStringRef WXUNUSED(crf)) { - OptionBits attributes = 0; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 - if ( UMAGetSystemVersion() >= 0x1040 ) - { - attributes = kHISearchFieldAttributesSearchIcon; - } -#endif + OptionBits attributes = kHISearchFieldAttributesSearchIcon; + HIRect hibounds = { { bounds->left, bounds->top }, { bounds->right-bounds->left, bounds->bottom-bounds->top } }; verify_noerr( HISearchFieldCreate( &hibounds, @@ -102,33 +94,24 @@ void wxMacSearchFieldControl::CreateControl( wxTextCtrl* /*peer*/, const Rect* b // search field options void wxMacSearchFieldControl::ShowSearchButton( bool show ) { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 - if ( UMAGetSystemVersion() >= 0x1040 ) + OptionBits set = 0; + OptionBits clear = 0; + if ( show ) { - OptionBits set = 0; - OptionBits clear = 0; - if ( show ) - { - set |= kHISearchFieldAttributesSearchIcon; - } - else - { - clear |= kHISearchFieldAttributesSearchIcon; - } - HISearchFieldChangeAttributes( m_controlRef, set, clear ); + set |= kHISearchFieldAttributesSearchIcon; } -#endif + else + { + clear |= kHISearchFieldAttributesSearchIcon; + } + HISearchFieldChangeAttributes( m_controlRef, set, clear ); } bool wxMacSearchFieldControl::IsSearchButtonVisible() const { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 OptionBits attributes = 0; verify_noerr( HISearchFieldGetAttributes( m_controlRef, &attributes ) ); return ( attributes & kHISearchFieldAttributesSearchIcon ) != 0; -#else - return false; -#endif } void wxMacSearchFieldControl::ShowCancelButton( bool show ) @@ -176,7 +159,7 @@ void wxMacSearchFieldControl::SetDescriptiveText(const wxString& text) { verify_noerr( HISearchFieldSetDescriptiveText( m_controlRef, - wxMacCFStringHolder( text, wxFont::GetDefaultEncoding() ))); + wxCFStringRef( text, wxFont::GetDefaultEncoding() ))); } wxString wxMacSearchFieldControl::GetDescriptiveText() const @@ -185,7 +168,7 @@ wxString wxMacSearchFieldControl::GetDescriptiveText() const verify_noerr( HISearchFieldCopyDescriptiveText( m_controlRef, &cfStr )); if ( cfStr ) { - return wxMacCFStringHolder(cfStr).AsString(); + return wxCFStringRef(cfStr).AsString(); } else { @@ -193,8 +176,6 @@ wxString wxMacSearchFieldControl::GetDescriptiveText() const } } -#endif - // ============================================================================ // implementation // ============================================================================ @@ -214,11 +195,9 @@ static pascal OSStatus wxMacSearchControlEventHandler( EventHandlerCallRef handl case kEventSearchFieldCancelClicked : thisWindow->MacSearchFieldCancelHit( handler , event ) ; break ; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 case kEventSearchFieldSearchClicked : thisWindow->MacSearchFieldSearchHit( handler , event ) ; break ; -#endif } return result ; @@ -275,6 +254,8 @@ bool wxSearchCtrl::Create(wxWindow *parent, wxWindowID id, GetEventTypeCount(eventList), eventList, this, (EventHandlerRef *)&searchEventHandler); + SetValue(value); + return true; } @@ -409,18 +390,7 @@ void wxSearchCtrl::CreatePeer( const wxPoint& pos, const wxSize& size, long style ) { -#ifdef __WXMAC_OSX__ -#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2 - if ( UMAGetSystemVersion() >= 0x1030 ) - { - m_peer = new wxMacSearchFieldControl( this , str , pos , size , style ); - } -#endif -#endif - if ( !m_peer ) - { - wxTextCtrl::CreatePeer( str, pos, size, style ); - } + m_peer = new wxMacSearchFieldControl( this , str , pos , size , style ); } #endif // wxUSE_NATIVE_SEARCH_CONTROL