anybutton.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: anybutton.h
  3. // Purpose: interface of wxAnyButton
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. #define wxBU_LEFT 0x0040
  8. #define wxBU_TOP 0x0080
  9. #define wxBU_RIGHT 0x0100
  10. #define wxBU_BOTTOM 0x0200
  11. #define wxBU_ALIGN_MASK ( wxBU_LEFT | wxBU_TOP | wxBU_RIGHT | wxBU_BOTTOM )
  12. #define wxBU_EXACTFIT 0x0001
  13. #define wxBU_NOTEXT 0x0002
  14. #define wxBU_AUTODRAW 0x0004
  15. /**
  16. @class wxAnyButton
  17. A class for common button functionality used as the base for the
  18. various button classes.
  19. */
  20. class wxAnyButton : public wxControl
  21. {
  22. public:
  23. wxAnyButton();
  24. ~wxAnyButton();
  25. /**
  26. Return the bitmap shown by the button.
  27. The returned bitmap may be invalid only if the button doesn't show any
  28. images.
  29. @see SetBitmap()
  30. @since 2.9.1
  31. */
  32. wxBitmap GetBitmap() const;
  33. /**
  34. Returns the bitmap used when the mouse is over the button, which may be
  35. invalid.
  36. @see SetBitmapCurrent()
  37. @since 2.9.1 (available as wxBitmapButton::GetBitmapHover() in previous
  38. versions)
  39. */
  40. wxBitmap GetBitmapCurrent() const;
  41. /**
  42. Returns the bitmap for the disabled state, which may be invalid.
  43. @see SetBitmapDisabled()
  44. @since 2.9.1 (available in wxBitmapButton only in previous versions)
  45. */
  46. wxBitmap GetBitmapDisabled() const;
  47. /**
  48. Returns the bitmap for the focused state, which may be invalid.
  49. @see SetBitmapFocus()
  50. @since 2.9.1 (available in wxBitmapButton only in previous versions)
  51. */
  52. wxBitmap GetBitmapFocus() const;
  53. /**
  54. Returns the bitmap for the normal state.
  55. This is exactly the same as GetBitmap() but uses a name
  56. backwards-compatible with wxBitmapButton.
  57. @see SetBitmap(), SetBitmapLabel()
  58. @since 2.9.1 (available in wxBitmapButton only in previous versions)
  59. */
  60. wxBitmap GetBitmapLabel() const;
  61. /**
  62. Returns the bitmap for the pressed state, which may be invalid.
  63. @see SetBitmapPressed()
  64. @since 2.9.1 (available as wxBitmapButton::GetBitmapSelected() in
  65. previous versions)
  66. */
  67. wxBitmap GetBitmapPressed() const;
  68. /**
  69. Sets the bitmap to display in the button.
  70. The bitmap is displayed together with the button label. This method
  71. sets up a single bitmap which is used in all button states, use
  72. SetBitmapDisabled(), SetBitmapPressed(), SetBitmapCurrent() or
  73. SetBitmapFocus() to change the individual images used in different
  74. states.
  75. @param bitmap
  76. The bitmap to display in the button. If the bitmap is invalid, any
  77. currently shown bitmaps are removed from the button.
  78. @param dir
  79. The position of the bitmap inside the button. By default it is
  80. positioned to the left of the text, near to the left button border.
  81. Other possible values include wxRIGHT, wxTOP and wxBOTTOM.
  82. @see SetBitmapPosition(), SetBitmapMargins()
  83. @since 2.9.1
  84. */
  85. void SetBitmap(const wxBitmap& bitmap, wxDirection dir = wxLEFT);
  86. /**
  87. Sets the bitmap to be shown when the mouse is over the button.
  88. If @a bitmap is invalid, the normal bitmap will be used in the current
  89. state.
  90. @see GetBitmapCurrent()
  91. @since 2.9.1 (available as wxBitmapButton::SetBitmapHover() in previous
  92. versions)
  93. */
  94. void SetBitmapCurrent(const wxBitmap& bitmap);
  95. /**
  96. Sets the bitmap for the disabled button appearance.
  97. If @a bitmap is invalid, the disabled bitmap is set to the
  98. automatically generated greyed out version of the normal bitmap, i.e.
  99. the same bitmap as is used by default if this method is not called at
  100. all. Use SetBitmap() with an invalid bitmap to remove the bitmap
  101. completely (for all states).
  102. @see GetBitmapDisabled(), SetBitmapLabel(),
  103. SetBitmapPressed(), SetBitmapFocus()
  104. @since 2.9.1 (available in wxBitmapButton only in previous versions)
  105. */
  106. void SetBitmapDisabled(const wxBitmap& bitmap);
  107. /**
  108. Sets the bitmap for the button appearance when it has the keyboard
  109. focus.
  110. If @a bitmap is invalid, the normal bitmap will be used in the focused
  111. state.
  112. @see GetBitmapFocus(), SetBitmapLabel(),
  113. SetBitmapPressed(), SetBitmapDisabled()
  114. @since 2.9.1 (available in wxBitmapButton only in previous versions)
  115. */
  116. void SetBitmapFocus(const wxBitmap& bitmap);
  117. /**
  118. Sets the bitmap label for the button.
  119. @remarks This is the bitmap used for the unselected state, and for all
  120. other states if no other bitmaps are provided.
  121. @see SetBitmap(), GetBitmapLabel()
  122. @since 2.9.1 (available in wxBitmapButton only in previous versions)
  123. */
  124. void SetBitmapLabel(const wxBitmap& bitmap);
  125. /**
  126. Sets the bitmap for the selected (depressed) button appearance.
  127. @since 2.9.1 (available as wxBitmapButton::SetBitmapSelected() in
  128. previous versions)
  129. */
  130. void SetBitmapPressed(const wxBitmap& bitmap);
  131. /**
  132. Get the margins between the bitmap and the text of the button.
  133. @see SetBitmapMargins()
  134. @since 2.9.1
  135. */
  136. wxSize GetBitmapMargins();
  137. /**
  138. Set the margins between the bitmap and the text of the button.
  139. This method is currently only implemented under MSW. If it is not
  140. called, default margin is used around the bitmap.
  141. @see SetBitmap(), SetBitmapPosition()
  142. @since 2.9.1
  143. */
  144. //@{
  145. void SetBitmapMargins(wxCoord x, wxCoord y);
  146. void SetBitmapMargins(const wxSize& sz);
  147. //@}
  148. /**
  149. Set the position at which the bitmap is displayed.
  150. This method should only be called if the button does have an associated
  151. bitmap.
  152. @since 2.9.1
  153. @param dir
  154. Direction in which the bitmap should be positioned, one of wxLEFT,
  155. wxRIGHT, wxTOP or wxBOTTOM.
  156. */
  157. void SetBitmapPosition(wxDirection dir);
  158. };