git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29690
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
{ return false; }
virtual bool Cocoa_otherMouseUp(WX_NSEvent theEvent)
{ return false; }
{ return false; }
virtual bool Cocoa_otherMouseUp(WX_NSEvent theEvent)
{ return false; }
+ virtual bool Cocoa_resetCursorRects()
+ { return false; }
};
#endif // _WX_COCOA_NSVIEW_H_
};
#endif // _WX_COCOA_NSVIEW_H_
protected:
int m_width, m_height;
protected:
int m_width, m_height;
};
#define M_CURSORDATA ((wxCursorRefData *)m_refData)
};
#define M_CURSORDATA ((wxCursorRefData *)m_refData)
inline wxCursor& operator = (const wxCursor& cursor) { if (*this == cursor) return (*this); Ref(cursor); return *this; }
inline bool operator == (const wxCursor& cursor) { return m_refData == cursor.m_refData; }
inline bool operator != (const wxCursor& cursor) { return m_refData != cursor.m_refData; }
inline wxCursor& operator = (const wxCursor& cursor) { if (*this == cursor) return (*this); Ref(cursor); return *this; }
inline bool operator == (const wxCursor& cursor) { return m_refData == cursor.m_refData; }
inline bool operator != (const wxCursor& cursor) { return m_refData != cursor.m_refData; }
+
+ inline WX_NSCursor GetNSCursor() const
+ {
+ return (M_CURSORDATA ? M_CURSORDATA->m_hCursor : 0);
+ }
virtual bool Cocoa_otherMouseDown(WX_NSEvent theEvent);
virtual bool Cocoa_otherMouseDragged(WX_NSEvent theEvent);
virtual bool Cocoa_otherMouseUp(WX_NSEvent theEvent);
virtual bool Cocoa_otherMouseDown(WX_NSEvent theEvent);
virtual bool Cocoa_otherMouseDragged(WX_NSEvent theEvent);
virtual bool Cocoa_otherMouseUp(WX_NSEvent theEvent);
+ virtual bool Cocoa_resetCursorRects();
void SetNSView(WX_NSView cocoaNSView);
WX_NSView m_cocoaNSView;
wxWindowCocoaHider *m_cocoaHider;
void SetNSView(WX_NSView cocoaNSView);
WX_NSView m_cocoaNSView;
wxWindowCocoaHider *m_cocoaHider;
// Get/set client (application-useable) size
virtual void DoGetClientSize(int *width, int *height) const;
virtual void DoSetClientSize(int width, int size);
// Get/set client (application-useable) size
virtual void DoGetClientSize(int *width, int *height) const;
virtual void DoSetClientSize(int width, int size);
+ // Set this window's tooltip
+ virtual void DoSetToolTip( wxToolTip *tip );
// Set the size of the wxWindow (the contentView of an NSWindow)
// wxTopLevelWindow will override this and set the NSWindow size
// such that the contentView will be this size
// Set the size of the wxWindow (the contentView of an NSWindow)
// wxTopLevelWindow will override this and set the NSWindow size
// such that the contentView will be this size
- (void)otherMouseDown:(NSEvent *)theEvent;
- (void)otherMouseDragged:(NSEvent *)theEvent;
- (void)otherMouseUp:(NSEvent *)theEvent;
- (void)otherMouseDown:(NSEvent *)theEvent;
- (void)otherMouseDragged:(NSEvent *)theEvent;
- (void)otherMouseUp:(NSEvent *)theEvent;
+- (void)resetCursorRects;
@end // wxPoserNSView
WX_IMPLEMENT_POSER(wxPoserNSView);
@end // wxPoserNSView
WX_IMPLEMENT_POSER(wxPoserNSView);
[super otherMouseUp:theEvent];
}
[super otherMouseUp:theEvent];
}
+- (void)resetCursorRects
+{
+ wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self);
+ if( !win || !win->Cocoa_resetCursorRects() )
+ [super resetCursorRects];
+}
+
@end // implementation wxPoserNSView
@interface wxNSViewNotificationObserver : NSObject
@end // implementation wxPoserNSView
@interface wxNSViewNotificationObserver : NSObject
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
-// Name: cursor.cpp
-// Purpose: wxCursor class
-// Author: AUTHOR
+// Name: cursor.mm
+// Purpose: wxCursor class for wxCocoa
+// Author: Ryan Norton
-// Copyright: (c) AUTHOR
+// Copyright: (c) Ryan Norton
// Licence: wxWidgets licence
/////////////////////////////////////////////////////////////////////////////
// Licence: wxWidgets licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/cursor.h"
#endif //WX_PRECOMP
#include "wx/cursor.h"
#endif //WX_PRECOMP
+#import <AppKit/NSCursor.h>
+#import <AppKit/NSImage.h>
+#include <wx/cocoa/string.h>
+
#if !USE_SHARED_LIBRARIES
IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
#endif
#if !USE_SHARED_LIBRARIES
IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
#endif
-wxCursorRefData::wxCursorRefData()
+wxCursorRefData::wxCursorRefData() :
+ m_width(32), m_height(32), m_hCursor(nil)
- m_width = 32; m_height = 32;
-
-/* TODO
- m_hCursor = 0 ;
-*/
}
wxCursorRefData::~wxCursorRefData()
{
}
wxCursorRefData::~wxCursorRefData()
{
- // TODO: destroy cursor
+ if (m_hCursor)
+ [m_hCursor release];
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 char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSED(height),
int WXUNUSED(hotSpotX), int WXUNUSED(hotSpotY), const char WXUNUSED(maskBits)[])
{
}
wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int hotSpotY)
{
m_refData = new wxCursorRefData;
}
wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int hotSpotY)
{
m_refData = new wxCursorRefData;
-
- // TODO: create cursor from a file
+
+ //TODO: Not sure if this works or not
+ NSImage* theImage;
+
+ if (flags & wxBITMAP_TYPE_MACCURSOR_RESOURCE)
+ {
+ //[NSBundle bundleForClass:[self class]]?
+ theImage = [[NSImage alloc]
+ initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:wxNSStringWithWxString(cursor_file) ofType:nil]
+ ];
+
+ }
+ else
+ theImage = [[NSImage alloc] initByReferencingFile:wxNSStringWithWxString(cursor_file)
+ ];
+
+ wxASSERT(theImage);
+
+ M_CURSORDATA->m_hCursor = [[NSCursor alloc] initWithImage:theImage
+ hotSpot:NSMakePoint(hotSpotX, hotSpotY)
+ ];
+
+ [theImage release];
}
// Cursors by stock number
}
// Cursors by stock number
{
m_refData = new wxCursorRefData;
{
m_refData = new wxCursorRefData;
+ case wxCURSOR_IBEAM:
+ M_CURSORDATA->m_hCursor = [[NSCursor IBeamCursor] retain];
+ break;
+ case wxCURSOR_ARROW:
+ M_CURSORDATA->m_hCursor = [[NSCursor arrowCursor] retain];
+ break;
+/* TODO
case wxCURSOR_WAIT:
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_WAIT);
break;
case wxCURSOR_WAIT:
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_WAIT);
break;
- case wxCURSOR_IBEAM:
- M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_IBEAM);
- break;
case wxCURSOR_CROSS:
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_CROSS);
break;
case wxCURSOR_CROSS:
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_CROSS);
break;
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_BLANK");
break;
}
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_BLANK");
break;
}
- case wxCURSOR_ARROW:
- M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW);
- break;
// Global cursor setting
void wxSetCursor(const wxCursor& cursor)
{
// Global cursor setting
void wxSetCursor(const wxCursor& cursor)
{
- // TODO (optional on platforms with no global cursor)
+ if (cursor.GetNSCursor())
+ [cursor.GetNSCursor() push];
}
static int wxBusyCursorCount = 0;
}
static int wxBusyCursorCount = 0;
[m_owner->GetNSViewForHiding() setFrame:[m_dummyNSView frame]];
}
[m_owner->GetNSViewForHiding() setFrame:[m_dummyNSView frame]];
}
#ifdef WXCOCOA_FILL_DUMMY_VIEW
bool wxWindowCocoaHider::Cocoa_drawRect(const NSRect& rect)
{
#ifdef WXCOCOA_FILL_DUMMY_VIEW
bool wxWindowCocoaHider::Cocoa_drawRect(const NSRect& rect)
{
GetEventHandler()->ProcessEvent(event);
}
GetEventHandler()->ProcessEvent(event);
}
+bool wxWindowCocoa::Cocoa_resetCursorRects()
+{
+ if(!m_cursor.GetNSCursor())
+ return false;
+
+ [GetNSView() addCursorRect: [GetNSView() visibleRect] cursor: m_cursor.GetNSCursor()];
+
+ return true;
+}
+
bool wxWindow::Close(bool force)
{
// The only reason this function exists is that it is virtual and
bool wxWindow::Close(bool force)
{
// The only reason this function exists is that it is virtual and
}
// Get the window with the focus
}
// Get the window with the focus
-wxWindow *wxWindowBase::DoFindFocus()
+wxWindow *wxWindowBase::FindFocus()