iconbndl.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: iconbndl.h
  3. // Purpose: interface of wxIconBundle
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @class wxIconBundle
  9. This class contains multiple copies of an icon in different sizes.
  10. It is typically used in wxDialog::SetIcons and wxTopLevelWindow::SetIcons.
  11. @library{wxcore}
  12. @category{gdi}
  13. @stdobjects
  14. ::wxNullIconBundle
  15. */
  16. class wxIconBundle : public wxGDIObject
  17. {
  18. public:
  19. /**
  20. The elements of this enum determine what happens if GetIcon() doesn't
  21. find the icon of exactly the requested size.
  22. @since 2.9.4
  23. */
  24. enum
  25. {
  26. /// Return invalid icon if exact size is not found.
  27. FALLBACK_NONE = 0,
  28. /// Return the icon of the system icon size if exact size is not found.
  29. /// May be combined with other non-NONE enum elements to determine what
  30. /// happens if the system icon size is not found neither.
  31. FALLBACK_SYSTEM = 1,
  32. /// Return the icon of closest larger size or, if there is no icon of
  33. /// larger size in the bundle, the closest icon of smaller size.
  34. FALLBACK_NEAREST_LARGER = 2
  35. };
  36. /**
  37. Default ctor.
  38. */
  39. wxIconBundle();
  40. /**
  41. Initializes the bundle with the icon(s) found in the file.
  42. */
  43. wxIconBundle(const wxString& file, wxBitmapType type = wxBITMAP_TYPE_ANY);
  44. /**
  45. Initializes the bundle with the icon(s) found in the stream.
  46. Notice that the @a stream must be seekable, at least if it contains
  47. more than one icon. The stream pointer is positioned after the last
  48. icon read from the stream when this function returns.
  49. @since 2.9.0
  50. */
  51. wxIconBundle(wxInputStream& stream, wxBitmapType type = wxBITMAP_TYPE_ANY);
  52. /**
  53. Initializes the bundle with a single icon.
  54. */
  55. wxIconBundle(const wxIcon& icon);
  56. /**
  57. Copy constructor.
  58. */
  59. wxIconBundle(const wxIconBundle& ic);
  60. /**
  61. Destructor.
  62. */
  63. virtual ~wxIconBundle();
  64. /**
  65. Adds all the icons contained in the file to the bundle; if the
  66. collection already contains icons with the same width and height, they
  67. are replaced by the new ones.
  68. */
  69. void AddIcon(const wxString& file, wxBitmapType type = wxBITMAP_TYPE_ANY);
  70. /**
  71. Adds all the icons contained in the stream to the bundle; if the
  72. collection already contains icons with the same width and height, they
  73. are replaced by the new ones.
  74. Notice that, as well as in the constructor loading the icon bundle from
  75. stream, the @a stream must be seekable, at least if more than one icon
  76. is to be loaded from it.
  77. @since 2.9.0
  78. */
  79. void AddIcon(wxInputStream& stream, wxBitmapType type = wxBITMAP_TYPE_ANY);
  80. /**
  81. Adds the icon to the collection; if the collection already
  82. contains an icon with the same width and height, it is
  83. replaced by the new one.
  84. */
  85. void AddIcon(const wxIcon& icon);
  86. /**
  87. Returns the icon with the given size.
  88. If @a size is ::wxDefaultSize, it is interpreted as the standard system
  89. icon size, i.e. the size returned by wxSystemSettings::GetMetric() for
  90. @c wxSYS_ICON_X and @c wxSYS_ICON_Y.
  91. If the bundle contains an icon with exactly the requested size, it's
  92. always returned. Otherwise, the behaviour depends on the flags. If only
  93. wxIconBundle::FALLBACK_NONE is given, the function returns an invalid
  94. icon. If wxIconBundle::FALLBACK_SYSTEM is given, it tries to find the
  95. icon of standard system size, regardless of the size passed as
  96. parameter. Otherwise, or if the icon system size is not found neither,
  97. but wxIconBundle::FALLBACK_NEAREST_LARGER flag is specified, the
  98. function returns the smallest icon of the size larger than the
  99. requested one or, if this fails too, just the icon closest to the
  100. specified size.
  101. The @a flags parameter is available only since wxWidgets 2.9.4.
  102. */
  103. wxIcon GetIcon(const wxSize& size, int flags = FALLBACK_SYSTEM) const;
  104. /**
  105. Same as @code GetIcon( wxSize( size, size ) ) @endcode.
  106. */
  107. wxIcon GetIcon(wxCoord size = wxDefaultCoord,
  108. int flags = FALLBACK_SYSTEM) const;
  109. /**
  110. Returns the icon with exactly the given size or ::wxNullIcon if this
  111. size is not available.
  112. */
  113. wxIcon GetIconOfExactSize(const wxSize& size) const;
  114. /**
  115. return the number of available icons
  116. */
  117. size_t GetIconCount() const;
  118. /**
  119. return the icon at index (must be < GetIconCount())
  120. */
  121. wxIcon GetIconByIndex(size_t n) const;
  122. /**
  123. Returns @true if the bundle doesn't contain any icons, @false otherwise
  124. (in which case a call to GetIcon() with default parameter should return
  125. a valid icon).
  126. */
  127. bool IsEmpty() const;
  128. /**
  129. Assignment operator, using @ref overview_refcount "reference counting".
  130. */
  131. wxIconBundle& operator=(const wxIconBundle& ic);
  132. };
  133. /**
  134. An empty wxIconBundle.
  135. */
  136. wxIconBundle wxNullIconBundle;