X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e9576ca53db96b462ed4c0b4bdf47d64c40203e4..2fe212b0336512aac9eace69fab09ce856b0bf4b:/src/mac/carbon/icon.cpp diff --git a/src/mac/carbon/icon.cpp b/src/mac/carbon/icon.cpp index 6deee7dbdc..0133e45534 100644 --- a/src/mac/carbon/icon.cpp +++ b/src/mac/carbon/icon.cpp @@ -23,22 +23,23 @@ IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap) * Icons */ - -wxIconRefData::wxIconRefData() +wxIcon::wxIcon() { - // TODO: init icon handle } -wxIconRefData::~wxIconRefData() +wxIcon::wxIcon(const char bits[], int width, int height) : + wxBitmap(bits,width,height ) { - // TODO: destroy icon handle + } -wxIcon::wxIcon() +wxIcon::wxIcon( const char **bits ) : + wxBitmap(bits ) { } -wxIcon::wxIcon(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSED(height)) +wxIcon::wxIcon( char **bits ) : + wxBitmap(bits ) { } @@ -58,9 +59,9 @@ bool wxIcon::LoadFile(const wxString& filename, long type, { UnRef(); - m_refData = new wxIconRefData; + m_refData = new wxBitmapRefData; - wxBitmapHandler *handler = FindHandler(type); + wxBitmapHandler *handler = FindHandler((wxBitmapType)type); if ( handler ) return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight); @@ -68,3 +69,68 @@ bool wxIcon::LoadFile(const wxString& filename, long type, return FALSE; } +void wxIcon::CopyFromBitmap(const wxBitmap& bmp) +{ + wxIcon *icon = (wxIcon*)(&bmp); + *this = *icon; +} + +IMPLEMENT_DYNAMIC_CLASS(wxICONResourceHandler, wxBitmapHandler) + +bool wxICONResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags, + int desiredWidth, int desiredHeight) +{ + short theId = -1 ; + if ( name == "wxICON_INFO" ) + { + theId = kNoteIcon ; + } + else if ( name == "wxICON_QUESTION" ) + { + theId = kCautionIcon ; + } + else if ( name == "wxICON_WARNING" ) + { + theId = kCautionIcon ; + } + else if ( name == "wxICON_ERROR" ) + { + theId = kStopIcon ; + } + else + { + Str255 theName ; + OSType theType ; + + #if TARGET_CARBON + c2pstrcpy( (StringPtr) theName , name ) ; + #else + strcpy( (char *) theName , name ) ; + c2pstr( (char *) theName ) ; + #endif + + Handle resHandle = GetNamedResource( 'cicn' , theName ) ; + if ( resHandle != 0L ) + { + GetResInfo( resHandle , &theId , &theType , theName ) ; + ReleaseResource( resHandle ) ; + } + } + if ( theId != -1 ) + { + CIconHandle theIcon = (CIconHandle ) GetCIcon( theId ) ; + if ( theIcon ) + { + M_BITMAPHANDLERDATA->m_hIcon = theIcon ; + M_BITMAPHANDLERDATA->m_width = 32 ; + M_BITMAPHANDLERDATA->m_height = 32 ; + + M_BITMAPHANDLERDATA->m_depth = 8 ; + M_BITMAPHANDLERDATA->m_ok = true ; + M_BITMAPHANDLERDATA->m_numColors = 256 ; + M_BITMAPHANDLERDATA->m_bitmapType = kMacBitmapTypeIcon ; + return TRUE ; + } + } + return FALSE ; +}