M_BRUSHDATA->m_macBrushKind = kwxMacBrushTheme;
M_BRUSHDATA->m_macThemeBrush = macThemeBrush;
- RGBColor color ;
+ RGBColor color = { 0,0,0 } ;
+#ifdef __LP64__
+ CGColorRef colorref = 0;
+ HIThemeBrushCreateCGColor( macThemeBrush, &colorref );
+ size_t noComp = CGColorGetNumberOfComponents( colorref );
+ if ( noComp >=3 && noComp <= 4 )
+ {
+ // TODO verify whether we really are on a RGB color space
+ const CGFloat *components = CGColorGetComponents( colorref );
+ color.red = (int)(components[0]*255+0.5);
+ color.green = (int)(components[1]*255+0.5);
+ color.blue = (int)(components[2]*255+0.5);
+ }
+ CFRelease( colorref );
+#else
GetThemeBrushAsColor( macThemeBrush , 32, true, &color );
+#endif
M_BRUSHDATA->m_colour = color;
RealizeResource();
}
+/* TODO REMOVE
void wxBrush::MacSetThemeBackground(unsigned long macThemeBackground, const WXRECTPTR extent)
{
Unshare();
RealizeResource();
}
+*/
bool wxBrush::RealizeResource()
{
return true;
}
+/*
unsigned long wxBrush::MacGetThemeBackground(WXRECTPTR extent) const
{
if ( M_BRUSHDATA && M_BRUSHDATA->m_macBrushKind == kwxMacBrushThemeBackground )
return 0;
}
}
+ */
short wxBrush::MacGetTheme() const
{
wxColour::wxColour(const RGBColor& col)
{
- FromRGBColor((WXCOLORREF *)&col);
+ InitRGBColor(col);
}
-static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green )
+wxColour::wxColour(CGColorRef col)
{
- RGBColor* col = (RGBColor*) color;
- col->red = (red << 8) + red;
- col->blue = (blue << 8) + blue;
- col->green = (green << 8) + green;
+ InitCGColorRef(col);
}
-void wxColour::Init()
+void wxColour::GetRGBColor( RGBColor *col ) const
{
- m_isInit = false;
- m_red =
- m_blue =
- m_green = 0;
-
- wxComposeRGBColor( &m_pixel, m_red, m_blue, m_green );
+ col->red = (m_red << 8) + m_red;
+ col->blue = (m_blue << 8) + m_blue;
+ col->green = (m_green << 8) + m_green;
}
wxColour::~wxColour ()
{
}
-void wxColour::InitRGBA (unsigned char r, unsigned char g, unsigned char b, unsigned char a)
+wxColour& wxColour::operator=(const RGBColor& col)
+{
+ InitRGBColor(col);
+ return *this;
+}
+
+wxColour& wxColour::operator=(CGColorRef col)
+{
+ InitCGColorRef(col);
+ return *this;
+}
+
+bool wxColour::IsOk() const
+{
+ return m_cgColour.get() != NULL;
+}
+
+void wxColour::InitRGBA (ChannelType r, ChannelType g, ChannelType b, ChannelType a)
{
m_red = r;
m_green = g;
m_blue = b;
m_alpha = a ;
- m_isInit = true;
- wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green );
+ CGColorRef col = 0 ;
+#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
+ if ( CGColorCreateGenericRGB )
+ col = CGColorCreateGenericRGB( r / 255.0, g / 255.0, b / 255.0, a / 255.0 );
+ else
+#endif
+ {
+ CGFloat components[4] = { r / 255.0, g / 255.0, b / 255.0, a / 255.0 } ;
+ col = CGColorCreate( wxMacGetGenericRGBColorSpace() , components ) ;
+ }
+ m_cgColour.reset( col );
}
-void wxColour::FromRGBColor( WXCOLORREF* color )
+void wxColour::InitRGBColor( const RGBColor& col )
{
- RGBColor* col = (RGBColor*) color;
- memcpy( &m_pixel, color, 6 );
- m_red = col->red >> 8;
- m_blue = col->blue >> 8;
- m_green = col->green >> 8;
- m_alpha = 255;
+ m_red = col.red >> 8;
+ m_blue = col.blue >> 8;
+ m_green = col.green >> 8;
+ m_alpha = wxALPHA_OPAQUE;
+ CGColorRef cfcol;
+#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
+ if ( CGColorCreateGenericRGB )
+ cfcol = CGColorCreateGenericRGB( col.red / 65535.0, col.green / 65535.0, col.blue / 65535.0, 1.0 );
+ else
+#endif
+ {
+ CGFloat components[4] = { col.red / 65535.0, col.green / 65535.0, col.blue / 65535.0, 1.0 } ;
+ cfcol = CGColorCreate( wxMacGetGenericRGBColorSpace() , components ) ;
+ }
+ m_cgColour.reset( cfcol );
}
-wxColour& wxColour::operator=(const RGBColor& col)
+void wxColour::InitCGColorRef( CGColorRef col )
{
- FromRGBColor((WXCOLORREF *)&col);
- return *this;
+ m_cgColour.reset( col );
+ size_t noComp = CGColorGetNumberOfComponents( col );
+ if ( noComp >=3 && noComp <= 4 )
+ {
+ // TODO verify whether we really are on a RGB color space
+ const CGFloat *components = CGColorGetComponents( col );
+ m_red = (int)(components[0]*255+0.5);
+ m_green = (int)(components[1]*255+0.5);
+ m_blue = (int)(components[2]*255+0.5);
+ if ( noComp == 4 )
+ m_alpha = (int)(components[3]*255+0.5);
+ else
+ m_alpha = wxALPHA_OPAQUE;
+ }
+ else
+ {
+ m_alpha = wxALPHA_OPAQUE;
+ m_red = m_green = m_blue = 0;
+ }
}
-bool wxColour::IsOk() const
+bool wxColour::operator == (const wxColour& colour) const
{
- return m_isInit;
+ return ( (IsOk() == colour.IsOk()) && (!IsOk() ||
+ CGColorEqualToColor( m_cgColour, colour.m_cgColour ) ) );
}
+
m_bitmap.Create( CGImageGetWidth(cgImageRef) , CGImageGetHeight(cgImageRef) );
CGRect r = CGRectMake( 0 , 0 , CGImageGetWidth(cgImageRef) , CGImageGetHeight(cgImageRef) );
// since our context is upside down we dont use CGContextDrawImage
- HIViewDrawCGImage( (CGContextRef) m_bitmap.GetHBITMAP() , &r, cgImageRef ) ;
+ wxMacDrawCGImage( (CGContextRef) m_bitmap.GetHBITMAP() , &r, cgImageRef ) ;
CGImageRelease(cgImageRef);
cgImageRef = NULL;
}
#pragma mark -
#pragma mark wxMacCoreGraphicsPattern, ImagePattern, HatchPattern classes
+OSStatus wxMacDrawCGImage(
+ CGContextRef inContext,
+ const HIRect * inBounds,
+ CGImageRef inImage)
+{
+#ifdef __LP64__
+ // todo flip
+ CGContextDrawImage(inContext, *inBounds, inImage );
+#else
+ HIViewDrawCGImage( inContext, inBounds, inImage );
+#endif
+}
+
// CGPattern wrapper class: always allocate on heap, never call destructor
class wxMacCoreGraphicsPattern
virtual void Render( CGContextRef ctxRef )
{
if (m_image != NULL)
- HIViewDrawCGImage( ctxRef, &m_imageBounds, m_image );
+ wxMacDrawCGImage( ctxRef, &m_imageBounds, m_image );
}
protected :
// we need the scale here ...
Fixed atsuSize = IntToFixed( int( 1 * font.MacGetFontSize()) );
- RGBColor atsuColor = MAC_WXCOLORREF( col.GetPixel() );
+ RGBColor atsuColor ;
+ col.GetRGBColor( &atsuColor );
ATSUAttributeTag atsuTags[] =
{
kATSUSizeTag ,
else
{
((wxMacCoreGraphicsBrushData*)m_brush.GetRefData())->Apply(this);
- HIViewDrawCGImage( m_cgContext , &r , image );
+ wxMacDrawCGImage( m_cgContext , &r , image );
}
}
}
else
{
- HIViewDrawCGImage( m_cgContext , &r , image );
+ wxMacDrawCGImage( m_cgContext , &r , image );
}
CGImageRelease( image );
}
{
if (color.Ok())
- labelColor = MAC_WXCOLORREF( color.GetPixel() );
+ color.GetRGBColor(&labelColor);
else if (list->GetTextColour().Ok())
- labelColor = MAC_WXCOLORREF( list->GetTextColour().GetPixel() );
+ list->GetTextColour().GetRGBColor(&labelColor);
if (bgColor.Ok())
{
- backgroundColor = MAC_WXCOLORREF( bgColor.GetPixel() );
+ bgColor.GetRGBColor(&backgroundColor);
CGContextSaveGState(context);
CGContextSetRGBFillColor(context, (float)backgroundColor.red / (float)USHRT_MAX,
m_refData = new wxMetafileRefData((CFDataRef)mf);
}
+#ifndef __LP64__
void wxMetafile::SetPICT(void* pictHandle)
{
UnRef();
QDPictRelease( pictRef );
((wxMetafileRefData*) m_refData)->Close();
}
+#endif
bool wxMetaFile::Play(wxDC *dc)
{
return result;
}
-#endif
+#endif // LP64
//
// On the mac there are two ways to open a file - one is through apple events and the
// finder, another is through mime types.
{
int major, minor;
wxColour resultColor;
- RGBColor macRGB;
ThemeBrush colorBrushID;
wxGetOsVersion( &major, &minor );
break ;
case wxSYS_COLOUR_HIGHLIGHT:
-
+ {
#if 0
// NB: enable this case as desired
- colorBrushID = kThemeBrushAlternatePrimaryHighlightColor;
+ colorBrushID = kThemeBrushAlternatePrimaryHighlightColor;
#else
- colorBrushID = kThemeBrushPrimaryHighlightColor;
+ colorBrushID = kThemeBrushPrimaryHighlightColor;
#endif
-
- GetThemeBrushAsColor( colorBrushID, 32, true, &macRGB );
- resultColor = wxColor( macRGB );
+ CGColorRef color ;
+ HIThemeBrushCreateCGColor( colorBrushID, &color );
+ resultColor = wxColor( color );
+ }
break ;
case wxSYS_COLOUR_BTNHIGHLIGHT:
// NB: enable this case as desired
resultColor = *wxWHITE ;
#else
- GetThemeBrushAsColor( kThemeBrushPrimaryHighlightColor, 32, true, &macRGB );
- if ((macRGB.red + macRGB.green + macRGB.blue) == 0)
- resultColor = *wxWHITE ;
- else
- resultColor = *wxBLACK ;
+ {
+ CGColorRef color ;
+ HIThemeBrushCreateCGColor( kThemeBrushPrimaryHighlightColor, &color );
+ wxColour highlightcolor( color );
+ if ((highlightcolor.Red() + highlightcolor.Green() + highlightcolor.Blue() ) == 0)
+ resultColor = *wxWHITE ;
+ else
+ resultColor = *wxBLACK ;
+ }
#endif
break ;
// TODO: case wxSYS_SHOW_SOUNDS:
case wxSYS_DCLICK_MSEC:
+#ifdef __LP64__
+ // default on mac is 30 ticks, we shouldn't really use wxSYS_DCLICK_MSEC anyway
+ // but rather rely on the 'click-count' by the system delivered in a mouse event
+ return 500;
+#else
return (int)(GetDblTime() * 1000. / 60.);
-
+#endif
default:
// unsupported metric
break;
TXNBackground tback;
tback.bgType = kTXNBackgroundTypeRGB;
- tback.bg.color = MAC_WXCOLORREF( background.GetPixel() );
+ background.GetRGBColor( &tback.bg.color );
TXNSetBackground( m_txn , &tback );
TXNBackground tback;
tback.bgType = kTXNBackgroundTypeRGB;
- tback.bg.color = MAC_WXCOLORREF( brush.GetColour().GetPixel() );
+ brush.GetColour().GetRGBColor(&tback.bg.color);
TXNSetBackground( m_txn , &tback );
}
if ( style.HasTextColour() )
{
wxASSERT( typeAttrCount < WXSIZEOF(typeAttr) );
- color = MAC_WXCOLORREF(style.GetTextColour().GetPixel()) ;
-
+ style.GetTextColour().GetRGBColor( &color );
typeAttr[typeAttrCount].tag = kTXNQDFontColorAttribute ;
typeAttr[typeAttrCount].size = kTXNQDFontColorAttributeSize ;
typeAttr[typeAttrCount].data.dataPtr = (void*) &color ;
#if 0
CGColorSpaceRef rgbSpace = CGColorSpaceCreateDeviceRGB();
- RGBColor col = MAC_WXCOLORREF(brush.GetColour().GetPixel()) ;
+ RGBColor col;
+ brush.GetColour().GetRGBColor(&col) ;
float component[4] ;
component[0] = col.red / 65536.0 ;
#include "wx/thread.h"
-#ifdef __WXMAC__
-#ifdef __DARWIN__
- #include <CoreServices/CoreServices.h>
-#else
- #include <DriverServices.h>
- #include <Multiprocessing.h>
-#endif
-
+#include <CoreServices/CoreServices.h>
#include "wx/mac/uma.h"
-#endif
// the possible states of the thread:
// ("=>" shows all possible transitions from this state)
#include <string.h>
#include <stdarg.h>
-#include "MoreFilesX.h"
+// #include "MoreFilesX.h"
#ifndef __DARWIN__
#include <Threads.h>
if ( foreground != *wxBLACK )
{
- fontStyle.foreColor = MAC_WXCOLORREF( foreground.GetPixel() );
+ foreground.GetRGBColor( &fontStyle.foreColor );
fontStyle.flags |= kControlUseForeColorMask;
}
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#include "wx/wxprec.h"
-#ifndef WX_PRECOMP
- #include "wx/log.h"
- #include "wx/utils.h"
-#endif //ndef WX_PRECOMP
-
-#ifndef __DARWIN__
-
-#include "wx/mac/private.h"
-#include "LaunchServices.h"
-
-long wxExecute(const wxString& command, int flags, wxProcess *WXUNUSED(handler))
-{
- wxASSERT_MSG( flags == wxEXEC_ASYNC,
- wxT("wxExecute: Only wxEXEC_ASYNC is supported") );
-
- FSRef fsRef ;
- OSErr err = noErr ;
- err = wxMacPathToFSRef( command , &fsRef ) ;
- if ( noErr == err )
- {
- err = LSOpenFSRef( &fsRef , NULL ) ;
- }
-
- // 0 means execution failed. Returning non-zero is a PID, but not
- // on Mac where PIDs are 64 bits and won't fit in a long, so we
- // return a dummy value for now.
- return ( err == noErr ) ? -1 : 0;
-}
-
-#endif //ndef __DARWIN__
-
+// TODO REMOVE