]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/classic/icon.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/classic/icon.cpp
3 // Purpose: wxIcon class
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
16 IMPLEMENT_DYNAMIC_CLASS(wxIcon
, wxBitmap
)
18 #include "wx/mac/private.h"
29 wxIcon::wxIcon(const char bits
[], int width
, int height
)
30 :wxBitmap(bits
, width
, height
)
34 wxIcon::wxIcon( const char **bits
) :
39 wxIcon::wxIcon( char **bits
) :
44 wxIcon::wxIcon(const wxString
& icon_file
, int flags
,
45 int desiredWidth
, int desiredHeight
)
47 LoadFile(icon_file
, (wxBitmapType
) flags
, desiredWidth
, desiredHeight
);
54 bool wxIcon::LoadFile(const wxString
& filename
, wxBitmapType type
,
55 int desiredWidth
, int desiredHeight
)
59 m_refData
= new wxBitmapRefData
;
61 wxBitmapHandler
*handler
= FindHandler((wxBitmapType
)type
);
64 return handler
->LoadFile(this, filename
, type
, desiredWidth
, desiredHeight
);
69 void wxIcon::CopyFromBitmap(const wxBitmap
& bmp
)
71 wxIcon
*icon
= (wxIcon
*)(&bmp
);
75 IMPLEMENT_DYNAMIC_CLASS(wxICONResourceHandler
, wxBitmapHandler
)
77 bool wxICONResourceHandler::LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
78 int desiredWidth
, int desiredHeight
)
81 if ( name
== wxT("wxICON_INFORMATION") )
85 else if ( name
== wxT("wxICON_QUESTION") )
87 theId
= kCautionIcon
;
89 else if ( name
== wxT("wxICON_WARNING") )
91 theId
= kCautionIcon
;
93 else if ( name
== wxT("wxICON_ERROR") )
101 wxMacStringToPascal( name
, theName
) ;
103 Handle resHandle
= GetNamedResource( 'cicn' , theName
) ;
104 if ( resHandle
!= 0L )
106 GetResInfo( resHandle
, &theId
, &theType
, theName
) ;
107 ReleaseResource( resHandle
) ;
112 CIconHandle theIcon
= (CIconHandle
) GetCIcon( theId
) ;
115 M_BITMAPHANDLERDATA
->m_hIcon
= theIcon
;
116 M_BITMAPHANDLERDATA
->m_width
= 32 ;
117 M_BITMAPHANDLERDATA
->m_height
= 32 ;
119 M_BITMAPHANDLERDATA
->m_depth
= 8 ;
120 M_BITMAPHANDLERDATA
->m_ok
= true ;
121 M_BITMAPHANDLERDATA
->m_numColors
= 256 ;
122 M_BITMAPHANDLERDATA
->m_bitmapType
= kMacBitmapTypeIcon
;