page.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: ribbon/page.h
  3. // Purpose: interface of wxRibbonPage
  4. // Author: Peter Cawley
  5. // Licence: wxWindows licence
  6. ///////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @class wxRibbonPage
  9. Container for related ribbon panels, and a tab within a ribbon bar.
  10. @see wxRibbonBar
  11. @see wxRibbonPanel
  12. @library{wxribbon}
  13. @category{ribbon}
  14. */
  15. class wxRibbonPage : public wxRibbonControl
  16. {
  17. public:
  18. /**
  19. Default constructor.
  20. With this constructor, Create() should be called in order to create
  21. the ribbon page.
  22. */
  23. wxRibbonPage();
  24. /**
  25. Constructs a ribbon page, which must be a child of a ribbon bar.
  26. @param parent
  27. Pointer to a parent wxRibbonBar (unlike most controls, a wxRibbonPage
  28. can only have wxRibbonBar as a parent).
  29. @param id
  30. Window identifier.
  31. @param label
  32. Label to be used in the wxRibbonBar's tab list for this page (if the
  33. ribbon bar is set to display labels).
  34. @param icon
  35. Icon to be used in the wxRibbonBar's tab list for this page (if the
  36. ribbon bar is set to display icons).
  37. @param style
  38. Currently unused, should be zero.
  39. */
  40. wxRibbonPage(wxRibbonBar* parent,
  41. wxWindowID id = wxID_ANY,
  42. const wxString& label = wxEmptyString,
  43. const wxBitmap& icon = wxNullBitmap,
  44. long style = 0);
  45. /**
  46. Destructor.
  47. */
  48. virtual ~wxRibbonPage();
  49. /**
  50. Create a ribbon page in two-step ribbon page construction.
  51. Should only be called when the default constructor is used, and
  52. arguments have the same meaning as in the full constructor.
  53. */
  54. bool Create(wxRibbonBar* parent,
  55. wxWindowID id = wxID_ANY,
  56. const wxString& label = wxEmptyString,
  57. const wxBitmap& icon = wxNullBitmap,
  58. long style = 0);
  59. /**
  60. Set the art provider to be used. Normally called automatically by
  61. wxRibbonBar when the page is created, or the art provider changed on the
  62. bar.
  63. The new art provider will be propagated to the children of the page.
  64. */
  65. void SetArtProvider(wxRibbonArtProvider* art);
  66. /**
  67. Get the icon used for the page in the ribbon bar tab area (only
  68. displayed if the ribbon bar is actually showing icons).
  69. */
  70. wxBitmap& GetIcon();
  71. /**
  72. Set the size of the page and the external scroll buttons (if any).
  73. When a page is too small to display all of its children, scroll buttons
  74. will appear (and if the page is sized up enough, they will disappear again).
  75. Slightly counter-intuitively, these buttons are created as siblings of the
  76. page rather than children of the page (to achieve correct cropping and
  77. paint ordering of the children and the buttons). When there are no scroll
  78. buttons, this function behaves the same as SetSize(), however when there
  79. are scroll buttons, it positions them at the edges of the given area, and
  80. then calls SetSize() with the remaining area.
  81. This is provided as a separate function to SetSize() rather than within
  82. the implementation of SetSize(), as interacting algorithms may not expect
  83. SetSize() to also set the size of siblings.
  84. */
  85. void SetSizeWithScrollButtonAdjustment(int x, int y, int width, int height);
  86. /**
  87. Expand a rectangle of the page to include external scroll buttons (if
  88. any). When no scroll buttons are shown, has no effect.
  89. @param[in,out] rect
  90. The rectangle to adjust. The width and height will not be reduced,
  91. and the x and y will not be increased.
  92. */
  93. void AdjustRectToIncludeScrollButtons(wxRect* rect) const;
  94. /**
  95. Dismiss the current externally expanded panel, if there is one.
  96. When a ribbon panel automatically minimises, it can be externally
  97. expanded into a floating window. When the user clicks a button in such
  98. a panel, the panel should generally re-minimise. Event handlers for
  99. buttons on ribbon panels should call this method to achieve this
  100. behaviour.
  101. @return @true if a panel was minimised, @false otherwise.
  102. */
  103. bool DismissExpandedPanel();
  104. /**
  105. Perform a full re-layout of all panels on the page.
  106. Should be called after panels are added to the page, or the sizing
  107. behaviour of a panel on the page changes (i.e. due to children being
  108. added to it). Usually called automatically when wxRibbonBar::Realize()
  109. is called.
  110. Will invoke wxRibbonPanel::Realize() for all child panels.
  111. */
  112. virtual bool Realize();
  113. /**
  114. Scroll the page by some amount up / down / left / right.
  115. When the page's children are too big to fit in the onscreen area given to
  116. the page, scroll buttons will appear, and the page can be programmatically
  117. scrolled. Positive values of @a lines will scroll right or down, while
  118. negative values will scroll up or left (depending on the direction in which
  119. panels are stacked). A line is equivalent to a constant number of pixels.
  120. @return @true if the page scrolled at least one pixel in the given
  121. direction, @false if it did not scroll.
  122. @see GetMajorAxis()
  123. @see ScrollPixels()
  124. @see ScrollSections()
  125. */
  126. virtual bool ScrollLines(int lines);
  127. /**
  128. Scroll the page by a set number of pixels up / down / left / right.
  129. When the page's children are too big to fit in the onscreen area given to
  130. the page, scroll buttons will appear, and the page can be programmatically
  131. scrolled. Positive values of @a lines will scroll right or down, while
  132. negative values will scroll up or left (depending on the direction in which
  133. panels are stacked).
  134. @return @true if the page scrolled at least one pixel in the given
  135. direction, @false if it did not scroll.
  136. @see GetMajorAxis()
  137. @see ScrollLines()
  138. @see ScrollSections()
  139. */
  140. bool ScrollPixels(int pixels);
  141. /**
  142. Scroll the page by an entire child section.
  143. The @a sections parameter value should be 1 or -1. This will scroll
  144. enough to uncover a partially visible child section or totally uncover
  145. the next child section that may not be visible at all.
  146. @return @true if the page scrolled at least one pixel in the given
  147. direction, @false if it did not scroll.
  148. @see ScrollPixels()
  149. @see ScrollSections()
  150. @since 2.9.5
  151. */
  152. bool ScrollSections(int sections);
  153. /**
  154. Get the direction in which ribbon panels are stacked within the page.
  155. This is controlled by the style of the containing wxRibbonBar, meaning
  156. that all pages within a bar will have the same major axis. As well as
  157. being the direction in which panels are stacked, it is also the axis in
  158. which scrolling will occur (when required).
  159. @return wxHORIZONTAL or wxVERTICAL (never wxBOTH).
  160. */
  161. wxOrientation GetMajorAxis() const;
  162. };