panel.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: ribbon/panel.h
  3. // Purpose: interface of wxRibbonPage
  4. // Author: Peter Cawley
  5. // Licence: wxWindows licence
  6. ///////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @class wxRibbonPanelEvent
  9. Event used to indicate various actions relating to a wxRibbonPanel.
  10. See wxRibbonPanel for available event types.
  11. @since 2.9.4
  12. @library{wxribbon}
  13. @category{events,ribbon}
  14. @see wxRibbonPanel
  15. */
  16. class wxRibbonPanelEvent : public wxCommandEvent
  17. {
  18. public:
  19. /**
  20. Constructor.
  21. */
  22. wxRibbonPanelEvent(wxEventType command_type = wxEVT_NULL,
  23. int win_id = 0,
  24. wxRibbonPanel* panel = NULL)
  25. /**
  26. Returns the panel relating to this event.
  27. */
  28. wxRibbonPanel* GetPanel();
  29. /**
  30. Sets the page relating to this event.
  31. */
  32. void SetPanel(wxRibbonPanel* page);
  33. };
  34. /**
  35. @class wxRibbonPanel
  36. Serves as a container for a group of (ribbon) controls. A wxRibbonPage will
  37. typically have panels for children, with the controls for that page placed
  38. on the panels.
  39. A panel adds a border and label to a group of controls, and can be
  40. minimised (either automatically to conserve space, or manually by the user).
  41. Non ribbon controls can be placed on a panel using wxSizers to manage
  42. layout. Panel size is governed by the sizer's minimum calculated size and
  43. the parent wxRibbonPage's dimensions. For functional and aesthetic reasons
  44. it is recommended that ribbon and non ribbon controls are not mixed in one
  45. panel.
  46. @sa wxRibbonPage
  47. @beginStyleTable
  48. @style{wxRIBBON_PANEL_DEFAULT_STYLE}
  49. Defined as no other flags set.
  50. @style{wxRIBBON_PANEL_NO_AUTO_MINIMISE}
  51. Prevents the panel from automatically minimising to conserve screen
  52. space.
  53. @style{wxRIBBON_PANEL_EXT_BUTTON}
  54. Causes an extension button to be shown in the panel's chrome (if the
  55. bar in which it is contained has wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS
  56. set). The behaviour of this button is application controlled, but
  57. typically will show an extended drop-down menu relating to the
  58. panel.
  59. @style{wxRIBBON_PANEL_MINIMISE_BUTTON}
  60. Causes a (de)minimise button to be shown in the panel's chrome (if
  61. the bar in which it is contained has the
  62. wxRIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONS style set). This flag is
  63. typically combined with wxRIBBON_PANEL_NO_AUTO_MINIMISE to make a
  64. panel which the user always has manual control over when it
  65. minimises.
  66. @style{wxRIBBON_PANEL_STRETCH}
  67. Stretches a single panel to fit the parent page.
  68. @style{wxRIBBON_PANEL_FLEXIBLE}
  69. Allows the panel to size in both directions; currently only useful
  70. when a single wxRibbonToolBar is the child of the panel, particularly
  71. in vertical orientation where the number of rows is dependent on the
  72. amount of horizontal space available. Set the minimum and maximum
  73. toolbar rows to take full advantage of this wrapping behaviour.
  74. @endStyleTable
  75. @beginEventEmissionTable{wxRibbonPanelEvent}
  76. @event{EVT_RIBBONPANEL_EXTBUTTON_ACTIVATED(id, func)}
  77. Triggered when the user activate the panel extension button.
  78. @endEventTable
  79. @library{wxribbon}
  80. @category{ribbon}
  81. */
  82. class wxRibbonPanel : public wxRibbonControl
  83. {
  84. public:
  85. /**
  86. Default constructor.
  87. With this constructor, Create() should be called in order to create
  88. the ribbon panel.
  89. */
  90. wxRibbonPanel();
  91. /**
  92. Constructs a ribbon panel.
  93. @param parent
  94. Pointer to a parent window, which is typically a wxRibbonPage,
  95. though it can be any window.
  96. @param id
  97. Window identifier.
  98. @param label
  99. Label to be used in the wxRibbonPanel's chrome.
  100. @param minimised_icon
  101. Icon to be used in place of the panel's children when the panel
  102. is minimised.
  103. @param pos
  104. The initial position of the panel. Not relevant when the parent is
  105. a ribbon page, as the position and size of the panel will be
  106. dictated by the page.
  107. @param size
  108. The initial size of the panel. Not relevant when the parent is a
  109. ribbon page, as the position and size of the panel will be
  110. dictated by the page.
  111. @param style
  112. Style flags for the panel.
  113. */
  114. wxRibbonPanel(wxWindow* parent,
  115. wxWindowID id = wxID_ANY,
  116. const wxString& label = wxEmptyString,
  117. const wxBitmap& minimised_icon = wxNullBitmap,
  118. const wxPoint& pos = wxDefaultPosition,
  119. const wxSize& size = wxDefaultSize,
  120. long style = wxRIBBON_PANEL_DEFAULT_STYLE);
  121. /**
  122. Create a ribbon panel in two-step ribbon panel construction.
  123. Should only be called when the default constructor is used, and
  124. arguments have the same meaning as in the full constructor.
  125. */
  126. bool Create(wxWindow* parent,
  127. wxWindowID id = wxID_ANY,
  128. const wxString& label = wxEmptyString,
  129. const wxBitmap& icon = wxNullBitmap,
  130. const wxPoint& pos = wxDefaultPosition,
  131. const wxSize& size = wxDefaultSize,
  132. long style = wxRIBBON_PANEL_DEFAULT_STYLE);
  133. /**
  134. Destructor.
  135. */
  136. virtual ~wxRibbonPanel();
  137. /**
  138. Get the bitmap to be used in place of the panel children when it is
  139. minimised.
  140. */
  141. wxBitmap& GetMinimisedIcon();
  142. const wxBitmap& GetMinimisedIcon() const;
  143. /**
  144. Test if the panel has an extension button.
  145. Such button is shown in the top right corner of the panel if
  146. @c wxRIBBON_PANEL_EXT_BUTTON style is used for it.
  147. @since 2.9.4
  148. @return @true if the panel and its wxRibbonBar allow it in their styles.
  149. */
  150. virtual bool HasExtButton() const;
  151. /**
  152. Query if the panel is currently minimised.
  153. */
  154. bool IsMinimised() const;
  155. /**
  156. Query if the panel would be minimised at a given size.
  157. */
  158. bool IsMinimised(wxSize at_size) const;
  159. /**
  160. Query is the mouse is currently hovered over the panel.
  161. @return @true if the cursor is within the bounds of the panel (i.e.
  162. hovered over the panel or one of its children), @false otherwise.
  163. */
  164. bool IsHovered() const;
  165. /**
  166. Query if the mouse is currently hovered over the extension button.
  167. Extension button is only shown for panels with @c
  168. wxRIBBON_PANEL_EXT_BUTTON style.
  169. @since 2.9.4
  170. */
  171. bool IsExtButtonHovered() const;
  172. /**
  173. Query if the panel can automatically minimise itself at small sizes.
  174. */
  175. bool CanAutoMinimise() const;
  176. /**
  177. Show the panel externally expanded.
  178. When a panel is minimised, it can be shown full-size in a pop-out
  179. window, which is referred to as being (externally) expanded. Note that
  180. when a panel is expanded, there exist two panels - the original panel
  181. (which is referred to as the dummy panel) and the expanded panel. The
  182. original is termed a dummy as it sits in the ribbon bar doing nothing,
  183. while the expanded panel holds the panel children.
  184. @return @true if the panel was expanded, @false if it was not (possibly
  185. due to it not being minimised, or already being expanded).
  186. @see HideExpanded()
  187. @see GetExpandedPanel()
  188. */
  189. bool ShowExpanded();
  190. /**
  191. Hide the panel's external expansion.
  192. @return @true if the panel was un-expanded, @false if it was not
  193. (normally due to it not being expanded in the first place).
  194. @see HideExpanded()
  195. @see GetExpandedPanel()
  196. */
  197. bool HideExpanded();
  198. /**
  199. Set the art provider to be used. Normally called automatically by
  200. wxRibbonPage when the panel is created, or the art provider changed on the
  201. page.
  202. The new art provider will be propagated to the children of the panel.
  203. */
  204. void SetArtProvider(wxRibbonArtProvider* art);
  205. /**
  206. Realize all children of the panel.
  207. */
  208. bool Realize();
  209. /**
  210. Get the dummy panel of an expanded panel.
  211. Note that this should be called on an expanded panel to get the dummy
  212. associated with it - it will return NULL when called on the dummy
  213. itself.
  214. @see ShowExpanded()
  215. @see GetExpandedPanel()
  216. */
  217. wxRibbonPanel* GetExpandedDummy();
  218. /**
  219. Get the expanded panel of a dummy panel.
  220. Note that this should be called on a dummy panel to get the expanded
  221. panel associated with it - it will return NULL when called on the
  222. expanded panel itself.
  223. @see ShowExpanded()
  224. @see GetExpandedDummy()
  225. */
  226. wxRibbonPanel* GetExpandedPanel();
  227. };