juce_PopupMenu.h 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCE_POPUPMENU_H_INCLUDED
  18. #define JUCE_POPUPMENU_H_INCLUDED
  19. //==============================================================================
  20. /** Creates and displays a popup-menu.
  21. To show a popup-menu, you create one of these, add some items to it, then
  22. call its show() method, which returns the id of the item the user selects.
  23. E.g. @code
  24. void MyWidget::mouseDown (const MouseEvent& e)
  25. {
  26. PopupMenu m;
  27. m.addItem (1, "item 1");
  28. m.addItem (2, "item 2");
  29. const int result = m.show();
  30. if (result == 0)
  31. {
  32. // user dismissed the menu without picking anything
  33. }
  34. else if (result == 1)
  35. {
  36. // user picked item 1
  37. }
  38. else if (result == 2)
  39. {
  40. // user picked item 2
  41. }
  42. }
  43. @endcode
  44. Submenus are easy too: @code
  45. void MyWidget::mouseDown (const MouseEvent& e)
  46. {
  47. PopupMenu subMenu;
  48. subMenu.addItem (1, "item 1");
  49. subMenu.addItem (2, "item 2");
  50. PopupMenu mainMenu;
  51. mainMenu.addItem (3, "item 3");
  52. mainMenu.addSubMenu ("other choices", subMenu);
  53. const int result = m.show();
  54. ...etc
  55. }
  56. @endcode
  57. */
  58. class JUCE_API PopupMenu
  59. {
  60. private:
  61. class Window;
  62. public:
  63. class CustomComponent;
  64. //==============================================================================
  65. /** Creates an empty popup menu. */
  66. PopupMenu();
  67. /** Creates a copy of another menu. */
  68. PopupMenu (const PopupMenu& other);
  69. /** Destructor. */
  70. ~PopupMenu();
  71. /** Copies this menu from another one. */
  72. PopupMenu& operator= (const PopupMenu& other);
  73. #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
  74. PopupMenu (PopupMenu&& other) noexcept;
  75. PopupMenu& operator= (PopupMenu&& other) noexcept;
  76. #endif
  77. //==============================================================================
  78. /** Resets the menu, removing all its items. */
  79. void clear();
  80. /** Describes a popup menu item. */
  81. struct JUCE_API Item
  82. {
  83. /** Creates a null item.
  84. You'll need to set some fields after creating an Item before you
  85. can add it to a PopupMenu
  86. */
  87. Item() noexcept;
  88. /** Creates a copy of an item. */
  89. Item (const Item&);
  90. /** Creates a copy of an item. */
  91. Item& operator= (const Item&);
  92. /** The menu item's name. */
  93. String text;
  94. /** The menu item's ID. This can not be 0 if you want the item to be triggerable! */
  95. int itemID;
  96. /** A sub-menu, or nullptr if there isn't one. */
  97. ScopedPointer<PopupMenu> subMenu;
  98. /** A drawable to use as an icon, or nullptr if there isn't one. */
  99. ScopedPointer<Drawable> image;
  100. /** A custom component for the item to display, or nullptr if there isn't one. */
  101. ReferenceCountedObjectPtr<CustomComponent> customComponent;
  102. /** A command manager to use to automatically invoke the command, or nullptr if none is specified. */
  103. ApplicationCommandManager* commandManager;
  104. /** An optional string describing the shortcut key for this item.
  105. This is only used for displaying at the right-hand edge of a menu item - the
  106. menu won't attempt to actually catch or process the key. If you supply a
  107. commandManager parameter then the menu will attempt to fill-in this field
  108. automatically.
  109. */
  110. String shortcutKeyDescription;
  111. /** A colour to use to draw the menu text.
  112. By default this is transparent black, which means that the LookAndFeel should choose the colour.
  113. */
  114. Colour colour;
  115. /** True if this menu item is enabled. */
  116. bool isEnabled;
  117. /** True if this menu item should have a tick mark next to it. */
  118. bool isTicked;
  119. /** True if this menu item is a separator line. */
  120. bool isSeparator;
  121. /** True if this menu item is a section header. */
  122. bool isSectionHeader;
  123. };
  124. /** Adds an item to the menu.
  125. You can call this method for full control over the item that is added, or use the other
  126. addItem helper methods if you want to pass arguments rather than creating an Item object.
  127. */
  128. void addItem (const Item& newItem);
  129. /** Appends a new text item for this menu to show.
  130. @param itemResultID the number that will be returned from the show() method
  131. if the user picks this item. The value should never be
  132. zero, because that's used to indicate that the user didn't
  133. select anything.
  134. @param itemText the text to show.
  135. @param isEnabled if false, the item will be shown 'greyed-out' and can't be picked
  136. @param isTicked if true, the item will be shown with a tick next to it
  137. @see addSeparator, addColouredItem, addCustomItem, addSubMenu
  138. */
  139. void addItem (int itemResultID,
  140. const String& itemText,
  141. bool isEnabled = true,
  142. bool isTicked = false);
  143. /** Appends a new item with an icon.
  144. @param itemResultID the number that will be returned from the show() method
  145. if the user picks this item. The value should never be
  146. zero, because that's used to indicate that the user didn't
  147. select anything.
  148. @param itemText the text to show.
  149. @param isEnabled if false, the item will be shown 'greyed-out' and can't be picked
  150. @param isTicked if true, the item will be shown with a tick next to it
  151. @param iconToUse if this is a valid image, it will be displayed to the left of the item.
  152. @see addSeparator, addColouredItem, addCustomItem, addSubMenu
  153. */
  154. void addItem (int itemResultID,
  155. const String& itemText,
  156. bool isEnabled,
  157. bool isTicked,
  158. const Image& iconToUse);
  159. /** Appends a new item with an icon.
  160. @param itemResultID the number that will be returned from the show() method
  161. if the user picks this item. The value should never be
  162. zero, because that's used to indicate that the user didn't
  163. select anything.
  164. @param itemText the text to show.
  165. @param isEnabled if false, the item will be shown 'greyed-out' and can't be picked
  166. @param isTicked if true, the item will be shown with a tick next to it
  167. @param iconToUse a Drawable object to use as the icon to the left of the item.
  168. The menu will take ownership of this drawable object and will
  169. delete it later when no longer needed
  170. @see addSeparator, addColouredItem, addCustomItem, addSubMenu
  171. */
  172. void addItem (int itemResultID,
  173. const String& itemText,
  174. bool isEnabled,
  175. bool isTicked,
  176. Drawable* iconToUse);
  177. /** Adds an item that represents one of the commands in a command manager object.
  178. @param commandManager the manager to use to trigger the command and get information
  179. about it
  180. @param commandID the ID of the command
  181. @param displayName if this is non-empty, then this string will be used instead of
  182. the command's registered name
  183. @param iconToUse an optional Drawable object to use as the icon to the left of the item.
  184. The menu will take ownership of this drawable object and will
  185. delete it later when no longer needed
  186. */
  187. void addCommandItem (ApplicationCommandManager* commandManager,
  188. CommandID commandID,
  189. const String& displayName = String::empty,
  190. Drawable* iconToUse = nullptr);
  191. /** Appends a text item with a special colour.
  192. This is the same as addItem(), but specifies a colour to use for the
  193. text, which will override the default colours that are used by the
  194. current look-and-feel. See addItem() for a description of the parameters.
  195. */
  196. void addColouredItem (int itemResultID,
  197. const String& itemText,
  198. Colour itemTextColour,
  199. bool isEnabled = true,
  200. bool isTicked = false,
  201. const Image& iconToUse = Image());
  202. /** Appends a text item with a special colour.
  203. This is the same as addItem(), but specifies a colour to use for the
  204. text, which will override the default colours that are used by the
  205. current look-and-feel. See addItem() for a description of the parameters.
  206. */
  207. void addColouredItem (int itemResultID,
  208. const String& itemText,
  209. Colour itemTextColour,
  210. bool isEnabled,
  211. bool isTicked,
  212. Drawable* iconToUse);
  213. /** Appends a custom menu item.
  214. This will add a user-defined component to use as a menu item. The component
  215. passed in will be deleted by this menu when it's no longer needed.
  216. @see CustomComponent
  217. */
  218. void addCustomItem (int itemResultID,
  219. CustomComponent* customComponent,
  220. const PopupMenu* optionalSubMenu = nullptr);
  221. /** Appends a custom menu item that can't be used to trigger a result.
  222. This will add a user-defined component to use as a menu item.
  223. It's the caller's responsibility to delete the component that is passed-in
  224. when it's no longer needed after the menu has been hidden.
  225. If triggerMenuItemAutomaticallyWhenClicked is true, the menu itself will handle
  226. detection of a mouse-click on your component, and use that to trigger the
  227. menu ID specified in itemResultID. If this is false, the menu item can't
  228. be triggered, so itemResultID is not used.
  229. */
  230. void addCustomItem (int itemResultID,
  231. Component* customComponent,
  232. int idealWidth,
  233. int idealHeight,
  234. bool triggerMenuItemAutomaticallyWhenClicked,
  235. const PopupMenu* optionalSubMenu = nullptr);
  236. /** Appends a sub-menu.
  237. If the menu that's passed in is empty, it will appear as an inactive item.
  238. If the itemResultID argument is non-zero, then the sub-menu item itself can be
  239. clicked to trigger it as a command.
  240. */
  241. void addSubMenu (const String& subMenuName,
  242. const PopupMenu& subMenu,
  243. bool isEnabled = true);
  244. /** Appends a sub-menu with an icon.
  245. If the menu that's passed in is empty, it will appear as an inactive item.
  246. If the itemResultID argument is non-zero, then the sub-menu item itself can be
  247. clicked to trigger it as a command.
  248. */
  249. void addSubMenu (const String& subMenuName,
  250. const PopupMenu& subMenu,
  251. bool isEnabled,
  252. const Image& iconToUse,
  253. bool isTicked = false,
  254. int itemResultID = 0);
  255. /** Appends a sub-menu with an icon.
  256. If the menu that's passed in is empty, it will appear as an inactive item.
  257. If the itemResultID argument is non-zero, then the sub-menu item itself can be
  258. clicked to trigger it as a command.
  259. The iconToUse parameter is a Drawable object to use as the icon to the left of
  260. the item. The menu will take ownership of this drawable object and will delete it
  261. later when no longer needed
  262. */
  263. void addSubMenu (const String& subMenuName,
  264. const PopupMenu& subMenu,
  265. bool isEnabled,
  266. Drawable* iconToUse,
  267. bool isTicked = false,
  268. int itemResultID = 0);
  269. /** Appends a separator to the menu, to help break it up into sections.
  270. The menu class is smart enough not to display separators at the top or bottom
  271. of the menu, and it will replace mutliple adjacent separators with a single
  272. one, so your code can be quite free and easy about adding these, and it'll
  273. always look ok.
  274. */
  275. void addSeparator();
  276. /** Adds a non-clickable text item to the menu.
  277. This is a bold-font items which can be used as a header to separate the items
  278. into named groups.
  279. */
  280. void addSectionHeader (const String& title);
  281. /** Returns the number of items that the menu currently contains.
  282. (This doesn't count separators).
  283. */
  284. int getNumItems() const noexcept;
  285. /** Returns true if the menu contains a command item that triggers the given command. */
  286. bool containsCommandItem (int commandID) const;
  287. /** Returns true if the menu contains any items that can be used. */
  288. bool containsAnyActiveItems() const noexcept;
  289. //==============================================================================
  290. /** Class used to create a set of options to pass to the show() method.
  291. You can chain together a series of calls to this class's methods to create
  292. a set of whatever options you want to specify.
  293. E.g. @code
  294. PopupMenu menu;
  295. ...
  296. menu.showMenu (PopupMenu::Options().withMinimumWidth (100)
  297. .withMaximumNumColumns (3)
  298. .withTargetComponent (myComp));
  299. @endcode
  300. */
  301. class JUCE_API Options
  302. {
  303. public:
  304. Options();
  305. Options withTargetComponent (Component* targetComponent) const noexcept;
  306. Options withTargetScreenArea (const Rectangle<int>& targetArea) const noexcept;
  307. Options withMinimumWidth (int minWidth) const noexcept;
  308. Options withMaximumNumColumns (int maxNumColumns) const noexcept;
  309. Options withStandardItemHeight (int standardHeight) const noexcept;
  310. Options withItemThatMustBeVisible (int idOfItemToBeVisible) const noexcept;
  311. private:
  312. friend class PopupMenu;
  313. friend class PopupMenu::Window;
  314. Rectangle<int> targetArea;
  315. Component* targetComponent;
  316. int visibleItemID, minWidth, maxColumns, standardHeight;
  317. };
  318. //==============================================================================
  319. #if JUCE_MODAL_LOOPS_PERMITTED
  320. /** Displays the menu and waits for the user to pick something.
  321. This will display the menu modally, and return the ID of the item that the
  322. user picks. If they click somewhere off the menu to get rid of it without
  323. choosing anything, this will return 0.
  324. The current location of the mouse will be used as the position to show the
  325. menu - to explicitly set the menu's position, use showAt() instead. Depending
  326. on where this point is on the screen, the menu will appear above, below or
  327. to the side of the point.
  328. @param itemIDThatMustBeVisible if you set this to the ID of one of the menu items,
  329. then when the menu first appears, it will make sure
  330. that this item is visible. So if the menu has too many
  331. items to fit on the screen, it will be scrolled to a
  332. position where this item is visible.
  333. @param minimumWidth a minimum width for the menu, in pixels. It may be wider
  334. than this if some items are too long to fit.
  335. @param maximumNumColumns if there are too many items to fit on-screen in a single
  336. vertical column, the menu may be laid out as a series of
  337. columns - this is the maximum number allowed. To use the
  338. default value for this (probably about 7), you can pass
  339. in zero.
  340. @param standardItemHeight if this is non-zero, it will be used as the standard
  341. height for menu items (apart from custom items)
  342. @param callback if this is non-zero, the menu will be launched asynchronously,
  343. returning immediately, and the callback will receive a
  344. call when the menu is either dismissed or has an item
  345. selected. This object will be owned and deleted by the
  346. system, so make sure that it works safely and that any
  347. pointers that it uses are safely within scope.
  348. @see showAt
  349. */
  350. int show (int itemIDThatMustBeVisible = 0,
  351. int minimumWidth = 0,
  352. int maximumNumColumns = 0,
  353. int standardItemHeight = 0,
  354. ModalComponentManager::Callback* callback = nullptr);
  355. /** Displays the menu at a specific location.
  356. This is the same as show(), but uses a specific location (in global screen
  357. coordinates) rather than the current mouse position.
  358. The screenAreaToAttachTo parameter indicates a screen area to which the menu
  359. will be adjacent. Depending on where this is, the menu will decide which edge to
  360. attach itself to, in order to fit itself fully on-screen. If you just want to
  361. trigger a menu at a specific point, you can pass in a rectangle of size (0, 0)
  362. with the position that you want.
  363. @see show()
  364. */
  365. int showAt (const Rectangle<int>& screenAreaToAttachTo,
  366. int itemIDThatMustBeVisible = 0,
  367. int minimumWidth = 0,
  368. int maximumNumColumns = 0,
  369. int standardItemHeight = 0,
  370. ModalComponentManager::Callback* callback = nullptr);
  371. /** Displays the menu as if it's attached to a component such as a button.
  372. This is similar to showAt(), but will position it next to the given component, e.g.
  373. so that the menu's edge is aligned with that of the component. This is intended for
  374. things like buttons that trigger a pop-up menu.
  375. */
  376. int showAt (Component* componentToAttachTo,
  377. int itemIDThatMustBeVisible = 0,
  378. int minimumWidth = 0,
  379. int maximumNumColumns = 0,
  380. int standardItemHeight = 0,
  381. ModalComponentManager::Callback* callback = nullptr);
  382. /** Displays and runs the menu modally, with a set of options.
  383. */
  384. int showMenu (const Options& options);
  385. #endif
  386. /** Runs the menu asynchronously, with a user-provided callback that will receive the result. */
  387. void showMenuAsync (const Options& options,
  388. ModalComponentManager::Callback* callback);
  389. //==============================================================================
  390. /** Closes any menus that are currently open.
  391. This might be useful if you have a situation where your window is being closed
  392. by some means other than a user action, and you'd like to make sure that menus
  393. aren't left hanging around.
  394. */
  395. static bool JUCE_CALLTYPE dismissAllActiveMenus();
  396. //==============================================================================
  397. /** Specifies a look-and-feel for the menu and any sub-menus that it has.
  398. This can be called before show() if you need a customised menu. Be careful
  399. not to delete the LookAndFeel object before the menu has been deleted.
  400. */
  401. void setLookAndFeel (LookAndFeel* newLookAndFeel);
  402. //==============================================================================
  403. /** A set of colour IDs to use to change the colour of various aspects of the menu.
  404. These constants can be used either via the LookAndFeel::setColour()
  405. method for the look and feel that is set for this menu with setLookAndFeel()
  406. @see setLookAndFeel, LookAndFeel::setColour, LookAndFeel::findColour
  407. */
  408. enum ColourIds
  409. {
  410. backgroundColourId = 0x1000700, /**< The colour to fill the menu's background with. */
  411. textColourId = 0x1000600, /**< The colour for normal menu item text, (unless the
  412. colour is specified when the item is added). */
  413. headerTextColourId = 0x1000601, /**< The colour for section header item text (see the
  414. addSectionHeader() method). */
  415. highlightedBackgroundColourId = 0x1000900, /**< The colour to fill the background of the currently
  416. highlighted menu item. */
  417. highlightedTextColourId = 0x1000800, /**< The colour to use for the text of the currently
  418. highlighted item. */
  419. };
  420. //==============================================================================
  421. /**
  422. Allows you to iterate through the items in a pop-up menu, and examine
  423. their properties.
  424. To use this, just create one and repeatedly call its next() method. When this
  425. returns true, all the member variables of the iterator are filled-out with
  426. information describing the menu item. When it returns false, the end of the
  427. list has been reached.
  428. */
  429. class JUCE_API MenuItemIterator
  430. {
  431. public:
  432. //==============================================================================
  433. /** Creates an iterator that will scan through the items in the specified
  434. menu.
  435. Be careful not to add any items to a menu while it is being iterated,
  436. or things could get out of step.
  437. */
  438. MenuItemIterator (const PopupMenu& menu);
  439. /** Destructor. */
  440. ~MenuItemIterator();
  441. /** Returns true if there is another item, and sets up all this object's
  442. member variables to reflect that item's properties.
  443. */
  444. bool next();
  445. /** Returns a reference to the description of the current item.
  446. It is only valid to call this after next() has returned true!
  447. */
  448. const Item& getItem() const noexcept;
  449. private:
  450. //==============================================================================
  451. const PopupMenu& menu;
  452. int index;
  453. MenuItemIterator& operator= (const MenuItemIterator&);
  454. JUCE_LEAK_DETECTOR (MenuItemIterator)
  455. };
  456. //==============================================================================
  457. /** A user-defined component that can be used as an item in a popup menu.
  458. @see PopupMenu::addCustomItem
  459. */
  460. class JUCE_API CustomComponent : public Component,
  461. public SingleThreadedReferenceCountedObject
  462. {
  463. public:
  464. /** Creates a custom item.
  465. If isTriggeredAutomatically is true, then the menu will automatically detect
  466. a mouse-click on this component and use that to invoke the menu item. If it's
  467. false, then it's up to your class to manually trigger the item when it wants to.
  468. */
  469. CustomComponent (bool isTriggeredAutomatically = true);
  470. /** Destructor. */
  471. ~CustomComponent();
  472. /** Returns a rectangle with the size that this component would like to have.
  473. Note that the size which this method returns isn't necessarily the one that
  474. the menu will give it, as the items will be stretched to have a uniform width.
  475. */
  476. virtual void getIdealSize (int& idealWidth, int& idealHeight) = 0;
  477. /** Dismisses the menu, indicating that this item has been chosen.
  478. This will cause the menu to exit from its modal state, returning
  479. this item's id as the result.
  480. */
  481. void triggerMenuItem();
  482. /** Returns true if this item should be highlighted because the mouse is over it.
  483. You can call this method in your paint() method to find out whether
  484. to draw a highlight.
  485. */
  486. bool isItemHighlighted() const noexcept { return isHighlighted; }
  487. /** @internal */
  488. bool isTriggeredAutomatically() const noexcept { return triggeredAutomatically; }
  489. /** @internal */
  490. void setHighlighted (bool shouldBeHighlighted);
  491. private:
  492. //==============================================================================
  493. bool isHighlighted, triggeredAutomatically;
  494. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CustomComponent)
  495. };
  496. //==============================================================================
  497. /** This abstract base class is implemented by LookAndFeel classes to provide
  498. menu drawing functionality.
  499. */
  500. struct JUCE_API LookAndFeelMethods
  501. {
  502. virtual ~LookAndFeelMethods() {}
  503. /** Fills the background of a popup menu component. */
  504. virtual void drawPopupMenuBackground (Graphics&, int width, int height) = 0;
  505. /** Draws one of the items in a popup menu. */
  506. virtual void drawPopupMenuItem (Graphics&, const Rectangle<int>& area,
  507. bool isSeparator, bool isActive, bool isHighlighted,
  508. bool isTicked, bool hasSubMenu,
  509. const String& text,
  510. const String& shortcutKeyText,
  511. const Drawable* icon,
  512. const Colour* textColour) = 0;
  513. virtual void drawPopupMenuSectionHeader (Graphics&, const Rectangle<int>& area,
  514. const String& sectionName) = 0;
  515. /** Returns the size and style of font to use in popup menus. */
  516. virtual Font getPopupMenuFont() = 0;
  517. virtual void drawPopupMenuUpDownArrow (Graphics&,
  518. int width, int height,
  519. bool isScrollUpArrow) = 0;
  520. /** Finds the best size for an item in a popup menu. */
  521. virtual void getIdealPopupMenuItemSize (const String& text,
  522. bool isSeparator,
  523. int standardMenuItemHeight,
  524. int& idealWidth,
  525. int& idealHeight) = 0;
  526. virtual int getMenuWindowFlags() = 0;
  527. virtual void drawMenuBarBackground (Graphics&, int width, int height,
  528. bool isMouseOverBar,
  529. MenuBarComponent&) = 0;
  530. virtual int getDefaultMenuBarHeight() = 0;
  531. virtual int getMenuBarItemWidth (MenuBarComponent&, int itemIndex, const String& itemText) = 0;
  532. virtual Font getMenuBarFont (MenuBarComponent&, int itemIndex, const String& itemText) = 0;
  533. virtual void drawMenuBarItem (Graphics&, int width, int height,
  534. int itemIndex,
  535. const String& itemText,
  536. bool isMouseOverItem,
  537. bool isMenuOpen,
  538. bool isMouseOverBar,
  539. MenuBarComponent&) = 0;
  540. };
  541. private:
  542. //==============================================================================
  543. JUCE_PUBLIC_IN_DLL_BUILD (struct HelperClasses)
  544. friend struct HelperClasses;
  545. friend class MenuBarComponent;
  546. OwnedArray<Item> items;
  547. WeakReference<LookAndFeel> lookAndFeel;
  548. Component* createWindow (const Options&, ApplicationCommandManager**) const;
  549. int showWithOptionalCallback (const Options&, ModalComponentManager::Callback*, bool);
  550. #if JUCE_CATCH_DEPRECATED_CODE_MISUSE
  551. // These methods have new implementations now - see its new definition
  552. int drawPopupMenuItem (Graphics&, int, int, bool, bool, bool, bool, bool, const String&, const String&, Image*, const Colour*) { return 0; }
  553. #endif
  554. JUCE_LEAK_DETECTOR (PopupMenu)
  555. };
  556. #endif // JUCE_POPUPMENU_H_INCLUDED