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