]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/classic/icon.cpp
1c32358a38aa6e16cd08e56b70d7c94af91d4227
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxIcon class
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "icon.h"
18 IMPLEMENT_DYNAMIC_CLASS(wxIcon
, wxBitmap
)
20 #include "wx/mac/private.h"
31 wxIcon::wxIcon(const char bits
[], int width
, int height
) :
32 wxBitmap(bits
, width
, height
)
37 wxIcon::wxIcon( const char **bits
) :
42 wxIcon::wxIcon( char **bits
) :
47 wxIcon::wxIcon(const wxString
& icon_file
, int flags
,
48 int desiredWidth
, int desiredHeight
)
50 LoadFile(icon_file
, (wxBitmapType
) flags
, desiredWidth
, desiredHeight
);
57 bool wxIcon::LoadFile(const wxString
& filename
, wxBitmapType 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
== wxT("wxICON_INFORMATION") )
88 else if ( name
== wxT("wxICON_QUESTION") )
90 theId
= kCautionIcon
;
92 else if ( name
== wxT("wxICON_WARNING") )
94 theId
= kCautionIcon
;
96 else if ( name
== wxT("wxICON_ERROR") )
104 wxMacStringToPascal( name
, 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
;