/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/carbon/cursor.cpp
+// Name: src/osx/carbon/cursor.cpp
// Purpose: wxCursor class
// Author: Stefan Csomor
// Modified by:
#include "wx/xpmdecod.h"
-#include "wx/mac/private.h"
+#include "wx/osx/private.h"
IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxGDIObject)
virtual bool IsOk() const
{
+#if wxOSX_USE_COCOA_OR_CARBON
if ( m_hCursor != NULL )
return true;
-#if !wxMAC_USE_COCOA
+#if wxOSX_USE_CARBON
if ( m_themeCursor != -1 )
return true;
#endif
return false;
+#else
+ // in order to avoid asserts, always claim to have a valid cursor
+ return true;
+#endif
}
protected:
-#if wxMAC_USE_COCOA
+#if wxOSX_USE_COCOA
WX_NSCursor m_hCursor;
-#else
+#elif wxOSX_USE_CARBON
WXHCURSOR m_hCursor;
bool m_disposeHandle;
bool m_releaseHandle;
bool m_isColorCursor;
long m_themeCursor;
+#elif wxOSX_USE_IPHONE
+ void* m_hCursor;
#endif
friend class wxCursor;
- DECLARE_NO_ASSIGN_CLASS(wxCursorRefData)
+ wxDECLARE_NO_ASSIGN_CLASS(wxCursorRefData);
};
-#define M_CURSORDATA wx_static_cast(wxCursorRefData*, m_refData)
+#define M_CURSORDATA static_cast<wxCursorRefData*>(m_refData)
+
+#if wxOSX_USE_COCOA_OR_CARBON
ClassicCursor gMacCursors[kwxCursorLast+1] =
{
};
+#endif
+
wxCursor gMacCurrentCursor ;
-#if !wxMAC_USE_COCOA
+#if wxOSX_USE_CARBON
CursHandle wxGetStockCursor( int number )
{
wxASSERT_MSG( number >= 0 && number <=kwxCursorLast , wxT("invalid stock cursor id") ) ;
wxCursorRefData::wxCursorRefData()
{
m_hCursor = NULL;
-#if wxMAC_USE_COCOA
-#else
+#if wxOSX_USE_CARBON
m_disposeHandle = false;
m_releaseHandle = false;
m_isColorCursor = false;
// FIXME: need to copy the cursor
m_hCursor = NULL;
-#if wxMAC_USE_COCOA
+#if wxOSX_USE_COCOA
wxUnusedVar(cursor);
-#else
+#elif wxOSX_USE_CARBON
m_disposeHandle = false;
m_releaseHandle = false;
m_isColorCursor = cursor.m_isColorCursor;
wxCursorRefData::~wxCursorRefData()
{
-#if wxMAC_USE_COCOA
+#if wxOSX_USE_COCOA
if ( m_hCursor )
wxMacCocoaRelease(m_hCursor);
-#else
+#elif wxOSX_USE_CARBON
if ( m_isColorCursor )
{
#ifndef __LP64__
{
}
-wxCursor::wxCursor(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSED(height),
- int WXUNUSED(hotSpotX), int WXUNUSED(hotSpotY), const char WXUNUSED(maskBits)[])
-{
-}
-
wxCursor::wxCursor( const wxImage &image )
{
#if wxUSE_IMAGE
#endif
}
-wxCursor::wxCursor(const char* const* bits)
-{
- (void) CreateFromXpm(bits);
-}
-
wxGDIRefData *wxCursor::CreateGDIRefData() const
{
return new wxCursorRefData;
wxGDIRefData *wxCursor::CloneGDIRefData(const wxGDIRefData *data) const
{
- return new wxCursorRefData(*wx_static_cast(const wxCursorRefData *, data));
-}
-
-bool wxCursor::CreateFromXpm(const char* const* bits)
-{
-#if wxUSE_IMAGE
- wxCHECK_MSG( bits != NULL, false, wxT("invalid cursor data") );
- wxXPMDecoder decoder;
- wxImage img = decoder.ReadData(bits);
- wxCHECK_MSG( img.Ok(), false, wxT("invalid cursor data") );
- CreateFromImage( img ) ;
- return true;
-#else
- return false;
-#endif
+ return new wxCursorRefData(*static_cast<const wxCursorRefData *>(data));
}
WXHCURSOR wxCursor::GetHCURSOR() const
return (M_CURSORDATA ? M_CURSORDATA->m_hCursor : 0);
}
-#if !wxMAC_USE_COCOA
+#if wxOSX_USE_CARBON
short GetCTabIndex( CTabHandle colors , RGBColor *col )
{
short retval = 0 ;
m_refData = new wxCursorRefData;
int hotSpotX = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X);
int hotSpotY = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y);
-#if wxMAC_USE_COCOA
+#if wxOSX_USE_COCOA
wxBitmap bmp( image );
CGImageRef cgimage = wxMacCreateCGImageFromBitmap(bmp);
if ( cgimage )
{
- M_CURSORDATA->m_hCursor = wxMacCocoaCreateCursorFromCGImage( cgimage, hotSpotX, hotSpotY );
+ M_CURSORDATA->m_hCursor = wxMacCocoaCreateCursorFromCGImage( cgimage, hotSpotX, hotSpotY );
CFRelease( cgimage );
}
-#else
+#elif wxOSX_USE_CARBON
#ifndef __LP64__
int w = 16;
int h = 16;
m_refData = new wxCursorRefData;
if ( flags == wxBITMAP_TYPE_MACCURSOR_RESOURCE )
{
-#if wxMAC_USE_COCOA
+#if wxOSX_USE_COCOA
wxFAIL_MSG( wxT("Not implemented") );
-#else
+#elif wxOSX_USE_CARBON
#ifndef __LP64__
Str255 theName ;
wxMacStringToPascal( cursor_file , theName ) ;
}
// Cursors by stock number
-wxCursor::wxCursor(int cursor_type)
+void wxCursor::InitFromStock(wxStockCursor cursor_type)
{
m_refData = new wxCursorRefData;
-#if wxMAC_USE_COCOA
+#if wxOSX_USE_COCOA
M_CURSORDATA->m_hCursor = wxMacCocoaCreateStockCursor( cursor_type );
-#else
+#elif wxOSX_USE_CARBON
switch (cursor_type)
{
case wxCURSOR_COPY_ARROW:
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorRoller);
break;
+ case wxCURSOR_OPEN_HAND:
+ M_CURSORDATA->m_themeCursor = kThemeOpenHandCursor;
+ break;
+
+ case wxCURSOR_CLOSED_HAND:
+ M_CURSORDATA->m_themeCursor = kThemeClosedHandCursor;
+ break;
+
case wxCURSOR_CHAR:
case wxCURSOR_ARROW:
case wxCURSOR_LEFT_BUTTON:
void wxCursor::MacInstall() const
{
gMacCurrentCursor = *this ;
-#if wxMAC_USE_COCOA
+#if wxOSX_USE_COCOA
if ( IsOk() )
wxMacCocoaSetCursor( M_CURSORDATA->m_hCursor );
-#else
+#elif wxOSX_USE_CARBON
if ( m_refData && M_CURSORDATA->m_themeCursor != -1 )
{
SetThemeCursor( M_CURSORDATA->m_themeCursor ) ;