control.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: ribbon/control.h
  3. // Purpose: interface of wxRibbonControl
  4. // Author: Peter Cawley
  5. // Licence: wxWindows licence
  6. ///////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @class wxRibbonControl
  9. wxRibbonControl serves as a base class for all controls which share the
  10. ribbon characteristics of having a ribbon art provider, and (optionally)
  11. non-continuous resizing. Despite what the name may imply, it is not the
  12. top-level control for creating a ribbon interface - that is wxRibbonBar.
  13. Ribbon controls often have a region which is "transparent", and shows the
  14. contents of the ribbon page or panel behind it. If implementing a new
  15. ribbon control, then it may be useful to realise that this effect is done
  16. by the art provider when painting the background of the control, and hence
  17. in the paint handler for the new control, you should call a draw background
  18. method on the art provider (wxRibbonArtProvider::DrawButtonBarBackground()
  19. and wxRibbonArtProvider::DrawToolBarBackground() typically just redraw what
  20. is behind the rectangle being painted) if you want transparent regions.
  21. @library{wxribbon}
  22. @category{ribbon}
  23. */
  24. class wxRibbonControl : public wxControl
  25. {
  26. public:
  27. /**
  28. Constructor.
  29. */
  30. wxRibbonControl();
  31. /**
  32. Constructor.
  33. If @a parent is a wxRibbonControl with a non-NULL art provider, then
  34. the art provider of new control is set to that of @a parent.
  35. */
  36. wxRibbonControl(wxWindow *parent, wxWindowID id,
  37. const wxPoint& pos = wxDefaultPosition,
  38. const wxSize& size = wxDefaultSize, long style = 0,
  39. const wxValidator& validator = wxDefaultValidator,
  40. const wxString& name = wxControlNameStr);
  41. /**
  42. Set the art provider to be used. In many cases, setting the art provider
  43. will also set the art provider on all child windows which extend
  44. wxRibbonControl.
  45. In most cases, controls will not take ownership of the given pointer,
  46. with the notable exception being wxRibbonBar::SetArtProvider().
  47. */
  48. virtual void SetArtProvider(wxRibbonArtProvider* art);
  49. /**
  50. Get the art provider to be used. Note that until an art provider has
  51. been set in some way, this function may return NULL.
  52. */
  53. wxRibbonArtProvider* GetArtProvider() const;
  54. /**
  55. @return @true if this window can take any size (greater than its minimum
  56. size), @false if it can only take certain sizes.
  57. @see GetNextSmallerSize()
  58. @see GetNextLargerSize()
  59. */
  60. virtual bool IsSizingContinuous() const;
  61. /**
  62. If sizing is not continuous, then return a suitable size for the control
  63. which is smaller than the current size.
  64. @param direction
  65. The direction(s) in which the size should reduce.
  66. @return
  67. The current size if there is no smaller size, otherwise a suitable
  68. size which is smaller in the given direction(s), and the same as the
  69. current size in the other direction (if any).
  70. @see IsSizingContinuous()
  71. */
  72. wxSize GetNextSmallerSize(wxOrientation direction) const;
  73. /**
  74. If sizing is not continuous, then return a suitable size for the control
  75. which is smaller than the given size.
  76. @param direction
  77. The direction(s) in which the size should reduce.
  78. @param relative_to
  79. The size for which a smaller size should be found.
  80. @return
  81. @a relative_to if there is no smaller size, otherwise a suitable
  82. size which is smaller in the given direction(s), and the same as
  83. @a relative_to in the other direction (if any).
  84. @see IsSizingContinuous()
  85. @see DoGetNextSmallerSize()
  86. */
  87. wxSize GetNextSmallerSize(wxOrientation direction, wxSize relative_to) const;
  88. /**
  89. If sizing is not continuous, then return a suitable size for the control
  90. which is larger than the current size.
  91. @param direction
  92. The direction(s) in which the size should increase.
  93. @return
  94. The current size if there is no larger size, otherwise a suitable
  95. size which is larger in the given direction(s), and the same as the
  96. current size in the other direction (if any).
  97. @see IsSizingContinuous()
  98. */
  99. wxSize GetNextLargerSize(wxOrientation direction) const;
  100. /**
  101. If sizing is not continuous, then return a suitable size for the control
  102. which is larger than the given size.
  103. @param direction
  104. The direction(s) in which the size should increase.
  105. @param relative_to
  106. The size for which a larger size should be found.
  107. @return
  108. @a relative_to if there is no larger size, otherwise a suitable
  109. size which is larger in the given direction(s), and the same as
  110. @a relative_to in the other direction (if any).
  111. @see IsSizingContinuous()
  112. @see DoGetNextLargerSize()
  113. */
  114. wxSize GetNextLargerSize(wxOrientation direction, wxSize relative_to) const;
  115. /**
  116. Perform initial size and layout calculations after children have been
  117. added, and/or realize children.
  118. */
  119. virtual bool Realize();
  120. /**
  121. Alias for Realize().
  122. */
  123. bool Realise();
  124. /**
  125. Get the first ancestor which is a wxRibbonBar (or derived) or NULL
  126. if not having such parent.
  127. @since 2.9.4
  128. */
  129. virtual wxRibbonBar* GetAncestorRibbonBar()const;
  130. /**
  131. Finds the best width and height given the parent's width and height.
  132. Used to implement the wxRIBBON_PANEL_FLEXIBLE panel style.
  133. */
  134. virtual wxSize GetBestSizeForParentSize(const wxSize& parentSize) const;
  135. protected:
  136. /**
  137. Implementation of GetNextSmallerSize().
  138. Controls which have non-continuous sizing must override this virtual
  139. function rather than GetNextSmallerSize().
  140. */
  141. virtual wxSize DoGetNextSmallerSize(wxOrientation direction,
  142. wxSize relative_to) const;
  143. /**
  144. Implementation of GetNextLargerSize().
  145. Controls which have non-continuous sizing must override this virtual
  146. function rather than GetNextLargerSize().
  147. */
  148. virtual wxSize DoGetNextLargerSize(wxOrientation direction,
  149. wxSize relative_to) const;
  150. };