Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
2.7 KiB

  1. /*--------------------------------------------------------------------------*
  2. *
  3. * Microsoft Windows
  4. * Copyright (C) Microsoft Corporation, 1992 - 1999
  5. *
  6. * File: picon.h
  7. *
  8. * Contents: Interface file for CPersistableIcon
  9. *
  10. * History: 19-Nov-98 jeffro Created
  11. *
  12. *--------------------------------------------------------------------------*/
  13. #ifndef PICON_H
  14. #define PICON_H
  15. #pragma once
  16. #include <objidl.h> // for IStorage
  17. #include "tstring.h"
  18. #include "smarticon.h"
  19. #include "cpputil.h"
  20. class CPersistableIconData
  21. {
  22. public:
  23. CPersistableIconData() :
  24. m_nIndex (-1)
  25. {}
  26. CPersistableIconData(LPCTSTR pszIconFile, int nIndex) :
  27. m_strIconFile (pszIconFile), m_nIndex (nIndex)
  28. {}
  29. // default copy construction and assignment are fine
  30. // CPersistableIconData (const CPersistableIconData& other)
  31. // CPersistableIconData& operator= (const CPersistableIconData& other)
  32. void Clear ()
  33. {
  34. m_strIconFile.erase();
  35. m_nIndex = -1;
  36. ASSERT (m_strIconFile.empty());
  37. }
  38. bool operator== (const CPersistableIconData& other) const
  39. { return ((m_nIndex == other.m_nIndex) && (m_strIconFile == other.m_strIconFile)); }
  40. bool operator!= (const CPersistableIconData& other) const
  41. { return (!operator== (other)); }
  42. public:
  43. tstring m_strIconFile;
  44. int m_nIndex;
  45. };
  46. class CXMLPersistableIcon;
  47. class CPersistableIcon
  48. {
  49. DECLARE_NOT_COPIABLE (CPersistableIcon);
  50. DECLARE_NOT_ASSIGNABLE (CPersistableIcon);
  51. // these guys need to assign new icons to the object
  52. friend class CXMLPersistableIcon;
  53. friend HRESULT LoadIconFromXMLData(LPCSTR pFileData, DWORD dwLen, CPersistableIcon &persistableIcon);
  54. public:
  55. CPersistableIcon () {}
  56. ~CPersistableIcon ();
  57. operator bool () const
  58. { return (!m_Data.m_strIconFile.empty()); }
  59. bool operator== (const CPersistableIconData& data) const
  60. { return (m_Data == data); }
  61. bool operator!= (const CPersistableIconData& data) const
  62. { return (m_Data != data); }
  63. CPersistableIcon& operator= (const CPersistableIconData& data);
  64. HRESULT GetIcon (int nIconSize, CSmartIcon& icon) const;
  65. void GetData (CPersistableIconData& data) const
  66. { data = m_Data; }
  67. HRESULT Load (LPCWSTR pszFilename);
  68. HRESULT Load (IStorage* pstg);
  69. private:
  70. void Cleanup();
  71. bool ExtractIcons();
  72. private:
  73. CPersistableIconData m_Data;
  74. CSmartIcon m_icon16;
  75. CSmartIcon m_icon32;
  76. static const LPCWSTR s_pszDefaultStorage;
  77. static const LPCWSTR s_pszIconFileStream;
  78. static const LPCWSTR s_pszIconBitsStream;
  79. };
  80. IStream& operator>> (IStream& stm, CPersistableIconData& data);
  81. extern const LPCWSTR g_pszCustomDataStorage;
  82. #endif /* PICON_H */