icon.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/osx/icon.h
  3. // Purpose: wxIcon class
  4. // Author: Stefan Csomor
  5. // Modified by:
  6. // Created: 1998-01-01
  7. // Copyright: (c) Stefan Csomor
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_ICON_H_
  11. #define _WX_ICON_H_
  12. #include "wx/bitmap.h"
  13. // Icon
  14. class WXDLLIMPEXP_CORE wxIcon : public wxGDIObject
  15. {
  16. public:
  17. wxIcon();
  18. wxIcon(const char* const* data);
  19. wxIcon(const char bits[], int width , int height );
  20. wxIcon(const wxString& name, wxBitmapType flags = wxICON_DEFAULT_TYPE,
  21. int desiredWidth = -1, int desiredHeight = -1);
  22. wxIcon(const wxIconLocation& loc)
  23. {
  24. LoadFile(loc.GetFileName(), wxBITMAP_TYPE_ICON);
  25. }
  26. wxIcon(WXHICON icon, const wxSize& size);
  27. virtual ~wxIcon();
  28. bool LoadFile(const wxString& name, wxBitmapType flags = wxICON_DEFAULT_TYPE,
  29. int desiredWidth = -1, int desiredHeight = -1);
  30. // create from bitmap (which should have a mask unless it's monochrome):
  31. // there shouldn't be any implicit bitmap -> icon conversion (i.e. no
  32. // ctors, assignment operators...), but it's ok to have such function
  33. void CopyFromBitmap(const wxBitmap& bmp);
  34. int GetWidth() const;
  35. int GetHeight() const;
  36. int GetDepth() const;
  37. void SetWidth(int w);
  38. void SetHeight(int h);
  39. void SetDepth(int d);
  40. void SetOk(bool isOk);
  41. wxSize GetSize() const { return wxSize(GetWidth(), GetHeight()); }
  42. WXHICON GetHICON() const;
  43. protected:
  44. virtual wxGDIRefData *CreateGDIRefData() const;
  45. virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
  46. private:
  47. DECLARE_DYNAMIC_CLASS(wxIcon)
  48. bool LoadIconFromSystemResource(const wxString& resourceName, int desiredWidth, int desiredHeight);
  49. bool LoadIconFromBundleResource(const wxString& resourceName, int desiredWidth, int desiredHeight);
  50. bool LoadIconFromFile(const wxString& filename, int desiredWidth, int desiredHeight);
  51. bool LoadIconAsBitmap(const wxString& filename, wxBitmapType flags = wxICON_DEFAULT_TYPE, int desiredWidth = -1, int desiredHeight = -1);
  52. };
  53. class WXDLLIMPEXP_CORE wxICONResourceHandler: public wxBitmapHandler
  54. {
  55. public:
  56. wxICONResourceHandler()
  57. {
  58. SetName(wxT("ICON resource"));
  59. SetExtension(wxEmptyString);
  60. SetType(wxBITMAP_TYPE_ICON_RESOURCE);
  61. }
  62. virtual bool LoadFile(wxBitmap *bitmap,
  63. const wxString& name,
  64. wxBitmapType flags,
  65. int desiredWidth = -1,
  66. int desiredHeight = -1);
  67. // unhide the base class virtual
  68. virtual bool LoadFile(wxBitmap *bitmap,
  69. const wxString& name,
  70. wxBitmapType flags)
  71. { return LoadFile(bitmap, name, flags, -1, -1); }
  72. private:
  73. DECLARE_DYNAMIC_CLASS(wxICONResourceHandler)
  74. };
  75. #endif
  76. // _WX_ICON_H_