Implement wxBitmap(const wxCursor&) constructor for OSX

This commit is contained in:
Igor Korot
2020-07-29 09:45:28 +02:00
committed by Maarten Bent
parent 0ff1bdec09
commit 9394d26c40
5 changed files with 18 additions and 3 deletions

View File

@@ -126,6 +126,11 @@ public:
// Convert from wxIcon // Convert from wxIcon
wxBitmap(const wxIcon& icon) { CopyFromIcon(icon); } wxBitmap(const wxIcon& icon) { CopyFromIcon(icon); }
#if wxOSX_USE_COCOA
// Convert from wxCursor
wxBitmap(const wxCursor &cursor);
#endif
virtual ~wxBitmap() {} virtual ~wxBitmap() {}
wxImage ConvertToImage() const wxOVERRIDE; wxImage ConvertToImage() const wxOVERRIDE;

View File

@@ -45,6 +45,7 @@ void WXDLLIMPEXP_CORE wxOSXSetImageSize(WX_NSImage image, CGFloat width, CGFloat
wxBitmap WXDLLIMPEXP_CORE wxOSXCreateSystemBitmap(const wxString& id, const wxString &client, const wxSize& size); wxBitmap WXDLLIMPEXP_CORE wxOSXCreateSystemBitmap(const wxString& id, const wxString &client, const wxSize& size);
WXWindow WXDLLIMPEXP_CORE wxOSXGetMainWindow(); WXWindow WXDLLIMPEXP_CORE wxOSXGetMainWindow();
WXWindow WXDLLIMPEXP_CORE wxOSXGetKeyWindow(); WXWindow WXDLLIMPEXP_CORE wxOSXGetKeyWindow();
WXImage WXDLLIMPEXP_CORE wxOSXGetNSImageFromNSCursor(const WXHCURSOR cursor);
class WXDLLIMPEXP_FWD_CORE wxDialog; class WXDLLIMPEXP_FWD_CORE wxDialog;

View File

@@ -359,9 +359,6 @@ public:
This can be useful to display a cursor as it cannot be drawn directly This can be useful to display a cursor as it cannot be drawn directly
on a window. on a window.
This constructor only exists in wxMSW and wxGTK (where it is
implemented for GTK+ 2.8 or later) only.
@param cursor A valid wxCursor. @param cursor A valid wxCursor.
@since 3.1.0 @since 3.1.0

View File

@@ -577,6 +577,11 @@ WX_NSCursor wxMacCocoaCreateStockCursor( int cursor_type )
return cursor; return cursor;
} }
WXImage WXDLLIMPEXP_CORE wxOSXGetNSImageFromNSCursor(const WXHCURSOR cursor)
{
return [(NSCursor *)cursor image];
}
// C-based style wrapper routines around NSCursor // C-based style wrapper routines around NSCursor
WX_NSCursor wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef, float hotSpotX, float hotSpotY ) WX_NSCursor wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef, float hotSpotX, float hotSpotY )
{ {

View File

@@ -919,6 +919,13 @@ wxBitmap::wxBitmap(WXImage image)
(void)Create(image); (void)Create(image);
} }
#if wxOSX_USE_COCOA
wxBitmap::wxBitmap(const wxCursor &cursor)
{
m_refData = new wxBitmapRefData( wxOSXGetNSImageFromNSCursor( cursor.GetHCURSOR() ) );
}
#endif
bool wxBitmap::Create(WXImage image) bool wxBitmap::Create(WXImage image)
{ {
UnRef(); UnRef();