]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/classic/icon.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxIcon class
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
14 IMPLEMENT_DYNAMIC_CLASS(wxIcon
, wxBitmap
)
16 #include "wx/mac/private.h"
27 wxIcon::wxIcon(const char bits
[], int width
, int height
) :
28 wxBitmap(bits
, width
, height
)
33 wxIcon::wxIcon( const char **bits
) :
38 wxIcon::wxIcon( char **bits
) :
43 wxIcon::wxIcon(const wxString
& icon_file
, int flags
,
44 int desiredWidth
, int desiredHeight
)
46 LoadFile(icon_file
, (wxBitmapType
) flags
, desiredWidth
, desiredHeight
);
53 bool wxIcon::LoadFile(const wxString
& filename
, wxBitmapType type
,
54 int desiredWidth
, int desiredHeight
)
58 m_refData
= new wxBitmapRefData
;
60 wxBitmapHandler
*handler
= FindHandler((wxBitmapType
)type
);
63 return handler
->LoadFile(this, filename
, type
, desiredWidth
, desiredHeight
);
68 void wxIcon::CopyFromBitmap(const wxBitmap
& bmp
)
70 wxIcon
*icon
= (wxIcon
*)(&bmp
);
74 IMPLEMENT_DYNAMIC_CLASS(wxICONResourceHandler
, wxBitmapHandler
)
76 bool wxICONResourceHandler::LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
77 int desiredWidth
, int desiredHeight
)
80 if ( name
== wxT("wxICON_INFORMATION") )
84 else if ( name
== wxT("wxICON_QUESTION") )
86 theId
= kCautionIcon
;
88 else if ( name
== wxT("wxICON_WARNING") )
90 theId
= kCautionIcon
;
92 else if ( name
== wxT("wxICON_ERROR") )
100 wxMacStringToPascal( name
, theName
) ;
102 Handle resHandle
= GetNamedResource( 'cicn' , theName
) ;
103 if ( resHandle
!= 0L )
105 GetResInfo( resHandle
, &theId
, &theType
, theName
) ;
106 ReleaseResource( resHandle
) ;
111 CIconHandle theIcon
= (CIconHandle
) GetCIcon( theId
) ;
114 M_BITMAPHANDLERDATA
->m_hIcon
= theIcon
;
115 M_BITMAPHANDLERDATA
->m_width
= 32 ;
116 M_BITMAPHANDLERDATA
->m_height
= 32 ;
118 M_BITMAPHANDLERDATA
->m_depth
= 8 ;
119 M_BITMAPHANDLERDATA
->m_ok
= true ;
120 M_BITMAPHANDLERDATA
->m_numColors
= 256 ;
121 M_BITMAPHANDLERDATA
->m_bitmapType
= kMacBitmapTypeIcon
;