]>
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
)
22 #include "wx/mac/private.h"
33 wxIcon::wxIcon(const char bits
[], int width
, int height
) :
34 wxBitmap(bits
,width
,height
)
39 wxIcon::wxIcon( const char **bits
) :
44 wxIcon::wxIcon( char **bits
) :
49 wxIcon::wxIcon(const wxString
& icon_file
, int flags
,
50 int desiredWidth
, int desiredHeight
)
53 LoadFile(icon_file
, (wxBitmapType
) flags
, desiredWidth
, desiredHeight
);
60 bool wxIcon::LoadFile(const wxString
& filename
, wxBitmapType type
,
61 int desiredWidth
, int desiredHeight
)
65 m_refData
= new wxBitmapRefData
;
67 wxBitmapHandler
*handler
= FindHandler((wxBitmapType
)type
);
70 return handler
->LoadFile(this, filename
, type
, desiredWidth
, desiredHeight
);
75 void wxIcon::CopyFromBitmap(const wxBitmap
& bmp
)
77 wxIcon
*icon
= (wxIcon
*)(&bmp
);
81 IMPLEMENT_DYNAMIC_CLASS(wxICONResourceHandler
, wxBitmapHandler
)
83 bool wxICONResourceHandler::LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
84 int desiredWidth
, int desiredHeight
)
87 if ( name
== "wxICON_INFO" )
91 else if ( name
== "wxICON_QUESTION" )
93 theId
= kCautionIcon
;
95 else if ( name
== "wxICON_WARNING" )
97 theId
= kCautionIcon
;
99 else if ( name
== "wxICON_ERROR" )
109 c2pstrcpy( (StringPtr
) theName
, name
) ;
111 strcpy( (char *) theName
, name
) ;
112 c2pstr( (char *) theName
) ;
115 Handle resHandle
= GetNamedResource( 'cicn' , theName
) ;
116 if ( resHandle
!= 0L )
118 GetResInfo( resHandle
, &theId
, &theType
, theName
) ;
119 ReleaseResource( resHandle
) ;
124 CIconHandle theIcon
= (CIconHandle
) GetCIcon( theId
) ;
127 M_BITMAPHANDLERDATA
->m_hIcon
= theIcon
;
128 M_BITMAPHANDLERDATA
->m_width
= 32 ;
129 M_BITMAPHANDLERDATA
->m_height
= 32 ;
131 M_BITMAPHANDLERDATA
->m_depth
= 8 ;
132 M_BITMAPHANDLERDATA
->m_ok
= true ;
133 M_BITMAPHANDLERDATA
->m_numColors
= 256 ;
134 M_BITMAPHANDLERDATA
->m_bitmapType
= kMacBitmapTypeIcon
;