]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/icon.cpp
   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 #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 
== wxT("wxICON_INFORMATION") ) 
  90     else if ( name 
== wxT("wxICON_QUESTION") ) 
  92         theId 
= kCautionIcon 
; 
  94     else if ( name 
== wxT("wxICON_WARNING") ) 
  96         theId 
= kCautionIcon 
; 
  98     else if ( name 
== wxT("wxICON_ERROR") ) 
 106         wxMacStringToPascal( name 
, theName 
) ; 
 108         Handle resHandle 
= GetNamedResource( 'cicn' , theName 
) ; 
 109         if ( resHandle 
!= 0L ) 
 111             GetResInfo( resHandle 
, &theId 
, &theType 
, theName 
) ; 
 112             ReleaseResource( resHandle 
) ; 
 117         CIconHandle theIcon 
= (CIconHandle 
) GetCIcon( theId 
) ; 
 120             M_BITMAPHANDLERDATA
->m_hIcon 
= theIcon 
; 
 121             M_BITMAPHANDLERDATA
->m_width 
=  32 ; 
 122             M_BITMAPHANDLERDATA
->m_height 
= 32 ; 
 124             M_BITMAPHANDLERDATA
->m_depth 
= 8 ; 
 125             M_BITMAPHANDLERDATA
->m_ok 
= true ; 
 126             M_BITMAPHANDLERDATA
->m_numColors 
= 256 ; 
 127             M_BITMAPHANDLERDATA
->m_bitmapType 
= kMacBitmapTypeIcon 
;