Inherits MouseListener, and MessageListener.
Inherited by ActiveXControlComponent, AudioDeviceSelectorComponent, AudioProcessorEditor, BubbleComponent, Button, CarbonViewWrapperComponent, CodeEditorComponent, ColourSelector, ComboBox, FileBrowserComponent, FileChooserDialogBox::ContentComponent, FilenameComponent, FilePreviewComponent, FileSearchPathListComponent, GroupComponent, KeyMappingEditorComponent, Label, LassoComponent< SelectableItemType >, ListBox, MagnifierComponent, MenuBarComponent, MidiKeyboardComponent, MultiDocumentPanel, NSViewComponent, OpenGLComponent, PluginListComponent, PopupMenuCustomComponent, PreferencesPanel, ProgressBar, PropertyComponent, PropertyPanel, ResizableBorderComponent, ResizableCornerComponent, ScrollBar, Slider, SplashScreen, StretchableLayoutResizerBar, SystemTrayIconComponent, TabbedButtonBar, TabbedComponent, TableHeaderComponent, TextEditor, Toolbar, ToolbarItemPalette, TooltipWindow, TopLevelWindow, TreeView, Viewport, and WebBrowserComponent.
Classes | |
| struct | ComponentFlags |
Public Types | |
| enum | FocusChangeType { focusChangedByMouseClick, focusChangedByTabKey, focusChangedDirectly } |
| Enumeration used by the focusChanged() and focusLost() methods. More... | |
Public Member Functions | |
| Component () throw () | |
| Creates a component. | |
| virtual | ~Component () |
| Destructor. | |
| Component (const String &componentName) throw () | |
| Creates a component, setting its name at the same time. | |
| const String & | getName () const throw () |
| Returns the name of this component. | |
| virtual void | setName (const String &newName) |
| Sets the name of this component. | |
| bool | isValidComponent () const throw () |
| Checks whether this Component object has been deleted. | |
| virtual void | setVisible (bool shouldBeVisible) |
| Makes the component visible or invisible. | |
| bool | isVisible () const throw () |
| Tests whether the component is visible or not. | |
| virtual void | visibilityChanged () |
| Called when this component's visiblility changes. | |
| bool | isShowing () const throw () |
| Tests whether this component and all its parents are visible. | |
| void | fadeOutComponent (const int lengthOfFadeOutInMilliseconds, const int deltaXToMove=0, const int deltaYToMove=0, const float scaleFactorAtEnd=1.0f) |
| Makes a component invisible using a groovy fade-out and animated zoom effect. | |
| virtual void | addToDesktop (int windowStyleFlags, void *nativeWindowToAttachTo=0) |
| Makes this component appear as a window on the desktop. | |
| void | removeFromDesktop () |
| If the component is currently showing on the desktop, this will hide it. | |
| bool | isOnDesktop () const throw () |
| Returns true if this component is currently showing on the desktop. | |
| ComponentPeer * | getPeer () const throw () |
| Returns the heavyweight window that contains this component. | |
| virtual void | userTriedToCloseWindow () |
| For components on the desktop, this is called if the system wants to close the window. | |
| virtual void | minimisationStateChanged (bool isNowMinimised) |
| Called for a desktop component which has just been minimised or un-minimised. | |
| void | toFront (const bool shouldAlsoGainFocus) |
| Brings the component to the front of its siblings. | |
| void | toBack () |
| Changes this component's z-order to be at the back of all its siblings. | |
| void | toBehind (Component *const other) |
| Changes this component's z-order so that it's just behind another component. | |
| void | setAlwaysOnTop (const bool shouldStayOnTop) |
| Sets whether the component should always be kept at the front of its siblings. | |
| bool | isAlwaysOnTop () const throw () |
| Returns true if this component is set to always stay in front of its siblings. | |
| int | getX () const throw () |
| Returns the x co-ordinate of the component's left edge. | |
| int | getY () const throw () |
| Returns the y co-ordinate of the top of this component. | |
| int | getWidth () const throw () |
| Returns the component's width in pixels. | |
| int | getHeight () const throw () |
| Returns the component's height in pixels. | |
| int | getRight () const throw () |
| Returns the x co-ordinate of the component's right-hand edge. | |
| int | getBottom () const throw () |
| Returns the y co-ordinate of the bottom edge of this component. | |
| const Rectangle & | getBounds () const throw () |
| Returns this component's bounding box. | |
| void | getVisibleArea (RectangleList &result, const bool includeSiblings) const |
| Returns the region of this component that's not obscured by other, opaque components. | |
| int | getScreenX () const throw () |
| Returns this component's x co-ordinate relative the the screen's top-left origin. | |
| int | getScreenY () const throw () |
| Returns this component's y co-ordinate relative the the screen's top-left origin. | |
| void | relativePositionToGlobal (int &x, int &y) const throw () |
| Converts a position relative to this component's top-left into a screen co-ordinate. | |
| void | globalPositionToRelative (int &x, int &y) const throw () |
| Converts a screen co-ordinate into a position relative to this component's top-left. | |
| void | relativePositionToOtherComponent (const Component *const targetComponent, int &x, int &y) const throw () |
| Converts a position relative to this component's top-left into a position relative to another component's top-left. | |
| void | setTopLeftPosition (const int x, const int y) |
| Moves the component to a new position. | |
| void | setTopRightPosition (const int x, const int y) |
| Moves the component to a new position. | |
| void | setSize (const int newWidth, const int newHeight) |
| Changes the size of the component. | |
| void | setBounds (int x, int y, int width, int height) |
| Changes the component's position and size. | |
| void | setBounds (const Rectangle &newBounds) |
| Changes the component's position and size. | |
| void | setBoundsRelative (const float proportionalX, const float proportionalY, const float proportionalWidth, const float proportionalHeight) |
| Changes the component's position and size in terms of fractions of its parent's size. | |
| void | setBoundsInset (const BorderSize &borders) |
| Changes the component's position and size based on the amount of space to leave around it. | |
| void | setBoundsToFit (int x, int y, int width, int height, const Justification &justification, const bool onlyReduceInSize) |
| Positions the component within a given rectangle, keeping its proportions unchanged. | |
| void | setCentrePosition (const int x, const int y) |
| Changes the position of the component's centre. | |
| void | setCentreRelative (const float x, const float y) |
| Changes the position of the component's centre. | |
| void | centreWithSize (const int width, const int height) |
| Changes the component's size and centres it within its parent. | |
| int | proportionOfWidth (const float proportion) const throw () |
| Returns a proportion of the component's width. | |
| int | proportionOfHeight (const float proportion) const throw () |
| Returns a proportion of the component's height. | |
| int | getParentWidth () const throw () |
| Returns the width of the component's parent. | |
| int | getParentHeight () const throw () |
| Returns the height of the component's parent. | |
| const Rectangle | getParentMonitorArea () const throw () |
| Returns the screen co-ordinates of the monitor that contains this component. | |
| int | getNumChildComponents () const throw () |
| Returns the number of child components that this component contains. | |
| Component * | getChildComponent (const int index) const throw () |
| Returns one of this component's child components, by it index. | |
| int | getIndexOfChildComponent (const Component *const child) const throw () |
| Returns the index of this component in the list of child components. | |
| void | addChildComponent (Component *const child, int zOrder=-1) |
| Adds a child component to this one. | |
| void | addAndMakeVisible (Component *const child, int zOrder=-1) |
| Adds a child component to this one, and also makes the child visible if it isn't. | |
| void | removeChildComponent (Component *const childToRemove) |
| Removes one of this component's child-components. | |
| Component * | removeChildComponent (const int childIndexToRemove) |
| Removes one of this component's child-components by index. | |
| void | removeAllChildren () |
| Removes all this component's children. | |
| void | deleteAllChildren () |
| Removes all this component's children, and deletes them. | |
| Component * | getParentComponent () const throw () |
| Returns the component which this component is inside. | |
| template<class TargetClass > | |
| TargetClass * | findParentComponentOfClass (TargetClass *const dummyParameter=0) const |
| Searches the parent components for a component of a specified class. | |
| Component * | getTopLevelComponent () const throw () |
| Returns the highest-level component which contains this one or its parents. | |
| bool | isParentOf (const Component *possibleChild) const throw () |
| Checks whether a component is anywhere inside this component or its children. | |
| virtual void | parentHierarchyChanged () |
| Called to indicate that the component's parents have changed. | |
| virtual void | childrenChanged () |
| Subclasses can use this callback to be told when children are added or removed. | |
| virtual bool | hitTest (int x, int y) |
| Tests whether a given point inside the component. | |
| void | setInterceptsMouseClicks (const bool allowClicksOnThisComponent, const bool allowClicksOnChildComponents) throw () |
| Changes the default return value for the hitTest() method. | |
| void | getInterceptsMouseClicks (bool &allowsClicksOnThisComponent, bool &allowsClicksOnChildComponents) const throw () |
| Retrieves the current state of the mouse-click interception flags. | |
| virtual bool | contains (int x, int y) |
| Returns true if a given point lies within this component or one of its children. | |
| bool | reallyContains (int x, int y, const bool returnTrueIfWithinAChild) |
| Returns true if a given point lies in this component, taking any overlapping siblings into account. | |
| Component * | getComponentAt (const int x, const int y) |
| Returns the component at a certain point within this one. | |
| void | repaint () throw () |
| Marks the whole component as needing to be redrawn. | |
| void | repaint (const int x, const int y, const int width, const int height) throw () |
| Marks a subsection of this component as needing to be redrawn. | |
| void | setBufferedToImage (const bool shouldBeBuffered) throw () |
| Makes the component use an internal buffer to optimise its redrawing. | |
| Image * | createComponentSnapshot (const Rectangle &areaToGrab, const bool clipImageToComponentBounds=true) |
| Generates a snapshot of part of this component. | |
| void | paintEntireComponent (Graphics &context) |
| Draws this component and all its subcomponents onto the specified graphics context. | |
| void | setComponentEffect (ImageEffectFilter *const newEffect) |
| Adds an effect filter to alter the component's appearance. | |
| ImageEffectFilter * | getComponentEffect () const throw () |
| Returns the current component effect. | |
| LookAndFeel & | getLookAndFeel () const throw () |
| Finds the appropriate look-and-feel to use for this component. | |
| void | setLookAndFeel (LookAndFeel *const newLookAndFeel) |
| Sets the look and feel to use for this component. | |
| virtual void | lookAndFeelChanged () |
| Called to let the component react to a change in the look-and-feel setting. | |
| void | sendLookAndFeelChange () |
| Calls the lookAndFeelChanged() method in this component and all its children. | |
| void | setOpaque (const bool shouldBeOpaque) throw () |
| Indicates whether any parts of the component might be transparent. | |
| bool | isOpaque () const throw () |
| Returns true if no parts of this component are transparent. | |
| void | setBroughtToFrontOnMouseClick (const bool shouldBeBroughtToFront) throw () |
| Indicates whether the component should be brought to the front when clicked. | |
| bool | isBroughtToFrontOnMouseClick () const throw () |
| Indicates whether the component should be brought to the front when clicked-on. | |
| void | setWantsKeyboardFocus (const bool wantsFocus) throw () |
| Sets a flag to indicate whether this component needs keyboard focus or not. | |
| bool | getWantsKeyboardFocus () const throw () |
| Returns true if the component is interested in getting keyboard focus. | |
| void | setMouseClickGrabsKeyboardFocus (const bool shouldGrabFocus) |
| Chooses whether a click on this component automatically grabs the focus. | |
| bool | getMouseClickGrabsKeyboardFocus () const throw () |
| Returns the last value set with setMouseClickGrabsKeyboardFocus(). | |
| void | grabKeyboardFocus () |
| Tries to give keyboard focus to this component. | |
| bool | hasKeyboardFocus (const bool trueIfChildIsFocused) const throw () |
| Returns true if this component currently has the keyboard focus. | |
| void | moveKeyboardFocusToSibling (const bool moveToNext) |
| Tries to move the keyboard focus to one of this component's siblings. | |
| virtual KeyboardFocusTraverser * | createFocusTraverser () |
| Creates a KeyboardFocusTraverser object to use to determine the logic by which focus should be passed from this component. | |
| int | getExplicitFocusOrder () const throw () |
| Returns the focus order of this component, if one has been specified. | |
| void | setExplicitFocusOrder (const int newFocusOrderIndex) throw () |
| Sets the index used in determining the order in which focusable components should be traversed. | |
| void | setFocusContainer (const bool isFocusContainer) throw () |
| Indicates whether this component is a parent for components that can have their focus traversed. | |
| bool | isFocusContainer () const throw () |
| Returns true if this component has been marked as a focus container. | |
| bool | isEnabled () const throw () |
| Returns true if the component (and all its parents) are enabled. | |
| void | setEnabled (const bool shouldBeEnabled) |
| Enables or disables this component. | |
| virtual void | enablementChanged () |
| Callback to indicate that this component has been enabled or disabled. | |
| void | setMouseCursor (const MouseCursor &cursorType) throw () |
| Changes the mouse cursor shape to use when the mouse is over this component. | |
| virtual const MouseCursor | getMouseCursor () |
| Returns the mouse cursor shape to use when the mouse is over this component. | |
| void | updateMouseCursor () const throw () |
| Forces the current mouse cursor to be updated. | |
| virtual void | paint (Graphics &g) |
| Components can override this method to draw their content. | |
| virtual void | paintOverChildren (Graphics &g) |
| Components can override this method to draw over the top of their children. | |
| virtual void | mouseMove (const MouseEvent &e) |
| Called when the mouse moves inside this component. | |
| virtual void | mouseEnter (const MouseEvent &e) |
| Called when the mouse first enters this component. | |
| virtual void | mouseExit (const MouseEvent &e) |
| Called when the mouse moves out of this component. | |
| virtual void | mouseDown (const MouseEvent &e) |
| Called when a mouse button is pressed while it's over this component. | |
| virtual void | mouseDrag (const MouseEvent &e) |
| Called when the mouse is moved while a button is held down. | |
| virtual void | mouseUp (const MouseEvent &e) |
| Called when a mouse button is released. | |
| virtual void | mouseDoubleClick (const MouseEvent &e) |
| Called when a mouse button has been double-clicked in this component. | |
| virtual void | mouseWheelMove (const MouseEvent &e, float wheelIncrementX, float wheelIncrementY) |
| Called when the mouse-wheel is moved. | |
| void | setRepaintsOnMouseActivity (const bool shouldRepaint) throw () |
| Causes automatic repaints when the mouse enters or exits this component. | |
| void | addMouseListener (MouseListener *const newListener, const bool wantsEventsForAllNestedChildComponents) throw () |
| Registers a listener to be told when mouse events occur in this component. | |
| void | removeMouseListener (MouseListener *const listenerToRemove) throw () |
| Deregisters a mouse listener. | |
| void | addKeyListener (KeyListener *const newListener) throw () |
| Adds a listener that wants to hear about keypresses that this component receives. | |
| void | removeKeyListener (KeyListener *const listenerToRemove) throw () |
| Removes a previously-registered key listener. | |
| virtual bool | keyPressed (const KeyPress &key) |
| Called when a key is pressed. | |
| virtual bool | keyStateChanged (const bool isKeyDown) |
| Called when a key is pressed or released. | |
| virtual void | modifierKeysChanged (const ModifierKeys &modifiers) |
| Called when a modifier key is pressed or released. | |
| virtual void | focusGained (FocusChangeType cause) |
| Called to indicate that this component has just acquired the keyboard focus. | |
| virtual void | focusLost (FocusChangeType cause) |
| Called to indicate that this component has just lost the keyboard focus. | |
| virtual void | focusOfChildComponentChanged (FocusChangeType cause) |
| Called to indicate that one of this component's children has been focused or unfocused. | |
| bool | isMouseOver () const throw () |
| Returns true if the mouse is currently over this component. | |
| bool | isMouseButtonDown () const throw () |
| Returns true if the mouse button is currently held down in this component. | |
| bool | isMouseOverOrDragging () const throw () |
| True if the mouse is over this component, or if it's being dragged in this component. | |
| void | getMouseXYRelative (int &x, int &y) const throw () |
| Returns the mouse's current position, relative to this component. | |
| void | enableUnboundedMouseMovement (bool shouldUnboundedMovementBeEnabled, bool keepCursorVisibleUntilOffscreen=false) throw () |
| Allows the mouse to move beyond the edges of the screen. | |
| virtual void | resized () |
| Called when this component's size has been changed. | |
| virtual void | moved () |
| Called when this component's position has been changed. | |
| virtual void | childBoundsChanged (Component *child) |
| Called when one of this component's children is moved or resized. | |
| virtual void | parentSizeChanged () |
| Called when this component's immediate parent has been resized. | |
| virtual void | broughtToFront () |
| Called when this component has been moved to the front of its siblings. | |
| void | addComponentListener (ComponentListener *const newListener) throw () |
| Adds a listener to be told about changes to the component hierarchy or position. | |
| void | removeComponentListener (ComponentListener *const listenerToRemove) throw () |
| Removes a component listener. | |
| void | postCommandMessage (const int commandId) throw () |
| Dispatches a numbered message to this component. | |
| virtual void | handleCommandMessage (int commandId) |
| Called to handle a command that was sent by postCommandMessage(). | |
| int | runModalLoop () |
| Runs a component modally, waiting until the loop terminates. | |
| void | enterModalState (const bool takeKeyboardFocus=true) |
| Puts the component into a modal state. | |
| void | exitModalState (const int returnValue) |
| Ends a component's modal state. | |
| bool | isCurrentlyModal () const throw () |
| Returns true if this component is the modal one. | |
| bool | isCurrentlyBlockedByAnotherModalComponent () const throw () |
| Checks whether there's a modal component somewhere that's stopping this one from receiving messages. | |
| virtual bool | canModalEventBeSentToComponent (const Component *targetComponent) |
| When a component is modal, this callback allows it to choose which other components can still receive events. | |
| virtual void | inputAttemptWhenModal () |
| Called when the user tries to click on a component that is blocked by another modal component. | |
| const String | getComponentProperty (const String &keyName, const bool useParentComponentIfNotFound, const String &defaultReturnValue=String::empty) const throw () |
| Returns one of the component's properties as a string. | |
| int | getComponentPropertyInt (const String &keyName, const bool useParentComponentIfNotFound, const int defaultReturnValue=0) const throw () |
| Returns one of the properties as an integer. | |
| double | getComponentPropertyDouble (const String &keyName, const bool useParentComponentIfNotFound, const double defaultReturnValue=0.0) const throw () |
| Returns one of the properties as an double. | |
| bool | getComponentPropertyBool (const String &keyName, const bool useParentComponentIfNotFound, const bool defaultReturnValue=false) const throw () |
| Returns one of the properties as an boolean. | |
| const Colour | getComponentPropertyColour (const String &keyName, const bool useParentComponentIfNotFound, const Colour &defaultReturnValue=Colours::black) const throw () |
| Returns one of the properties as an colour. | |
| void | setComponentProperty (const String &keyName, const String &value) throw () |
| Sets a named property as a string. | |
| void | setComponentProperty (const String &keyName, const int value) throw () |
| Sets a named property to an integer. | |
| void | setComponentProperty (const String &keyName, const double value) throw () |
| Sets a named property to a double. | |
| void | setComponentProperty (const String &keyName, const bool value) throw () |
| Sets a named property to a boolean. | |
| void | setComponentProperty (const String &keyName, const Colour &newColour) throw () |
| Sets a named property to a colour. | |
| void | removeComponentProperty (const String &keyName) throw () |
| Deletes a named component property. | |
| PropertySet * | getComponentProperties () const throw () |
| Returns the complete set of properties that have been set for this component. | |
| const Colour | findColour (const int colourId, const bool inheritFromParent=false) const throw () |
| Looks for a colour that has been registered with the given colour ID number. | |
| void | setColour (const int colourId, const Colour &colour) |
| Registers a colour to be used for a particular purpose. | |
| void | removeColour (const int colourId) |
| If a colour has been set with setColour(), this will remove it. | |
| bool | isColourSpecified (const int colourId) const throw () |
| Returns true if the specified colour ID has been explicitly set for this component using the setColour() method. | |
| void | copyAllExplicitColoursTo (Component &target) const throw () |
| This looks for any colours that have been specified for this component, and copies them to the specified target component. | |
| virtual void | colourChanged () |
| This method is called when a colour is changed by the setColour() method. | |
| void * | getWindowHandle () const throw () |
| Returns the underlying native window handle for this component. | |
| uint32 | getComponentUID () const throw () |
| When created, each component is given a number to uniquely identify it. | |
Static Public Member Functions | |
| static Component *JUCE_CALLTYPE | getCurrentlyFocusedComponent () throw () |
| Returns the component that currently has the keyboard focus. | |
| static void | beginDragAutoRepeat (const int millisecondIntervalBetweenCallbacks) |
| Ensures that a non-stop stream of mouse-drag events will be sent during the next mouse-drag operation. | |
| static bool JUCE_CALLTYPE | isMouseButtonDownAnywhere () throw () |
| Returns true if a mouse button is currently down. | |
| static Component *JUCE_CALLTYPE | getComponentUnderMouse () throw () |
| Returns the component that's currently underneath the mouse. | |
| static int JUCE_CALLTYPE | getNumCurrentlyModalComponents () throw () |
| Returns the number of components that are currently in a modal state. | |
| static Component *JUCE_CALLTYPE | getCurrentlyModalComponent (int index=0) throw () |
| Returns one of the components that are currently modal. | |
Protected Member Functions | |
| virtual void | internalRepaint (int x, int y, int w, int h) |
| virtual ComponentPeer * | createNewPeer (int styleFlags, void *nativeWindowToAttachTo) |
| void | handleMessage (const Message &) |
| Overridden from the MessageListener parent class. | |
Enumeration used by the focusChanged() and focusLost() methods.
| focusChangedByMouseClick |
Means that the user clicked the mouse to change focus.
|
| focusChangedByTabKey |
Means that the user pressed the tab key to move the focus.
|
| focusChangedDirectly |
Means that the focus was changed by a call to grabKeyboardFocus().
|
| Component::Component | ( | ) | throw () |
Creates a component.
To get it to actually appear, you'll also need to:
And for it to serve any useful purpose, you'll need to write a subclass of Component or use one of the other types of component from the library.
| virtual Component::~Component | ( | ) | [virtual] |
Destructor.
Note that when a component is deleted, any child components it might contain are NOT deleted unless you explicitly call deleteAllChildren() first.
| Component::Component | ( | const String & | componentName | ) | throw () |
| const String& Component::getName | ( | ) | const throw () |
| virtual void Component::setName | ( | const String & | newName | ) | [virtual] |
Sets the name of this component.
When the name changes, all registered ComponentListeners will receive a ComponentListener::componentNameChanged() callback.
Reimplemented in DocumentWindow.
| bool Component::isValidComponent | ( | ) | const throw () |
Checks whether this Component object has been deleted.
This will check whether this object is still a valid component, or whether it's been deleted.
It's safe to call this on null or dangling pointers, but note that there is a small risk if another new (but different) component has been created at the same memory address which this one occupied, this methods can return a false positive.
| virtual void Component::setVisible | ( | bool | shouldBeVisible | ) | [virtual] |
Makes the component visible or invisible.
This method will show or hide the component. Note that components default to being non-visible when first created. Also note that visible components won't be seen unless all their parent components are also visible.
This method will call visibilityChanged() and also componentVisibilityChanged() for any component listeners that are interested in this component.
| shouldBeVisible | whether to show or hide the component |
Reimplemented in Button.
Referenced by LassoComponent< SelectableItemType >::dragLasso(), and LassoComponent< SelectableItemType >::endLasso().
| bool Component::isVisible | ( | ) | const throw () |
Tests whether the component is visible or not.
this doesn't necessarily tell you whether this comp is actually on the screen because this depends on whether all the parent components are also visible - use isShowing() to find this out.
| virtual void Component::visibilityChanged | ( | ) | [virtual] |
Called when this component's visiblility changes.
Reimplemented in ListBox, ProgressBar, WebBrowserComponent, ResizableWindow, and TopLevelWindow.
| bool Component::isShowing | ( | ) | const throw () |
Tests whether this component and all its parents are visible.
Referenced by CarbonViewWrapperComponent::componentVisibilityChanged().
| void Component::fadeOutComponent | ( | const int | lengthOfFadeOutInMilliseconds, | |
| const int | deltaXToMove = 0, |
|||
| const int | deltaYToMove = 0, |
|||
| const float | scaleFactorAtEnd = 1.0f | |||
| ) |
Makes a component invisible using a groovy fade-out and animated zoom effect.
To do this, this function will cunningly:
As soon as this method returns, the component can be safely removed and deleted leaving the proxy to do the fade-out, so it's even ok to call this in a component's destructor.
Passing non-zero x and y values will cause the ghostly component image to also whizz off by this distance while fading out. If the scale factor is not 1.0, it will also zoom from the component's current size to this new size.
One thing to be careful about is that the parent component must be able to cope with this unknown component type being added to it.
| virtual void Component::addToDesktop | ( | int | windowStyleFlags, | |
| void * | nativeWindowToAttachTo = 0 | |||
| ) | [virtual] |
Makes this component appear as a window on the desktop.
Note that before calling this, you should make sure that the component's opacity is set correctly using setOpaque(). If the component is non-opaque, the windowing system will try to create a special transparent window for it, which will generally take a lot more CPU to operate (and might not even be possible on some platforms).
If the component is inside a parent component at the time this method is called, it will be first be removed from that parent. Likewise if a component on the desktop is subsequently added to another component, it'll be removed from the desktop.
| windowStyleFlags | a combination of the flags specified in the ComponentPeer::StyleFlags enum, which define the window's characteristics. | |
| nativeWindowToAttachTo | this allows an OS object to be passed-in as the window in which the juce component should place itself. On Windows, this would be a HWND, a HIViewRef on the Mac. Not necessarily supported on all platforms, and best left as 0 unless you know what you're doing |
Reimplemented in TopLevelWindow.
| void Component::removeFromDesktop | ( | ) |
If the component is currently showing on the desktop, this will hide it.
You can also use setVisible() to hide a desktop window temporarily, but removeFromDesktop() will free any system resources that are being used up.
| bool Component::isOnDesktop | ( | ) | const throw () |
Returns true if this component is currently showing on the desktop.
Referenced by TopLevelWindow::isUsingNativeTitleBar().
| ComponentPeer* Component::getPeer | ( | ) | const throw () |
Returns the heavyweight window that contains this component.
If this component is itself on the desktop, this will return the window object that it is using. Otherwise, it will return the window of its top-level parent component.
This may return 0 if there isn't a desktop component.
| virtual void Component::userTriedToCloseWindow | ( | ) | [virtual] |
For components on the desktop, this is called if the system wants to close the window.
This is a signal that either the user or the system wants the window to close. The default implementation of this method will trigger an assertion to warn you that your component should do something about it, but you can override this to ignore the event if you want.
Reimplemented in AlertWindow, and DocumentWindow.
| virtual void Component::minimisationStateChanged | ( | bool | isNowMinimised | ) | [virtual] |
Called for a desktop component which has just been minimised or un-minimised.
This will only be called for components on the desktop.
| void Component::toFront | ( | const bool | shouldAlsoGainFocus | ) |
Brings the component to the front of its siblings.
If some of the component's siblings have had their 'always-on-top' flag set, then they will still be kept in front of this one (unless of course this one is also 'always-on-top').
| shouldAlsoGainFocus | if true, this will also try to assign keyboard focus to the component (see grabKeyboardFocus() for more details) |
Referenced by CarbonViewWrapperComponent::carbonEventHandler().
| void Component::toBack | ( | ) |
Changes this component's z-order to be at the back of all its siblings.
If the component is set to be 'always-on-top', it will only be moved to the back of the other other 'always-on-top' components.
| void Component::toBehind | ( | Component *const | other | ) |
| void Component::setAlwaysOnTop | ( | const bool | shouldStayOnTop | ) |
Sets whether the component should always be kept at the front of its siblings.
| bool Component::isAlwaysOnTop | ( | ) | const throw () |
Returns true if this component is set to always stay in front of its siblings.
| int Component::getX | ( | ) | const throw () |
Returns the x co-ordinate of the component's left edge.
This is a distance in pixels from the left edge of the component's parent.
Referenced by LassoComponent< SelectableItemType >::dragLasso().
| int Component::getY | ( | ) | const throw () |
Returns the y co-ordinate of the top of this component.
This is a distance in pixels from the top edge of the component's parent.
Referenced by LassoComponent< SelectableItemType >::dragLasso().
| int Component::getWidth | ( | ) | const throw () |
Returns the component's width in pixels.
Referenced by CarbonViewWrapperComponent::createWindow(), LassoComponent< SelectableItemType >::dragLasso(), LassoComponent< SelectableItemType >::paint(), CarbonViewWrapperComponent::setEmbeddedWindowToOurSize(), and CarbonViewWrapperComponent::setOurSizeToEmbeddedViewSize().
| int Component::getHeight | ( | ) | const throw () |
Returns the component's height in pixels.
Referenced by CarbonViewWrapperComponent::createWindow(), LassoComponent< SelectableItemType >::dragLasso(), LassoComponent< SelectableItemType >::paint(), CarbonViewWrapperComponent::setEmbeddedWindowToOurSize(), and CarbonViewWrapperComponent::setOurSizeToEmbeddedViewSize().
| int Component::getRight | ( | ) | const throw () |
Returns the x co-ordinate of the component's right-hand edge.
This is a distance in pixels from the left edge of the component's parent.
| int Component::getBottom | ( | ) | const throw () |
Returns the y co-ordinate of the bottom edge of this component.
This is a distance in pixels from the top edge of the component's parent.
| const Rectangle& Component::getBounds | ( | ) | const throw () |
Returns this component's bounding box.
The rectangle returned is relative to the top-left of the component's parent.
| void Component::getVisibleArea | ( | RectangleList & | result, | |
| const bool | includeSiblings | |||
| ) | const |
Returns the region of this component that's not obscured by other, opaque components.
The RectangleList that is returned represents the area of this component which isn't covered by opaque child components.
If includeSiblings is true, it will also take into account any siblings that may be overlapping the component.
| int Component::getScreenX | ( | ) | const throw () |
Returns this component's x co-ordinate relative the the screen's top-left origin.
Referenced by CarbonViewWrapperComponent::createWindow(), and CarbonViewWrapperComponent::setEmbeddedWindowToOurSize().
| int Component::getScreenY | ( | ) | const throw () |
Returns this component's y co-ordinate relative the the screen's top-left origin.
Referenced by CarbonViewWrapperComponent::createWindow(), and CarbonViewWrapperComponent::setEmbeddedWindowToOurSize().
| void Component::relativePositionToGlobal | ( | int & | x, | |
| int & | y | |||
| ) | const throw () |
Converts a position relative to this component's top-left into a screen co-ordinate.
| void Component::globalPositionToRelative | ( | int & | x, | |
| int & | y | |||
| ) | const throw () |
Converts a screen co-ordinate into a position relative to this component's top-left.
| void Component::relativePositionToOtherComponent | ( | const Component *const | targetComponent, | |
| int & | x, | |||
| int & | y | |||
| ) | const throw () |
Converts a position relative to this component's top-left into a position relative to another component's top-left.
| void Component::setTopLeftPosition | ( | const int | x, | |
| const int | y | |||
| ) |
Moves the component to a new position.
Changes the component's top-left position (without changing its size). The position is relative to the top-left of the component's parent.
If the component actually moves, this method will make a synchronous call to moved().
| void Component::setTopRightPosition | ( | const int | x, | |
| const int | y | |||
| ) |
Moves the component to a new position.
Changes the position of the component's top-right corner (keeping it the same size). The position is relative to the top-left of the component's parent.
If the component actually moves, this method will make a synchronous call to moved().
| void Component::setSize | ( | const int | newWidth, | |
| const int | newHeight | |||
| ) |
Changes the size of the component.
A synchronous call to resized() will be occur if the size actually changes.
Referenced by LassoComponent< SelectableItemType >::beginLasso(), and CarbonViewWrapperComponent::setOurSizeToEmbeddedViewSize().
| void Component::setBounds | ( | int | x, | |
| int | y, | |||
| int | width, | |||
| int | height | |||
| ) |
Changes the component's position and size.
The co-ordinates are relative to the top-left of the component's parent, or relative to the origin of the screen is the component is on the desktop.
If this method changes the component's top-left position, it will make a synchronous call to moved(). If it changes the size, it will also make a call to resized().
Referenced by LassoComponent< SelectableItemType >::dragLasso().
| void Component::setBounds | ( | const Rectangle & | newBounds | ) |
| void Component::setBoundsRelative | ( | const float | proportionalX, | |
| const float | proportionalY, | |||
| const float | proportionalWidth, | |||
| const float | proportionalHeight | |||
| ) |
Changes the component's position and size in terms of fractions of its parent's size.
The values are factors of the parent's size, so for example setBoundsRelative (0.2f, 0.2f, 0.5f, 0.5f) would give it half the width and height of the parent, with its top-left position 20% of the way across and down the parent.
| void Component::setBoundsInset | ( | const BorderSize & | borders | ) |
Changes the component's position and size based on the amount of space to leave around it.
This will position the component within its parent, leaving the specified number of pixels around each edge.
| void Component::setBoundsToFit | ( | int | x, | |
| int | y, | |||
| int | width, | |||
| int | height, | |||
| const Justification & | justification, | |||
| const bool | onlyReduceInSize | |||
| ) |
Positions the component within a given rectangle, keeping its proportions unchanged.
If onlyReduceInSize is false, the component will be resized to fill as much of the rectangle as possible without changing its aspect ratio (the component's current size is used to determine its aspect ratio, so a zero-size component won't work here). If onlyReduceInSize is true, it will only be resized if it's too big to fit inside the rectangle.
It will then be positioned within the rectangle according to the justification flags specified.
| void Component::setCentrePosition | ( | const int | x, | |
| const int | y | |||
| ) |
Changes the position of the component's centre.
Leaves the component's size unchanged, but sets the position of its centre relative to its parent's top-left.
| void Component::setCentreRelative | ( | const float | x, | |
| const float | y | |||
| ) |
Changes the position of the component's centre.
Leaves the position unchanged, but positions its centre relative to its parent's size. E.g. setCentreRelative (0.5f, 0.5f) would place it centrally in its parent.
| void Component::centreWithSize | ( | const int | width, | |
| const int | height | |||
| ) |
Changes the component's size and centres it within its parent.
After changing the size, the component will be moved so that it's centred within its parent.
| int Component::proportionOfWidth | ( | const float | proportion | ) | const throw () |
Returns a proportion of the component's width.
This is a handy equivalent of (getWidth() * proportion).
| int Component::proportionOfHeight | ( | const float | proportion | ) | const throw () |
Returns a proportion of the component's height.
This is a handy equivalent of (getHeight() * proportion).
| int Component::getParentWidth | ( | ) | const throw () |
Returns the width of the component's parent.
If the component has no parent (i.e. if it's on the desktop), this will return the width of the screen.
| int Component::getParentHeight | ( | ) | const throw () |
Returns the height of the component's parent.
If the component has no parent (i.e. if it's on the desktop), this will return the height of the screen.
| const Rectangle Component::getParentMonitorArea | ( | ) | const throw () |
Returns the screen co-ordinates of the monitor that contains this component.
If there's only one monitor, this will return its size - if there are multiple monitors, it will return the area of the monitor that contains the component's centre.
| int Component::getNumChildComponents | ( | ) | const throw () |
Returns the number of child components that this component contains.
| Component* Component::getChildComponent | ( | const int | index | ) | const throw () |
Returns one of this component's child components, by it index.
The component with index 0 is at the back of the z-order, the one at the front will have index (getNumChildComponents() - 1).
If the index is out-of-range, this will return a null pointer.
| int Component::getIndexOfChildComponent | ( | const Component *const | child | ) | const throw () |
Returns the index of this component in the list of child components.
A value of 0 means it is first in the list (i.e. behind all other components). Higher values are further towards the front.
Returns -1 if the component passed-in is not a child of this component.
| void Component::addChildComponent | ( | Component *const | child, | |
| int | zOrder = -1 | |||
| ) |
Adds a child component to this one.
| child | the new component to add. If the component passed-in is already the child of another component, it'll first be removed from that. | |
| zOrder | The index in the child-list at which this component should be inserted. A value of -1 will insert it in front of the others, 0 is the back. |
| void Component::addAndMakeVisible | ( | Component *const | child, | |
| int | zOrder = -1 | |||
| ) |
Adds a child component to this one, and also makes the child visible if it isn't.
Quite a useful function, this is just the same as calling addChildComponent() followed by setVisible (true) on the child.
| void Component::removeChildComponent | ( | Component *const | childToRemove | ) |
Removes one of this component's child-components.
If the child passed-in isn't actually a child of this component (either because it's invalid or is the child of a different parent), then nothing is done.
Note that removing a child will not delete it!
| Component* Component::removeChildComponent | ( | const int | childIndexToRemove | ) |
Removes one of this component's child-components by index.
This will return a pointer to the component that was removed, or null if the index was out-of-range.
Note that removing a child will not delete it!
| void Component::removeAllChildren | ( | ) |
Removes all this component's children.
Note that this won't delete them! To do that, use deleteAllChildren() instead.
| void Component::deleteAllChildren | ( | ) |
| Component* Component::getParentComponent | ( | ) | const throw () |
Returns the component which this component is inside.
If this is the highest-level component or hasn't yet been added to a parent, this will return null.
Referenced by LassoComponent< SelectableItemType >::beginLasso(), and CarbonViewWrapperComponent::setOurSizeToEmbeddedViewSize().
| TargetClass* Component::findParentComponentOfClass | ( | TargetClass *const | dummyParameter = 0 |
) | const |
Searches the parent components for a component of a specified class.
For example findParentComponentOfClass <MyComp>() would return the first parent component that can be dynamically cast to a MyComp, or will return 0 if none of the parents are suitable.
N.B. The dummy parameter is needed to work around a VC6 compiler bug.
| Component* Component::getTopLevelComponent | ( | ) | const throw () |
Returns the highest-level component which contains this one or its parents.
This will search upwards in the parent-hierarchy from this component, until it finds the highest one that doesn't have a parent (i.e. is on the desktop or not yet added to a parent), and will return that.
Referenced by CarbonViewWrapperComponent::carbonEventHandler().
| bool Component::isParentOf | ( | const Component * | possibleChild | ) | const throw () |
Checks whether a component is anywhere inside this component or its children.
This will recursively check through this components children to see if the given component is anywhere inside.
| virtual void Component::parentHierarchyChanged | ( | ) | [virtual] |
Called to indicate that the component's parents have changed.
When a component is added or removed from its parent, this method will be called on all of its children (recursively - so all children of its children will also be called as well).
Subclasses can override this if they need to react to this in some way.
Reimplemented in Button, KeyMappingEditorComponent, WebBrowserComponent, DocumentWindow, and TopLevelWindow.
| virtual void Component::childrenChanged | ( | ) | [virtual] |
Subclasses can use this callback to be told when children are added or removed.
| virtual bool Component::hitTest | ( | int | x, | |
| int | y | |||
| ) | [virtual] |
Tests whether a given point inside the component.
Overriding this method allows you to create components which only intercept mouse-clicks within a user-defined area.
This is called to find out whether a particular x, y co-ordinate is considered to be inside the component or not, and is used by methods such as contains() and getComponentAt() to work out which component the mouse is clicked on.
Components with custom shapes will probably want to override it to perform some more complex hit-testing.
The default implementation of this method returns either true or false, depending on the value that was set by calling setInterceptsMouseClicks() (true is the default return value).
Note that the hit-test region is not related to the opacity with which areas of a component are painted.
Applications should never call hitTest() directly - instead use the contains() method, because this will also test for occlusion by the component's parent.
Note that for components on the desktop, this method will be ignored, because it's not always possible to implement this behaviour on all platforms.
| x | the x co-ordinate to test, relative to the left hand edge of this component. This value is guaranteed to be greater than or equal to zero, and less than the component's width | |
| y | the y co-ordinate to test, relative to the top edge of this component. This value is guaranteed to be greater than or equal to zero, and less than the component's height |
Reimplemented in ImageButton, ResizableBorderComponent, ResizableCornerComponent, TabBarButton, and LassoComponent< SelectableItemType >.
| void Component::setInterceptsMouseClicks | ( | const bool | allowClicksOnThisComponent, | |
| const bool | allowClicksOnChildComponents | |||
| ) | throw () |
Changes the default return value for the hitTest() method.
Setting this to false is an easy way to make a component pass its mouse-clicks through to the components behind it.
When a component is created, the default setting for this is true.
| allowClicksOnThisComponent | if true, hitTest() will always return true; if false, it will return false (or true for child components if allowClicksOnChildComponents is true) | |
| allowClicksOnChildComponents | if this is true and allowClicksOnThisComponent is false, then child components can be clicked on as normal but clicks on this component pass straight through; if this is false and allowClicksOnThisComponent is false, then neither this component nor any child components can be clicked on |
| void Component::getInterceptsMouseClicks | ( | bool & | allowsClicksOnThisComponent, | |
| bool & | allowsClicksOnChildComponents | |||
| ) | const throw () |
Retrieves the current state of the mouse-click interception flags.
On return, the two parameters are set to the state used in the last call to setInterceptsMouseClicks().
| virtual bool Component::contains | ( | int | x, | |
| int | y | |||
| ) | [virtual] |
Returns true if a given point lies within this component or one of its children.
Never override this method! Use hitTest to create custom hit regions.
| x | the x co-ordinate to test, relative to this component's left hand edge. | |
| y | the y co-ordinate to test, relative to this component's top edge. |
| bool Component::reallyContains | ( | int | x, | |
| int | y, | |||
| const bool | returnTrueIfWithinAChild | |||
| ) |
Returns true if a given point lies in this component, taking any overlapping siblings into account.
| x | the x co-ordinate to test, relative to this component's left hand edge. | |
| y | the y co-ordinate to test, relative to this component's top edge. | |
| returnTrueIfWithinAChild | if the point actually lies within a child of this component, this determines the value that will be returned. |
| Component* Component::getComponentAt | ( | const int | x, | |
| const int | y | |||
| ) |
Returns the component at a certain point within this one.
| x | the x co-ordinate to test, relative to this component's left hand edge. | |
| y | the y co-ordinate to test, relative to this component's top edge. |
| void Component::repaint | ( | ) | throw () |
Marks the whole component as needing to be redrawn.
Calling this will not do any repainting immediately, but will mark the component as 'dirty'. At some point in the near future the operating system will send a paint message, which will redraw all the dirty regions of all components. There's no guarantee about how soon after calling repaint() the redraw will actually happen, and other queued events may be delivered before a redraw is done.
If the setBufferedToImage() method has been used to cause this component to use a buffer, the repaint() call will invalidate the component's buffer.
To redraw just a subsection of the component rather than the whole thing, use the repaint (int, int, int, int) method.
| void Component::repaint | ( | const int | x, | |
| const int | y, | |||
| const int | width, | |||
| const int | height | |||
| ) | throw () |
Marks a subsection of this component as needing to be redrawn.
Calling this will not do any repainting immediately, but will mark the given region of the component as 'dirty'. At some point in the near future the operating system will send a paint message, which will redraw all the dirty regions of all components. There's no guarantee about how soon after calling repaint() the redraw will actually happen, and other queued events may be delivered before a redraw is done.
The region that is passed in will be clipped to keep it within the bounds of this component.
| void Component::setBufferedToImage | ( | const bool | shouldBeBuffered | ) | throw () |
Makes the component use an internal buffer to optimise its redrawing.
Setting this flag to true will cause the component to allocate an internal buffer into which it paints itself, so that when asked to redraw itself, it can use this buffer rather than actually calling the paint() method.
The buffer is kept until the repaint() method is called directly on this component (or until it is resized), when the image is invalidated and then redrawn the next time the component is painted.
Note that only the drawing that happens within the component's paint() method is drawn into the buffer, it's child components are not buffered, and nor is the paintOverChildren() method.
| Image* Component::createComponentSnapshot | ( | const Rectangle & | areaToGrab, | |
| const bool | clipImageToComponentBounds = true | |||
| ) |
Generates a snapshot of part of this component.
This will return a new Image, the size of the rectangle specified, containing a snapshot of the specified area of the component and all its children.
The image may or may not have an alpha-channel, depending on whether the image is opaque or not.
If the clipImageToComponentBounds parameter is true and the area is greater than the size of the component, it'll be clipped. If clipImageToComponentBounds is false then parts of the component beyond its bounds can be drawn.
The caller is responsible for deleting the image that is returned.
| void Component::paintEntireComponent | ( | Graphics & | context | ) |
Draws this component and all its subcomponents onto the specified graphics context.
You should very rarely have to use this method, it's simply there in case you need to draw a component with a custom graphics context for some reason, e.g. for creating a snapshot of the component.
It calls paint(), paintOverChildren() and recursively calls paintEntireComponent() on its children in order to render the entire tree.
The graphics context may be left in an undefined state after this method returns, so you may need to reset it if you're going to use it again.
| void Component::setComponentEffect | ( | ImageEffectFilter *const | newEffect | ) |
Adds an effect filter to alter the component's appearance.
When a component has an effect filter set, then this is applied to the results of its paint() method. There are a few preset effects, such as a drop-shadow or glow, but they can be user-defined as well.
The effect that is passed in will not be deleted by the component - the caller must take care of deleting it.
To remove an effect from a component, pass a null pointer in as the parameter.
| ImageEffectFilter* Component::getComponentEffect | ( | ) | const throw () |
| LookAndFeel& Component::getLookAndFeel | ( | ) | const throw () |
Finds the appropriate look-and-feel to use for this component.
If the component hasn't had a look-and-feel explicitly set, this will return the parent's look-and-feel, or just the default one if there's no parent.
| void Component::setLookAndFeel | ( | LookAndFeel *const | newLookAndFeel | ) |
Sets the look and feel to use for this component.
This will also change the look and feel for any child components that haven't had their look set explicitly.
The object passed in will not be deleted by the component, so it's the caller's responsibility to manage it. It may be used at any time until this component has been deleted.
Calling this method will also invoke the sendLookAndFeelChange() method.
| virtual void Component::lookAndFeelChanged | ( | ) | [virtual] |
Called to let the component react to a change in the look-and-feel setting.
When the look-and-feel is changed for a component, this will be called in all its child components, recursively.
It can also be triggered manually by the sendLookAndFeelChange() method, in case an application uses a LookAndFeel class that might have changed internally.
Reimplemented in ComboBox, ProgressBar, Slider, FilenameComponent, ScrollBar, TabbedButtonBar, TabbedComponent, AlertWindow, DocumentWindow, and ResizableWindow.
| void Component::sendLookAndFeelChange | ( | ) |
Calls the lookAndFeelChanged() method in this component and all its children.
This will recurse through the children and their children, calling lookAndFeelChanged() on them all.
| void Component::setOpaque | ( | const bool | shouldBeOpaque | ) | throw () |
Indicates whether any parts of the component might be transparent.
Components that always paint all of their contents with solid colour and thus completely cover any components behind them should use this method to tell the repaint system that they are opaque.
This information is used to optimise drawing, because it means that objects underneath opaque windows don't need to be painted.
By default, components are considered transparent, unless this is used to make it otherwise.
| bool Component::isOpaque | ( | ) | const throw () |
Returns true if no parts of this component are transparent.
| void Component::setBroughtToFrontOnMouseClick | ( | const bool | shouldBeBroughtToFront | ) | throw () |
Indicates whether the component should be brought to the front when clicked.
Setting this flag to true will cause the component to be brought to the front when the mouse is clicked somewhere inside it or its child components.
Note that a top-level desktop window might still be brought to the front by the operating system when it's clicked, depending on how the OS works.
By default this is set to false.
| bool Component::isBroughtToFrontOnMouseClick | ( | ) | const throw () |
Indicates whether the component should be brought to the front when clicked-on.
| void Component::setWantsKeyboardFocus | ( | const bool | wantsFocus | ) | throw () |
Sets a flag to indicate whether this component needs keyboard focus or not.
By default components aren't actually interested in gaining the focus, but this method can be used to turn this on.
See the grabKeyboardFocus() method for details about the way a component is chosen to receive the focus.
| bool Component::getWantsKeyboardFocus | ( | ) | const throw () |
Returns true if the component is interested in getting keyboard focus.
This returns the flag set by setWantsKeyboardFocus(). The default setting is false.
| void Component::setMouseClickGrabsKeyboardFocus | ( | const bool | shouldGrabFocus | ) |
Chooses whether a click on this component automatically grabs the focus.
By default this is set to true, but you might want a component which can be focused, but where you don't want the user to be able to affect it directly by clicking.
| bool Component::getMouseClickGrabsKeyboardFocus | ( | ) | const throw () |
Returns the last value set with setMouseClickGrabsKeyboardFocus().
See setMouseClickGrabsKeyboardFocus() for more info.
| void Component::grabKeyboardFocus | ( | ) |
Tries to give keyboard focus to this component.
When the user clicks on a component or its grabKeyboardFocus() method is called, the following procedure is used to work out which component should get it:
| bool Component::hasKeyboardFocus | ( | const bool | trueIfChildIsFocused | ) | const throw () |
Returns true if this component currently has the keyboard focus.
| trueIfChildIsFocused | if this is true, then the method returns true if either this component or any of its children (recursively) have the focus. If false, the method only returns true if this component has the focus. |
| static Component* JUCE_CALLTYPE Component::getCurrentlyFocusedComponent | ( | ) | throw () [static] |
Returns the component that currently has the keyboard focus.
| void Component::moveKeyboardFocusToSibling | ( | const bool | moveToNext | ) |
Tries to move the keyboard focus to one of this component's siblings.
This will try to move focus to either the next or previous component. (This is the method that is used when shifting focus by pressing the tab key).
Components for which getWantsKeyboardFocus() returns false are not looked at.
| moveToNext | if true, the focus will move forwards; if false, it will move backwards |
| virtual KeyboardFocusTraverser* Component::createFocusTraverser | ( | ) | [virtual] |
Creates a KeyboardFocusTraverser object to use to determine the logic by which focus should be passed from this component.
The default implementation of this method will return a default KeyboardFocusTraverser if this component is a focus container (as determined by the setFocusContainer() method). If the component isn't a focus container, then it will recursively ask its parents for a KeyboardFocusTraverser.
If you overrride this to return a custom KeyboardFocusTraverser, then this component and all its sub-components will use the new object to make their focusing decisions.
The method should return a new object, which the caller is required to delete when no longer needed.
Reimplemented in Label.
| int Component::getExplicitFocusOrder | ( | ) | const throw () |
Returns the focus order of this component, if one has been specified.
By default components don't have a focus order - in that case, this will return 0. Lower numbers indicate that the component will be earlier in the focus traversal order.
To change the order, call setExplicitFocusOrder().
The focus order may be used by the KeyboardFocusTraverser class as part of its algorithm for deciding the order in which components should be traversed. See the KeyboardFocusTraverser class for more details on this.
| void Component::setExplicitFocusOrder | ( | const int | newFocusOrderIndex | ) | throw () |
Sets the index used in determining the order in which focusable components should be traversed.
A value of 0 or less is taken to mean that no explicit order is wanted, and that traversal should use other factors, like the component's position.
| void Component::setFocusContainer | ( | const bool | isFocusContainer | ) | throw () |
Indicates whether this component is a parent for components that can have their focus traversed.
This flag is used by the default implementation of the createFocusTraverser() method, which uses the flag to find the first parent component (of the currently focused one) which wants to be a focus container.
So using this method to set the flag to 'true' causes this component to act as the top level within which focus is passed around.
| bool Component::isFocusContainer | ( | ) | const throw () |
Returns true if this component has been marked as a focus container.
See setFocusContainer() for more details.
| bool Component::isEnabled | ( | ) | const throw () |
Returns true if the component (and all its parents) are enabled.
Components are enabled by default, and can be disabled with setEnabled(). Exactly what difference this makes to the component depends on the type. E.g. buttons and sliders will choose to draw themselves differently, etc.
Note that if one of this component's parents is disabled, this will always return false, even if this component itself is enabled.
| void Component::setEnabled | ( | const bool | shouldBeEnabled | ) |
Enables or disables this component.
Disabling a component will also cause all of its child components to become disabled.
Similarly, enabling a component which is inside a disabled parent component won't make any difference until the parent is re-enabled.
| virtual void Component::enablementChanged | ( | ) | [virtual] |
Callback to indicate that this component has been enabled or disabled.
This can be triggered by one of the component's parent components being enabled or disabled, as well as changes to the component itself.
The default implementation of this method does nothing; your class may wish to repaint itself or something when this happens.
Reimplemented in Button, ComboBox, Label, Slider, TextEditor, TreeView, GroupComponent, and PropertyComponent.
| void Component::setMouseCursor | ( | const MouseCursor & | cursorType | ) | throw () |
Changes the mouse cursor shape to use when the mouse is over this component.
Note that the cursor set by this method can be overridden by the getMouseCursor method.
| virtual const MouseCursor Component::getMouseCursor | ( | ) | [virtual] |
Returns the mouse cursor shape to use when the mouse is over this component.
The default implementation will return the cursor that was set by setCursor() but can be overridden for more specialised purposes, e.g. returning different cursors depending on the mouse position.
Reimplemented in TableHeaderComponent.
| void Component::updateMouseCursor | ( | ) | const throw () |
Forces the current mouse cursor to be updated.
If you're overriding the getMouseCursor() method to control which cursor is displayed, then this will only be checked each time the user moves the mouse. So if you want to force the system to check that the cursor being displayed is up-to-date (even if the mouse is just sitting there), call this method.
This isn't needed if you're only using setMouseCursor().
| virtual void Component::paint | ( | Graphics & | g | ) | [virtual] |
Components can override this method to draw their content.
The paint() method gets called when a region of a component needs redrawing, either because the component's repaint() method has been called, or because something has happened on the screen that means a section of a window needs to be redrawn.
Any child components will draw themselves over whatever this method draws. If you need to paint over the top of your child components, you can also implement the paintOverChildren() method to do this.
If you want to cause a component to redraw itself, this is done asynchronously - calling the repaint() method marks a region of the component as "dirty", and the paint() method will automatically be called sometime later, by the message thread, to paint any bits that need refreshing. In Juce (and almost all modern UI frameworks), you never redraw something synchronously.
You should never need to call this method directly - to take a snapshot of the component you could use createComponentSnapshot() or paintEntireComponent().
| g | the graphics context that must be used to do the drawing operations. |
Reimplemented in GenericAudioProcessorEditor, Button, CodeEditorComponent, ComboBox, Label, ListBox, ProgressBar, Slider, TableHeaderComponent, TextEditor, Toolbar, TreeView, FileSearchPathListComponent, ImagePreviewComponent, GroupComponent, MultiDocumentPanel, ResizableBorderComponent, ResizableCornerComponent, ScrollBar, StretchableLayoutResizerBar, TabbedComponent, MenuBarComponent, LassoComponent< SelectableItemType >, BooleanPropertyComponent, PropertyComponent, PropertyPanel, ActiveXControlComponent, BubbleComponent, MidiKeyboardComponent, NSViewComponent, OpenGLComponent, PreferencesPanel, QuickTimeMovieComponent, SystemTrayIconComponent, WebBrowserComponent, AlertWindow, DocumentWindow, ResizableWindow, and SplashScreen.
| virtual void Component::paintOverChildren | ( | Graphics & | g | ) | [virtual] |
Components can override this method to draw over the top of their children.
For most drawing operations, it's better to use the normal paint() method, but if you need to overlay something on top of the children, this can be used.
Reimplemented in ListBox, TextEditor, and FilenameComponent.
| virtual void Component::mouseMove | ( | const MouseEvent & | e | ) | [virtual] |
Called when the mouse moves inside this component.
If the mouse button isn't pressed and the mouse moves over a component, this will be called to let the component react to this.
A component will always get a mouseEnter callback before a mouseMove.
| e | details about the position and status of the mouse event |
Reimplemented from MouseListener.
Reimplemented in ListBox, TableHeaderComponent, ResizableBorderComponent, MenuBarComponent, and MidiKeyboardComponent.
| virtual void Component::mouseEnter | ( | const MouseEvent & | e | ) | [virtual] |
Called when the mouse first enters this component.
If the mouse button isn't pressed and the mouse moves into a component, this will be called to let the component react to this.
When the mouse button is pressed and held down while being moved in or out of a component, no mouseEnter or mouseExit callbacks are made - only mouseDrag messages are sent to the component that the mouse was originally clicked on, until the button is released.
If you're writing a component that needs to repaint itself when the mouse enters and exits, it might be quicker to use the setRepaintsOnMouseActivity() method.
| e | details about the position and status of the mouse event |
Reimplemented from MouseListener.
Reimplemented in Button, TableHeaderComponent, ResizableBorderComponent, MenuBarComponent, and MidiKeyboardComponent.
| virtual void Component::mouseExit | ( | const MouseEvent & | e | ) | [virtual] |
Called when the mouse moves out of this component.
This will be called when the mouse moves off the edge of this component.
If the mouse button was pressed, and it was then dragged off the edge of the component and released, then this callback will happen when the button is released, after the mouseUp callback.
If you're writing a component that needs to repaint itself when the mouse enters and exits, it might be quicker to use the setRepaintsOnMouseActivity() method.
| e | details about the position and status of the mouse event |
Reimplemented from MouseListener.
Reimplemented in Button, ListBox, TableHeaderComponent, MenuBarComponent, and MidiKeyboardComponent.
| virtual void Component::mouseDown | ( | const MouseEvent & | e | ) | [virtual] |
Called when a mouse button is pressed while it's over this component.
The MouseEvent object passed in contains lots of methods for finding out which button was pressed, as well as which modifier keys (e.g. shift, ctrl) were held down at the time.
Once a button is held down, the mouseDrag method will be called when the mouse moves, until the button is released.
| e | details about the position and status of the mouse event |
Reimplemented from MouseListener.
Reimplemented in Button, CodeEditorComponent, ComboBox, Slider, TableHeaderComponent, TextEditor, Toolbar, ResizableBorderComponent, ResizableCornerComponent, ScrollBar, StretchableLayoutResizerBar, MenuBarComponent, MidiKeyboardComponent, AlertWindow, and ResizableWindow.
| virtual void Component::mouseDrag | ( | const MouseEvent & | e | ) | [virtual] |
Called when the mouse is moved while a button is held down.
When a mouse button is pressed inside a component, that component receives mouseDrag callbacks each time the mouse moves, even if the mouse strays outside the component's bounds.
If you want to be able to drag things off the edge of a component and have the component scroll when you get to the edges, the beginDragAutoRepeat() method might be useful.
| e | details about the position and status of the mouse event |
Reimplemented from MouseListener.
Reimplemented in Button, CodeEditorComponent, ComboBox, Slider, TableHeaderComponent, TextEditor, ResizableBorderComponent, ResizableCornerComponent, ScrollBar, StretchableLayoutResizerBar, MenuBarComponent, MidiKeyboardComponent, AlertWindow, and ResizableWindow.
| virtual void Component::mouseUp | ( | const MouseEvent & | e | ) | [virtual] |
Called when a mouse button is released.
A mouseUp callback is sent to the component in which a button was pressed even if the mouse is actually over a different component when the button is released.
The MouseEvent object passed in contains lots of methods for finding out which buttons were down just before they were released.
| e | details about the position and status of the mouse event |
Reimplemented from MouseListener.
Reimplemented in Button, CodeEditorComponent, ComboBox, Label, ListBox, Slider, TableHeaderComponent, TextEditor, ResizableBorderComponent, ResizableCornerComponent, ScrollBar, MenuBarComponent, and MidiKeyboardComponent.
| virtual void Component::mouseDoubleClick | ( | const MouseEvent & | e | ) | [virtual] |
Called when a mouse button has been double-clicked in this component.
The MouseEvent object passed in contains lots of methods for finding out which button was pressed, as well as which modifier keys (e.g. shift, ctrl) were held down at the time.
For altering the time limit used to detect double-clicks, see MouseEvent::setDoubleClickTimeout.
| e | details about the position and status of the mouse event |
Reimplemented from MouseListener.
Reimplemented in CodeEditorComponent, Label, Slider, TextEditor, and DocumentWindow.
| virtual void Component::mouseWheelMove | ( | const MouseEvent & | e, | |
| float | wheelIncrementX, | |||
| float | wheelIncrementY | |||
| ) | [virtual] |
Called when the mouse-wheel is moved.
This callback is sent to the component that the mouse is over when the wheel is moved.
If not overridden, the component will forward this message to its parent, so that parent components can collect mouse-wheel messages that happen to child components which aren't interested in them.
| e | details about the position and status of the mouse event | |
| wheelIncrementX | the speed and direction of the horizontal scroll-wheel - a positive value means the wheel has been pushed to the right, negative means it was pushed to the left | |
| wheelIncrementY | the speed and direction of the vertical scroll-wheel - a positive value means the wheel has been pushed upwards, negative means it was pushed downwards |
Reimplemented from MouseListener.
Reimplemented in CodeEditorComponent, ListBox, Slider, TextEditor, ScrollBar, Viewport, and MidiKeyboardComponent.
| static void Component::beginDragAutoRepeat | ( | const int | millisecondIntervalBetweenCallbacks | ) | [static] |
Ensures that a non-stop stream of mouse-drag events will be sent during the next mouse-drag operation.
This allows you to make sure that mouseDrag() events sent continuously, even when the mouse isn't moving. This can be useful for things like auto-scrolling components when the mouse is near an edge.
Call this method during a mouseDown() or mouseDrag() callback, specifying the minimum interval between consecutive mouse drag callbacks. The callbacks will continue until the mouse is released, and then the interval will be reset, so you need to make sure it's called every time you begin a drag event. If it is called when the mouse isn't actually being pressed, it will apply to the next mouse-drag operation that happens.
Passing an interval of 0 or less will cancel the auto-repeat.
| void Component::setRepaintsOnMouseActivity | ( | const bool | shouldRepaint | ) | throw () |
Causes automatic repaints when the mouse enters or exits this component.
If turned on, then when the mouse enters/exits, or when the button is pressed/released on the component, it will trigger a repaint.
This is handy for things like buttons that need to draw themselves differently when the mouse moves over them, and it avoids having to override all the different mouse callbacks and call repaint().
| void Component::addMouseListener | ( | MouseListener *const | newListener, | |
| const bool | wantsEventsForAllNestedChildComponents | |||
| ) | throw () |
Registers a listener to be told when mouse events occur in this component.
If you need to get informed about mouse events in a component but can't or don't want to override its methods, you can attach any number of listeners to the component, and these will get told about the events in addition to the component's own callbacks being called.
Note that a MouseListener can also be attached to more than one component.
| newListener | the listener to register | |
| wantsEventsForAllNestedChildComponents | if true, the listener will receive callbacks for events that happen to any child component within this component, including deeply-nested child components. If false, it will only be told about events that this component handles. |
| void Component::removeMouseListener | ( | MouseListener *const | listenerToRemove | ) | throw () |
| void Component::addKeyListener | ( | KeyListener *const | newListener | ) | throw () |
Adds a listener that wants to hear about keypresses that this component receives.
The listeners that are registered with a component are called by its keyPressed() or keyStateChanged() methods (assuming these haven't been overridden to do something else).
If you add an object as a key listener, be careful to remove it when the object is deleted, or the component will be left with a dangling pointer.
| void Component::removeKeyListener | ( | KeyListener *const | listenerToRemove | ) | throw () |
| virtual bool Component::keyPressed | ( | const KeyPress & | key | ) | [virtual] |
Called when a key is pressed.
When a key is pressed, the component that has the keyboard focus will have this method called. Remember that a component will only be given the focus if its setWantsKeyboardFocus() method has been used to enable this.
If your implementation returns true, the event will be consumed and not passed on to any other listeners. If it returns false, the key will be passed to any KeyListeners that have been registered with this component. As soon as one of these returns true, the process will stop, but if they all return false, the event will be passed upwards to this component's parent, and so on.
The default implementation of this method does nothing and returns false.
Reimplemented in Button, CodeEditorComponent, ComboBox, ListBox, TextEditor, TreeView, FileBrowserComponent, ScrollBar, Viewport, MenuBarComponent, and AlertWindow.
| virtual bool Component::keyStateChanged | ( | const bool | isKeyDown | ) | [virtual] |
Called when a key is pressed or released.
Whenever a key on the keyboard is pressed or released (including modifier keys like shift and ctrl), this method will be called on the component that currently has the keyboard focus. Remember that a component will only be given the focus if its setWantsKeyboardFocus() method has been used to enable this.
If your implementation returns true, the event will be consumed and not passed on to any other listeners. If it returns false, then any KeyListeners that have been registered with this component will have their keyStateChanged methods called. As soon as one of these returns true, the process will stop, but if they all return false, the event will be passed upwards to this component's parent, and so on.
The default implementation of this method does nothing and returns false.
To find out which keys are up or down at any time, see the KeyPress::isKeyCurrentlyDown() method.
| isKeyDown | true if a key has been pressed; false if it has been released |
Reimplemented in ComboBox, ListBox, TextEditor, and MidiKeyboardComponent.
| virtual void Component::modifierKeysChanged | ( | const ModifierKeys & | modifiers | ) | [virtual] |
Called when a modifier key is pressed or released.
Whenever the shift, control, alt or command keys are pressed or released, this method will be called on the component that currently has the keyboard focus. Remember that a component will only be given the focus if its setWantsKeyboardFocus() method has been used to enable this.
The default implementation of this method actually calls its parent's modifierKeysChanged method, so that focused components which aren't interested in this will give their parents a chance to act on the event instead.
Reimplemented in Slider.
| virtual void Component::focusGained | ( | FocusChangeType | cause | ) | [virtual] |
Called to indicate that this component has just acquired the keyboard focus.
Reimplemented in Button, ComboBox, Label, and TextEditor.
| virtual void Component::focusLost | ( | FocusChangeType | cause | ) | [virtual] |
Called to indicate that this component has just lost the keyboard focus.
Reimplemented in Button, ComboBox, TextEditor, and MidiKeyboardComponent.
| virtual void Component::focusOfChildComponentChanged | ( | FocusChangeType | cause | ) | [virtual] |
Called to indicate that one of this component's children has been focused or unfocused.
Essentially this means that the return value of a call to hasKeyboardFocus (true) has changed. It happens when focus moves from one of this component's children (at any depth) to a component that isn't contained in this one, (or vice-versa).
Reimplemented in Slider, and TopLevelWindow.
| bool Component::isMouseOver | ( | ) | const throw () |
Returns true if the mouse is currently over this component.
If the mouse isn't over the component, this will return false, even if the mouse is currently being dragged - so you can use this in your mouseDrag method to find out whether it's really over the component or not.
Note that when the mouse button is being held down, then the only component for which this method will return true is the one that was originally clicked on.
| bool Component::isMouseButtonDown | ( | ) | const throw () |
Returns true if the mouse button is currently held down in this component.
Note that this is a test to see whether the mouse is being pressed in this component, so it'll return false if called on component A when the mouse is actually being dragged in component B.
| bool Component::isMouseOverOrDragging | ( | ) | const throw () |
True if the mouse is over this component, or if it's being dragged in this component.
This is a handy equivalent to (isMouseOver() || isMouseButtonDown()).
| static bool JUCE_CALLTYPE Component::isMouseButtonDownAnywhere | ( | ) | throw () [static] |
Returns true if a mouse button is currently down.
Unlike isMouseButtonDown, this will test the current state of the buttons without regard to which component (if any) it has been pressed in.
Referenced by LassoComponent< SelectableItemType >::paint().
| void Component::getMouseXYRelative | ( | int & | x, | |
| int & | y | |||
| ) | const throw () |
Returns the mouse's current position, relative to this component.
The co-ordinates are relative to the component's top-left corner.
| static Component* JUCE_CALLTYPE Component::getComponentUnderMouse | ( | ) | throw () [static] |
Returns the component that's currently underneath the mouse.
| void Component::enableUnboundedMouseMovement | ( | bool | shouldUnboundedMovementBeEnabled, | |
| bool | keepCursorVisibleUntilOffscreen = false | |||
| ) | throw () |
Allows the mouse to move beyond the edges of the screen.
Calling this method when the mouse button is currently pressed inside this component will remove the cursor from the screen and allow the mouse to (seem to) move beyond the edges of the screen.
This means that the co-ordinates returned to mouseDrag() will be unbounded, and this can be used for things like custom slider controls or dragging objects around, where movement would be otherwise be limited by the mouse hitting the edges of the screen.
The unbounded mode is automatically turned off when the mouse button is released, or it can be turned off explicitly by calling this method again.
| shouldUnboundedMovementBeEnabled | whether to turn this mode on or off | |
| keepCursorVisibleUntilOffscreen | if set to false, the cursor will immediately be hidden; if true, it will only be hidden when it is moved beyond the edge of the screen |
| virtual void Component::resized | ( | ) | [virtual] |
Called when this component's size has been changed.
A component can implement this method to do things such as laying out its child components when its width or height changes.
The method is called synchronously as a result of the setBounds or setSize methods, so repeatedly changing a components size will repeatedly call its resized method (unlike things like repainting, where multiple calls to repaint are coalesced together).
If the component is a top-level window on the desktop, its size could also be changed by operating-system factors beyond the application's control.
Reimplemented in PluginListComponent, GenericAudioProcessorEditor, CodeEditorComponent, ComboBox, Label, ListBox, Slider, TableHeaderComponent, TableListBox, TextEditor, Toolbar, ToolbarItemComponent, ToolbarItemPalette, TreeView, FileBrowserComponent, FilenameComponent, FileSearchPathListComponent, KeyMappingEditorComponent, MultiDocumentPanel, ScrollBar, TabbedButtonBar, TabbedComponent, Viewport, MenuBarComponent, PropertyComponent, PropertyPanel, AudioDeviceSelectorComponent, MidiKeyboardComponent, PreferencesPanel, WebBrowserComponent, DialogWindow, DocumentWindow, and ResizableWindow.
| virtual void Component::moved | ( | ) | [virtual] |
Called when this component's position has been changed.
This is called when the position relative to its parent changes, not when its absolute position on the screen changes (so it won't be called for all child components when a parent component is moved).
The method is called synchronously as a result of the setBounds, setTopLeftPosition or any of the other repositioning methods, and like resized(), it will be called each time those methods are called.
If the component is a top-level window on the desktop, its position could also be changed by operating-system factors beyond the application's control.
Reimplemented in ResizableWindow.
| virtual void Component::childBoundsChanged | ( | Component * | child | ) | [virtual] |
Called when one of this component's children is moved or resized.
If the parent wants to know about changes to its immediate children (not to children of its children), this is the method to override.
Reimplemented in AudioDeviceSelectorComponent, MagnifierComponent, and ResizableWindow.
| virtual void Component::parentSizeChanged | ( | ) | [virtual] |
Called when this component's immediate parent has been resized.
If the component is a top-level window, this indicates that the screen size has changed.
Reimplemented in ResizableWindow.
| virtual void Component::broughtToFront | ( | ) | [virtual] |
Called when this component has been moved to the front of its siblings.
The component may have been brought to the front by the toFront() method, or by the operating system if it's a top-level window.
Reimplemented in MultiDocumentPanelWindow.
| void Component::addComponentListener | ( | ComponentListener *const | newListener | ) | throw () |
Adds a listener to be told about changes to the component hierarchy or position.
Component listeners get called when this component's size, position or children change - see the ComponentListener class for more details.
| newListener | the listener to register - if this is already registered, it will be ignored. |
| void Component::removeComponentListener | ( | ComponentListener *const | listenerToRemove | ) | throw () |
| void Component::postCommandMessage | ( | const int | commandId | ) | throw () |
Dispatches a numbered message to this component.
This is a quick and cheap way of allowing simple asynchronous messages to be sent to components. It's also safe, because if the component that you send the message to is a null or dangling pointer, this won't cause an error.
The command ID is later delivered to the component's handleCommandMessage() method by the application's message queue.
| virtual void Component::handleCommandMessage | ( | int | commandId | ) | [virtual] |
Called to handle a command that was sent by postCommandMessage().
This is called by the message thread when a command message arrives, and the component can override this method to process it in any way it needs to.
Reimplemented in Button, TextEditor, and MenuBarComponent.
| int Component::runModalLoop | ( | ) |
Runs a component modally, waiting until the loop terminates.
This method first makes the component visible, brings it to the front and gives it the keyboard focus.
It then runs a loop, dispatching messages from the system message queue, but blocking all mouse or keyboard messages from reaching any components other than this one and its children.
This loop continues until the component's exitModalState() method is called (or the component is deleted), and then this method returns, returning the value passed into exitModalState().
| void Component::enterModalState | ( | const bool | takeKeyboardFocus = true |
) |
Puts the component into a modal state.
This makes the component modal, so that messages are blocked from reaching any components other than this one and its children, but unlike runModalLoop(), this method returns immediately.
If takeKeyboardFocus is true, the component will use grabKeyboardFocus() to get the focus, which is usually what you'll want it to do. If not, it will leave the focus unchanged.
| void Component::exitModalState | ( | const int | returnValue | ) |
Ends a component's modal state.
If this component is currently modal, this will turn of its modalness, and return a value to the runModalLoop() method that might have be running its modal loop.
| bool Component::isCurrentlyModal | ( | ) | const throw () |
Returns true if this component is the modal one.
It's possible to have nested modal components, e.g. a pop-up dialog box that launches another pop-up, but this will only return true for the one at the top of the stack.
| static int JUCE_CALLTYPE Component::getNumCurrentlyModalComponents | ( | ) | throw () [static] |
Returns the number of components that are currently in a modal state.
| static Component* JUCE_CALLTYPE Component::getCurrentlyModalComponent | ( | int | index = 0 |
) | throw () [static] |
Returns one of the components that are currently modal.
The index specifies which of the possible modal components to return. The order of the components in this list is the reverse of the order in which they became modal - so the component at index 0 is always the active component, and the others are progressively earlier ones that are themselves now blocked by later ones.
| bool Component::isCurrentlyBlockedByAnotherModalComponent | ( | ) | const throw () |
Checks whether there's a modal component somewhere that's stopping this one from receiving messages.
If there is a modal component, its canModalEventBeSentToComponent() method will be called to see if it will still allow this component to receive events.
| virtual bool Component::canModalEventBeSentToComponent | ( | const Component * | targetComponent | ) | [virtual] |
When a component is modal, this callback allows it to choose which other components can still receive events.
When a modal component is active and the user clicks on a non-modal component, this method is called on the modal component, and if it returns true, the event is allowed to reach its target. If it returns false, the event is blocked and the inputAttemptWhenModal() callback is made.
It called by the isCurrentlyBlockedByAnotherModalComponent() method. The default implementation just returns false in all cases.
| virtual void Component::inputAttemptWhenModal | ( | ) | [virtual] |
Called when the user tries to click on a component that is blocked by another modal component.
When a component is modal and the user clicks on one of the other components, the modal component will receive this callback.
The default implementation of this method will play a beep, and bring the currently modal component to the front, but it can be overridden to do other tasks.
Reimplemented in Label, and MenuBarComponent.
| const String Component::getComponentProperty | ( | const String & | keyName, | |
| const bool | useParentComponentIfNotFound, | |||
| const String & | defaultReturnValue = String::empty | |||
| ) | const throw () |
Returns one of the component's properties as a string.
| keyName | the name of the property to retrieve | |
| useParentComponentIfNotFound | if this is true and the key isn't present in this component's properties, then it will check whether the parent component has the key. | |
| defaultReturnValue | a value to return if the named property doesn't actually exist |
| int Component::getComponentPropertyInt | ( | const String & | keyName, | |
| const bool | useParentComponentIfNotFound, | |||
| const int | defaultReturnValue = 0 | |||
| ) | const throw () |
Returns one of the properties as an integer.
| keyName | the name of the property to retrieve | |
| useParentComponentIfNotFound | if this is true and the key isn't present in this component's properties, then it will check whether the parent component has the key. | |
| defaultReturnValue | a value to return if the named property doesn't actually exist |
| double Component::getComponentPropertyDouble | ( | const String & | keyName, | |
| const bool | useParentComponentIfNotFound, | |||
| const double | defaultReturnValue = 0.0 | |||
| ) | const throw () |
Returns one of the properties as an double.
| keyName | the name of the property to retrieve | |
| useParentComponentIfNotFound | if this is true and the key isn't present in this component's properties, then it will check whether the parent component has the key. | |
| defaultReturnValue | a value to return if the named property doesn't actually exist |
| bool Component::getComponentPropertyBool | ( | const String & | keyName, | |
| const bool | useParentComponentIfNotFound, | |||
| const bool | defaultReturnValue = false | |||
| ) | const throw () |
Returns one of the properties as an boolean.
The result will be true if the string found for this key name can be parsed as a non-zero integer.
| keyName | the name of the property to retrieve | |
| useParentComponentIfNotFound | if this is true and the key isn't present in this component's properties, then it will check whether the parent component has the key. | |
| defaultReturnValue | a value to return if the named property doesn't actually exist |
| const Colour Component::getComponentPropertyColour | ( | const String & | keyName, | |
| const bool | useParentComponentIfNotFound, | |||
| const Colour & | defaultReturnValue = Colours::black | |||
| ) | const throw () |
Returns one of the properties as an colour.
| keyName | the name of the property to retrieve | |
| useParentComponentIfNotFound | if this is true and the key isn't present in this component's properties, then it will check whether the parent component has the key. | |
| defaultReturnValue | a colour to return if the named property doesn't actually exist |
Sets a named property as a string.
| keyName | the name of the property to set. (This mustn't be an empty string) | |
| value | the new value to set it to |
| void Component::setComponentProperty | ( | const String & | keyName, | |
| const int | value | |||
| ) | throw () |
Sets a named property to an integer.
| keyName | the name of the property to set. (This mustn't be an empty string) | |
| value | the new value to set it to |
| void Component::setComponentProperty | ( | const String & | keyName, | |
| const double | value | |||
| ) | throw () |
Sets a named property to a double.
| keyName | the name of the property to set. (This mustn't be an empty string) | |
| value | the new value to set it to |
| void Component::setComponentProperty | ( | const String & | keyName, | |
| const bool | value | |||
| ) | throw () |
Sets a named property to a boolean.
| keyName | the name of the property to set. (This mustn't be an empty string) | |
| value | the new value to set it to |
Sets a named property to a colour.
| keyName | the name of the property to set. (This mustn't be an empty string) | |
| newColour | the new colour to set it to |
| void Component::removeComponentProperty | ( | const String & | keyName | ) | throw () |
Deletes a named component property.
| keyName | the name of the property to delete. (This mustn't be an empty string) |
| PropertySet* Component::getComponentProperties | ( | ) | const throw () |
Returns the complete set of properties that have been set for this component.
If no properties have been set, this will return a null pointer.
| const Colour Component::findColour | ( | const int | colourId, | |
| const bool | inheritFromParent = false | |||
| ) | const throw () |
Looks for a colour that has been registered with the given colour ID number.
If a colour has been set for this ID number using setColour(), then it is returned. If none has been set, the method will try calling the component's LookAndFeel class's findColour() method. If none has been registered with the look-and-feel either, it will just return black.
The colour IDs for various purposes are stored as enums in the components that they are relevent to - for an example, see Slider::ColourIds, Label::ColourIds, TextEditor::ColourIds, TreeView::ColourIds, etc.
Referenced by LassoComponent< SelectableItemType >::paint().
| void Component::setColour | ( | const int | colourId, | |
| const Colour & | colour | |||
| ) |
Registers a colour to be used for a particular purpose.
Changing a colour will cause a synchronous callback to the colourChanged() method, which your component can override if it needs to do something when colours are altered.
For more details about colour IDs, see the comments for findColour().
| void Component::removeColour | ( | const int | colourId | ) |
If a colour has been set with setColour(), this will remove it.
This allows you to make a colour revert to its default state.
| bool Component::isColourSpecified | ( | const int | colourId | ) | const throw () |
Returns true if the specified colour ID has been explicitly set for this component using the setColour() method.
| void Component::copyAllExplicitColoursTo | ( | Component & | target | ) | const throw () |
This looks for any colours that have been specified for this component, and copies them to the specified target component.
| virtual void Component::colourChanged | ( | ) | [virtual] |
This method is called when a colour is changed by the setColour() method.
Reimplemented in HyperlinkButton, TextButton, ToggleButton, ComboBox, Label, ListBox, ProgressBar, Slider, TextEditor, TreeView, GroupComponent, and MidiKeyboardComponent.
| void* Component::getWindowHandle | ( | ) | const throw () |
Returns the underlying native window handle for this component.
This is platform-dependent and strictly for power-users only!
Referenced by CarbonViewWrapperComponent::createWindow().
| uint32 Component::getComponentUID | ( | ) | const throw () |
When created, each component is given a number to uniquely identify it.
The number is incremented each time a new component is created, so it's a more unique way of identifying a component than using its memory location (which may be reused after the component is deleted, of course).
| virtual void Component::internalRepaint | ( | int | x, | |
| int | y, | |||
| int | w, | |||
| int | h | |||
| ) | [protected, virtual] |
For internal use only.
| virtual ComponentPeer* Component::createNewPeer | ( | int | styleFlags, | |
| void * | nativeWindowToAttachTo | |||
| ) | [protected, virtual] |
| void Component::handleMessage | ( | const Message & | ) | [protected, virtual] |
Overridden from the MessageListener parent class.
You can override this if you really need to, but be sure to pass your unwanted messages up to this base class implementation, as the Component class needs to send itself messages to work properly.
Implements MessageListener.
| ComponentFlags Component::flags |
1.5.9