From 1bd568fa44a864a4110b13e8e0d08f923e5fb4ff Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Sat, 24 Nov 2007 09:41:14 +0000 Subject: [PATCH] 64 bit fixes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50211 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/aboutdlg.cpp | 2 ++ src/mac/carbon/accel.cpp | 4 +++ src/mac/carbon/app.cpp | 40 +++++++++++++++++---------- src/mac/carbon/dcclient.cpp | 6 +++- src/mac/carbon/dcscreen.cpp | 8 ++++++ src/mac/carbon/font.cpp | 3 +- src/mac/carbon/graphics.cpp | 55 ++++++++++++++++++++++++++++++++++--- src/mac/carbon/printdlg.cpp | 11 ++++++-- 8 files changed, 106 insertions(+), 23 deletions(-) diff --git a/src/mac/carbon/aboutdlg.cpp b/src/mac/carbon/aboutdlg.cpp index 9cf251339a..191598e543 100644 --- a/src/mac/carbon/aboutdlg.cpp +++ b/src/mac/carbon/aboutdlg.cpp @@ -61,6 +61,7 @@ void wxAboutBox(const wxAboutDialogInfo& info) // Mac native about box currently can show only name, version, copyright // and description fields and we also shoehorn the credits text into the // description but if we have anything else we must use the generic version +#ifndef __LP64__ if ( info.IsSimple() ) { AboutBoxOptions opts; @@ -78,6 +79,7 @@ void wxAboutBox(const wxAboutDialogInfo& info) HIAboutBox(opts); } else // simple "native" version is not enough +#endif { // we need to use the full-blown generic version wxGenericAboutBox(info); diff --git a/src/mac/carbon/accel.cpp b/src/mac/carbon/accel.cpp index b221f9107c..f33bbe28e0 100644 --- a/src/mac/carbon/accel.cpp +++ b/src/mac/carbon/accel.cpp @@ -17,6 +17,8 @@ #include "wx/string.h" #endif +#ifndef __WXUNIVERSAL__ + IMPLEMENT_DYNAMIC_CLASS(wxAcceleratorTable, wxObject) // ---------------------------------------------------------------------------- @@ -103,3 +105,5 @@ int wxAcceleratorTable::GetCommand( wxKeyEvent &event ) return -1; } + +#endif \ No newline at end of file diff --git a/src/mac/carbon/app.cpp b/src/mac/carbon/app.cpp index 524f623b83..f17bc48c4a 100644 --- a/src/mac/carbon/app.cpp +++ b/src/mac/carbon/app.cpp @@ -594,6 +594,7 @@ wxMacAppMenuEventHandler( EventHandlerCallRef WXUNUSED(handler), return eventNotHandledErr; } +#ifndef __LP64__ static pascal OSStatus wxMacAppCommandEventHandler( EventHandlerCallRef WXUNUSED(handler) , EventRef event , @@ -630,6 +631,7 @@ wxMacAppCommandEventHandler( EventHandlerCallRef WXUNUSED(handler) , } return result ; } +#endif static pascal OSStatus wxMacAppApplicationEventHandler( EventHandlerCallRef WXUNUSED(handler) , @@ -667,14 +669,15 @@ pascal OSStatus wxMacAppEventHandler( EventHandlerCallRef handler , EventRef eve OSStatus result = eventNotHandledErr ; switch ( GetEventClass( event ) ) { +#ifndef __LP64__ case kEventClassCommand : result = wxMacAppCommandEventHandler( handler , event , data ) ; break ; - +#endif case kEventClassApplication : result = wxMacAppApplicationEventHandler( handler , event , data ) ; break ; - +#ifndef __LP64__ case kEventClassMenu : result = wxMacAppMenuEventHandler( handler , event , data ) ; break ; @@ -692,13 +695,23 @@ pascal OSStatus wxMacAppEventHandler( EventHandlerCallRef handler , EventRef eve result = wxMacTopLevelMouseEventHandler( handler , event , NULL ) ; } break ; - +#endif case kEventClassAppleEvent : { - EventRecord rec ; +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + if ( AEProcessEvent != NULL ) + { + result = AEProcessEvent(event); + } +#endif +#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 + { + EventRecord rec ; - wxMacConvertEventToRecord( event , &rec ) ; - result = AEProcessAppleEvent( &rec ) ; + wxMacConvertEventToRecord( event , &rec ) ; + result = AEProcessAppleEvent( &rec ) ; + } +#endif } break ; @@ -777,7 +790,7 @@ bool wxApp::Initialize(int& argc, wxChar **argv) #endif UMAInitToolbox( 4, sm_isEmbedded ) ; - SetEventMask( everyEvent ) ; +// TODO CHECK Can Be Removed SetEventMask( everyEvent ) ; UMAShowWatchCursor() ; // Mac OS X passes a process serial number command line argument when @@ -842,15 +855,15 @@ bool wxApp::OnInitGui() { if ( !wxAppBase::OnInitGui() ) return false ; - +#ifndef __LP64__ InstallStandardEventHandler( GetApplicationEventTarget() ) ; - if (!sm_isEmbedded) { InstallApplicationEventHandler( GetwxMacAppEventHandlerUPP(), GetEventTypeCount(eventList), eventList, wxTheApp, (EventHandlerRef *)&(wxTheApp->m_macEventHandler)); } +#endif if (!sm_isEmbedded) { @@ -931,6 +944,7 @@ void wxApp::CleanUp() // misc initialization stuff //---------------------------------------------------------------------- +#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec) { OSStatus err = noErr ; @@ -971,9 +985,7 @@ bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec) UInt32 keyCode ; unsigned char charCode ; UInt32 modifiers ; -#ifndef __LP64__ GetMouse( &rec->where) ; -#endif err = GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, 4, NULL, &modifiers); err = GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, 4, NULL, &keyCode); err = GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar, NULL, 1, NULL, &charCode); @@ -998,10 +1010,7 @@ bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec) { UInt32 keyCode, modifiers; unsigned char charCode ; -#ifndef __LP64__ - GetMouse( &rec->where) ; -#endif rec->what = keyDown ; err = GetEventParameter(rawEvent, kEventParamKeyModifiers, typeUInt32, NULL, 4, NULL, &modifiers); err = GetEventParameter(rawEvent, kEventParamKeyCode, typeUInt32, NULL, 4, NULL, &keyCode); @@ -1025,6 +1034,7 @@ bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec) return converted ; } +#endif wxApp::wxApp() { @@ -1514,6 +1524,7 @@ bool wxApp::MacSendCharEvent( wxWindow* focus , long keymessage , long modifiers { // if window is not having a focus still testing for default enter or cancel // TODO: add the UMA version for ActiveNonFloatingWindow +#ifndef __LP64__ wxWindow* focus = wxFindWinFromMacWindow( FrontWindow() ) ; if ( focus ) { @@ -1541,6 +1552,7 @@ bool wxApp::MacSendCharEvent( wxWindow* focus , long keymessage , long modifiers handled = focus->GetEventHandler()->ProcessEvent( new_event ); } } +#endif } return handled ; } diff --git a/src/mac/carbon/dcclient.cpp b/src/mac/carbon/dcclient.cpp index 63eb7a328e..bc776fb9dd 100644 --- a/src/mac/carbon/dcclient.cpp +++ b/src/mac/carbon/dcclient.cpp @@ -115,10 +115,13 @@ wxBitmap wxWindowDC::DoGetAsBitmap(const wxRect *subrect) const if (!m_window) return wxNullBitmap; +#ifdef __LP64__ + return wxNullBitmap; +#else ControlRef handle = (ControlRef) m_window->GetHandle(); if ( !handle ) return wxNullBitmap; - + HIRect rect; CGImageRef image; CGContextRef context; @@ -161,6 +164,7 @@ wxBitmap wxWindowDC::DoGetAsBitmap(const wxRect *subrect) const } return bmp; +#endif } /* diff --git a/src/mac/carbon/dcscreen.cpp b/src/mac/carbon/dcscreen.cpp index 1de302dade..ba827defdd 100644 --- a/src/mac/carbon/dcscreen.cpp +++ b/src/mac/carbon/dcscreen.cpp @@ -25,6 +25,10 @@ IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC) // Create a DC representing the whole screen wxScreenDC::wxScreenDC() { +#ifdef __LP64__ + m_graphicContext = NULL; + m_ok = false ; +#else CGRect cgbounds ; cgbounds = CGDisplayBounds(CGMainDisplayID()); Rect bounds; @@ -39,11 +43,15 @@ wxScreenDC::wxScreenDC() m_width = (wxCoord)cgbounds.size.width; m_height = (wxCoord)cgbounds.size.height; m_ok = true ; +#endif } wxScreenDC::~wxScreenDC() { delete m_graphicContext; m_graphicContext = NULL; +#ifdef __LP64__ +#else DisposeWindow((WindowRef) m_overlayWindow ); +#endif } diff --git a/src/mac/carbon/font.cpp b/src/mac/carbon/font.cpp index 9e0fe30b92..e509a7f34b 100644 --- a/src/mac/carbon/font.cpp +++ b/src/mac/carbon/font.cpp @@ -310,12 +310,13 @@ void wxFontRefData::MacFindFont() int attributeCount = sizeof(atsuTags) / sizeof(ATSUAttributeTag) ; // attempt to add atsu font +#if 0 status = ATSUFindFontFromName(m_faceName.c_str(), strlen(m_faceName.c_str()), kFontFamilyName, kFontNoPlatform, kFontNoScript, kFontNoLanguage, &atsuFontID); if ( status != noErr ) { attributeCount--; } - +#endif ATSUAttributeValuePtr atsuValues[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] = { &atsuSize , diff --git a/src/mac/carbon/graphics.cpp b/src/mac/carbon/graphics.cpp index d0f3507011..e06b5404c0 100644 --- a/src/mac/carbon/graphics.cpp +++ b/src/mac/carbon/graphics.cpp @@ -39,6 +39,12 @@ typedef float CGFloat; #endif +#ifdef __LP64__ +#define wxMAC_USE_CORE_TEXT 1 +#else +#define wxMAC_USE_ATSU_TEXT 1 +#endif +#undef wxMAC_USE_CG_TEXT //----------------------------------------------------------------------------- // constants //----------------------------------------------------------------------------- @@ -66,8 +72,9 @@ OSStatus wxMacDrawCGImage( #ifdef __LP64__ // todo flip CGContextDrawImage(inContext, *inBounds, inImage ); + return noErr; #else - HIViewDrawCGImage( inContext, inBounds, inImage ); + return HIViewDrawCGImage( inContext, inBounds, inImage ); #endif } @@ -708,6 +715,8 @@ wxMacCoreGraphicsFontData::wxMacCoreGraphicsFontData(wxGraphicsRenderer* rendere { m_macATSUIStyle = NULL; +#ifdef wxMAC_USE_CORE_TEXT +#elif defined(wxMAC_USE_ATSU_TEXT) OSStatus status; status = ATSUCreateAndCopyStyle( (ATSUStyle) font.MacGetATSUStyle() , &m_macATSUIStyle ); @@ -740,15 +749,21 @@ wxMacCoreGraphicsFontData::wxMacCoreGraphicsFontData(wxGraphicsRenderer* rendere atsuTags, atsuSizes, atsuValues); wxASSERT_MSG( status == noErr , wxT("couldn't modify ATSU style") ); +#elif defined(WXMAC_USE_CG_TEXT) +#endif } wxMacCoreGraphicsFontData::~wxMacCoreGraphicsFontData() { +#ifdef wxMAC_USE_CORE_TEXT +#elif defined(wxMAC_USE_ATSU_TEXT) if ( m_macATSUIStyle ) { ::ATSUDisposeStyle((ATSUStyle)m_macATSUIStyle); m_macATSUIStyle = NULL; } +#elif defined(WXMAC_USE_CG_TEXT) +#endif } // @@ -1320,9 +1335,12 @@ wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( wxGraphicsRenderer* renderer int originX , originY; originX = originY = 0; window->MacWindowToRootWindow( &originX , &originY ); - Rect bounds; - GetWindowBounds( m_windowRef, kWindowContentRgn, &bounds ); + Rect bounds = { 0,0,0,0 }; +#ifdef __LP64__ +#else + GetWindowBounds( m_windowRef, kWindowContentRgn, &bounds ); +#endif m_windowTransform = CGAffineTransformMakeTranslation( 0 , bounds.bottom - bounds.top ); m_windowTransform = CGAffineTransformScale( m_windowTransform , 1 , -1 ); m_windowTransform = CGAffineTransformTranslate( m_windowTransform, originX, originY ) ; @@ -1711,7 +1729,17 @@ void wxMacCoreGraphicsContext::PopState() void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDouble y ) { + if ( m_font.IsNull() ) + return; + + EnsureIsValid(); +#ifdef wxMAC_USE_CORE_TEXT + // TODO core text implementation here +#elif defined(wxMAC_USE_ATSU_TEXT) DrawText(str, x, y, 0.0); +#elif defined(WXMAC_USE_CG_TEXT) + // TODO core graphics text implementation here +#endif } void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle ) @@ -1720,7 +1748,10 @@ void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDoub return; EnsureIsValid(); - +#ifdef wxMAC_USE_CORE_TEXT + // default implementation takes care of rotation and calls non rotated DrawText afterwards + wxGraphicsContext::DrawText( str, x, y, angle ); +#elif defined(wxMAC_USE_ATSU_TEXT) OSStatus status = noErr; ATSUTextLayout atsuLayout; UniCharCount chars = str.length(); @@ -1826,6 +1857,10 @@ void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDoub #if SIZEOF_WCHAR_T == 4 free( ubuf ); #endif +#elif defined(WXMAC_USE_CG_TEXT) + // default implementation takes care of rotation and calls non rotated DrawText afterwards + wxGraphicsContext::DrawText( str, x, y, angle ); +#endif } void wxMacCoreGraphicsContext::GetTextExtent( const wxString &str, wxDouble *width, wxDouble *height, @@ -1845,6 +1880,9 @@ void wxMacCoreGraphicsContext::GetTextExtent( const wxString &str, wxDouble *wid if (str.empty()) return; +#ifdef wxMAC_USE_CORE_TEXT + // TODO core text implementation here +#elif defined(wxMAC_USE_ATSU_TEXT) OSStatus status = noErr; ATSUTextLayout atsuLayout; @@ -1899,6 +1937,9 @@ void wxMacCoreGraphicsContext::GetTextExtent( const wxString &str, wxDouble *wid #if SIZEOF_WCHAR_T == 4 free( ubuf ) ; #endif +#elif defined(WXMAC_USE_CG_TEXT) + // TODO core graphics text implementation here +#endif } void wxMacCoreGraphicsContext::GetPartialTextExtents(const wxString& text, wxArrayDouble& widths) const @@ -1909,6 +1950,9 @@ void wxMacCoreGraphicsContext::GetPartialTextExtents(const wxString& text, wxArr if (text.empty()) return; +#ifdef wxMAC_USE_CORE_TEXT + // TODO core text implementation here +#elif defined(wxMAC_USE_ATSU_TEXT) ATSUTextLayout atsuLayout; UniCharCount chars = text.length(); UniChar* ubuf = NULL; @@ -1960,6 +2004,9 @@ void wxMacCoreGraphicsContext::GetPartialTextExtents(const wxString& text, wxArr #if SIZEOF_WCHAR_T == 4 free( ubuf ) ; #endif +#elif defined(WXMAC_USE_CG_TEXT) + // TODO core graphics text implementation here +#endif } void * wxMacCoreGraphicsContext::GetNativeContext() diff --git a/src/mac/carbon/printdlg.cpp b/src/mac/carbon/printdlg.cpp index 8e13503729..87632fc308 100644 --- a/src/mac/carbon/printdlg.cpp +++ b/src/mac/carbon/printdlg.cpp @@ -82,9 +82,12 @@ int wxMacPrintDialog::ShowModal() ((wxMacCarbonPrintData*)m_printDialogData.GetPrintData().GetNativeData())->TransferFrom( &m_printDialogData ); int result = wxID_CANCEL; + +#ifdef __LP64__ + // TODO use NSPrintPanel +#else OSErr err = noErr; Boolean accepted; - err = PMSessionPrintDialog( ((wxMacCarbonPrintData*)m_printDialogData.GetPrintData().GetNativeData())->m_macPrintSession, ((wxMacCarbonPrintData*)m_printDialogData.GetPrintData().GetNativeData())->m_macPrintSettings, @@ -116,7 +119,7 @@ int wxMacPrintDialog::ShowModal() m_printDialogData.GetPrintData().ConvertFromNative(); ((wxMacCarbonPrintData*)m_printDialogData.GetPrintData().GetNativeData())->TransferTo( &m_printDialogData ); } - +#endif return result; } @@ -158,6 +161,8 @@ int wxMacPageSetupDialog::ShowModal() ((wxMacCarbonPrintData*)m_pageSetupData.GetPrintData().GetNativeData())->TransferFrom( &m_pageSetupData ); int result = wxID_CANCEL; +#ifdef __LP64__ +#else OSErr err = noErr; Boolean accepted; @@ -194,7 +199,7 @@ int wxMacPageSetupDialog::ShowModal() m_pageSetupData.SetPaperSize( m_pageSetupData.GetPrintData().GetPaperSize() ); ((wxMacCarbonPrintData*)m_pageSetupData.GetPrintData().GetNativeData())->TransferTo( &m_pageSetupData ); } - +#endif return result; } -- 2.47.2