]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/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
)
52 LoadFile(icon_file
, (wxBitmapType
) flags
, desiredWidth
, desiredHeight
);
59 bool wxIcon::LoadFile(const wxString
& filename
, wxBitmapType type
,
60 int desiredWidth
, int desiredHeight
)
64 m_refData
= new wxBitmapRefData
;
66 wxBitmapHandler
*handler
= FindHandler((wxBitmapType
)type
);
69 return handler
->LoadFile(this, filename
, type
, desiredWidth
, desiredHeight
);
74 void wxIcon::CopyFromBitmap(const wxBitmap
& bmp
)
76 wxIcon
*icon
= (wxIcon
*)(&bmp
);
80 IMPLEMENT_DYNAMIC_CLASS(wxICONResourceHandler
, wxBitmapHandler
)
82 bool wxICONResourceHandler::LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
83 int desiredWidth
, int desiredHeight
)
86 if ( name
== "wxICON_INFORMATION" )
90 else if ( name
== "wxICON_QUESTION" )
92 theId
= kCautionIcon
;
94 else if ( name
== "wxICON_WARNING" )
96 theId
= kCautionIcon
;
98 else if ( name
== "wxICON_ERROR" )
108 c2pstrcpy( (StringPtr
) theName
, name
) ;
110 strcpy( (char *) theName
, name
) ;
111 c2pstr( (char *) theName
) ;
114 Handle resHandle
= GetNamedResource( 'cicn' , theName
) ;
115 if ( resHandle
!= 0L )
117 GetResInfo( resHandle
, &theId
, &theType
, theName
) ;
118 ReleaseResource( resHandle
) ;
123 CIconHandle theIcon
= (CIconHandle
) GetCIcon( theId
) ;
126 M_BITMAPHANDLERDATA
->m_hIcon
= theIcon
;
127 M_BITMAPHANDLERDATA
->m_width
= 32 ;
128 M_BITMAPHANDLERDATA
->m_height
= 32 ;
130 M_BITMAPHANDLERDATA
->m_depth
= 8 ;
131 M_BITMAPHANDLERDATA
->m_ok
= true ;
132 M_BITMAPHANDLERDATA
->m_numColors
= 256 ;
133 M_BITMAPHANDLERDATA
->m_bitmapType
= kMacBitmapTypeIcon
;