git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39264
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
15 files changed:
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+// Name: src/cocoa/cursor.mm
// Purpose: wxCursor class for wxCocoa
// Author: Ryan Norton
// Modified by:
// Created: 2004-10-05
// RCS-ID: $Id$
// Copyright: (c) Ryan Norton
// Purpose: wxCursor class for wxCocoa
// Author: Ryan Norton
// Modified by:
// Created: 2004-10-05
// RCS-ID: $Id$
// Copyright: (c) Ryan Norton
-// Licence: wxWidgets licence
+// Licence: wxWidgets licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/wxprec.h"
/////////////////////////////////////////////////////////////////////////////
#include "wx/wxprec.h"
+
+#include "wx/cursor.h"
+
#ifndef WX_PRECOMP
#include "wx/icon.h"
#ifndef WX_PRECOMP
#include "wx/icon.h"
#endif //WX_PRECOMP
#import <AppKit/NSCursor.h>
#endif //WX_PRECOMP
#import <AppKit/NSCursor.h>
{
ClassicCursor* pCursor = &gMacCursors[sIndex];
{
ClassicCursor* pCursor = &gMacCursors[sIndex];
- //Classic mac cursors are 1bps 16x16 black and white with a
+ //Classic mac cursors are 1bps 16x16 black and white with a
//identical mask that is 1 for on and 0 for off
NSImage *theImage = [[NSImage alloc] initWithSize:NSMakeSize(16.0,16.0)];
//identical mask that is 1 for on and 0 for off
NSImage *theImage = [[NSImage alloc] initWithSize:NSMakeSize(16.0,16.0)];
//NSCursor takes an NSImage takes a number of Representations - here
//we need only one for the raw data
//NSCursor takes an NSImage takes a number of Representations - here
//we need only one for the raw data
- NSBitmapImageRep *theRep =
- [[NSBitmapImageRep alloc]
+ NSBitmapImageRep *theRep =
+ [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes: nil // Allocate the buffer for us :)
initWithBitmapDataPlanes: nil // Allocate the buffer for us :)
pixelsHigh: 16
bitsPerSample: 1
pixelsHigh: 16
bitsPerSample: 1
- samplesPerPixel: 2
- hasAlpha: YES // Well, more like a mask...
- isPlanar: NO
+ samplesPerPixel: 2
+ hasAlpha: YES // Well, more like a mask...
+ isPlanar: NO
colorSpaceName: NSCalibratedWhiteColorSpace // Normal B/W - 0 black 1 white
bytesPerRow: 0 // I don't care - figure it out for me :)
bitsPerPixel: 2]; // bitsPerSample * samplesPerPixel
colorSpaceName: NSCalibratedWhiteColorSpace // Normal B/W - 0 black 1 white
bytesPerRow: 0 // I don't care - figure it out for me :)
bitsPerPixel: 2]; // bitsPerSample * samplesPerPixel
//unsigned int is better to put data in then a void*
//note that working with bitfields would be a lot better here -
//but since it breaks some compilers...
//unsigned int is better to put data in then a void*
//note that working with bitfields would be a lot better here -
//but since it breaks some compilers...
- wxUint32 *data = (wxUint32 *)[theRep bitmapData];
-
+ wxUint32 *data = (wxUint32 *)[theRep bitmapData];
+
//traverse through the bitmap data
for (int i = 0; i < 16; ++i)
{
//bit alpha bit alpha ... :D
//traverse through the bitmap data
for (int i = 0; i < 16; ++i)
{
//bit alpha bit alpha ... :D
-
- //Notice the = instead of |= -
+
+ //Notice the = instead of |= -
//this is to avoid doing a memset earlier
data[i] = 0;
//this is to avoid doing a memset earlier
data[i] = 0;
//do the rest of those bits and alphas :)
for (int shift = 0; shift < 32; ++shift)
{
//do the rest of those bits and alphas :)
for (int shift = 0; shift < 32; ++shift)
{
//add the representation (data) to the image
[theImage addRepresentation:theRep];
//add the representation (data) to the image
[theImage addRepresentation:theRep];
- NSCursor* theCursor = [[NSCursor alloc] initWithImage:theImage
+ NSCursor* theCursor = [[NSCursor alloc] initWithImage:theImage
hotSpot:NSMakePoint(pCursor->hotspot[1], pCursor->hotspot[0])
];
hotSpot:NSMakePoint(pCursor->hotspot[1], pCursor->hotspot[0])
];
//return the new cursor
return theCursor;
//return the new cursor
return theCursor;
wxCursorRefData::wxCursorRefData() :
m_width(32), m_height(32), m_hCursor(nil)
wxCursorRefData::wxCursorRefData() :
m_width(32), m_height(32), m_hCursor(nil)
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: Not sure if this works or not
NSImage* theImage;
//TODO: Not sure if this works or not
NSImage* theImage;
if (flags & wxBITMAP_TYPE_MACCURSOR_RESOURCE)
{
//[NSBundle bundleForClass:[self class]]?
if (flags & wxBITMAP_TYPE_MACCURSOR_RESOURCE)
{
//[NSBundle bundleForClass:[self class]]?
- theImage = [[NSImage alloc]
+ theImage = [[NSImage alloc]
initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:wxNSStringWithWxString(cursor_file) ofType:nil]
];
initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:wxNSStringWithWxString(cursor_file) ofType:nil]
];
theImage = [[NSImage alloc] initByReferencingFile:wxNSStringWithWxString(cursor_file)
];
theImage = [[NSImage alloc] initByReferencingFile:wxNSStringWithWxString(cursor_file)
];
M_CURSORDATA->m_hCursor = [[NSCursor alloc] initWithImage:theImage
hotSpot:NSMakePoint(hotSpotX, hotSpotY)
];
M_CURSORDATA->m_hCursor = [[NSCursor alloc] initWithImage:theImage
hotSpot:NSMakePoint(hotSpotX, hotSpotY)
];
case wxCURSOR_ARROW:
M_CURSORDATA->m_hCursor = [[NSCursor arrowCursor] retain];
break;
case wxCURSOR_ARROW:
M_CURSORDATA->m_hCursor = [[NSCursor arrowCursor] retain];
break;
case wxCURSOR_COPY_ARROW:
M_CURSORDATA->m_themeCursor = kThemeCopyArrowCursor ;
break;
case wxCURSOR_COPY_ARROW:
M_CURSORDATA->m_themeCursor = kThemeCopyArrowCursor ;
break;
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorSizeNESW);
}
break;
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorSizeNESW);
}
break;
case wxCURSOR_SIZEWE:
{
M_CURSORDATA->m_themeCursor = kThemeResizeLeftRightCursor;
case wxCURSOR_SIZEWE:
{
M_CURSORDATA->m_themeCursor = kThemeResizeLeftRightCursor;
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorSize);
}
break;
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorSize);
}
break;
case wxCURSOR_HAND:
{
M_CURSORDATA->m_themeCursor = kThemePointingHandCursor;
case wxCURSOR_HAND:
{
M_CURSORDATA->m_themeCursor = kThemePointingHandCursor;
// Set the cursor to the busy cursor for all windows
void wxBeginBusyCursor(const wxCursor *cursor)
{
// Set the cursor to the busy cursor for all windows
void wxBeginBusyCursor(const wxCursor *cursor)
{
- wxBusyCursorCount ++;
- if (wxBusyCursorCount == 1)
- {
+ wxBusyCursorCount ++;
+ if (wxBusyCursorCount == 1)
+ {
}
// Restore cursor to normal
void wxEndBusyCursor()
{
}
// Restore cursor to normal
void wxEndBusyCursor()
{
- if (wxBusyCursorCount == 0)
- return;
-
- wxBusyCursorCount --;
- if (wxBusyCursorCount == 0)
- {
- // TODO
- }
+ if (wxBusyCursorCount == 0)
+ return;
+
+ wxBusyCursorCount --;
+ if (wxBusyCursorCount == 0)
+ {
+ // TODO
+ }
-// TRUE if we're between the above two calls
+// true if we're between the above two calls
bool wxIsBusy()
{
return (wxBusyCursorCount > 0);
bool wxIsBusy()
{
return (wxBusyCursorCount > 0);
#include "wx/brush.h"
#include "wx/palette.h"
#include "wx/icon.h"
#include "wx/brush.h"
#include "wx/palette.h"
#include "wx/icon.h"
#endif
#include "wx/bitmap.h"
#endif
#include "wx/bitmap.h"
#include "wx/font.h"
#include "wx/settings.h"
#include "wx/hashmap.h"
#include "wx/font.h"
#include "wx/settings.h"
#include "wx/hashmap.h"
#include "wx/object.h"
#include "wx/window.h"
#include "wx/dc.h"
#include "wx/object.h"
#include "wx/window.h"
#include "wx/dc.h"
-#include "wx/cursor.h"
-
/* Current cursor, in order to hang on to
* cursor handle when setting the cursor globally */
wxCursor g_globalCursor;
/* Current cursor, in order to hang on to
* cursor handle when setting the cursor globally */
wxCursor g_globalCursor;
#ifndef WX_PRECOMP
#include "wx/app.h"
#include "wx/frame.h"
#ifndef WX_PRECOMP
#include "wx/app.h"
#include "wx/frame.h"
#include "wx/evtloop.h"
#include <gdk/gdk.h>
#include "wx/evtloop.h"
#include <gdk/gdk.h>
#ifndef WX_PRECOMP
#include "wx/app.h"
#include "wx/frame.h"
#ifndef WX_PRECOMP
#include "wx/app.h"
#include "wx/frame.h"
-#include "wx/cursor.h"
-
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "wx/object.h"
#include "wx/window.h"
#include "wx/dc.h"
#include "wx/object.h"
#include "wx/window.h"
#include "wx/dc.h"
-#include "wx/cursor.h"
-
/* Current cursor, in order to hang on to
* cursor handle when setting the cursor globally */
wxCursor g_globalCursor;
/* Current cursor, in order to hang on to
* cursor handle when setting the cursor globally */
wxCursor g_globalCursor;
#ifndef WX_PRECOMP
#include "wx/app.h"
#include "wx/frame.h"
#ifndef WX_PRECOMP
#include "wx/app.h"
#include "wx/frame.h"
#include "wx/evtloop.h"
#include <gdk/gdk.h>
#include "wx/evtloop.h"
#include <gdk/gdk.h>
#ifndef WX_PRECOMP
#include "wx/app.h"
#include "wx/frame.h"
#ifndef WX_PRECOMP
#include "wx/app.h"
#include "wx/frame.h"
-#include "wx/cursor.h"
-
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
gtk_signal_connect (GTK_OBJECT(m_widget), "button_press_event",
GTK_SIGNAL_FUNC(gtk_popup_button_press), (gpointer)this );
gtk_signal_connect (GTK_OBJECT(m_widget), "button_press_event",
GTK_SIGNAL_FUNC(gtk_popup_button_press), (gpointer)this );
}
void wxPopupWindow::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) )
}
void wxPopupWindow::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) )
#include "wx/brush.h"
#include "wx/palette.h"
#include "wx/icon.h"
#include "wx/brush.h"
#include "wx/palette.h"
#include "wx/icon.h"
#endif
#include "wx/gdicmn.h"
#endif
#include "wx/gdicmn.h"
#include "wx/dialog.h"
#include "wx/msgdlg.h"
#include "wx/module.h"
#include "wx/dialog.h"
#include "wx/msgdlg.h"
#include "wx/module.h"
#include "wx/brush.h"
#include "wx/palette.h"
#include "wx/icon.h"
#include "wx/brush.h"
#include "wx/palette.h"
#include "wx/icon.h"
#endif
#include "wx/gdicmn.h"
#endif
#include "wx/gdicmn.h"
#include "wx/dialog.h"
#include "wx/msgdlg.h"
#include "wx/module.h"
#include "wx/dialog.h"
#include "wx/msgdlg.h"
#include "wx/module.h"
+#ifndef WX_PRECOMP
+ #include "wx/cursor.h"
+#endif
/* Current cursor, in order to hang on to
* cursor handle when setting the cursor globally */
/* Current cursor, in order to hang on to
* cursor handle when setting the cursor globally */
+#include "wx/cursor.h"
+
#ifndef WX_PRECOMP
#include "wx/utils.h"
#include "wx/app.h"
#include "wx/bitmap.h"
#include "wx/icon.h"
#ifndef WX_PRECOMP
#include "wx/utils.h"
#include "wx/app.h"
#include "wx/bitmap.h"
#include "wx/icon.h"
#include "wx/settings.h"
#include "wx/intl.h"
#endif
#include "wx/settings.h"
#include "wx/intl.h"
#endif
}
#else
HCURSOR hcursor = 0;
}
#else
HCURSOR hcursor = 0;
m_refData = new wxCursorRefData(hcursor, true /* delete it later */);
}
m_refData = new wxCursorRefData(hcursor, true /* delete it later */);
}
{ false, _T("WXCURSOR_RIGHT_ARROW") }, // wxCURSOR_RIGHT_ARROW
{ false, _T("WXCURSOR_BULLSEYE") }, // wxCURSOR_BULLSEYE
{ true, IDC_ARROW }, // WXCURSOR_CHAR
{ false, _T("WXCURSOR_RIGHT_ARROW") }, // wxCURSOR_RIGHT_ARROW
{ false, _T("WXCURSOR_BULLSEYE") }, // wxCURSOR_BULLSEYE
{ true, IDC_ARROW }, // WXCURSOR_CHAR
// Displays as an I-beam on XP, so use a cursor file
// { true, IDC_CROSS }, // WXCURSOR_CROSS
{ false, _T("WXCURSOR_CROSS") }, // WXCURSOR_CROSS
// Displays as an I-beam on XP, so use a cursor file
// { true, IDC_CROSS }, // WXCURSOR_CROSS
{ false, _T("WXCURSOR_CROSS") }, // WXCURSOR_CROSS
// See special handling below for wxCURSOR_HAND
// { false, _T("WXCURSOR_HAND") }, // wxCURSOR_HAND
{ true, IDC_HAND }, // wxCURSOR_HAND
// See special handling below for wxCURSOR_HAND
// { false, _T("WXCURSOR_HAND") }, // wxCURSOR_HAND
{ true, IDC_HAND }, // wxCURSOR_HAND
{ true, IDC_IBEAM }, // WXCURSOR_IBEAM
{ true, IDC_ARROW }, // WXCURSOR_LEFT_BUTTON
{ false, _T("WXCURSOR_MAGNIFIER") }, // wxCURSOR_MAGNIFIER
{ true, IDC_IBEAM }, // WXCURSOR_IBEAM
{ true, IDC_ARROW }, // WXCURSOR_LEFT_BUTTON
{ false, _T("WXCURSOR_MAGNIFIER") }, // wxCURSOR_MAGNIFIER
hcursor = ::LoadCursor(wxGetInstance(), _T("WXCURSOR_HAND"));
deleteLater = true;
}
hcursor = ::LoadCursor(wxGetInstance(), _T("WXCURSOR_HAND"));
deleteLater = true;
}
if ( !hcursor )
{
wxLogLastError(_T("LoadCursor"));
if ( !hcursor )
{
wxLogLastError(_T("LoadCursor"));
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
+#include "wx/cursor.h"
+
#ifndef WX_PRECOMP
#include <stdio.h>
#include "wx/list.h"
#include "wx/utils.h"
#include "wx/app.h"
#ifndef WX_PRECOMP
#include <stdio.h>
#include "wx/list.h"
#include "wx/utils.h"
#include "wx/app.h"
#include "wx/icon.h"
#endif
#include "wx/icon.h"
#endif
+#include "wx/cursor.h"
+
#ifndef WX_PRECOMP
#include "wx/utils.h"
#include "wx/app.h"
#include "wx/bitmap.h"
#include "wx/icon.h"
#ifndef WX_PRECOMP
#include "wx/utils.h"
#include "wx/app.h"
#include "wx/bitmap.h"
#include "wx/icon.h"
#include "wx/settings.h"
#include "wx/intl.h"
#endif
#include "wx/settings.h"
#include "wx/intl.h"
#endif
bool wxCursor::operator==(const wxCursor& cursor) const
{
bool wxCursor::operator==(const wxCursor& cursor) const
{
}
wxGDIImageRefData *wxCursor::CreateData() const
}
wxGDIImageRefData *wxCursor::CreateData() const
void wxSetCursor(const wxCursor& cursor)
{
}
void wxSetCursor(const wxCursor& cursor)
{
}
#ifndef WX_PRECOMP
#include "wx/app.h"
#include "wx/window.h" // for wxTopLevelWindows
#ifndef WX_PRECOMP
#include "wx/app.h"
#include "wx/window.h" // for wxTopLevelWindows
#endif
#include "wx/apptrait.h"
#include "wx/msgdlg.h"
#endif
#include "wx/apptrait.h"
#include "wx/msgdlg.h"
#include <ctype.h>
#include <stdarg.h>
#include <ctype.h>
#include <stdarg.h>