85 virtual void setName (
const String& newName);
96 void setComponentID (
const String& newID);
112 virtual void setVisible (
bool shouldBeVisible);
122 bool isVisible() const noexcept {
return flags.visibleFlag; }
127 virtual void visibilityChanged();
134 bool isShowing()
const;
160 virtual void addToDesktop (
int windowStyleFlags,
161 void* nativeWindowToAttachTo =
nullptr);
170 void removeFromDesktop();
175 bool isOnDesktop() const noexcept;
196 virtual
void userTriedToCloseWindow();
202 virtual
void minimisationStateChanged (
bool isNowMinimised);
211 virtual
float getDesktopScaleFactor() const;
225 void toFront (
bool shouldAlsoGainKeyboardFocus);
244 void setAlwaysOnTop (
bool shouldStayOnTop);
249 bool isAlwaysOnTop() const noexcept;
259 int getX() const noexcept {
return boundsRelativeToParent.getX(); }
268 int getY() const noexcept {
return boundsRelativeToParent.getY(); }
271 int getWidth() const noexcept {
return boundsRelativeToParent.getWidth(); }
274 int getHeight() const noexcept {
return boundsRelativeToParent.getHeight(); }
283 int getRight() const noexcept {
return boundsRelativeToParent.getRight(); }
295 int getBottom() const noexcept {
return boundsRelativeToParent.getBottom(); }
319 Rectangle<
int> getBoundsInParent() const noexcept;
325 int getScreenX() const;
330 int getScreenY() const;
335 Point<
int> getScreenPosition() const;
349 Point<
int> pointRelativeToSourceComponent) const;
358 Point<
float> pointRelativeToSourceComponent) const;
371 Rectangle<
int> areaRelativeToSourceComponent) const;
384 Rectangle<
float> areaRelativeToSourceComponent) const;
389 Point<
int> localPointToGlobal (
Point<
int> localPoint) const;
394 Point<
float> localPointToGlobal (
Point<
float> localPoint) const;
428 void setTopLeftPosition (
int x,
int y);
443 void setTopLeftPosition (
Point<
int> newTopLeftPosition);
456 void setTopRightPosition (
int x,
int y);
466 void setSize (
int newWidth,
int newHeight);
482 void setBounds (
int x,
int y,
int width,
int height);
498 void setBounds (
Rectangle<
int> newBounds);
509 void setBoundsRelative (
float proportionalX,
float proportionalY,
510 float proportionalWidth,
float proportionalHeight);
521 void setBoundsRelative (
Rectangle<
float> proportionalArea);
530 void setBoundsInset (
BorderSize<
int> borders);
546 void setBoundsToFit (
Rectangle<
int> targetArea,
548 bool onlyReduceInSize);
557 void setCentrePosition (
int x,
int y);
566 void setCentrePosition (
Point<
int> newCentrePosition);
573 void setCentreRelative (
float x,
float y);
581 void centreWithSize (
int width,
int height);
613 bool isTransformed() const noexcept;
624 int proportionOfWidth (
float proportion) const noexcept;
629 int proportionOfHeight (
float proportion) const noexcept;
636 int getParentWidth() const noexcept;
643 int getParentHeight() const noexcept;
651 Rectangle<
int> getParentMonitorArea() const;
658 int getNumChildComponents() const noexcept;
669 Component* getChildComponent (
int index) const noexcept;
680 int getIndexOfChildComponent (const
Component* child) const noexcept;
685 const
Array<
Component*>& getChildren() const noexcept {
return childComponentList; }
708 void addChildComponent (
Component* child,
int zOrder = -1);
726 void addChildComponent (
Component& child,
int zOrder = -1);
738 void addAndMakeVisible (
Component* child,
int zOrder = -1);
750 void addAndMakeVisible (
Component& child,
int zOrder = -1);
768 void removeChildComponent (
Component* childToRemove);
781 Component* removeChildComponent (
int childIndexToRemove);
786 void removeAllChildren();
797 void deleteAllChildren();
812 template <
class TargetClass>
815 for (
auto* p = parentComponent; p !=
nullptr; p = p->parentComponent)
816 if (
auto* target =
dynamic_cast<TargetClass*
> (p))
828 Component* getTopLevelComponent() const noexcept;
835 bool isParentOf (const
Component* possibleChild) const noexcept;
848 virtual
void parentHierarchyChanged();
854 virtual
void childrenChanged();
893 virtual
bool hitTest (
int x,
int y);
912 void setInterceptsMouseClicks (
bool allowClicksOnThisComponent,
913 bool allowClicksOnChildComponents) noexcept;
922 void getInterceptsMouseClicks (
bool& allowsClicksOnThisComponent,
923 bool& allowsClicksOnChildComponents) const noexcept;
937 bool contains (
Point<
int> localPoint);
950 bool contains (
Point<
float> localPoint);
960 bool reallyContains (
Point<
int> localPoint,
bool returnTrueIfWithinAChild);
970 bool reallyContains (
Point<
float> localPoint,
bool returnTrueIfWithinAChild);
982 Component* getComponentAt (
int x,
int y);
1039 void repaint (
int x,
int y,
int width,
int height);
1069 void setBufferedToImage (
bool shouldBeBuffered);
1087 bool clipImageToComponentBounds = true,
1088 float scaleFactor = 1.0f);
1107 void paintEntireComponent (
Graphics& context,
bool ignoreAlphaLevel);
1121 void setPaintingIsUnclipped (
bool shouldPaintWithoutClipping) noexcept;
1126 bool isPaintingUnclipped() const noexcept;
1173 void setLookAndFeel (
LookAndFeel* newLookAndFeel);
1185 virtual
void lookAndFeelChanged();
1192 void sendLookAndFeelChange();
1209 void setOpaque (
bool shouldBeOpaque);
1216 bool isOpaque() const noexcept;
1231 void setBroughtToFrontOnMouseClick (
bool shouldBeBroughtToFront) noexcept;
1236 bool isBroughtToFrontOnMouseClick() const noexcept;
1251 void setExplicitFocusOrder (
int newFocusOrderIndex);
1260 int getExplicitFocusOrder() const;
1305 keyboardFocusContainer
1315 void setFocusContainerType (FocusContainerType containerType)
noexcept;
1321 bool isFocusContainer() const noexcept;
1327 bool isKeyboardFocusContainer() const noexcept;
1339 Component* findKeyboardFocusContainer() const;
1352 void setWantsKeyboardFocus (
bool wantsFocus) noexcept;
1361 bool getWantsKeyboardFocus() const noexcept;
1369 void setMouseClickGrabsKeyboardFocus (
bool shouldGrabFocus);
1375 bool getMouseClickGrabsKeyboardFocus() const noexcept;
1402 void grabKeyboardFocus();
1411 void giveAwayKeyboardFocus();
1423 bool hasKeyboardFocus (
bool trueIfChildIsFocused) const;
1437 void moveKeyboardFocusToSibling (
bool moveToNext);
1485 void setHasFocusOutline (
bool hasFocusOutline) noexcept { flags.hasFocusOutlineFlag = hasFocusOutline; }
1505 bool isEnabled() const noexcept;
1517 void setEnabled (
bool shouldBeEnabled);
1529 virtual
void enablementChanged();
1535 float getAlpha() const noexcept;
1544 void setAlpha (
float newAlpha);
1550 virtual
void alphaChanged();
1560 void setMouseCursor (const
MouseCursor& cursorType);
1582 void updateMouseCursor() const;
1618 virtual
void paintOverChildren (
Graphics& g);
1633 void mouseMove (const
MouseEvent& event) override;
1649 void mouseEnter (const
MouseEvent& event) override;
1664 void mouseExit (const
MouseEvent& event) override;
1679 void mouseDown (const
MouseEvent& event) override;
1691 void mouseDrag (const
MouseEvent& event) override;
1706 void mouseUp (const
MouseEvent& event) override;
1718 void mouseDoubleClick (const
MouseEvent& event) override;
1735 void mouseWheelMove (const
MouseEvent& event,
1749 void mouseMagnify (const
MouseEvent& event,
float scaleFactor) override;
1767 static
void JUCE_CALLTYPE beginDragAutoRepeat (
int millisecondsBetweenCallbacks);
1780 void setRepaintsOnMouseActivity (
bool shouldRepaint) noexcept;
1800 bool wantsEventsForAllNestedChildComponents);
1823 void removeKeyListener (
KeyListener* listenerToRemove);
1841 virtual
bool keyPressed (const
KeyPress& key);
1865 virtual
bool keyStateChanged (
bool isKeyDown);
1883 virtual
void modifierKeysChanged (const
ModifierKeys& modifiers);
1891 focusChangedDirectly
1905 virtual void focusGained (FocusChangeType cause);
1914 virtual void focusGainedWithDirection (FocusChangeType cause, FocusChangeDirection direction);
1919 virtual void focusLost (FocusChangeType cause);
1932 virtual void focusOfChildComponentChanged (FocusChangeType cause);
1954 bool isMouseOver (
bool includeChildren =
false)
const;
1964 bool isMouseButtonDown (
bool includeChildren =
false)
const;
1970 bool isMouseOverOrDragging (
bool includeChildren =
false)
const;
1980 static bool JUCE_CALLTYPE isMouseButtonDownAnywhere() noexcept;
1985 Point<
int> getMouseXYRelative() const;
2003 virtual
void resized();
2020 virtual
void moved();
2029 virtual
void childBoundsChanged (
Component* child);
2038 virtual
void parentSizeChanged();
2047 virtual
void broughtToFront();
2077 void postCommandMessage (
int commandId);
2086 virtual
void handleCommandMessage (
int commandId);
2089 #if JUCE_MODAL_LOOPS_PERMITTED
2140 void enterModalState (
bool takeKeyboardFocus =
true,
2142 bool deleteWhenDismissed =
false);
2151 void exitModalState (
int returnValue = 0);
2163 bool isCurrentlyModal (
bool onlyConsiderForemostModalComponent =
true) const noexcept;
2168 static
int JUCE_CALLTYPE getNumCurrentlyModalComponents() noexcept;
2191 bool isCurrentlyBlockedByAnotherModalComponent() const;
2204 virtual
bool canModalEventBeSentToComponent (const
Component* targetComponent);
2217 virtual
void inputAttemptWhenModal();
2247 Colour findColour (
int colourID,
bool inheritFromParent =
false)
const;
2261 void setColour (
int colourID,
Colour newColour);
2266 void removeColour (
int colourID);
2271 bool isColourSpecified (
int colourID)
const;
2276 void copyAllExplicitColoursTo (
Component& target)
const;
2284 virtual void colourChanged();
2291 void* getWindowHandle()
const;
2306 template <
class ComponentType>
2323 SafePointer& operator= (ComponentType* newComponent) { weakRef = newComponent;
return *
this; }
2326 ComponentType*
getComponent() const noexcept {
return dynamic_cast<ComponentType*
> (weakRef.get()); }
2329 operator ComponentType*()
const noexcept {
return getComponent(); }
2332 ComponentType*
operator->() const noexcept {
return getComponent(); }
2337 bool operator== (ComponentType* component)
const noexcept {
return weakRef == component; }
2338 bool operator!= (ComponentType* component)
const noexcept {
return weakRef != component; }
2341 WeakReference<Component> weakRef;
2358 bool shouldBailOut()
const noexcept;
2409 void setPositioner (
Positioner* newPositioner);
2449 void setTitle (
const String& newTitle);
2465 void setDescription (
const String& newDescription);
2481 void setHelpText (
const String& newHelpText);
2492 void setAccessible (
bool shouldBeAccessible);
2498 bool isAccessible() const noexcept;
2516 void invalidateAccessibilityHandler();
2544 [[deprecated (
"Use the setFocusContainerType that takes a more descriptive enum.")]]
2545 void setFocusContainer (
bool shouldBeFocusContainer)
noexcept
2547 setFocusContainerType (shouldBeFocusContainer ? FocusContainerType::keyboardFocusContainer
2548 : FocusContainerType::none);
2551 [[deprecated (
"Use the contains that takes a Point<int>.")]]
2552 void contains (
int,
int) =
delete;
2558 friend class ComponentPeer;
2559 friend class detail::MouseInputSourceImpl;
2562 static Component* currentlyFocusedComponent;
2565 String componentName, componentID, componentTitle, componentDescription, componentHelpText;
2566 Component* parentComponent =
nullptr;
2567 Rectangle<int> boundsRelativeToParent;
2570 Array<Component*> childComponentList;
2571 WeakReference<LookAndFeel> lookAndFeel;
2573 ImageEffectFilter* effect =
nullptr;
2576 class MouseListenerList;
2579 ListenerList<ComponentListener> componentListeners;
2580 NamedValueSet properties;
2582 friend class WeakReference<Component>;
2583 WeakReference<Component>::Master masterReference;
2587 struct ComponentFlags
2589 bool hasHeavyweightPeerFlag : 1;
2590 bool visibleFlag : 1;
2591 bool opaqueFlag : 1;
2592 bool ignoresMouseClicksFlag : 1;
2593 bool allowChildMouseClicksFlag : 1;
2594 bool wantsKeyboardFocusFlag : 1;
2595 bool isFocusContainerFlag : 1;
2596 bool isKeyboardFocusContainerFlag : 1;
2597 bool childKeyboardFocusedFlag : 1;
2598 bool dontFocusOnMouseClickFlag : 1;
2599 bool hasFocusOutlineFlag : 1;
2600 bool alwaysOnTopFlag : 1;
2601 bool bufferToImageFlag : 1;
2602 bool bringToFrontOnClickFlag : 1;
2603 bool repaintOnMouseActivityFlag : 1;
2604 bool isDisabledFlag : 1;
2605 bool dontClipGraphicsFlag : 1;
2606 bool mouseDownWasBlocked : 1;
2607 bool isMoveCallbackPending : 1;
2608 bool isResizeCallbackPending : 1;
2609 bool viewportIgnoreDragFlag : 1;
2610 bool accessibilityIgnoredFlag : 1;
2611 bool cachedMouseInsideComponent : 1;
2613 bool isInsidePaintCall : 1;
2619 uint32 componentFlags;
2623 uint8 componentTransparency = 0;
2626 void internalMouseEnter (MouseInputSource, Point<float>, Time);
2627 void internalMouseExit (MouseInputSource, Point<float>, Time);
2628 void internalMouseDown (MouseInputSource,
const detail::PointerState&, Time);
2629 void internalMouseUp (MouseInputSource,
const detail::PointerState&, Time, ModifierKeys oldModifiers);
2630 void internalMouseDrag (MouseInputSource,
const detail::PointerState&, Time);
2631 void internalMouseMove (MouseInputSource, Point<float>, Time);
2632 void internalMouseWheel (MouseInputSource, Point<float>, Time,
const MouseWheelDetails&);
2633 void internalMagnifyGesture (MouseInputSource, Point<float>, Time,
float);
2634 void internalBroughtToFront();
2635 void internalKeyboardFocusGain (FocusChangeType,
const WeakReference<Component>&, FocusChangeDirection);
2636 void internalKeyboardFocusGain (FocusChangeType);
2637 void internalKeyboardFocusLoss (FocusChangeType);
2638 void internalChildKeyboardFocusChange (FocusChangeType,
const WeakReference<Component>&);
2639 void internalModalInputAttempt();
2640 void internalModifierKeysChanged();
2641 void internalChildrenChanged();
2642 void internalHierarchyChanged();
2643 void internalRepaint (Rectangle<int>);
2644 void internalRepaintUnchecked (Rectangle<int>,
bool);
2645 Component* removeChildComponent (
int index,
bool sendParentEvents,
bool sendChildEvents);
2646 void reorderChildInternal (
int sourceIndex,
int destIndex);
2647 void paintComponentAndChildren (Graphics&);
2648 void paintWithinParentContext (Graphics&);
2649 void sendMovedResizedMessages (
bool wasMoved,
bool wasResized);
2650 void sendMovedResizedMessagesIfPending();
2651 void repaintParent();
2652 void sendFakeMouseMove()
const;
2653 void takeKeyboardFocus (FocusChangeType, FocusChangeDirection);
2654 void grabKeyboardFocusInternal (FocusChangeType,
bool canTryParent, FocusChangeDirection);
2655 void giveAwayKeyboardFocusInternal (
bool sendFocusLossEvent);
2656 void sendEnablementChangeMessage();
2657 void sendVisibilityChangeMessage();
2659 friend struct detail::ComponentHelpers;
2669 virtual ComponentPeer* createNewPeer (
int styleFlags,
void* nativeWindowToAttachTo);