LMMS
Loading...
Searching...
No Matches
juce::TreeView Class Reference

#include <juce_TreeView.h>

Inheritance diagram for juce::TreeView:
juce::Component juce::SettableTooltipClient juce::FileDragAndDropTarget juce::DragAndDropTarget juce::MouseListener juce::TooltipClient juce::FileTreeComponent

Classes

struct  LookAndFeelMethods
class  ItemComponent
class  ContentComponent
class  TreeViewport
struct  InsertPoint
class  InsertPointHighlight
class  TargetGroupHighlight

Public Types

enum  ColourIds {
  backgroundColourId = 0x1000500 , linesColourId = 0x1000501 , dragAndDropIndicatorColourId = 0x1000502 , selectedItemBackgroundColourId = 0x1000503 ,
  oddItemsColourId = 0x1000504 , evenItemsColourId = 0x1000505
}
Public Types inherited from juce::Component
enum class  FocusContainerType { none , focusContainer , keyboardFocusContainer }
enum  FocusChangeType { focusChangedByMouseClick , focusChangedByTabKey , focusChangedDirectly }

Public Member Functions

 TreeView (const String &componentName={})
 ~TreeView () override
void setRootItem (TreeViewItem *newRootItem)
TreeViewItemgetRootItem () const noexcept
void deleteRootItem ()
void setRootItemVisible (bool shouldBeVisible)
bool isRootItemVisible () const noexcept
void setDefaultOpenness (bool isOpenByDefault)
bool areItemsOpenByDefault () const noexcept
void setMultiSelectEnabled (bool canMultiSelect)
bool isMultiSelectEnabled () const noexcept
void setOpenCloseButtonsVisible (bool shouldBeVisible)
bool areOpenCloseButtonsVisible () const noexcept
void clearSelectedItems ()
int getNumSelectedItems (int maximumDepthToSearchTo=-1) const noexcept
TreeViewItemgetSelectedItem (int index) const noexcept
void moveSelectedRow (int deltaRows)
int getNumRowsInTree () const
TreeViewItemgetItemOnRow (int index) const
TreeViewItemgetItemAt (int yPosition) const noexcept
void scrollToKeepItemVisible (TreeViewItem *item)
ViewportgetViewport () const noexcept
int getIndentSize () noexcept
void setIndentSize (int newIndentSize)
TreeViewItemfindItemFromIdentifierString (const String &identifierString) const
ComponentgetItemComponent (const TreeViewItem *item) const
std::unique_ptr< XmlElementgetOpennessState (bool alsoIncludeScrollPosition) const
void restoreOpennessState (const XmlElement &newState, bool restoreStoredSelection)
void paint (Graphics &) override
void resized () override
bool keyPressed (const KeyPress &) override
void colourChanged () override
void enablementChanged () override
bool isInterestedInFileDrag (const StringArray &) override
void fileDragEnter (const StringArray &, int, int) override
void fileDragMove (const StringArray &, int, int) override
void fileDragExit (const StringArray &) override
void filesDropped (const StringArray &, int, int) override
bool isInterestedInDragSource (const SourceDetails &) override
void itemDragEnter (const SourceDetails &) override
void itemDragMove (const SourceDetails &) override
void itemDragExit (const SourceDetails &) override
void itemDropped (const SourceDetails &) override
Public Member Functions inherited from juce::Component
 Component () noexcept
 ~Component () override
 Component (const String &componentName) noexcept
String getName () const noexcept
virtual void setName (const String &newName)
String getComponentID () const noexcept
void setComponentID (const String &newID)
virtual void setVisible (bool shouldBeVisible)
bool isVisible () const noexcept
virtual void visibilityChanged ()
bool isShowing () const
virtual void addToDesktop (int windowStyleFlags, void *nativeWindowToAttachTo=nullptr)
void removeFromDesktop ()
bool isOnDesktop () const noexcept
ComponentPeergetPeer () const
virtual void userTriedToCloseWindow ()
virtual void minimisationStateChanged (bool isNowMinimised)
virtual float getDesktopScaleFactor () const
void toFront (bool shouldAlsoGainKeyboardFocus)
void toBack ()
void toBehind (Component *other)
void setAlwaysOnTop (bool shouldStayOnTop)
bool isAlwaysOnTop () const noexcept
int getX () const noexcept
int getY () const noexcept
int getWidth () const noexcept
int getHeight () const noexcept
int getRight () const noexcept
Point< intgetPosition () const noexcept
int getBottom () const noexcept
Rectangle< intgetBounds () const noexcept
Rectangle< intgetLocalBounds () const noexcept
Rectangle< intgetBoundsInParent () const noexcept
int getScreenX () const
int getScreenY () const
Point< intgetScreenPosition () const
Rectangle< intgetScreenBounds () const
Point< intgetLocalPoint (const Component *sourceComponent, Point< int > pointRelativeToSourceComponent) const
Point< float > getLocalPoint (const Component *sourceComponent, Point< float > pointRelativeToSourceComponent) const
Rectangle< intgetLocalArea (const Component *sourceComponent, Rectangle< int > areaRelativeToSourceComponent) const
Rectangle< float > getLocalArea (const Component *sourceComponent, Rectangle< float > areaRelativeToSourceComponent) const
Point< intlocalPointToGlobal (Point< int > localPoint) const
Point< float > localPointToGlobal (Point< float > localPoint) const
Rectangle< intlocalAreaToGlobal (Rectangle< int > localArea) const
Rectangle< float > localAreaToGlobal (Rectangle< float > localArea) const
void setTopLeftPosition (int x, int y)
void setTopLeftPosition (Point< int > newTopLeftPosition)
void setTopRightPosition (int x, int y)
void setSize (int newWidth, int newHeight)
void setBounds (int x, int y, int width, int height)
void setBounds (Rectangle< int > newBounds)
void setBoundsRelative (float proportionalX, float proportionalY, float proportionalWidth, float proportionalHeight)
void setBoundsRelative (Rectangle< float > proportionalArea)
void setBoundsInset (BorderSize< int > borders)
void setBoundsToFit (Rectangle< int > targetArea, Justification justification, bool onlyReduceInSize)
void setCentrePosition (int x, int y)
void setCentrePosition (Point< int > newCentrePosition)
void setCentreRelative (float x, float y)
void centreWithSize (int width, int height)
void setTransform (const AffineTransform &transform)
AffineTransform getTransform () const
bool isTransformed () const noexcept
int proportionOfWidth (float proportion) const noexcept
int proportionOfHeight (float proportion) const noexcept
int getParentWidth () const noexcept
int getParentHeight () const noexcept
Rectangle< intgetParentMonitorArea () const
int getNumChildComponents () const noexcept
ComponentgetChildComponent (int index) const noexcept
int getIndexOfChildComponent (const Component *child) const noexcept
const Array< Component * > & getChildren () const noexcept
ComponentfindChildWithID (StringRef componentID) const noexcept
void addChildComponent (Component *child, int zOrder=-1)
void addChildComponent (Component &child, int zOrder=-1)
void addAndMakeVisible (Component *child, int zOrder=-1)
void addAndMakeVisible (Component &child, int zOrder=-1)
void addChildAndSetID (Component *child, const String &componentID)
void removeChildComponent (Component *childToRemove)
ComponentremoveChildComponent (int childIndexToRemove)
void removeAllChildren ()
void deleteAllChildren ()
ComponentgetParentComponent () const noexcept
template<class TargetClass>
TargetClass * findParentComponentOfClass () const
ComponentgetTopLevelComponent () const noexcept
bool isParentOf (const Component *possibleChild) const noexcept
virtual void parentHierarchyChanged ()
virtual void childrenChanged ()
virtual bool hitTest (int x, int y)
void setInterceptsMouseClicks (bool allowClicksOnThisComponent, bool allowClicksOnChildComponents) noexcept
void getInterceptsMouseClicks (bool &allowsClicksOnThisComponent, bool &allowsClicksOnChildComponents) const noexcept
bool contains (Point< int > localPoint)
bool contains (Point< float > localPoint)
bool reallyContains (Point< int > localPoint, bool returnTrueIfWithinAChild)
bool reallyContains (Point< float > localPoint, bool returnTrueIfWithinAChild)
ComponentgetComponentAt (int x, int y)
ComponentgetComponentAt (Point< int > position)
ComponentgetComponentAt (Point< float > position)
void repaint ()
void repaint (int x, int y, int width, int height)
void repaint (Rectangle< int > area)
void setBufferedToImage (bool shouldBeBuffered)
Image createComponentSnapshot (Rectangle< int > areaToGrab, bool clipImageToComponentBounds=true, float scaleFactor=1.0f)
void paintEntireComponent (Graphics &context, bool ignoreAlphaLevel)
void setPaintingIsUnclipped (bool shouldPaintWithoutClipping) noexcept
bool isPaintingUnclipped () const noexcept
void setComponentEffect (ImageEffectFilter *newEffect)
ImageEffectFiltergetComponentEffect () const noexcept
LookAndFeelgetLookAndFeel () const noexcept
void setLookAndFeel (LookAndFeel *newLookAndFeel)
virtual void lookAndFeelChanged ()
void sendLookAndFeelChange ()
void setOpaque (bool shouldBeOpaque)
bool isOpaque () const noexcept
void setBroughtToFrontOnMouseClick (bool shouldBeBroughtToFront) noexcept
bool isBroughtToFrontOnMouseClick () const noexcept
void setExplicitFocusOrder (int newFocusOrderIndex)
int getExplicitFocusOrder () const
void setFocusContainerType (FocusContainerType containerType) noexcept
bool isFocusContainer () const noexcept
bool isKeyboardFocusContainer () const noexcept
ComponentfindFocusContainer () const
ComponentfindKeyboardFocusContainer () const
void setWantsKeyboardFocus (bool wantsFocus) noexcept
bool getWantsKeyboardFocus () const noexcept
void setMouseClickGrabsKeyboardFocus (bool shouldGrabFocus)
bool getMouseClickGrabsKeyboardFocus () const noexcept
void grabKeyboardFocus ()
void giveAwayKeyboardFocus ()
bool hasKeyboardFocus (bool trueIfChildIsFocused) const
void moveKeyboardFocusToSibling (bool moveToNext)
virtual std::unique_ptr< ComponentTraversercreateFocusTraverser ()
virtual std::unique_ptr< ComponentTraversercreateKeyboardFocusTraverser ()
void setHasFocusOutline (bool hasFocusOutline) noexcept
bool hasFocusOutline () const noexcept
bool isEnabled () const noexcept
void setEnabled (bool shouldBeEnabled)
float getAlpha () const noexcept
void setAlpha (float newAlpha)
virtual void alphaChanged ()
void setMouseCursor (const MouseCursor &cursorType)
virtual MouseCursor getMouseCursor ()
void updateMouseCursor () const
virtual void paintOverChildren (Graphics &g)
void mouseMove (const MouseEvent &event) override
void mouseEnter (const MouseEvent &event) override
void mouseExit (const MouseEvent &event) override
void mouseDown (const MouseEvent &event) override
void mouseDrag (const MouseEvent &event) override
void mouseUp (const MouseEvent &event) override
void mouseDoubleClick (const MouseEvent &event) override
void mouseWheelMove (const MouseEvent &event, const MouseWheelDetails &wheel) override
void mouseMagnify (const MouseEvent &event, float scaleFactor) override
void setRepaintsOnMouseActivity (bool shouldRepaint) noexcept
void addMouseListener (MouseListener *newListener, bool wantsEventsForAllNestedChildComponents)
void removeMouseListener (MouseListener *listenerToRemove)
void addKeyListener (KeyListener *newListener)
void removeKeyListener (KeyListener *listenerToRemove)
virtual bool keyStateChanged (bool isKeyDown)
virtual void modifierKeysChanged (const ModifierKeys &modifiers)
virtual void focusGained (FocusChangeType cause)
virtual void focusLost (FocusChangeType cause)
virtual void focusOfChildComponentChanged (FocusChangeType cause)
bool isMouseOver (bool includeChildren=false) const
bool isMouseButtonDown (bool includeChildren=false) const
bool isMouseOverOrDragging (bool includeChildren=false) const
Point< intgetMouseXYRelative () const
virtual void moved ()
virtual void childBoundsChanged (Component *child)
virtual void parentSizeChanged ()
virtual void broughtToFront ()
void addComponentListener (ComponentListener *newListener)
void removeComponentListener (ComponentListener *listenerToRemove)
void postCommandMessage (int commandId)
virtual void handleCommandMessage (int commandId)
void enterModalState (bool takeKeyboardFocus=true, ModalComponentManager::Callback *callback=nullptr, bool deleteWhenDismissed=false)
void exitModalState (int returnValue)
bool isCurrentlyModal (bool onlyConsiderForemostModalComponent=true) const noexcept
bool isCurrentlyBlockedByAnotherModalComponent () const
virtual bool canModalEventBeSentToComponent (const Component *targetComponent)
virtual void inputAttemptWhenModal ()
NamedValueSetgetProperties () noexcept
const NamedValueSetgetProperties () const noexcept
Colour findColour (int colourID, bool inheritFromParent=false) const
void setColour (int colourID, Colour newColour)
void removeColour (int colourID)
bool isColourSpecified (int colourID) const
void copyAllExplicitColoursTo (Component &target) const
voidgetWindowHandle () const
PositionergetPositioner () const noexcept
void setPositioner (Positioner *newPositioner)
void setCachedComponentImage (CachedComponentImage *newCachedImage)
CachedComponentImagegetCachedComponentImage () const noexcept
void setViewportIgnoreDragFlag (bool ignoreDrag) noexcept
bool getViewportIgnoreDragFlag () const noexcept
String getTitle () const noexcept
void setTitle (const String &newTitle)
String getDescription () const noexcept
void setDescription (const String &newDescription)
String getHelpText () const noexcept
void setHelpText (const String &newHelpText)
void setAccessible (bool shouldBeAccessible)
bool isAccessible () const noexcept
AccessibilityHandlergetAccessibilityHandler ()
void invalidateAccessibilityHandler ()
void setFocusContainer (bool shouldBeFocusContainer) noexcept
void contains (int, int)=delete
Public Member Functions inherited from juce::MouseListener
virtual ~MouseListener ()=default
Public Member Functions inherited from juce::SettableTooltipClient
 ~SettableTooltipClient () override=default
virtual void setTooltip (const String &newTooltip)
String getTooltip () override
Public Member Functions inherited from juce::TooltipClient
virtual ~TooltipClient ()=default
Public Member Functions inherited from juce::FileDragAndDropTarget
virtual ~FileDragAndDropTarget ()=default
Public Member Functions inherited from juce::DragAndDropTarget
virtual ~DragAndDropTarget ()=default
virtual bool shouldDrawDragImageWhenOver ()

Private Member Functions

std::unique_ptr< AccessibilityHandlercreateAccessibilityHandler () override
void itemsChanged () noexcept
void updateVisibleItems ()
void updateButtonUnderMouse (const MouseEvent &)
void showDragHighlight (const InsertPoint &) noexcept
void hideDragHighlight () noexcept
void handleDrag (const StringArray &, const SourceDetails &)
void handleDrop (const StringArray &, const SourceDetails &)
bool toggleOpenSelectedItem ()
void moveOutOfSelectedItem ()
void moveIntoSelectedItem ()
void moveByPages (int)

Private Attributes

std::unique_ptr< TreeViewportviewport
TreeViewItemrootItem = nullptr
std::unique_ptr< InsertPointHighlightdragInsertPointHighlight
std::unique_ptr< TargetGroupHighlightdragTargetGroupHighlight
int indentSize = -1
bool defaultOpenness = false
bool rootItemVisible = true
bool multiSelectEnabled = false
bool openCloseButtonsVisible = true

Friends

class TreeViewItem

Additional Inherited Members

Static Public Member Functions inherited from juce::Component
static float JUCE_CALLTYPE getApproximateScaleFactorForComponent (const Component *targetComponent)
static Component *JUCE_CALLTYPE getCurrentlyFocusedComponent () noexcept
static void JUCE_CALLTYPE unfocusAllComponents ()
static void JUCE_CALLTYPE beginDragAutoRepeat (int millisecondsBetweenCallbacks)
static bool JUCE_CALLTYPE isMouseButtonDownAnywhere () noexcept
static int JUCE_CALLTYPE getNumCurrentlyModalComponents () noexcept
static Component *JUCE_CALLTYPE getCurrentlyModalComponent (int index=0) noexcept
Protected Member Functions inherited from juce::Component
virtual ComponentPeercreateNewPeer (int styleFlags, void *nativeWindowToAttachTo)
Protected Member Functions inherited from juce::SettableTooltipClient
 SettableTooltipClient ()=default
Static Protected Member Functions inherited from juce::Component
static std::unique_ptr< AccessibilityHandlercreateIgnoredAccessibilityHandler (Component &)

Detailed Description

A tree-view component.

Use one of these to hold and display a structure of TreeViewItem objects.

@tags{GUI}

Member Enumeration Documentation

◆ ColourIds

enum juce::TreeView::ColourIds

A set of colour IDs to use to change the colour of various aspects of the TreeView.

These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() methods.

See also
Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
Enumerator
backgroundColourId 

A background colour to fill the component with.

linesColourId 

The colour to draw the lines with.

dragAndDropIndicatorColourId 

The colour to use for the drag-and-drop target position indicator.

selectedItemBackgroundColourId 

The colour to use to fill the background of any selected items.

oddItemsColourId 

The colour to use to fill the background of the odd numbered items.

evenItemsColourId 

The colour to use to fill the background of the even numbered items.

Constructor & Destructor Documentation

◆ TreeView()

juce::TreeView::TreeView ( const String & componentName = {})

Creates an empty TreeView.

Once you've got a TreeView component, you'll need to give it something to display, using the setRootItem() method.

◆ ~TreeView()

juce::TreeView::~TreeView ( )
override

Destructor.

Member Function Documentation

◆ areItemsOpenByDefault()

bool juce::TreeView::areItemsOpenByDefault ( ) const
inlinenoexcept

Returns true if the tree's items default to being open.

See also
setDefaultOpenness

◆ areOpenCloseButtonsVisible()

bool juce::TreeView::areOpenCloseButtonsVisible ( ) const
inlinenoexcept

Returns whether open/close buttons are shown.

See also
setOpenCloseButtonsVisible

◆ clearSelectedItems()

void juce::TreeView::clearSelectedItems ( )

Deselects any items that are currently selected.

◆ colourChanged()

void juce::TreeView::colourChanged ( )
overridevirtual

This method is called when a colour is changed by the setColour() method.

See also
setColour, findColour

Reimplemented from juce::Component.

◆ createAccessibilityHandler()

std::unique_ptr< AccessibilityHandler > juce::TreeView::createAccessibilityHandler ( )
overrideprivatevirtual

Override this method to return a custom AccessibilityHandler for this component.

The default implementation creates and returns a AccessibilityHandler object with an unspecified role, meaning that it will be visible to accessibility clients but without a specific role, action callbacks or interfaces. To control how accessibility clients see and interact with your component subclass AccessibilityHandler, implement the desired behaviours, and return an instance of it from this method in your component subclass.

The accessibility handler you return here is guaranteed to be destroyed before its Component, so it's safe to store and use a reference back to the Component inside the AccessibilityHandler if necessary.

See also
getAccessibilityHandler

Reimplemented from juce::Component.

◆ deleteRootItem()

void juce::TreeView::deleteRootItem ( )

This will remove and delete the current root item.

It's a convenient way of deleting the item and calling setRootItem (nullptr).

◆ enablementChanged()

void juce::TreeView::enablementChanged ( )
overridevirtual

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.

See also
setEnabled, isEnabled

Reimplemented from juce::Component.

◆ fileDragEnter()

void juce::TreeView::fileDragEnter ( const StringArray & files,
int x,
int y )
overridevirtual

Callback to indicate that some files are being dragged over this component.

This gets called when the user moves the mouse into this component while dragging.

Use this callback as a trigger to make your component repaint itself to give the user feedback about whether the files can be dropped here or not.

Parameters
filesthe set of (absolute) pathnames of the files that the user is dragging
xthe mouse x position, relative to this component
ythe mouse y position, relative to this component

Reimplemented from juce::FileDragAndDropTarget.

◆ fileDragExit()

void juce::TreeView::fileDragExit ( const StringArray & files)
overridevirtual

Callback to indicate that the mouse has moved away from this component.

This gets called when the user moves the mouse out of this component while dragging the files.

If you've used fileDragEnter() to repaint your component and give feedback, use this as a signal to repaint it in its normal state.

Parameters
filesthe set of (absolute) pathnames of the files that the user is dragging

Reimplemented from juce::FileDragAndDropTarget.

◆ fileDragMove()

void juce::TreeView::fileDragMove ( const StringArray & files,
int x,
int y )
overridevirtual

Callback to indicate that the user is dragging some files over this component.

This gets called when the user moves the mouse over this component while dragging. Normally overriding itemDragEnter() and itemDragExit() are enough, but this lets you know what happens in-between.

Parameters
filesthe set of (absolute) pathnames of the files that the user is dragging
xthe mouse x position, relative to this component
ythe mouse y position, relative to this component

Reimplemented from juce::FileDragAndDropTarget.

◆ filesDropped()

void juce::TreeView::filesDropped ( const StringArray & files,
int x,
int y )
overridevirtual

Callback to indicate that the user has dropped the files onto this component.

When the user drops the files, this get called, and you can use the files in whatever way is appropriate.

Note that after this is called, the fileDragExit method may not be called, so you should clean up in here if there's anything you need to do when the drag finishes.

Parameters
filesthe set of (absolute) pathnames of the files that the user is dragging
xthe mouse x position, relative to this component
ythe mouse y position, relative to this component

Implements juce::FileDragAndDropTarget.

◆ findItemFromIdentifierString()

TreeViewItem * juce::TreeView::findItemFromIdentifierString ( const String & identifierString) const

Searches the tree for an item with the specified identifier.

The identifier string must have been created by calling TreeViewItem::getItemIdentifierString(). If no such item exists, this will return false. If the item is found, all of its items will be automatically opened.

◆ getIndentSize()

int juce::TreeView::getIndentSize ( )
noexcept

Returns the number of pixels by which each nested level of the tree is indented.

See also
setIndentSize

◆ getItemAt()

TreeViewItem * juce::TreeView::getItemAt ( int yPosition) const
noexcept

Returns the item that contains a given y-position relative to the top of the TreeView component.

◆ getItemComponent()

Component * juce::TreeView::getItemComponent ( const TreeViewItem * item) const

Returns the component that currently represents a given TreeViewItem.

◆ getItemOnRow()

TreeViewItem * juce::TreeView::getItemOnRow ( int index) const

Returns the item on a particular row of the tree.

If the index is out of range, this will return nullptr.

See also
getNumRowsInTree, TreeViewItem::getRowNumberInTree()

◆ getNumRowsInTree()

int juce::TreeView::getNumRowsInTree ( ) const

Returns the number of rows the tree is using, depending on which items are open.

See also
TreeViewItem::getRowNumberInTree()

◆ getNumSelectedItems()

int juce::TreeView::getNumSelectedItems ( int maximumDepthToSearchTo = -1) const
noexcept

Returns the number of items that are currently selected.

If maximumDepthToSearchTo is >= 0, it lets you specify a maximum depth to which the tree will be recursed.

See also
getSelectedItem, clearSelectedItems

◆ getOpennessState()

std::unique_ptr< XmlElement > juce::TreeView::getOpennessState ( bool alsoIncludeScrollPosition) const

Saves the current state of open/closed nodes so it can be restored later.

This takes a snapshot of which nodes have been explicitly opened or closed, and records it as XML. To identify node objects it uses the TreeViewItem::getUniqueName() method to create named paths. This means that the same state of open/closed nodes can be restored to a completely different instance of the tree, as long as it contains nodes whose unique names are the same.

Parameters
alsoIncludeScrollPositionif this is true, the state will also include information about where the tree has been scrolled to vertically, so this can also be restored
See also
restoreOpennessState

◆ getRootItem()

TreeViewItem * juce::TreeView::getRootItem ( ) const
inlinenoexcept

Returns the tree's root item.

This will be the last object passed to setRootItem(), or nullptr if none has been set.

◆ getSelectedItem()

TreeViewItem * juce::TreeView::getSelectedItem ( int index) const
noexcept

Returns one of the selected items in the tree.

Parameters
indexthe index, 0 to (getNumSelectedItems() - 1)

◆ getViewport()

Viewport * juce::TreeView::getViewport ( ) const
noexcept

Returns the TreeView's Viewport object.

◆ handleDrag()

void juce::TreeView::handleDrag ( const StringArray & files,
const SourceDetails & dragSourceDetails )
private

◆ handleDrop()

void juce::TreeView::handleDrop ( const StringArray & files,
const SourceDetails & dragSourceDetails )
private

◆ hideDragHighlight()

void juce::TreeView::hideDragHighlight ( )
privatenoexcept

◆ isInterestedInDragSource()

bool juce::TreeView::isInterestedInDragSource ( const SourceDetails & dragSourceDetails)
overridevirtual

Callback to check whether this target is interested in the type of object being dragged.

Parameters
dragSourceDetailscontains information about the source of the drag operation.
Returns
true if this component wants to receive the other callbacks regarding this type of object; if it returns false, no other callbacks will be made.

Implements juce::DragAndDropTarget.

◆ isInterestedInFileDrag()

bool juce::TreeView::isInterestedInFileDrag ( const StringArray & files)
overridevirtual

Callback to check whether this target is interested in the set of files being offered.

Note that this will be called repeatedly when the user is dragging the mouse around over your component, so don't do anything time-consuming in here, like opening the files to have a look inside them!

Parameters
filesthe set of (absolute) pathnames of the files that the user is dragging
Returns
true if this component wants to receive the other callbacks regarding this type of object; if it returns false, no other callbacks will be made.

Implements juce::FileDragAndDropTarget.

◆ isMultiSelectEnabled()

bool juce::TreeView::isMultiSelectEnabled ( ) const
inlinenoexcept

Returns whether multi-select has been enabled for the tree.

See also
setMultiSelectEnabled

◆ isRootItemVisible()

bool juce::TreeView::isRootItemVisible ( ) const
inlinenoexcept

Returns true if the root item is visible.

See also
setRootItemVisible

◆ itemDragEnter()

void juce::TreeView::itemDragEnter ( const SourceDetails & dragSourceDetails)
overridevirtual

Callback to indicate that something is being dragged over this component.

This gets called when the user moves the mouse into this component while dragging something.

Use this callback as a trigger to make your component repaint itself to give the user feedback about whether the item can be dropped here or not.

Parameters
dragSourceDetailscontains information about the source of the drag operation.
See also
itemDragExit

Reimplemented from juce::DragAndDropTarget.

◆ itemDragExit()

void juce::TreeView::itemDragExit ( const SourceDetails & dragSourceDetails)
overridevirtual

Callback to indicate that something has been dragged off the edge of this component.

This gets called when the user moves the mouse out of this component while dragging something.

If you've used itemDragEnter() to repaint your component and give feedback, use this as a signal to repaint it in its normal state.

Parameters
dragSourceDetailscontains information about the source of the drag operation.
See also
itemDragEnter

Reimplemented from juce::DragAndDropTarget.

◆ itemDragMove()

void juce::TreeView::itemDragMove ( const SourceDetails & dragSourceDetails)
overridevirtual

Callback to indicate that the user is dragging something over this component.

This gets called when the user moves the mouse over this component while dragging something. Normally overriding itemDragEnter() and itemDragExit() are enough, but this lets you know what happens in-between.

Parameters
dragSourceDetailscontains information about the source of the drag operation.

Reimplemented from juce::DragAndDropTarget.

◆ itemDropped()

void juce::TreeView::itemDropped ( const SourceDetails & dragSourceDetails)
overridevirtual

Callback to indicate that the user has dropped something onto this component.

When the user drops an item this get called, and you can use the description to work out whether your object wants to deal with it or not.

Note that after this is called, the itemDragExit method may not be called, so you should clean up in here if there's anything you need to do when the drag finishes.

Parameters
dragSourceDetailscontains information about the source of the drag operation.

Implements juce::DragAndDropTarget.

◆ itemsChanged()

void juce::TreeView::itemsChanged ( )
privatenoexcept

◆ keyPressed()

bool juce::TreeView::keyPressed ( const KeyPress & key)
overridevirtual

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.

See also
keyStateChanged, getCurrentlyFocusedComponent, addKeyListener

Reimplemented from juce::Component.

◆ moveByPages()

void juce::TreeView::moveByPages ( int numPages)
private

◆ moveIntoSelectedItem()

void juce::TreeView::moveIntoSelectedItem ( )
private

◆ moveOutOfSelectedItem()

void juce::TreeView::moveOutOfSelectedItem ( )
private

◆ moveSelectedRow()

void juce::TreeView::moveSelectedRow ( int deltaRows)

Moves the selected row up or down by the specified number of rows.

◆ paint()

void juce::TreeView::paint ( Graphics & g)
overridevirtual

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().

Parameters
gthe graphics context that must be used to do the drawing operations.
See also
repaint, paintOverChildren, Graphics

Reimplemented from juce::Component.

◆ resized()

void juce::TreeView::resized ( )
overridevirtual

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.

See also
moved, setSize

Reimplemented from juce::Component.

◆ restoreOpennessState()

void juce::TreeView::restoreOpennessState ( const XmlElement & newState,
bool restoreStoredSelection )

Restores a previously saved arrangement of open/closed nodes.

This will try to restore a snapshot of the tree's state that was created by the getOpennessState() method. If any of the nodes named in the original XML aren't present in this tree, they will be ignored.

If restoreStoredSelection is true, it will also try to re-select any items that were selected in the stored state.

See also
getOpennessState

◆ scrollToKeepItemVisible()

void juce::TreeView::scrollToKeepItemVisible ( TreeViewItem * item)

Tries to scroll the tree so that this item is on-screen somewhere.

◆ setDefaultOpenness()

void juce::TreeView::setDefaultOpenness ( bool isOpenByDefault)

Sets whether items are open or closed by default.

Normally, items are closed until the user opens them, but you can use this to make them default to being open until explicitly closed.

See also
areItemsOpenByDefault

◆ setIndentSize()

void juce::TreeView::setIndentSize ( int newIndentSize)

Changes the distance by which each nested level of the tree is indented.

See also
getIndentSize

◆ setMultiSelectEnabled()

void juce::TreeView::setMultiSelectEnabled ( bool canMultiSelect)

This sets a flag to indicate that the tree can be used for multi-selection.

You can always select multiple items internally by calling the TreeViewItem::setSelected() method, but this flag indicates whether the user is allowed to multi-select by clicking on the tree.

By default it is disabled.

See also
isMultiSelectEnabled

◆ setOpenCloseButtonsVisible()

void juce::TreeView::setOpenCloseButtonsVisible ( bool shouldBeVisible)

Sets a flag to indicate whether to hide the open/close buttons.

See also
areOpenCloseButtonsVisible

◆ setRootItem()

void juce::TreeView::setRootItem ( TreeViewItem * newRootItem)

Sets the item that is displayed in the TreeView.

A tree has a single root item which contains as many sub-items as it needs. If you want the tree to contain a number of root items, you should still use a single root item above these, but hide it using setRootItemVisible().

You can pass nullptr to this method to clear the tree and remove its current root item.

The object passed in will not be deleted by the TreeView, it's up to the caller to delete it when no longer needed. BUT make absolutely sure that you don't delete this item until you've removed it from the tree, either by calling setRootItem (nullptr), or by deleting the tree first. You can also use deleteRootItem() as a quick way to delete it.

◆ setRootItemVisible()

void juce::TreeView::setRootItemVisible ( bool shouldBeVisible)

Changes whether the tree's root item is shown or not.

If the root item is hidden, only its sub-items will be shown in the TreeView - this lets you make the tree look as if it's got many root items. If it's hidden, this call will also make sure the root item is open (otherwise the TreeView would look empty).

◆ showDragHighlight()

void juce::TreeView::showDragHighlight ( const InsertPoint & insertPos)
privatenoexcept

◆ toggleOpenSelectedItem()

bool juce::TreeView::toggleOpenSelectedItem ( )
private

◆ updateButtonUnderMouse()

void juce::TreeView::updateButtonUnderMouse ( const MouseEvent & )
private

◆ updateVisibleItems()

void juce::TreeView::updateVisibleItems ( )
private

◆ TreeViewItem

friend class TreeViewItem
friend

Member Data Documentation

◆ defaultOpenness

bool juce::TreeView::defaultOpenness = false
private

◆ dragInsertPointHighlight

std::unique_ptr<InsertPointHighlight> juce::TreeView::dragInsertPointHighlight
private

◆ dragTargetGroupHighlight

std::unique_ptr<TargetGroupHighlight> juce::TreeView::dragTargetGroupHighlight
private

◆ indentSize

int juce::TreeView::indentSize = -1
private

◆ multiSelectEnabled

bool juce::TreeView::multiSelectEnabled = false
private

◆ openCloseButtonsVisible

bool juce::TreeView::openCloseButtonsVisible = true
private

◆ rootItem

TreeViewItem* juce::TreeView::rootItem = nullptr
private

◆ rootItemVisible

bool juce::TreeView::rootItemVisible = true
private

◆ viewport

std::unique_ptr<TreeViewport> juce::TreeView::viewport
private

The documentation for this class was generated from the following files: