1 ///////////////////////////////////////////////////////////////////////////// 
   3 // Purpose:     wxIcon class 
   4 // Author:      Stefan Csomor 
   8 // Copyright:   (c) Stefan Csomor 
   9 // Licence:     wxWindows licence 
  10 ///////////////////////////////////////////////////////////////////////////// 
  15 #include "wx/bitmap.h" 
  18 class WXDLLIMPEXP_CORE wxIcon 
: public wxGDIObject
 
  23     wxIcon(const char* const* data
); 
  24     wxIcon(const char bits
[], int width 
, int height 
); 
  25     wxIcon(const wxString
& name
, wxBitmapType flags 
= wxICON_DEFAULT_TYPE
, 
  26            int desiredWidth 
= -1, int desiredHeight 
= -1); 
  27     wxIcon(const wxIconLocation
& loc
) 
  29       LoadFile(loc
.GetFileName(), wxBITMAP_TYPE_ICON
); 
  32     wxIcon(WXHICON icon
, const wxSize
& size
); 
  36     bool LoadFile(const wxString
& name
, wxBitmapType flags 
= wxICON_DEFAULT_TYPE
, 
  37                   int desiredWidth 
= -1, int desiredHeight 
= -1); 
  40     // create from bitmap (which should have a mask unless it's monochrome): 
  41     // there shouldn't be any implicit bitmap -> icon conversion (i.e. no 
  42     // ctors, assignment operators...), but it's ok to have such function 
  43     void CopyFromBitmap(const wxBitmap
& bmp
); 
  46     int GetHeight() const; 
  49     void SetHeight(int h
); 
  51     void SetOk(bool isOk
); 
  53     wxSize 
GetSize() const { return wxSize(GetWidth(), GetHeight()); } 
  55     WXHICON 
GetHICON() const; 
  58     virtual wxGDIRefData 
*CreateGDIRefData() const; 
  59     virtual wxGDIRefData 
*CloneGDIRefData(const wxGDIRefData 
*data
) const; 
  62     DECLARE_DYNAMIC_CLASS(wxIcon
) 
  64     bool LoadIconFromSystemResource(const wxString
& resourceName
, int desiredWidth
, int desiredHeight
); 
  65     bool LoadIconFromBundleResource(const wxString
& resourceName
, int desiredWidth
, int desiredHeight
); 
  66     bool LoadIconFromFile(const wxString
& filename
, int desiredWidth
, int desiredHeight
); 
  67     bool LoadIconAsBitmap(const wxString
& filename
, wxBitmapType flags 
= wxICON_DEFAULT_TYPE
, int desiredWidth 
= -1, int desiredHeight 
= -1); 
  70 class WXDLLIMPEXP_CORE wxICONResourceHandler
: public wxBitmapHandler
 
  73     wxICONResourceHandler() 
  75         SetName(wxT("ICON resource")); 
  76         SetExtension(wxEmptyString
); 
  77         SetType(wxBITMAP_TYPE_ICON_RESOURCE
); 
  80     virtual bool LoadFile(wxBitmap 
*bitmap
, 
  83                           int desiredWidth 
= -1, 
  84                           int desiredHeight 
= -1); 
  86     // unhide the base class virtual 
  87     virtual bool LoadFile(wxBitmap 
*bitmap
, 
  90         { return LoadFile(bitmap
, name
, flags
, -1, -1); } 
  93     DECLARE_DYNAMIC_CLASS(wxICONResourceHandler
)