25 #ifndef JUCE_COMPONENT_H_INCLUDED
26 #define JUCE_COMPONENT_H_INCLUDED
83 virtual void setName (
const String& newName);
94 void setComponentID (
const String& newID);
110 virtual void setVisible (
bool shouldBeVisible);
125 virtual void visibilityChanged();
132 bool isShowing()
const;
158 virtual void addToDesktop (
int windowStyleFlags,
159 void* nativeWindowToAttachTo =
nullptr);
168 void removeFromDesktop();
194 virtual
void userTriedToCloseWindow();
200 virtual
void minimisationStateChanged (
bool isNowMinimised);
209 virtual
float getDesktopScaleFactor() const;
222 void toFront (
bool shouldAlsoGainFocus);
241 void setAlwaysOnTop (
bool shouldStayOnTop);
246 bool isAlwaysOnTop() const
noexcept;
256 int getX() const
noexcept {
return bounds.getX(); }
322 int getScreenX() const;
327 int getScreenY() const;
332 Point<
int> getScreenPosition() const;
346 Point<
int> pointRelativeToSourceComponent) const;
355 Point<
float> pointRelativeToSourceComponent) const;
368 const
Rectangle<
int>& areaRelativeToSourceComponent) const;
373 Point<
int> localPointToGlobal (
Point<
int> localPoint) const;
378 Point<
float> localPointToGlobal (
Point<
float> localPoint) const;
403 void setTopLeftPosition (
int x,
int y);
418 void setTopLeftPosition (
Point<
int> newTopLeftPosition);
431 void setTopRightPosition (
int x,
int y);
441 void setSize (
int newWidth,
int newHeight);
457 void setBounds (
int x,
int y,
int width,
int height);
473 void setBounds (const
Rectangle<
int>& newBounds);
495 void setBounds (const
String& newBoundsExpression);
506 void setBoundsRelative (
float proportionalX,
float proportionalY,
507 float proportionalWidth,
float proportionalHeight);
516 void setBoundsInset (const
BorderSize<
int>& borders);
532 void setBoundsToFit (
int x,
int y,
int width,
int height,
534 bool onlyReduceInSize);
543 void setCentrePosition (
int x,
int y);
551 void setCentreRelative (
float x,
float y);
559 void centreWithSize (
int width,
int height);
591 bool isTransformed() const
noexcept;
597 int proportionOfWidth (
float proportion) const
noexcept;
602 int proportionOfHeight (
float proportion) const
noexcept;
609 int getParentWidth() const
noexcept;
616 int getParentHeight() const
noexcept;
624 Rectangle<
int> getParentMonitorArea() const;
631 int getNumChildComponents() const
noexcept;
676 void addChildComponent (
Component* child,
int zOrder = -1);
694 void addChildComponent (
Component& child,
int zOrder = -1);
701 void addAndMakeVisible (
Component* child,
int zOrder = -1);
708 void addAndMakeVisible (
Component& child,
int zOrder = -1);
726 void removeChildComponent (
Component* childToRemove);
739 Component* removeChildComponent (
int childIndexToRemove);
744 void removeAllChildren();
755 void deleteAllChildren();
770 template <
class TargetClass>
773 for (
Component* p = parentComponent; p !=
nullptr; p = p->parentComponent)
774 if (TargetClass*
const target =
dynamic_cast<TargetClass*
> (p))
806 virtual
void parentHierarchyChanged();
812 virtual
void childrenChanged();
851 virtual
bool hitTest (
int x,
int y);
870 void setInterceptsMouseClicks (
bool allowClicksOnThisComponent,
871 bool allowClicksOnChildComponents)
noexcept;
880 void getInterceptsMouseClicks (
bool& allowsClicksOnThisComponent,
881 bool& allowsClicksOnChildComponents) const
noexcept;
895 bool contains (
Point<
int> localPoint);
905 bool reallyContains (
Point<
int> localPoint,
bool returnTrueIfWithinAChild);
917 Component* getComponentAt (
int x,
int y);
963 void repaint (
int x,
int y,
int width,
int height);
978 void repaint (const
Rectangle<
int>& area);
993 void setBufferedToImage (
bool shouldBeBuffered);
1011 bool clipImageToComponentBounds = true,
1012 float scaleFactor = 1.0f);
1031 void paintEntireComponent (
Graphics& context,
bool ignoreAlphaLevel);
1045 void setPaintingIsUnclipped (
bool shouldPaintWithoutClipping)
noexcept;
1092 void setLookAndFeel (
LookAndFeel* newLookAndFeel);
1104 virtual
void lookAndFeelChanged();
1113 void sendLookAndFeelChange();
1130 void setOpaque (
bool shouldBeOpaque);
1152 void setBroughtToFrontOnMouseClick (
bool shouldBeBroughtToFront)
noexcept;
1157 bool isBroughtToFrontOnMouseClick() const
noexcept;
1172 void setWantsKeyboardFocus (
bool wantsFocus)
noexcept;
1181 bool getWantsKeyboardFocus() const
noexcept;
1190 void setMouseClickGrabsKeyboardFocus (
bool shouldGrabFocus);
1195 bool getMouseClickGrabsKeyboardFocus() const
noexcept;
1217 void grabKeyboardFocus();
1229 bool hasKeyboardFocus (
bool trueIfChildIsFocused) const;
1251 void moveKeyboardFocusToSibling (
bool moveToNext);
1284 int getExplicitFocusOrder() const;
1294 void setExplicitFocusOrder (
int newFocusOrderIndex);
1308 void setFocusContainer (
bool shouldBeFocusContainer)
noexcept;
1316 bool isFocusContainer() const
noexcept;
1342 void setEnabled (
bool shouldBeEnabled);
1354 virtual
void enablementChanged();
1363 void setAlpha (
float newAlpha);
1368 float getAlpha() const;
1378 void setMouseCursor (const
MouseCursor& cursorType);
1400 void updateMouseCursor() const;
1436 virtual
void paintOverChildren (
Graphics& g);
1553 virtual
void mouseWheelMove (const
MouseEvent& event,
1567 virtual
void mouseMagnify (const
MouseEvent& event,
float scaleFactor);
1585 static
void JUCE_CALLTYPE beginDragAutoRepeat (
int millisecondsBetweenCallbacks);
1598 void setRepaintsOnMouseActivity (
bool shouldRepaint)
noexcept;
1618 bool wantsEventsForAllNestedChildComponents);
1641 void removeKeyListener (
KeyListener* listenerToRemove);
1659 virtual
bool keyPressed (const
KeyPress& key);
1683 virtual
bool keyStateChanged (
bool isKeyDown);
1698 virtual
void modifierKeysChanged (const
ModifierKeys& modifiers);
1706 focusChangedDirectly
1712 virtual void focusGained (FocusChangeType cause);
1717 virtual void focusLost (FocusChangeType cause);
1730 virtual void focusOfChildComponentChanged (FocusChangeType cause);
1748 bool isMouseOver (
bool includeChildren =
false)
const;
1758 bool isMouseButtonDown()
const;
1764 bool isMouseOverOrDragging()
const;
1779 Point<
int> getMouseXYRelative() const;
1797 virtual
void resized();
1814 virtual
void moved();
1823 virtual
void childBoundsChanged (
Component* child);
1832 virtual
void parentSizeChanged();
1841 virtual
void broughtToFront();
1871 void postCommandMessage (
int commandId);
1880 virtual
void handleCommandMessage (
int commandId);
1899 #if JUCE_MODAL_LOOPS_PERMITTED
1924 void enterModalState (
bool takeKeyboardFocus =
true,
1926 bool deleteWhenDismissed =
false);
1935 void exitModalState (
int returnValue);
1945 bool isCurrentlyModal() const
noexcept;
1973 bool isCurrentlyBlockedByAnotherModalComponent() const;
1986 virtual
bool canModalEventBeSentToComponent (const
Component* targetComponent);
1999 virtual
void inputAttemptWhenModal();
2029 Colour findColour (
int colourId,
bool inheritFromParent =
false)
const;
2041 void setColour (
int colourId,
Colour newColour);
2046 void removeColour (
int colourId);
2051 bool isColourSpecified (
int colourId)
const;
2056 void copyAllExplicitColoursTo (
Component& target)
const;
2061 virtual void colourChanged();
2076 void* getWindowHandle()
const;
2091 template <
class ComponentType>
2108 SafePointer& operator= (ComponentType* newComponent) { weakRef = newComponent;
return *
this; }
2114 operator ComponentType*()
const noexcept {
return getComponent(); }
2146 bool shouldBailOut()
const noexcept;
2179 virtual void applyNewBounds (
const Rectangle<int>& newBounds) = 0;
2190 Positioner* getPositioner() const
noexcept;
2198 void setPositioner (Positioner* newPositioner);
2225 static Component* currentlyFocusedComponent;
2228 String componentName, componentID;
2250 struct ComponentFlags
2252 bool hasHeavyweightPeerFlag : 1;
2253 bool visibleFlag : 1;
2254 bool opaqueFlag : 1;
2255 bool ignoresMouseClicksFlag : 1;
2256 bool allowChildMouseClicksFlag : 1;
2257 bool wantsFocusFlag : 1;
2258 bool isFocusContainerFlag : 1;
2259 bool dontFocusOnMouseClickFlag : 1;
2260 bool alwaysOnTopFlag : 1;
2261 bool bufferToImageFlag : 1;
2262 bool bringToFrontOnClickFlag : 1;
2263 bool repaintOnMouseActivityFlag : 1;
2264 bool currentlyModalFlag : 1;
2265 bool isDisabledFlag : 1;
2266 bool childCompFocusedFlag : 1;
2267 bool dontClipGraphicsFlag : 1;
2268 bool mouseDownWasBlocked : 1;
2269 bool isMoveCallbackPending : 1;
2270 bool isResizeCallbackPending : 1;
2272 bool isInsidePaintCall : 1;
2282 uint8 componentTransparency;
2293 void internalBroughtToFront();
2295 void internalFocusGain (FocusChangeType);
2296 void internalFocusLoss (FocusChangeType);
2298 void internalModalInputAttempt();
2299 void internalModifierKeysChanged();
2300 void internalChildrenChanged();
2301 void internalHierarchyChanged();
2304 Component* removeChildComponent (
int index,
bool sendParentEvents,
bool sendChildEvents);
2305 void reorderChildInternal (
int sourceIndex,
int destIndex);
2306 void paintComponentAndChildren (
Graphics&);
2307 void paintWithinParentContext (
Graphics&);
2308 void sendMovedResizedMessages (
bool wasMoved,
bool wasResized);
2309 void sendMovedResizedMessagesIfPending();
2310 void repaintParent();
2311 void sendFakeMouseMove()
const;
2312 void takeKeyboardFocus (
const FocusChangeType);
2313 void grabFocusInternal (
const FocusChangeType,
bool canTryParent);
2314 static void giveAwayFocus (
bool sendFocusLossEvent);
2315 void sendEnablementChangeMessage();
2316 void sendVisibilityChangeMessage();
2327 #if JUCE_CATCH_DEPRECATED_CODE_MISUSE
2332 virtual void filesDropped (
const StringArray&,
int,
int) {}
2342 virtual ComponentPeer* createNewPeer (
int styleFlags,
void* nativeWindowToAttachTo);
2347 #endif // JUCE_COMPONENT_H_INCLUDED