icon.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/os2/icon.h
  3. // Purpose: wxIcon class
  4. // Author: David Webster
  5. // Modified by:
  6. // Created: 10/09/99
  7. // Copyright: (c) David Webster
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_ICON_H_
  11. #define _WX_ICON_H_
  12. // ----------------------------------------------------------------------------
  13. // headers
  14. // ----------------------------------------------------------------------------
  15. #include "wx/bitmap.h"
  16. #include "wx/os2/gdiimage.h"
  17. #define wxIconRefDataBase wxGDIImageRefData
  18. #define wxIconBase wxGDIImage
  19. class WXDLLIMPEXP_CORE wxIconRefData: public wxIconRefDataBase
  20. {
  21. public:
  22. wxIconRefData() { }
  23. virtual ~wxIconRefData() { Free(); }
  24. virtual void Free();
  25. }; // end of
  26. // ---------------------------------------------------------------------------
  27. // Icon
  28. // ---------------------------------------------------------------------------
  29. class WXDLLIMPEXP_CORE wxIcon: public wxIconBase
  30. {
  31. public:
  32. wxIcon();
  33. wxIcon( const char bits[]
  34. ,int nWidth
  35. ,int nHeight
  36. );
  37. wxIcon(const char* const* ppData) { CreateIconFromXpm(ppData); }
  38. #ifdef wxNEEDS_CHARPP
  39. wxIcon(char** ppData) { CreateIconFromXpm(const_cast<const char* const*>(ppData)); }
  40. #endif
  41. wxIcon( const wxString& rName
  42. ,wxBitmapType lFlags = wxICON_DEFAULT_TYPE
  43. ,int nDesiredWidth = -1
  44. ,int nDesiredHeight = -1
  45. );
  46. wxIcon(const wxIconLocation& loc)
  47. {
  48. LoadFile(loc.GetFileName(), wxBITMAP_TYPE_ICO);
  49. }
  50. virtual ~wxIcon();
  51. bool LoadFile( const wxString& rName
  52. ,wxBitmapType lFlags = wxICON_DEFAULT_TYPE
  53. ,int nDesiredWidth = -1
  54. ,int nDesiredHeight = -1
  55. );
  56. wxIconRefData *GetIconData() const { return (wxIconRefData *)m_refData; }
  57. inline void SetHICON(WXHICON hIcon) { SetHandle((WXHANDLE)hIcon); }
  58. inline WXHICON GetHICON() const { return (WXHICON)GetHandle(); }
  59. inline bool IsXpm(void) const { return m_bIsXpm; }
  60. inline const wxBitmap& GetXpmSrc(void) const { return m_vXpmSrc; }
  61. void CopyFromBitmap(const wxBitmap& rBmp);
  62. protected:
  63. virtual wxGDIImageRefData* CreateData() const
  64. {
  65. return new wxIconRefData;
  66. }
  67. void CreateIconFromXpm(const char* const* ppData);
  68. private:
  69. bool m_bIsXpm;
  70. wxBitmap m_vXpmSrc;
  71. DECLARE_DYNAMIC_CLASS(wxIcon)
  72. };
  73. #endif
  74. // _WX_ICON_H_