📄 cursor.cpp
字号:
unsigned char mb = image16.GetMaskBlue() ;
for ( int y = 0 ; y < h ; ++y )
{
short rowbits = 0 ;
short maskbits = 0 ;
for ( int x = 0 ; x < w ; ++x )
{
long pos = (y * w + x) * 3;
unsigned char r = rgbBits[pos] ;
unsigned char g = rgbBits[pos+1] ;
unsigned char b = rgbBits[pos+2] ;
RGBColor col = { 0xFFFF ,0xFFFF, 0xFFFF } ;
if ( bHasMask && r==mr && g==mg && b==mb )
{
// masked area, does not appear anywhere
}
else
{
if ( (int)r + (int)g + (int)b < 0x0200 )
{
rowbits |= ( 1 << (15-x) ) ;
}
maskbits |= ( 1 << (15-x) ) ;
col = *((RGBColor*) wxColor( r , g , b ).GetPixel()) ;
}
*((*(**ch).crsrData) + y * bytesPerRow + x) =
GetCTabIndex( newColors , &col) ;
}
(**ch).crsr1Data[y] = rowbits ;
(**ch).crsrMask[y] = maskbits ;
}
if ( !bHasMask )
{
memcpy( (**ch).crsrMask , (**ch).crsr1Data , sizeof( Bits16) ) ;
}
HUnlock((Handle) ch) ;
M_CURSORDATA->m_hCursor = ch ;
M_CURSORDATA->m_isColorCursor = true ;
#endif
}
wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int hotSpotY)
{
m_refData = new wxCursorRefData;
if ( flags == wxBITMAP_TYPE_MACCURSOR_RESOURCE )
{
Str255 theName ;
wxMacStringToPascal( cursor_file , theName ) ;
wxStAppResource resload ;
Handle resHandle = ::GetNamedResource( 'crsr' , theName ) ;
if ( resHandle )
{
short theId = -1 ;
OSType theType ;
GetResInfo( resHandle , &theId , &theType , theName ) ;
ReleaseResource( resHandle ) ;
M_CURSORDATA->m_hCursor = GetCCursor( theId ) ;
if ( M_CURSORDATA->m_hCursor )
M_CURSORDATA->m_isColorCursor = true ;
}
else
{
Handle resHandle = ::GetNamedResource( 'CURS' , theName ) ;
if ( resHandle )
{
short theId = -1 ;
OSType theType ;
GetResInfo( resHandle , &theId , &theType , theName ) ;
ReleaseResource( resHandle ) ;
M_CURSORDATA->m_hCursor = GetCursor( theId ) ;
if ( M_CURSORDATA->m_hCursor )
M_CURSORDATA->m_releaseHandle = true ;
}
}
}
else
{
wxImage image ;
image.LoadFile( cursor_file , flags ) ;
if( image.Ok() )
{
image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X,hotSpotX ) ;
image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y,hotSpotY ) ;
delete m_refData ;
CreateFromImage(image) ;
}
}
}
// Cursors by stock number
wxCursor::wxCursor(int cursor_type)
{
m_refData = new wxCursorRefData;
switch (cursor_type)
{
case wxCURSOR_COPY_ARROW:
M_CURSORDATA->m_themeCursor = kThemeCopyArrowCursor ;
break;
case wxCURSOR_WAIT:
M_CURSORDATA->m_themeCursor = kThemeWatchCursor ;
break;
case wxCURSOR_IBEAM:
M_CURSORDATA->m_themeCursor = kThemeIBeamCursor ;
break;
case wxCURSOR_CROSS:
M_CURSORDATA->m_themeCursor = kThemeCrossCursor;
break;
case wxCURSOR_SIZENWSE:
{
wxStAppResource resload ;
M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeNWSE);
}
break;
case wxCURSOR_SIZENESW:
{
wxStAppResource resload ;
M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeNESW);
}
break;
case wxCURSOR_SIZEWE:
{
M_CURSORDATA->m_themeCursor = kThemeResizeLeftRightCursor;
}
break;
case wxCURSOR_SIZENS:
{
wxStAppResource resload ;
M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeNS);
}
break;
case wxCURSOR_SIZING:
{
wxStAppResource resload ;
M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSize);
}
break;
case wxCURSOR_HAND:
{
M_CURSORDATA->m_themeCursor = kThemePointingHandCursor;
}
break;
case wxCURSOR_BULLSEYE:
{
wxStAppResource resload ;
M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorBullseye);
}
break;
case wxCURSOR_PENCIL:
{
wxStAppResource resload ;
M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorPencil);
}
break;
case wxCURSOR_MAGNIFIER:
{
wxStAppResource resload ;
M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorMagnifier);
}
break;
case wxCURSOR_NO_ENTRY:
{
wxStAppResource resload ;
M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorNoEntry);
}
break;
case wxCURSOR_WATCH:
{
M_CURSORDATA->m_themeCursor = kThemeWatchCursor;
break;
}
case wxCURSOR_PAINT_BRUSH:
{
wxStAppResource resload ;
M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorPaintBrush);
break;
}
case wxCURSOR_POINT_LEFT:
{
wxStAppResource resload ;
M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorPointLeft);
break;
}
case wxCURSOR_POINT_RIGHT:
{
wxStAppResource resload ;
M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorPointRight);
break;
}
case wxCURSOR_QUESTION_ARROW:
{
wxStAppResource resload ;
M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorQuestionArrow);
break;
}
case wxCURSOR_BLANK:
{
wxStAppResource resload ;
M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorBlank);
break;
}
case wxCURSOR_RIGHT_ARROW:
{
wxStAppResource resload ;
M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorRightArrow);
break;
}
case wxCURSOR_SPRAYCAN:
{
wxStAppResource resload ;
M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorRoller);
break;
}
case wxCURSOR_CHAR:
case wxCURSOR_ARROW:
case wxCURSOR_LEFT_BUTTON:
case wxCURSOR_RIGHT_BUTTON:
case wxCURSOR_MIDDLE_BUTTON:
default:
M_CURSORDATA->m_themeCursor = kThemeArrowCursor ;
break;
}
if ( M_CURSORDATA->m_themeCursor == -1 )
M_CURSORDATA->m_releaseHandle = true ;
}
void wxCursor::MacInstall() const
{
gMacCurrentCursor = *this ;
if ( m_refData && M_CURSORDATA->m_themeCursor != -1 )
{
SetThemeCursor( M_CURSORDATA->m_themeCursor ) ;
}
else if ( m_refData && M_CURSORDATA->m_hCursor )
{
if ( M_CURSORDATA->m_isColorCursor )
::SetCCursor( (CCrsrHandle) M_CURSORDATA->m_hCursor ) ;
else
::SetCursor( * (CursHandle) M_CURSORDATA->m_hCursor ) ;
}
else
{
SetThemeCursor( kThemeArrowCursor ) ;
}
}
wxCursor::~wxCursor()
{
}
// Global cursor setting
void wxSetCursor(const wxCursor& cursor)
{
cursor.MacInstall() ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -