From 853ee8bf12011e65c885624736e032f030486dec Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 17 Oct 2013 12:34:12 +0000 Subject: [PATCH] Get rid of compile- and run-time checks for OS X < 10.5. As 10.5 is the minimal supported version, it doesn't make sense to check for it (or even earlier versions) during the build or run-time. Closes #15580. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75028 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/osx/carbon/chkconf.h | 18 +- include/wx/osx/carbon/dataview.h | 4 - include/wx/osx/carbon/drawer.h | 7 +- include/wx/osx/carbon/private.h | 15 - include/wx/osx/cocoa/chkconf.h | 26 +- include/wx/osx/cocoa/private.h | 6 - include/wx/osx/config_xcode.h | 8 - samples/dialogs/dialogs.h | 2 +- src/html/htmlctrl/webkit/webkit.mm | 5 +- src/osx/carbon/dataview.cpp | 2 - src/osx/carbon/glcanvas.cpp | 31 +- src/osx/carbon/graphics.cpp | 6 - src/osx/carbon/listctrl_mac.cpp | 15 +- src/osx/carbon/nonownedwnd.cpp | 7 - src/osx/carbon/textctrl.cpp | 704 +---------------------------- src/osx/carbon/toolbar.cpp | 38 +- src/osx/carbon/utils.cpp | 26 +- src/osx/carbon/window.cpp | 115 +---- src/osx/cocoa/dataview.mm | 10 +- src/osx/cocoa/evtloop.mm | 4 - src/osx/cocoa/scrolbar.mm | 4 - src/osx/iphone/evtloop.mm | 2 - src/osx/webview_webkit.mm | 11 +- 23 files changed, 40 insertions(+), 1026 deletions(-) diff --git a/include/wx/osx/carbon/chkconf.h b/include/wx/osx/carbon/chkconf.h index 68e395429d..d4a2cad621 100644 --- a/include/wx/osx/carbon/chkconf.h +++ b/include/wx/osx/carbon/chkconf.h @@ -30,22 +30,8 @@ * text rendering system */ -#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 - - #define wxOSX_USE_CORE_TEXT 1 - // MLTE-TextControl uses ATSU - #define wxOSX_USE_ATSU_TEXT 1 - -#else // platform < 10.5 - - #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - #define wxOSX_USE_CORE_TEXT 1 - #else - #define wxOSX_USE_CORE_TEXT 0 - #endif - #define wxOSX_USE_ATSU_TEXT 1 - -#endif +#define wxOSX_USE_CORE_TEXT 1 +#define wxOSX_USE_ATSU_TEXT 1 /* * Audio System diff --git a/include/wx/osx/carbon/dataview.h b/include/wx/osx/carbon/dataview.h index 6f7b05acdc..75185b092c 100644 --- a/include/wx/osx/carbon/dataview.h +++ b/include/wx/osx/carbon/dataview.h @@ -155,9 +155,7 @@ public: OSStatus EnableCellSizeModification(bool enableHeight=true, bool enableWidth=true); // enables or disables the column width and row height modification (default: false) -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 OSStatus GetAttributes (OptionBits* attributes); -#endif OSStatus GetColumnWidth (DataBrowserPropertyID column, UInt16 *width ) const; // returns the column width in pixels OSStatus GetDefaultColumnWidth(UInt16 *width ) const; // returns the default column width in pixels OSStatus GetDefaultRowHeight (UInt16 * height ) const; @@ -166,9 +164,7 @@ public: OSStatus GetRowHeight (DataBrowserItemID item , UInt16 *height) const; OSStatus GetScrollPosition (UInt32* top, UInt32 *left) const; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 OSStatus SetAttributes (OptionBits attributes); -#endif OSStatus SetColumnWidth(DataBrowserPropertyID column, UInt16 width); // sets the column width in pixels OSStatus SetDefaultColumnWidth( UInt16 width ); OSStatus SetDefaultRowHeight( UInt16 height ); diff --git a/include/wx/osx/carbon/drawer.h b/include/wx/osx/carbon/drawer.h index b20c9dd512..6edb3921d4 100644 --- a/include/wx/osx/carbon/drawer.h +++ b/include/wx/osx/carbon/drawer.h @@ -22,8 +22,6 @@ // near future // -#if ( MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2 ) - class WXDLLIMPEXP_ADV wxDrawerWindow : public wxTopLevelWindow { DECLARE_DYNAMIC_CLASS(wxDrawerWindow) @@ -64,7 +62,4 @@ public: wxDirection GetCurrentEdge() const; // not necessarily the preferred, due to screen constraints }; -#endif // defined( __WXMAC__ ) && TARGET_API_MAC_OSX && ( MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2 ) - -#endif - // _WX_DRAWERWINDOW_H_ +#endif // _WX_DRAWERWINDOW_H_ diff --git a/include/wx/osx/carbon/private.h b/include/wx/osx/carbon/private.h index 82db9b98e5..64fa447e14 100644 --- a/include/wx/osx/carbon/private.h +++ b/include/wx/osx/carbon/private.h @@ -13,11 +13,6 @@ #ifndef _WX_PRIVATE_H_ #define _WX_PRIVATE_H_ -#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 -typedef UInt32 URefCon; -typedef SInt32 SRefCon; -#endif - #if wxUSE_GUI #include "wx/osx/uma.h" @@ -29,10 +24,6 @@ typedef SInt32 SRefCon; // app.h -#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 -bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec); -#endif - #endif // wxUSE_GUI // filefn.h @@ -269,12 +260,6 @@ ControlActionUPP GetwxMacLiveScrollbarActionProc(); // additional optional event defines -#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 -enum { - kEventControlFocusPartChanged = 164 -}; -#endif - class WXDLLIMPEXP_CORE wxMacControl : public wxWidgetImpl { public : diff --git a/include/wx/osx/cocoa/chkconf.h b/include/wx/osx/cocoa/chkconf.h index 9789e77d54..0f26bf5de7 100644 --- a/include/wx/osx/cocoa/chkconf.h +++ b/include/wx/osx/cocoa/chkconf.h @@ -41,33 +41,15 @@ * text rendering system */ -#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 - - #define wxOSX_USE_CORE_TEXT 1 - #define wxOSX_USE_ATSU_TEXT 0 - -#else // platform < 10.5 - - #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - #define wxOSX_USE_CORE_TEXT 1 - #else - #define wxOSX_USE_CORE_TEXT 0 - #endif - #define wxOSX_USE_ATSU_TEXT 1 - -#endif +#define wxOSX_USE_CORE_TEXT 1 +#define wxOSX_USE_ATSU_TEXT 0 /* * Audio System */ -#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 - #define wxOSX_USE_QUICKTIME 0 - #define wxOSX_USE_AUDIOTOOLBOX 1 -#else // platform < 10.5 - #define wxOSX_USE_QUICKTIME 1 - #define wxOSX_USE_AUDIOTOOLBOX 0 -#endif +#define wxOSX_USE_QUICKTIME 0 +#define wxOSX_USE_AUDIOTOOLBOX 1 /* * turning off capabilities that don't work under cocoa yet diff --git a/include/wx/osx/cocoa/private.h b/include/wx/osx/cocoa/private.h index 1e28206cec..e92df39539 100644 --- a/include/wx/osx/cocoa/private.h +++ b/include/wx/osx/cocoa/private.h @@ -19,12 +19,6 @@ #import #endif -#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 -// available in 10.4 but not in the headers -enum { - kEventMouseScroll = 11 -}; -#endif // // shared between Cocoa and Carbon // diff --git a/include/wx/osx/config_xcode.h b/include/wx/osx/config_xcode.h index e293e90aea..6ae3060120 100644 --- a/include/wx/osx/config_xcode.h +++ b/include/wx/osx/config_xcode.h @@ -45,11 +45,7 @@ #define WX_GMTOFF_IN_TM 1 #define HAVE_PW_GECOS 1 #define HAVE_DLOPEN 1 -#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 -/* #undef HAVE_CXA_DEMANGLE */ -#else #define HAVE_CXA_DEMANGLE 1 -#endif #define HAVE_GETTIMEOFDAY 1 #define HAVE_FSYNC 1 #define HAVE_ROUND 1 @@ -108,11 +104,7 @@ #define HAVE_WCHAR_H 1 /* better to use the built-in CF conversions, also avoid iconv versioning problems */ /* #undef HAVE_ICONV */ -#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 -#define ICONV_CONST const -#else #define ICONV_CONST -#endif #define HAVE_LANGINFO_H 1 #define HAVE_WCSRTOMBS 1 #define HAVE_FPUTWS 1 diff --git a/samples/dialogs/dialogs.h b/samples/dialogs/dialogs.h index bff0ffeddb..24dd2208ec 100644 --- a/samples/dialogs/dialogs.h +++ b/samples/dialogs/dialogs.h @@ -52,7 +52,7 @@ of MSW, MAC and OS2 #define USE_WXMAC 0 #endif -#if defined(__WXMAC_OSX__) && ( MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2) && USE_NATIVE_FONT_DIALOG_FOR_MACOSX +#if defined(__WXMAC_OSX__) && && USE_NATIVE_FONT_DIALOG_FOR_MACOSX #define USE_WXMACFONTDLG 1 #else #define USE_WXMACFONTDLG 0 diff --git a/src/html/htmlctrl/webkit/webkit.mm b/src/html/htmlctrl/webkit/webkit.mm index 3e22316b39..d2a18baa79 100644 --- a/src/html/htmlctrl/webkit/webkit.mm +++ b/src/html/htmlctrl/webkit/webkit.mm @@ -458,10 +458,7 @@ bool wxWebKitCtrl::Create(wxWindow *parent, m_webView = (WebView*) HIWebViewGetWebView( peer->GetControlRef() ); -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 - if ( UMAGetSystemVersion() >= 0x1030 ) - HIViewChangeFeatures( peer->GetControlRef() , kHIViewIsOpaque , 0 ) ; -#endif + HIViewChangeFeatures( peer->GetControlRef() , kHIViewIsOpaque , 0 ) ; InstallControlEventHandler( peer->GetControlRef() , GetwxWebKitCtrlEventHandlerUPP(), GetEventTypeCount(eventList), eventList, this, (EventHandlerRef *)&m_webKitCtrlEventHandler); diff --git a/src/osx/carbon/dataview.cpp b/src/osx/carbon/dataview.cpp index 72edcc6144..66781a9e74 100644 --- a/src/osx/carbon/dataview.cpp +++ b/src/osx/carbon/dataview.cpp @@ -155,9 +155,7 @@ static bool InitializeColumnDescription(DataBrowserListViewColumnDesc& columnDes (columnDescription.propertyDesc.propertyType == kDataBrowserIconAndTextType) || (columnDescription.propertyDesc.propertyType == kDataBrowserTextType)) columnDescription.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn; // enables generally the possibility to have user input for the mentioned types -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 columnDescription.propertyDesc.propertyFlags |= kDataBrowserListViewNoGapForIconInHeaderButton; -#endif // set header's properties: columnDescription.headerBtnDesc.version = kDataBrowserListViewLatestHeaderDesc; columnDescription.headerBtnDesc.titleOffset = 0; diff --git a/src/osx/carbon/glcanvas.cpp b/src/osx/carbon/glcanvas.cpp index cf8dd6b07d..7006d5e68f 100644 --- a/src/osx/carbon/glcanvas.cpp +++ b/src/osx/carbon/glcanvas.cpp @@ -262,24 +262,7 @@ bool wxGLContext::SetCurrent(const wxGLCanvas& win) const const_cast(win).SetViewport(); - -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - if ( UMAGetSystemVersion() >= 0x1050 ) - { - aglSetWindowRef(m_glContext, win.MacGetTopLevelWindowRef()); - } - else -#endif - { - AGLDrawable drawable = (AGLDrawable)GetWindowPort( - MAC_WXHWND(win.MacGetTopLevelWindowRef())); - - if ( !aglSetDrawable(m_glContext, drawable) ) - { - wxLogAGLError("aglSetDrawable"); - return false; - } - } + aglSetWindowRef(m_glContext, win.MacGetTopLevelWindowRef()); return WXGLSetCurrentContext(m_glContext); } @@ -354,17 +337,7 @@ bool wxGLCanvas::Create(wxWindow *parent, m_bufferName = gCurrentBufferName++; aglSetInteger (m_dummyContext, AGL_BUFFER_NAME, &m_bufferName); -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - if ( UMAGetSystemVersion() >= 0x1050 ) - { - aglSetWindowRef(m_dummyContext, MacGetTopLevelWindowRef()); - } - else -#endif - { - AGLDrawable drawable = (AGLDrawable)GetWindowPort(MAC_WXHWND(MacGetTopLevelWindowRef())); - aglSetDrawable(m_dummyContext, drawable); - } + aglSetWindowRef(m_dummyContext, MacGetTopLevelWindowRef()); m_macCanvasIsShown = true; diff --git a/src/osx/carbon/graphics.cpp b/src/osx/carbon/graphics.cpp index ff015c21d9..620b844731 100644 --- a/src/osx/carbon/graphics.cpp +++ b/src/osx/carbon/graphics.cpp @@ -78,10 +78,6 @@ extern void wxOSXUnlockFocus( WXWidget view) ; #endif #endif -#if 1 // MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 - -// TODO test whether this private API also works under 10.3 - // copying values from NSCompositingModes (see also webkit and cairo sources) typedef enum CGCompositeOperation { @@ -106,8 +102,6 @@ extern "C" CG_EXTERN void CGContextSetCompositeOperation (CGContextRef context, int operation); } ; -#endif - //----------------------------------------------------------------------------- // constants //----------------------------------------------------------------------------- diff --git a/src/osx/carbon/listctrl_mac.cpp b/src/osx/carbon/listctrl_mac.cpp index c9084e057e..f91adbaf8c 100644 --- a/src/osx/carbon/listctrl_mac.cpp +++ b/src/osx/carbon/listctrl_mac.cpp @@ -2855,16 +2855,13 @@ void wxMacDataBrowserListCtrlControl::DrawItem( HIThemeTextInfo info; bool setup = false; #if wxOSX_USE_CORE_TEXT - if ( UMAGetSystemVersion() >= 0x1050 ) + info.version = kHIThemeTextInfoVersionOne; + info.fontID = kThemeViewsFont; + if (font.IsOk()) { - info.version = kHIThemeTextInfoVersionOne; - info.fontID = kThemeViewsFont; - if (font.IsOk()) - { - info.fontID = kThemeSpecifiedFont; - info.font = (CTFontRef) font.OSXGetCTFont(); - setup = true; - } + info.fontID = kThemeSpecifiedFont; + info.font = (CTFontRef) font.OSXGetCTFont(); + setup = true; } #endif #if wxOSX_USE_ATSU_TEXT diff --git a/src/osx/carbon/nonownedwnd.cpp b/src/osx/carbon/nonownedwnd.cpp index 881083c29c..f9acf7e4d8 100644 --- a/src/osx/carbon/nonownedwnd.cpp +++ b/src/osx/carbon/nonownedwnd.cpp @@ -1522,18 +1522,11 @@ void wxNonOwnedWindowCarbonImpl::Maximize(bool maximize) Point idealSize = { 0 , 0 } ; if ( maximize ) { -#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 HIRect bounds ; HIWindowGetAvailablePositioningBounds(kCGNullDirectDisplay,kHICoordSpace72DPIGlobal, &bounds); idealSize.h = bounds.size.width; idealSize.v = bounds.size.height; -#else - Rect rect ; - GetAvailableWindowPositioningBounds(GetMainDevice(),&rect) ; - idealSize.h = rect.right - rect.left ; - idealSize.v = rect.bottom - rect.top ; -#endif } ZoomWindowIdeal( (WindowRef)GetWXWindow() , maximize ? inZoomOut : inZoomIn , &idealSize ) ; } diff --git a/src/osx/carbon/textctrl.cpp b/src/osx/carbon/textctrl.cpp index 02ba93ad33..53a0f908d0 100644 --- a/src/osx/carbon/textctrl.cpp +++ b/src/osx/carbon/textctrl.cpp @@ -369,41 +369,7 @@ wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer, long style, long WXUNUSED(extraStyle)) { - bool forceMLTE = false ; - -#if wxUSE_SYSTEM_OPTIONS - if (wxSystemOptions::HasOption( wxMAC_TEXTCONTROL_USE_MLTE ) && (wxSystemOptions::GetOptionInt( wxMAC_TEXTCONTROL_USE_MLTE ) == 1)) - { - forceMLTE = true ; - } -#endif - - if ( UMAGetSystemVersion() >= 0x1050 ) - forceMLTE = false; - - wxMacControl* peer = NULL; - - if ( !forceMLTE ) - { - if ( style & wxTE_MULTILINE || ( UMAGetSystemVersion() >= 0x1050 ) ) - peer = new wxMacMLTEHIViewControl( wxpeer , str , pos , size , style ) ; - } - - if ( !peer ) - { - if ( !(style & wxTE_MULTILINE) && !forceMLTE ) - { - peer = new wxMacUnicodeTextControl( wxpeer , str , pos , size , style ) ; - } - } - - // the horizontal single line scrolling bug that made us keep the classic implementation - // is fixed in 10.5 -#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 - if ( !peer ) - peer = new wxMacMLTEClassicControl( wxpeer , str , pos , size , style ) ; -#endif - return peer; + return new wxMacMLTEHIViewControl( wxpeer , str , pos , size , style ) ; } // ---------------------------------------------------------------------------- @@ -1467,674 +1433,6 @@ int wxMacMLTEControl::GetLineLength(long lineNo) const return theLength ; } -#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 - -// ---------------------------------------------------------------------------- -// MLTE control implementation (classic part) -// ---------------------------------------------------------------------------- - -// OS X Notes : We still don't have a full replacement for MLTE, so this implementation -// has to live on. We have different problems coming from outdated implementations on the -// various OS X versions. Most deal with the scrollbars: they are not correctly embedded -// while this can be solved on 10.3 by reassigning them the correct place, on 10.2 there is -// no way out, therefore we are using our own implementation and our own scrollbars .... - -TXNScrollInfoUPP gTXNScrollInfoProc = NULL ; -ControlActionUPP gTXNScrollActionProc = NULL ; - -pascal void wxMacMLTEClassicControl::TXNScrollInfoProc( - SInt32 iValue, SInt32 iMaximumValue, - TXNScrollBarOrientation iScrollBarOrientation, SInt32 iRefCon ) -{ - wxMacMLTEClassicControl* mlte = (wxMacMLTEClassicControl*) iRefCon ; - SInt32 value = wxMax( iValue , 0 ) ; - SInt32 maximum = wxMax( iMaximumValue , 0 ) ; - - if ( iScrollBarOrientation == kTXNHorizontal ) - { - if ( mlte->m_sbHorizontal ) - { - SetControl32BitValue( mlte->m_sbHorizontal , value ) ; - SetControl32BitMaximum( mlte->m_sbHorizontal , maximum ) ; - mlte->m_lastHorizontalValue = value ; - } - } - else if ( iScrollBarOrientation == kTXNVertical ) - { - if ( mlte->m_sbVertical ) - { - SetControl32BitValue( mlte->m_sbVertical , value ) ; - SetControl32BitMaximum( mlte->m_sbVertical , maximum ) ; - mlte->m_lastVerticalValue = value ; - } - } -} - -pascal void wxMacMLTEClassicControl::TXNScrollActionProc( ControlRef controlRef , ControlPartCode partCode ) -{ - wxMacMLTEClassicControl* mlte = (wxMacMLTEClassicControl*) GetControlReference( controlRef ) ; - if ( mlte == NULL ) - return ; - - if ( controlRef != mlte->m_sbVertical && controlRef != mlte->m_sbHorizontal ) - return ; - - OSStatus err ; - bool isHorizontal = ( controlRef == mlte->m_sbHorizontal ) ; - - SInt32 minimum = 0 ; - SInt32 maximum = GetControl32BitMaximum( controlRef ) ; - SInt32 value = GetControl32BitValue( controlRef ) ; - SInt32 delta = 0; - - switch ( partCode ) - { - case kControlDownButtonPart : - delta = 10 ; - break ; - - case kControlUpButtonPart : - delta = -10 ; - break ; - - case kControlPageDownPart : - delta = GetControlViewSize( controlRef ) ; - break ; - - case kControlPageUpPart : - delta = -GetControlViewSize( controlRef ) ; - break ; - - case kControlIndicatorPart : - delta = value - (isHorizontal ? mlte->m_lastHorizontalValue : mlte->m_lastVerticalValue) ; - break ; - - default : - break ; - } - - if ( delta != 0 ) - { - SInt32 newValue = value ; - - if ( partCode != kControlIndicatorPart ) - { - if ( value + delta < minimum ) - delta = minimum - value ; - if ( value + delta > maximum ) - delta = maximum - value ; - - SetControl32BitValue( controlRef , value + delta ) ; - newValue = value + delta ; - } - - SInt32 verticalDelta = isHorizontal ? 0 : delta ; - SInt32 horizontalDelta = isHorizontal ? delta : 0 ; - - err = TXNScroll( - mlte->m_txn, kTXNScrollUnitsInPixels, kTXNScrollUnitsInPixels, - &verticalDelta, &horizontalDelta ); - verify_noerr( err ); - - if ( isHorizontal ) - mlte->m_lastHorizontalValue = newValue ; - else - mlte->m_lastVerticalValue = newValue ; - } -} - -// make correct activations -void wxMacMLTEClassicControl::MacActivatePaneText(bool setActive) -{ - wxTextCtrl* textctrl = (wxTextCtrl*) GetControlReference(m_controlRef); - - wxMacWindowClipper clipper( textctrl ) ; - TXNActivate( m_txn, m_txnFrameID, setActive ); - - ControlRef controlFocus = 0 ; - GetKeyboardFocus( m_txnWindow , &controlFocus ) ; - if ( controlFocus == m_controlRef ) - TXNFocus( m_txn, setActive ); -} - -void wxMacMLTEClassicControl::MacFocusPaneText(bool setFocus) -{ - TXNFocus( m_txn, setFocus ); -} - -// guards against inappropriate redraw (hidden objects drawing onto window) - -void wxMacMLTEClassicControl::MacSetObjectVisibility(bool vis) -{ - ControlRef controlFocus = 0 ; - GetKeyboardFocus( m_txnWindow , &controlFocus ) ; - - if ( !vis && (controlFocus == m_controlRef ) ) - SetKeyboardFocus( m_txnWindow , m_controlRef , kControlFocusNoPart ) ; - - TXNControlTag iControlTags[1] = { kTXNVisibilityTag }; - TXNControlData iControlData[1] = { { (UInt32)false } }; - - verify_noerr( TXNGetTXNObjectControls( m_txn , 1, iControlTags, iControlData ) ) ; - - if ( iControlData[0].uValue != vis ) - { - iControlData[0].uValue = vis ; - verify_noerr( TXNSetTXNObjectControls( m_txn, false , 1, iControlTags, iControlData ) ) ; - } - - // currently, we always clip as partial visibility (overlapped) visibility is also a problem, - // if we run into further problems we might set the FrameBounds to an empty rect here -} - -// make sure that the TXNObject is at the right position - -void wxMacMLTEClassicControl::MacUpdatePosition() -{ - wxTextCtrl* textctrl = (wxTextCtrl*)GetControlReference( m_controlRef ); - if ( textctrl == NULL ) - return ; - - Rect bounds ; - GetRectInWindowCoords( &bounds ); - - wxRect visRect = textctrl->MacGetClippedClientRect() ; - Rect visBounds = { visRect.y , visRect.x , visRect.y + visRect.height , visRect.x + visRect.width } ; - int x , y ; - x = y = 0 ; - textctrl->MacWindowToRootWindow( &x , &y ) ; - OffsetRect( &visBounds , x , y ) ; - - if ( !EqualRect( &bounds, &m_txnControlBounds ) || !EqualRect( &visBounds, &m_txnVisBounds ) ) - { - m_txnControlBounds = bounds ; - m_txnVisBounds = visBounds ; - wxMacWindowClipper cl( textctrl ) ; - - if ( m_sbHorizontal || m_sbVertical ) - { - int w = bounds.right - bounds.left ; - int h = bounds.bottom - bounds.top ; - - if ( m_sbHorizontal ) - { - Rect sbBounds ; - - sbBounds.left = -1 ; - sbBounds.top = h - 14 ; - sbBounds.right = w + 1 ; - sbBounds.bottom = h + 1 ; - - SetControlBounds( m_sbHorizontal , &sbBounds ) ; - SetControlViewSize( m_sbHorizontal , w ) ; - } - - if ( m_sbVertical ) - { - Rect sbBounds ; - - sbBounds.left = w - 14 ; - sbBounds.top = -1 ; - sbBounds.right = w + 1 ; - sbBounds.bottom = m_sbHorizontal ? h - 14 : h + 1 ; - - SetControlBounds( m_sbVertical , &sbBounds ) ; - SetControlViewSize( m_sbVertical , h ) ; - } - } - - Rect oldviewRect ; - TXNLongRect olddestRect ; - TXNGetRectBounds( m_txn , &oldviewRect , &olddestRect , NULL ) ; - - Rect viewRect = { m_txnControlBounds.top, m_txnControlBounds.left, - m_txnControlBounds.bottom - ( m_sbHorizontal ? 14 : 0 ) , - m_txnControlBounds.right - ( m_sbVertical ? 14 : 0 ) } ; - TXNLongRect destRect = { m_txnControlBounds.top, m_txnControlBounds.left, - m_txnControlBounds.bottom - ( m_sbHorizontal ? 14 : 0 ) , - m_txnControlBounds.right - ( m_sbVertical ? 14 : 0 ) } ; - - if ( olddestRect.right >= 10000 ) - destRect.right = destRect.left + 32000 ; - - if ( olddestRect.bottom >= 0x20000000 ) - destRect.bottom = destRect.top + 0x40000000 ; - - SectRect( &viewRect , &visBounds , &viewRect ) ; - TXNSetRectBounds( m_txn , &viewRect , &destRect , true ) ; - -#if 0 - TXNSetFrameBounds( - m_txn, - m_txnControlBounds.top, - m_txnControlBounds.left, - m_txnControlBounds.bottom - (m_sbHorizontal ? 14 : 0), - m_txnControlBounds.right - (m_sbVertical ? 14 : 0), - m_txnFrameID ); -#endif - - // the SetFrameBounds method under Classic sometimes does not correctly scroll a selection into sight after a - // movement, therefore we have to force it - - // this problem has been reported in OSX as well, so we use this here once again - - TXNLongRect textRect ; - TXNGetRectBounds( m_txn , NULL , NULL , &textRect ) ; - if ( textRect.left < m_txnControlBounds.left ) - TXNShowSelection( m_txn , kTXNShowStart ) ; - } -} - -void wxMacMLTEClassicControl::Move(int x, int y, int width, int height) -{ - wxMacControl::Move(x,y,width,height) ; - MacUpdatePosition() ; -} - -void wxMacMLTEClassicControl::MacControlUserPaneDrawProc(wxInt16 WXUNUSED(thePart)) -{ - wxTextCtrl* textctrl = (wxTextCtrl*)GetControlReference( m_controlRef ); - if ( textctrl == NULL ) - return ; - - if ( textctrl->IsShownOnScreen() ) - { - wxMacWindowClipper clipper( textctrl ) ; - TXNDraw( m_txn , NULL ) ; - } -} - -wxInt16 wxMacMLTEClassicControl::MacControlUserPaneHitTestProc(wxInt16 x, wxInt16 y) -{ - Point where = { y , x } ; - ControlPartCode result = kControlNoPart; - - wxTextCtrl* textctrl = (wxTextCtrl*) GetControlReference( m_controlRef ); - if ( (textctrl != NULL) && textctrl->IsShownOnScreen() ) - { - if (PtInRect( where, &m_txnControlBounds )) - { - result = kControlEditTextPart ; - } - else - { - // sometimes we get the coords also in control local coordinates, therefore test again - int x = 0 , y = 0 ; - textctrl->MacClientToRootWindow( &x , &y ) ; - where.h += x ; - where.v += y ; - - if (PtInRect( where, &m_txnControlBounds )) - result = kControlEditTextPart ; - } - } - - return result; -} - -wxInt16 wxMacMLTEClassicControl::MacControlUserPaneTrackingProc( wxInt16 x, wxInt16 y, void* WXUNUSED(actionProc) ) -{ - ControlPartCode result = kControlNoPart; - - wxTextCtrl* textctrl = (wxTextCtrl*) GetControlReference( m_controlRef ); - if ( (textctrl != NULL) && textctrl->IsShownOnScreen() ) - { - Point startPt = { y , x } ; - - // for compositing, we must convert these into toplevel window coordinates, because hittesting expects them - int x = 0 , y = 0 ; - textctrl->MacClientToRootWindow( &x , &y ) ; - startPt.h += x ; - startPt.v += y ; - - switch (MacControlUserPaneHitTestProc( startPt.h , startPt.v )) - { - case kControlEditTextPart : - { - wxMacWindowClipper clipper( textctrl ) ; - EventRecord rec ; - - ConvertEventRefToEventRecord( (EventRef) wxTheApp->MacGetCurrentEvent() , &rec ) ; - TXNClick( m_txn, &rec ); - } - break; - - default : - break; - } - } - - return result; -} - -void wxMacMLTEClassicControl::MacControlUserPaneIdleProc() -{ - wxTextCtrl* textctrl = (wxTextCtrl*)GetControlReference( m_controlRef ); - if ( textctrl == NULL ) - return ; - - if (textctrl->IsShownOnScreen()) - { - if (IsControlActive(m_controlRef)) - { - Point mousep; - - wxMacWindowClipper clipper( textctrl ) ; - GetMouse(&mousep); - - TXNIdle(m_txn); - - if (PtInRect(mousep, &m_txnControlBounds)) - { - RgnHandle theRgn = NewRgn(); - RectRgn(theRgn, &m_txnControlBounds); - TXNAdjustCursor(m_txn, theRgn); - DisposeRgn(theRgn); - } - } - } -} - -wxInt16 wxMacMLTEClassicControl::MacControlUserPaneKeyDownProc (wxInt16 keyCode, wxInt16 charCode, wxInt16 modifiers) -{ - wxTextCtrl* textctrl = (wxTextCtrl*)GetControlReference( m_controlRef ); - if ( textctrl == NULL ) - return kControlNoPart; - - wxMacWindowClipper clipper( textctrl ) ; - - EventRecord ev ; - memset( &ev , 0 , sizeof( ev ) ) ; - ev.what = keyDown ; - ev.modifiers = modifiers ; - ev.message = ((keyCode << 8) & keyCodeMask) | (charCode & charCodeMask); - TXNKeyDown( m_txn , &ev ); - - return kControlEntireControl; -} - -void wxMacMLTEClassicControl::MacControlUserPaneActivateProc(bool activating) -{ - MacActivatePaneText( activating ); -} - -wxInt16 wxMacMLTEClassicControl::MacControlUserPaneFocusProc(wxInt16 action) -{ - ControlPartCode focusResult = kControlFocusNoPart; - - wxTextCtrl* textctrl = (wxTextCtrl*)GetControlReference( m_controlRef ); - if ( textctrl == NULL ) - return focusResult; - - wxMacWindowClipper clipper( textctrl ) ; - - ControlRef controlFocus = NULL ; - GetKeyboardFocus( m_txnWindow , &controlFocus ) ; - bool wasFocused = ( controlFocus == m_controlRef ) ; - - switch (action) - { - case kControlFocusPrevPart: - case kControlFocusNextPart: - MacFocusPaneText( !wasFocused ); - focusResult = (!wasFocused ? (ControlPartCode) kControlEditTextPart : (ControlPartCode) kControlFocusNoPart); - break; - - case kControlFocusNoPart: - default: - MacFocusPaneText( false ); - focusResult = kControlFocusNoPart; - break; - } - - return focusResult; -} - -void wxMacMLTEClassicControl::MacControlUserPaneBackgroundProc( void *WXUNUSED(info) ) -{ -} - -wxMacMLTEClassicControl::wxMacMLTEClassicControl( wxTextCtrl *wxPeer, - const wxString& str, - const wxPoint& pos, - const wxSize& size, long style ) - : wxMacMLTEControl( wxPeer ) -{ - m_font = wxPeer->GetFont() ; - m_windowStyle = style ; - Rect bounds = wxMacGetBoundsForControl( wxPeer , pos , size ) ; - - short featureSet = - kControlSupportsEmbedding | kControlSupportsFocus | kControlWantsIdle - | kControlWantsActivate | kControlHandlesTracking -// | kControlHasSpecialBackground - | kControlGetsFocusOnClick | kControlSupportsLiveFeedback; - - OSStatus err = ::CreateUserPaneControl( - MAC_WXHWND(wxPeer->GetParent()->MacGetTopLevelWindowRef()), - &bounds, featureSet, &m_controlRef ); - verify_noerr( err ); - SetControlReference( m_controlRef , (URefCon) wxPeer ); - - DoCreate(); - - AdjustCreationAttributes( *wxWHITE , true ) ; - - MacSetObjectVisibility( wxPeer->IsShownOnScreen() ) ; - - { - wxString st = str ; - wxMacConvertNewlines10To13( &st ) ; - wxMacWindowClipper clipper( GetWXPeer() ) ; - SetTXNData( st , kTXNStartOffset, kTXNEndOffset ) ; - TXNSetSelection( m_txn, 0, 0 ) ; - } -} - -wxMacMLTEClassicControl::~wxMacMLTEClassicControl() -{ - TXNDeleteObject( m_txn ); - m_txn = NULL ; -} - -void wxMacMLTEClassicControl::VisibilityChanged(bool shown) -{ - MacSetObjectVisibility( shown ) ; - wxMacControl::VisibilityChanged( shown ) ; -} - -void wxMacMLTEClassicControl::SuperChangedPosition() -{ - MacUpdatePosition() ; - wxMacControl::SuperChangedPosition() ; -} - -ControlUserPaneDrawUPP gTPDrawProc = NULL; -ControlUserPaneHitTestUPP gTPHitProc = NULL; -ControlUserPaneTrackingUPP gTPTrackProc = NULL; -ControlUserPaneIdleUPP gTPIdleProc = NULL; -ControlUserPaneKeyDownUPP gTPKeyProc = NULL; -ControlUserPaneActivateUPP gTPActivateProc = NULL; -ControlUserPaneFocusUPP gTPFocusProc = NULL; - -static pascal void wxMacControlUserPaneDrawProc(ControlRef control, SInt16 part) -{ - wxTextCtrl *textCtrl = wxDynamicCast( wxFindWindowFromWXWidget( (WXWidget) control) , wxTextCtrl ) ; - wxMacMLTEClassicControl * win = textCtrl ? (wxMacMLTEClassicControl*)(textCtrl->GetPeer()) : NULL ; - if ( win ) - win->MacControlUserPaneDrawProc( part ) ; -} - -static pascal ControlPartCode wxMacControlUserPaneHitTestProc(ControlRef control, Point where) -{ - wxTextCtrl *textCtrl = wxDynamicCast( wxFindWindowFromWXWidget( (WXWidget) control) , wxTextCtrl ) ; - wxMacMLTEClassicControl * win = textCtrl ? (wxMacMLTEClassicControl*)(textCtrl->GetPeer()) : NULL ; - if ( win ) - return win->MacControlUserPaneHitTestProc( where.h , where.v ) ; - else - return kControlNoPart ; -} - -static pascal ControlPartCode wxMacControlUserPaneTrackingProc(ControlRef control, Point startPt, ControlActionUPP actionProc) -{ - wxTextCtrl *textCtrl = wxDynamicCast( wxFindWindowFromWXWidget( (WXWidget) control) , wxTextCtrl ) ; - wxMacMLTEClassicControl * win = textCtrl ? (wxMacMLTEClassicControl*)(textCtrl->GetPeer()) : NULL ; - if ( win ) - return win->MacControlUserPaneTrackingProc( startPt.h , startPt.v , (void*) actionProc ) ; - else - return kControlNoPart ; -} - -static pascal void wxMacControlUserPaneIdleProc(ControlRef control) -{ - wxTextCtrl *textCtrl = wxDynamicCast( wxFindWindowFromWXWidget((WXWidget) control) , wxTextCtrl ) ; - wxMacMLTEClassicControl * win = textCtrl ? (wxMacMLTEClassicControl*)(textCtrl->GetPeer()) : NULL ; - if ( win ) - win->MacControlUserPaneIdleProc() ; -} - -static pascal ControlPartCode wxMacControlUserPaneKeyDownProc(ControlRef control, SInt16 keyCode, SInt16 charCode, SInt16 modifiers) -{ - wxTextCtrl *textCtrl = wxDynamicCast( wxFindWindowFromWXWidget((WXWidget) control) , wxTextCtrl ) ; - wxMacMLTEClassicControl * win = textCtrl ? (wxMacMLTEClassicControl*)(textCtrl->GetPeer()) : NULL ; - if ( win ) - return win->MacControlUserPaneKeyDownProc( keyCode, charCode, modifiers ) ; - else - return kControlNoPart ; -} - -static pascal void wxMacControlUserPaneActivateProc(ControlRef control, Boolean activating) -{ - wxTextCtrl *textCtrl = wxDynamicCast( wxFindWindowFromWXWidget( (WXWidget)control) , wxTextCtrl ) ; - wxMacMLTEClassicControl * win = textCtrl ? (wxMacMLTEClassicControl*)(textCtrl->GetPeer()) : NULL ; - if ( win ) - win->MacControlUserPaneActivateProc( activating ) ; -} - -static pascal ControlPartCode wxMacControlUserPaneFocusProc(ControlRef control, ControlFocusPart action) -{ - wxTextCtrl *textCtrl = wxDynamicCast( wxFindWindowFromWXWidget((WXWidget) control) , wxTextCtrl ) ; - wxMacMLTEClassicControl * win = textCtrl ? (wxMacMLTEClassicControl*)(textCtrl->GetPeer()) : NULL ; - if ( win ) - return win->MacControlUserPaneFocusProc( action ) ; - else - return kControlNoPart ; -} - -#if 0 -static pascal void wxMacControlUserPaneBackgroundProc(ControlRef control, ControlBackgroundPtr info) -{ - wxTextCtrl *textCtrl = wxDynamicCast( wxFindWindowFromWXWidget(control) , wxTextCtrl ) ; - wxMacMLTEClassicControl * win = textCtrl ? (wxMacMLTEClassicControl*)(textCtrl->GetPeer()) : NULL ; - if ( win ) - win->MacControlUserPaneBackgroundProc(info) ; -} -#endif - -// TXNRegisterScrollInfoProc - -OSStatus wxMacMLTEClassicControl::DoCreate() -{ - Rect bounds; - OSStatus err = noErr ; - - // set up our globals - if (gTPDrawProc == NULL) gTPDrawProc = NewControlUserPaneDrawUPP(wxMacControlUserPaneDrawProc); - if (gTPHitProc == NULL) gTPHitProc = NewControlUserPaneHitTestUPP(wxMacControlUserPaneHitTestProc); - if (gTPTrackProc == NULL) gTPTrackProc = NewControlUserPaneTrackingUPP(wxMacControlUserPaneTrackingProc); - if (gTPIdleProc == NULL) gTPIdleProc = NewControlUserPaneIdleUPP(wxMacControlUserPaneIdleProc); - if (gTPKeyProc == NULL) gTPKeyProc = NewControlUserPaneKeyDownUPP(wxMacControlUserPaneKeyDownProc); - if (gTPActivateProc == NULL) gTPActivateProc = NewControlUserPaneActivateUPP(wxMacControlUserPaneActivateProc); - if (gTPFocusProc == NULL) gTPFocusProc = NewControlUserPaneFocusUPP(wxMacControlUserPaneFocusProc); - - if (gTXNScrollInfoProc == NULL ) gTXNScrollInfoProc = NewTXNScrollInfoUPP(TXNScrollInfoProc) ; - if (gTXNScrollActionProc == NULL ) gTXNScrollActionProc = NewControlActionUPP(TXNScrollActionProc) ; - - // set the initial settings for our private data - - m_txnWindow = GetControlOwner(m_controlRef); - m_txnPort = (GrafPtr) GetWindowPort(m_txnWindow); - - // set up the user pane procedures - SetControlData(m_controlRef, kControlEntireControl, kControlUserPaneDrawProcTag, sizeof(gTPDrawProc), &gTPDrawProc); - SetControlData(m_controlRef, kControlEntireControl, kControlUserPaneHitTestProcTag, sizeof(gTPHitProc), &gTPHitProc); - SetControlData(m_controlRef, kControlEntireControl, kControlUserPaneTrackingProcTag, sizeof(gTPTrackProc), &gTPTrackProc); - SetControlData(m_controlRef, kControlEntireControl, kControlUserPaneIdleProcTag, sizeof(gTPIdleProc), &gTPIdleProc); - SetControlData(m_controlRef, kControlEntireControl, kControlUserPaneKeyDownProcTag, sizeof(gTPKeyProc), &gTPKeyProc); - SetControlData(m_controlRef, kControlEntireControl, kControlUserPaneActivateProcTag, sizeof(gTPActivateProc), &gTPActivateProc); - SetControlData(m_controlRef, kControlEntireControl, kControlUserPaneFocusProcTag, sizeof(gTPFocusProc), &gTPFocusProc); - - // calculate the rectangles used by the control - GetRectInWindowCoords( &bounds ); - - m_txnControlBounds = bounds ; - m_txnVisBounds = bounds ; - - CGrafPtr origPort ; - GDHandle origDev ; - - GetGWorld( &origPort, &origDev ) ; - SetPort( m_txnPort ); - - // create the new edit field - TXNFrameOptions frameOptions = FrameOptionsFromWXStyle( m_windowStyle ); - - // the scrollbars are not correctly embedded but are inserted at the root: - // this gives us problems as we have erratic redraws even over the structure area - - m_sbHorizontal = 0 ; - m_sbVertical = 0 ; - m_lastHorizontalValue = 0 ; - m_lastVerticalValue = 0 ; - - Rect sb = { 0 , 0 , 0 , 0 } ; - if ( frameOptions & kTXNWantVScrollBarMask ) - { - CreateScrollBarControl( m_txnWindow, &sb, 0, 0, 100, 1, true, gTXNScrollActionProc, &m_sbVertical ); - SetControlReference( m_sbVertical, (SInt32)this ); - SetControlAction( m_sbVertical, gTXNScrollActionProc ); - ShowControl( m_sbVertical ); - EmbedControl( m_sbVertical , m_controlRef ); - frameOptions &= ~kTXNWantVScrollBarMask; - } - - if ( frameOptions & kTXNWantHScrollBarMask ) - { - CreateScrollBarControl( m_txnWindow, &sb, 0, 0, 100, 1, true, gTXNScrollActionProc, &m_sbHorizontal ); - SetControlReference( m_sbHorizontal, (SInt32)this ); - SetControlAction( m_sbHorizontal, gTXNScrollActionProc ); - ShowControl( m_sbHorizontal ); - EmbedControl( m_sbHorizontal, m_controlRef ); - frameOptions &= ~(kTXNWantHScrollBarMask | kTXNDrawGrowIconMask); - } - - err = TXNNewObject( - NULL, m_txnWindow, &bounds, frameOptions, - kTXNTextEditStyleFrameType, kTXNTextensionFile, kTXNSystemDefaultEncoding, - &m_txn, &m_txnFrameID, NULL ); - verify_noerr( err ); - -#if 0 - TXNControlTag iControlTags[] = { kTXNUseCarbonEvents }; - TXNControlData iControlData[] = { { (UInt32)&cInfo } }; - int toptag = WXSIZEOF( iControlTags ) ; - TXNCarbonEventInfo cInfo ; - cInfo.useCarbonEvents = false ; - cInfo.filler = 0 ; - cInfo.flags = 0 ; - cInfo.fDictionary = NULL ; - - verify_noerr( TXNSetTXNObjectControls( m_txn, false, toptag, iControlTags, iControlData ) ); -#endif - - TXNRegisterScrollInfoProc( m_txn, gTXNScrollInfoProc, (SInt32)this ); - - SetGWorld( origPort , origDev ) ; - - return err; -} -#endif - // ---------------------------------------------------------------------------- // MLTE control implementation (OSX part) // ---------------------------------------------------------------------------- diff --git a/src/osx/carbon/toolbar.cpp b/src/osx/carbon/toolbar.cpp index a44e23bbda..374b7e471b 100644 --- a/src/osx/carbon/toolbar.cpp +++ b/src/osx/carbon/toolbar.cpp @@ -113,14 +113,6 @@ public: if ( m_toolbarItemRef ) { CFIndex count = CFGetRetainCount( m_toolbarItemRef ) ; - // different behaviour under Leopard - if ( UMAGetSystemVersion() < 0x1050 ) - { - if ( count != 1 ) - { - wxFAIL_MSG("Reference count of native tool was not 1 in wxToolBarTool destructor"); - } - } wxTheApp->MacAddToAutorelease(m_toolbarItemRef); CFRelease(m_toolbarItemRef); m_toolbarItemRef = NULL; @@ -941,14 +933,6 @@ wxToolBar::~wxToolBar() } CFIndex count = CFGetRetainCount( m_macToolbar ) ; - // Leopard seems to have one refcount more, so we cannot check reliably at the moment - if ( UMAGetSystemVersion() < 0x1050 ) - { - if ( count != 1 ) - { - wxFAIL_MSG("Reference count of native control was not 1 in wxToolBar destructor"); - } - } CFRelease( (HIToolbarRef)m_macToolbar ); m_macToolbar = NULL; #endif // wxOSX_USE_NATIVE_TOOLBAR @@ -1619,23 +1603,11 @@ bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), wxToolBarToolBase *toolBase) ControlButtonContentInfo info; wxMacCreateBitmapButton( &info, tool->GetNormalBitmap() ); - if ( UMAGetSystemVersion() >= 0x1000) - { - // contrary to the docs this control only works with iconrefs - ControlButtonContentInfo info; - wxMacCreateBitmapButton( &info, tool->GetNormalBitmap(), kControlContentIconRef ); - CreateIconControl( window, &toolrect, &info, false, &controlHandle ); - wxMacReleaseBitmapButton( &info ); - } - else - { - SInt16 behaviour = kControlBehaviorOffsetContents; - if ( tool->CanBeToggled() ) - behaviour |= kControlBehaviorToggles; - err = CreateBevelButtonControl( window, - &toolrect, CFSTR(""), kControlBevelButtonNormalBevel, - behaviour, &info, 0, 0, 0, &controlHandle ); - } + // contrary to the docs this control only works with iconrefs + ControlButtonContentInfo info; + wxMacCreateBitmapButton( &info, tool->GetNormalBitmap(), kControlContentIconRef ); + CreateIconControl( window, &toolrect, &info, false, &controlHandle ); + wxMacReleaseBitmapButton( &info ); #if wxOSX_USE_NATIVE_TOOLBAR if (m_macToolbar != NULL) diff --git a/src/osx/carbon/utils.cpp b/src/osx/carbon/utils.cpp index 8598ad1be8..9653ee4191 100644 --- a/src/osx/carbon/utils.cpp +++ b/src/osx/carbon/utils.cpp @@ -33,9 +33,7 @@ // #include "MoreFilesX.h" -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - #include -#endif +#include #include "wx/osx/private.h" #if wxUSE_GUI @@ -49,17 +47,8 @@ // Emit a beeeeeep void wxBell() { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 if ( AudioServicesPlayAlertSound != NULL ) AudioServicesPlayAlertSound(kUserPreferredAlert); - else -#endif -#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 - AlertSoundPlay(); -#else - { - } -#endif } wxTimerImpl* wxGUIAppTraits::CreateTimerImpl(wxTimer *timer) @@ -156,7 +145,6 @@ void wxGetMousePosition( int* x, int* y ) void wxClientDisplayRect(int *x, int *y, int *width, int *height) { -#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 HIRect bounds ; HIWindowGetAvailablePositioningBounds(kCGNullDirectDisplay,kHICoordSpace72DPIGlobal, &bounds); @@ -168,18 +156,6 @@ void wxClientDisplayRect(int *x, int *y, int *width, int *height) *width = bounds.size.width; if ( height ) *height = bounds.size.height; -#else - Rect r; - GetAvailableWindowPositioningBounds( GetMainDevice() , &r ); - if ( x ) - *x = r.left; - if ( y ) - *y = r.top; - if ( width ) - *width = r.right - r.left; - if ( height ) - *height = r.bottom - r.top; -#endif } #endif // wxUSE_GUI diff --git a/src/osx/carbon/window.cpp b/src/osx/carbon/window.cpp index 5a4a0bf791..69f7603605 100644 --- a/src/osx/carbon/window.cpp +++ b/src/osx/carbon/window.cpp @@ -299,11 +299,6 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl case kEventControlFocusPartChanged : // the event is emulated by wxmac for systems lower than 10.5 { - if ( UMAGetSystemVersion() < 0x1050 ) - { - // as it is synthesized here, we have to manually avoid propagation - result = noErr; - } ControlPartCode previousControlPart = cEvent.GetParameter(kEventParamControlPreviousPart , typeControlPartCode ); ControlPartCode currentControlPart = cEvent.GetParameter(kEventParamControlCurrentPart , typeControlPartCode ); @@ -387,76 +382,6 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl } else result = CallNextEventHandler(handler, event); - - if ( UMAGetSystemVersion() < 0x1050 ) - { -// set back to 0 if problems arise -#if 1 - if ( result == noErr ) - { - ControlPartCode currentControlPart = cEvent.GetParameter(kEventParamControlPart , typeControlPartCode ); - // synthesize the event focus changed event - EventRef evRef = NULL ; - - OSStatus err = MacCreateEvent( - NULL , kEventClassControl , kEventControlFocusPartChanged , TicksToEventTime( TickCount() ) , - kEventAttributeUserEvent , &evRef ); - verify_noerr( err ); - - wxMacCarbonEvent iEvent( evRef ) ; - iEvent.SetParameter( kEventParamDirectObject , controlRef ); - iEvent.SetParameter( kEventParamPostTarget, typeEventTargetRef, GetControlEventTarget( controlRef ) ); - iEvent.SetParameter( kEventParamControlPreviousPart, typeControlPartCode, previousControlPart ); - iEvent.SetParameter( kEventParamControlCurrentPart, typeControlPartCode, currentControlPart ); - -#if 1 - // TODO test this first, avoid double posts etc... - PostEventToQueue( GetMainEventQueue(), evRef , kEventPriorityHigh ); -#else - wxMacWindowControlEventHandler( NULL , evRef , data ) ; -#endif - ReleaseEvent( evRef ) ; - } -#else - // old implementation, to be removed if the new one works - if ( controlPart == kControlFocusNoPart ) - { -#if wxUSE_CARET - if ( thisWindow->GetCaret() ) - thisWindow->GetCaret()->OnKillFocus(); -#endif - - wxLogTrace(wxT("Focus"), wxT("focus lost(%p)"), static_cast(thisWindow)); - - static bool inKillFocusEvent = false ; - - if ( !inKillFocusEvent ) - { - inKillFocusEvent = true ; - wxFocusEvent event( wxEVT_KILL_FOCUS, thisWindow->GetId()); - event.SetEventObject(thisWindow); - thisWindow->HandleWindowEvent(event) ; - inKillFocusEvent = false ; - } - } - else - { - // panel wants to track the window which was the last to have focus in it - wxLogTrace(wxT("Focus"), wxT("focus set(%p)"), static_cast(thisWindow)); - wxChildFocusEvent eventFocus((wxWindow*)thisWindow); - thisWindow->HandleWindowEvent(eventFocus); - - #if wxUSE_CARET - if ( thisWindow->GetCaret() ) - thisWindow->GetCaret()->OnSetFocus(); - #endif - - wxFocusEvent event(wxEVT_SET_FOCUS, thisWindow->GetId()); - event.SetEventObject(thisWindow); - thisWindow->HandleWindowEvent(event) ; - } -#endif - } } break ; @@ -1136,19 +1061,10 @@ void wxMacControl::SetCursor(const wxCursor& cursor) ControlPartCode part ; ControlRef control ; Point pt ; -#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 HIPoint hiPoint ; HIGetMousePosition(kHICoordSpaceWindow, window, &hiPoint); pt.h = hiPoint.x; pt.v = hiPoint.y; -#else - GetGlobalMouse( &pt ); - int x = pt.h; - int y = pt.v; - tlwwx->ScreenToClient(&x, &y); - pt.h = x; - pt.v = y; -#endif control = FindControlUnderMouse( pt , window , &part ) ; if ( control ) mouseWin = wxFindWindowFromWXWidget( (WXWidget) control ) ; @@ -1263,24 +1179,21 @@ void wxMacControl::SetFont( const wxFont & font , const wxColour& foreground , l { m_font = font; #if wxOSX_USE_CORE_TEXT - if ( UMAGetSystemVersion() >= 0x1050 ) - { - HIViewPartCode part = 0; - HIThemeTextHorizontalFlush flush = kHIThemeTextHorizontalFlushDefault; - if ( ( windowStyle & wxALIGN_MASK ) & wxALIGN_CENTER_HORIZONTAL ) - flush = kHIThemeTextHorizontalFlushCenter; - else if ( ( windowStyle & wxALIGN_MASK ) & wxALIGN_RIGHT ) - flush = kHIThemeTextHorizontalFlushRight; - HIViewSetTextFont( m_controlRef , part , (CTFontRef) font.OSXGetCTFont() ); - HIViewSetTextHorizontalFlush( m_controlRef, part, flush ); + HIViewPartCode part = 0; + HIThemeTextHorizontalFlush flush = kHIThemeTextHorizontalFlushDefault; + if ( ( windowStyle & wxALIGN_MASK ) & wxALIGN_CENTER_HORIZONTAL ) + flush = kHIThemeTextHorizontalFlushCenter; + else if ( ( windowStyle & wxALIGN_MASK ) & wxALIGN_RIGHT ) + flush = kHIThemeTextHorizontalFlushRight; + HIViewSetTextFont( m_controlRef , part , (CTFontRef) font.OSXGetCTFont() ); + HIViewSetTextHorizontalFlush( m_controlRef, part, flush ); - if ( foreground != *wxBLACK || ignoreBlack == false ) - { - ControlFontStyleRec fontStyle; - foreground.GetRGBColor( &fontStyle.foreColor ); - fontStyle.flags = kControlUseForeColorMask; - ::SetControlFontStyle( m_controlRef , &fontStyle ); - } + if ( foreground != *wxBLACK || ignoreBlack == false ) + { + ControlFontStyleRec fontStyle; + foreground.GetRGBColor( &fontStyle.foreColor ); + fontStyle.flags = kControlUseForeColorMask; + ::SetControlFontStyle( m_controlRef , &fontStyle ); } #endif #if wxOSX_USE_ATSU_TEXT diff --git a/src/osx/cocoa/dataview.mm b/src/osx/cocoa/dataview.mm index d2d219d18e..e7af0fb007 100644 --- a/src/osx/cocoa/dataview.mm +++ b/src/osx/cocoa/dataview.mm @@ -367,10 +367,8 @@ NSTableColumn* CreateNativeColumn(const wxDataViewColumn *column) } [nativeColumn setResizingMask:resizingMask]; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 // setting the visibility: [nativeColumn setHidden:static_cast(column->IsHidden())]; -#endif wxDataViewRendererNativeData * const renderData = renderer->GetNativeData(); @@ -1486,7 +1484,6 @@ outlineView:(NSOutlineView*)outlineView [super editWithFrame:textFrame inView:controlView editor:textObj delegate:anObject event:theEvent]; } -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 -(NSUInteger) hitTestForEvent:(NSEvent*)event inRect:(NSRect)cellFrame ofView:(NSView*)controlView { NSPoint point = [controlView convertPoint:[event locationInWindow] fromView:nil]; @@ -1528,7 +1525,6 @@ outlineView:(NSOutlineView*)outlineView return [super hitTestForEvent:event inRect:textFrame ofView:controlView]; } -#endif -(NSRect) imageRectForBounds:(NSRect)cellFrame { @@ -2060,7 +2056,6 @@ bool wxCocoaDataViewControl::InsertColumn(unsigned int pos, wxDataViewColumn* co void wxCocoaDataViewControl::FitColumnWidthToContent(unsigned int pos) { -#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 const int count = GetCount(); NSTableColumn *column = GetColumn(pos)->GetNativeData()->GetNativeColumnPtr(); @@ -2173,7 +2168,6 @@ void wxCocoaDataViewControl::FitColumnWidthToContent(unsigned int pos) } [column setWidth:calculator.GetMaxWidth()]; -#endif // MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 } // @@ -3295,15 +3289,13 @@ void wxDataViewColumn::SetWidth(int width) switch ( width ) { case wxCOL_WIDTH_AUTOSIZE: -#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 if ( GetOwner() ) { wxCocoaDataViewControl *peer = static_cast(GetOwner()->GetPeer()); peer->FitColumnWidthToContent(GetOwner()->GetColumnPosition(this)); break; } -#endif - // fall through if unsupported (OSX < 10.5) or not yet settable + // fall through if not yet settable case wxCOL_WIDTH_DEFAULT: width = wxDVC_DEFAULT_WIDTH; diff --git a/src/osx/cocoa/evtloop.mm b/src/osx/cocoa/evtloop.mm index 2a27139d35..c6c55d948f 100644 --- a/src/osx/cocoa/evtloop.mm +++ b/src/osx/cocoa/evtloop.mm @@ -66,10 +66,8 @@ static NSUInteger CalculateNSEventMaskFromEventCategory(wxEventCategory cat) NSMouseEnteredMask | NSMouseExitedMask | NSScrollWheelMask | -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 NSTabletPointMask | NSTabletProximityMask | -#endif NSOtherMouseDownMask | NSOtherMouseUpMask | NSOtherMouseDraggedMask | @@ -77,14 +75,12 @@ static NSUInteger CalculateNSEventMaskFromEventCategory(wxEventCategory cat) NSKeyDownMask | NSKeyUpMask | NSFlagsChangedMask | -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 NSEventMaskGesture | NSEventMaskMagnify | NSEventMaskSwipe | NSEventMaskRotate | NSEventMaskBeginGesture | NSEventMaskEndGesture | -#endif 0; } diff --git a/src/osx/cocoa/scrolbar.mm b/src/osx/cocoa/scrolbar.mm index 6559a8d47c..a93ae41f15 100644 --- a/src/osx/cocoa/scrolbar.mm +++ b/src/osx/cocoa/scrolbar.mm @@ -57,12 +57,8 @@ public : { double v = ((double) value)/m_maximum; double t = ((double) thumbSize)/(m_maximum+thumbSize); -#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 - [(wxNSScroller*) m_osxView setFloatValue:v knobProportion:t]; -#else [(wxNSScroller*) m_osxView setDoubleValue:v]; [(wxNSScroller*) m_osxView setKnobProportion:t]; -#endif } virtual wxInt32 GetValue() const diff --git a/src/osx/iphone/evtloop.mm b/src/osx/iphone/evtloop.mm index f928274e41..4e179b6241 100644 --- a/src/osx/iphone/evtloop.mm +++ b/src/osx/iphone/evtloop.mm @@ -54,10 +54,8 @@ static int CalculateUIEventMaskFromEventCategory(wxEventCategory cat) NSMouseEnteredMask = 1 << NSMouseEntered, NSMouseExitedMask = 1 << NSMouseExited, NSScrollWheelMask = 1 << NSScrollWheel, -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 NSTabletPointMask = 1 << NSTabletPoint, NSTabletProximityMask = 1 << NSTabletProximity, -#endif NSOtherMouseDownMask = 1 << NSOtherMouseDown, NSOtherMouseUpMask = 1 << NSOtherMouseUp, NSOtherMouseDraggedMask = 1 << NSOtherMouseDragged, diff --git a/src/osx/webview_webkit.mm b/src/osx/webview_webkit.mm index f58975ca52..e616f233bd 100644 --- a/src/osx/webview_webkit.mm +++ b/src/osx/webview_webkit.mm @@ -351,10 +351,7 @@ bool wxWebViewWebKit::Create(wxWindow *parent, m_webView = (WebView*) HIWebViewGetWebView( peer->GetControlRef() ); -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 - if ( UMAGetSystemVersion() >= 0x1030 ) - HIViewChangeFeatures( peer->GetControlRef() , kHIViewIsOpaque , 0 ) ; -#endif + HIViewChangeFeatures( peer->GetControlRef() , kHIViewIsOpaque , 0 ) ; InstallControlEventHandler(peer->GetControlRef(), GetwxWebViewWebKitEventHandlerUPP(), GetEventTypeCount(eventList), eventList, this, @@ -1074,9 +1071,7 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out) case NSURLErrorResourceUnavailable: case NSURLErrorHTTPTooManyRedirects: -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 case NSURLErrorDataLengthExceedsMaximum: -#endif case NSURLErrorBadURL: case NSURLErrorFileIsDirectory: *out = wxWEBVIEW_NAV_ERR_REQUEST; @@ -1098,20 +1093,16 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out) *out = wxWEBVIEW_NAV_ERR_USER_CANCELLED; break; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 case NSURLErrorCannotDecodeRawData: case NSURLErrorCannotDecodeContentData: case NSURLErrorCannotParseResponse: -#endif case NSURLErrorBadServerResponse: *out = wxWEBVIEW_NAV_ERR_REQUEST; break; case NSURLErrorUserAuthenticationRequired: case NSURLErrorSecureConnectionFailed: -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 case NSURLErrorClientCertificateRequired: -#endif *out = wxWEBVIEW_NAV_ERR_AUTH; break;