The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
4.5KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-10 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #ifndef __JUCE_MENUBARCOMPONENT_JUCEHEADER__
  19. #define __JUCE_MENUBARCOMPONENT_JUCEHEADER__
  20. #include "juce_MenuBarModel.h"
  21. //==============================================================================
  22. /**
  23. A menu bar component.
  24. @see MenuBarModel
  25. */
  26. class JUCE_API MenuBarComponent : public Component,
  27. private MenuBarModelListener,
  28. private Timer
  29. {
  30. public:
  31. //==============================================================================
  32. /** Creates a menu bar.
  33. @param model the model object to use to control this bar. You can
  34. pass 0 into this if you like, and set the model later
  35. using the setModel() method
  36. */
  37. MenuBarComponent (MenuBarModel* model);
  38. /** Destructor. */
  39. ~MenuBarComponent();
  40. //==============================================================================
  41. /** Changes the model object to use to control the bar.
  42. This can be 0, in which case the bar will be empty. Don't delete the object
  43. that is passed-in while it's still being used by this MenuBar.
  44. */
  45. void setModel (MenuBarModel* newModel);
  46. /** Returns the current menu bar model being used.
  47. */
  48. MenuBarModel* getModel() const throw();
  49. //==============================================================================
  50. /** Pops up one of the menu items.
  51. This lets you manually open one of the menus - it could be triggered by a
  52. key shortcut, for example.
  53. */
  54. void showMenu (int menuIndex);
  55. //==============================================================================
  56. /** @internal */
  57. void paint (Graphics& g);
  58. /** @internal */
  59. void resized();
  60. /** @internal */
  61. void mouseEnter (const MouseEvent& e);
  62. /** @internal */
  63. void mouseExit (const MouseEvent& e);
  64. /** @internal */
  65. void mouseDown (const MouseEvent& e);
  66. /** @internal */
  67. void mouseDrag (const MouseEvent& e);
  68. /** @internal */
  69. void mouseUp (const MouseEvent& e);
  70. /** @internal */
  71. void mouseMove (const MouseEvent& e);
  72. /** @internal */
  73. void handleCommandMessage (int commandId);
  74. /** @internal */
  75. bool keyPressed (const KeyPress& key);
  76. /** @internal */
  77. void menuBarItemsChanged (MenuBarModel* menuBarModel);
  78. /** @internal */
  79. void menuCommandInvoked (MenuBarModel* menuBarModel,
  80. const ApplicationCommandTarget::InvocationInfo& info);
  81. //==============================================================================
  82. juce_UseDebuggingNewOperator
  83. private:
  84. class AsyncCallback;
  85. friend class AsyncCallback;
  86. MenuBarModel* model;
  87. StringArray menuNames;
  88. Array <int> xPositions;
  89. int itemUnderMouse, currentPopupIndex, topLevelIndexClicked;
  90. int lastMouseX, lastMouseY;
  91. int getItemAt (int x, int y);
  92. void setItemUnderMouse (int index);
  93. void setOpenItem (int index);
  94. void updateItemUnderMouse (int x, int y);
  95. void timerCallback();
  96. void repaintMenuItem (int index);
  97. void menuDismissed (int topLevelIndex, int itemId);
  98. MenuBarComponent (const MenuBarComponent&);
  99. MenuBarComponent& operator= (const MenuBarComponent&);
  100. };
  101. #endif // __JUCE_MENUBARCOMPONENT_JUCEHEADER__