X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c60122bf37a65f07f517e14a98ce988a3eae8305..bbd92d1dbea02db8c28e9c17bfacc0563d855b25:/src/mac/carbon/srchctrl.cpp diff --git a/src/mac/carbon/srchctrl.cpp b/src/mac/carbon/srchctrl.cpp index b8a450ef40..4a78629391 100644 --- a/src/mac/carbon/srchctrl.cpp +++ b/src/mac/carbon/srchctrl.cpp @@ -37,9 +37,6 @@ 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 } , @@ -66,6 +63,10 @@ public : virtual void SetSearchMenu( wxMenu* menu ); virtual wxMenu* GetSearchMenu() const; + + virtual void SetDescriptiveText(const wxString& text); + virtual wxString GetDescriptiveText() const; + protected : virtual void CreateControl( wxTextCtrl* peer, const Rect* bounds, CFStringRef crf ); @@ -73,13 +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 ( UMAGetSystemVersion() >= 0x1040 ) - { - attributes = kHISearchFieldAttributesSearchIcon; - } + OptionBits attributes = kHISearchFieldAttributesSearchIcon; + HIRect hibounds = { { bounds->left, bounds->top }, { bounds->right-bounds->left, bounds->bottom-bounds->top } }; verify_noerr( HISearchFieldCreate( &hibounds, @@ -94,20 +94,17 @@ void wxMacSearchFieldControl::CreateControl( wxTextCtrl* /*peer*/, const Rect* b // search field options void wxMacSearchFieldControl::ShowSearchButton( bool show ) { - 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; } + else + { + clear |= kHISearchFieldAttributesSearchIcon; + } + HISearchFieldChangeAttributes( m_controlRef, set, clear ); } bool wxMacSearchFieldControl::IsSearchButtonVisible() const @@ -157,7 +154,27 @@ wxMenu* wxMacSearchFieldControl::GetSearchMenu() const return m_menu; } -#endif + +void wxMacSearchFieldControl::SetDescriptiveText(const wxString& text) +{ + verify_noerr( HISearchFieldSetDescriptiveText( + m_controlRef, + wxCFStringRef( text, wxFont::GetDefaultEncoding() ))); +} + +wxString wxMacSearchFieldControl::GetDescriptiveText() const +{ + CFStringRef cfStr; + verify_noerr( HISearchFieldCopyDescriptiveText( m_controlRef, &cfStr )); + if ( cfStr ) + { + return wxCFStringRef(cfStr).AsString(); + } + else + { + return wxEmptyString; + } +} // ============================================================================ // implementation @@ -237,6 +254,8 @@ bool wxSearchCtrl::Create(wxWindow *parent, wxWindowID id, GetEventTypeCount(eventList), eventList, this, (EventHandlerRef *)&searchEventHandler); + SetValue(value); + return true; } @@ -339,6 +358,16 @@ bool wxSearchCtrl::IsCancelButtonVisible() const return GetPeer()->IsCancelButtonVisible(); } +void wxSearchCtrl::SetDescriptiveText(const wxString& text) +{ + GetPeer()->SetDescriptiveText(text); +} + +wxString wxSearchCtrl::GetDescriptiveText() const +{ + return GetPeer()->GetDescriptiveText(); +} + wxInt32 wxSearchCtrl::MacSearchFieldSearchHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) ) { wxCommandEvent event(wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN, m_windowId ); @@ -361,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