]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/icon.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxIcon class
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "icon.h"
18 #if !USE_SHARED_LIBRARIES
19 IMPLEMENT_DYNAMIC_CLASS(wxIcon
, wxBitmap
)
30 wxIcon::wxIcon(const char bits
[], int width
, int height
) :
31 wxBitmap(bits
,width
,height
)
36 wxIcon::wxIcon( const char **bits
) :
41 wxIcon::wxIcon( char **bits
) :
46 wxIcon::wxIcon(const wxString
& icon_file
, long flags
,
47 int desiredWidth
, int desiredHeight
)
50 LoadFile(icon_file
, flags
, desiredWidth
, desiredHeight
);
57 bool wxIcon::LoadFile(const wxString
& filename
, long type
,
58 int desiredWidth
, int desiredHeight
)
62 m_refData
= new wxBitmapRefData
;
64 wxBitmapHandler
*handler
= FindHandler(type
);
67 return handler
->LoadFile(this, filename
, type
, desiredWidth
, desiredHeight
);
72 IMPLEMENT_DYNAMIC_CLASS(wxICONResourceHandler
, wxBitmapHandler
)
74 bool wxICONResourceHandler::LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
75 int desiredWidth
, int desiredHeight
)
78 if ( name
== "wxICON_INFO" )
82 else if ( name
== "wxICON_QUESTION" )
84 theId
= kCautionIcon
;
86 else if ( name
== "wxICON_WARNING" )
88 theId
= kCautionIcon
;
90 else if ( name
== "wxICON_ERROR" )
100 c2pstrcpy( (StringPtr
) theName
, name
) ;
102 strcpy( (char *) theName
, name
) ;
103 c2pstr( (char *) theName
) ;
106 Handle resHandle
= GetNamedResource( 'cicn' , theName
) ;
107 if ( resHandle
!= 0L )
109 GetResInfo( resHandle
, &theId
, &theType
, theName
) ;
110 ReleaseResource( resHandle
) ;
115 CIconHandle theIcon
= (CIconHandle
) GetCIcon( theId
) ;
118 M_BITMAPHANDLERDATA
->m_hIcon
= theIcon
;
119 M_BITMAPHANDLERDATA
->m_width
= 32 ;
120 M_BITMAPHANDLERDATA
->m_height
= 32 ;
122 M_BITMAPHANDLERDATA
->m_depth
= 8 ;
123 M_BITMAPHANDLERDATA
->m_ok
= true ;
124 M_BITMAPHANDLERDATA
->m_numColors
= 256 ;
125 M_BITMAPHANDLERDATA
->m_bitmapType
= kMacBitmapTypeIcon
;