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_CALLOUTBOX_JUCEHEADER__
27 #define __JUCE_CALLOUTBOX_JUCEHEADER__
29 #include "../juce_Component.h"
32 //==============================================================================
34 A box with a small arrow that can be used as a temporary pop-up window to show
35 extra controls when a button or other component is clicked.
37 Using one of these is similar to having a popup menu attached to a button or
38 other component - but it looks fancier, and has an arrow that can indicate the
39 object that it applies to.
41 Normally, you'd create one of these on the stack and run it modally, e.g.
44 void mouseUp (const MouseEvent& e)
46 MyContentComponent content;
47 content.setSize (300, 300);
49 CallOutBox callOut (content, *this, nullptr);
50 callOut.runModalLoop();
54 The call-out will resize and position itself when the content changes size.
56 class JUCE_API CallOutBox
: public Component
59 //==============================================================================
60 /** Creates a CallOutBox.
62 @param contentComponent the component to display inside the call-out. This should
63 already have a size set (although the call-out will also
64 update itself when the component's size is changed later).
65 Obviously this component must not be deleted until the
66 call-out box has been deleted.
67 @param componentToPointTo the component that the call-out's arrow should point towards
68 @param parentComponent if non-zero, this is the component to add the call-out to. If
69 this is zero, the call-out will be added to the desktop.
71 CallOutBox (Component
& contentComponent
,
72 Component
& componentToPointTo
,
73 Component
* parentComponent
);
78 //==============================================================================
79 /** Changes the length of the arrow. */
80 void setArrowSize (float newSize
);
82 /** Updates the position and size of the box.
84 You shouldn't normally need to call this, unless you need more precise control over the
87 @param newAreaToPointTo the rectangle to make the box's arrow point to
88 @param newAreaToFitIn the area within which the box's position should be constrained
90 void updatePosition (const Rectangle
<int>& newAreaToPointTo
,
91 const Rectangle
<int>& newAreaToFitIn
);
93 //==============================================================================
95 void paint (Graphics
& g
);
101 void childBoundsChanged (Component
*);
103 bool hitTest (int x
, int y
);
105 void inputAttemptWhenModal();
107 bool keyPressed (const KeyPress
& key
);
109 void handleCommandMessage (int commandId
);
112 //==============================================================================
117 Point
<float> targetPoint
;
118 Rectangle
<int> availableArea
, targetArea
;
123 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CallOutBox
);
127 #endif // __JUCE_CALLOUTBOX_JUCEHEADER__