icon.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/cocoa/icon.h
  3. // Purpose: wxIcon class
  4. // Author: David Elliott
  5. // Modified by:
  6. // Created: 2003/08/11
  7. // Copyright: (c) 2003 David Elliott
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_COCOA_ICON_H__
  11. #define _WX_COCOA_ICON_H__
  12. #include "wx/gdicmn.h"
  13. #include "wx/gdiobj.h"
  14. // ========================================================================
  15. // wxIcon
  16. // ========================================================================
  17. class WXDLLIMPEXP_CORE wxIcon : public wxGDIObject
  18. {
  19. public:
  20. wxIcon();
  21. wxIcon(const char* const* data) { CreateFromXpm(data); }
  22. wxIcon(const char bits[], int width , int height );
  23. wxIcon(const wxString& name, int flags = wxICON_DEFAULT_TYPE,
  24. int desiredWidth = -1, int desiredHeight = -1);
  25. wxIcon(const wxIconLocation& loc)
  26. {
  27. LoadFile(loc.GetFileName(), wxBITMAP_TYPE_ICON);
  28. }
  29. virtual ~wxIcon();
  30. bool LoadFile(const wxString& name, wxBitmapType flags = wxICON_DEFAULT_TYPE,
  31. int desiredWidth=-1, int desiredHeight=-1);
  32. bool operator==(const wxIcon& icon) const
  33. { return m_refData == icon.m_refData; }
  34. bool operator!=(const wxIcon& icon) const { return !(*this == icon); }
  35. // create from bitmap (which should have a mask unless it's monochrome):
  36. // there shouldn't be any implicit bitmap -> icon conversion (i.e. no
  37. // ctors, assignment operators...), but it's ok to have such function
  38. void CopyFromBitmap(const wxBitmap& bmp);
  39. int GetWidth() const;
  40. int GetHeight() const;
  41. wxSize GetSize() const { return wxSize(GetWidth(), GetHeight()); }
  42. WX_NSImage GetNSImage() const;
  43. bool CreateFromXpm(const char* const* bits);
  44. protected:
  45. virtual wxGDIRefData *CreateGDIRefData() const;
  46. virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
  47. private:
  48. DECLARE_DYNAMIC_CLASS(wxIcon)
  49. };
  50. #endif // _WX_COCOA_ICON_H__