]>
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
)
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((wxBitmapType
)type
);
67 return handler
->LoadFile(this, filename
, type
, desiredWidth
, desiredHeight
);
72 void wxIcon::CopyFromBitmap(const wxBitmap
& bmp
)
74 wxIcon
*icon
= (wxIcon
*)(&bmp
);
78 IMPLEMENT_DYNAMIC_CLASS(wxICONResourceHandler
, wxBitmapHandler
)
80 bool wxICONResourceHandler::LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
81 int desiredWidth
, int desiredHeight
)
84 if ( name
== "wxICON_INFO" )
88 else if ( name
== "wxICON_QUESTION" )
90 theId
= kCautionIcon
;
92 else if ( name
== "wxICON_WARNING" )
94 theId
= kCautionIcon
;
96 else if ( name
== "wxICON_ERROR" )
106 c2pstrcpy( (StringPtr
) theName
, name
) ;
108 strcpy( (char *) theName
, name
) ;
109 c2pstr( (char *) theName
) ;
112 Handle resHandle
= GetNamedResource( 'cicn' , theName
) ;
113 if ( resHandle
!= 0L )
115 GetResInfo( resHandle
, &theId
, &theType
, theName
) ;
116 ReleaseResource( resHandle
) ;
121 CIconHandle theIcon
= (CIconHandle
) GetCIcon( theId
) ;
124 M_BITMAPHANDLERDATA
->m_hIcon
= theIcon
;
125 M_BITMAPHANDLERDATA
->m_width
= 32 ;
126 M_BITMAPHANDLERDATA
->m_height
= 32 ;
128 M_BITMAPHANDLERDATA
->m_depth
= 8 ;
129 M_BITMAPHANDLERDATA
->m_ok
= true ;
130 M_BITMAPHANDLERDATA
->m_numColors
= 256 ;
131 M_BITMAPHANDLERDATA
->m_bitmapType
= kMacBitmapTypeIcon
;