63 int getNumSubItems()
const noexcept;
84 void addSubItem (
TreeViewItem* newItem,
int insertPosition = -1);
94 template <
class ElementComparator>
97 addSubItem (newItem, findInsertIndexInSortedArray (comparator, subItems.begin(), newItem, 0, subItems.size()));
105 void removeSubItem (
int index,
bool deleteItem =
true);
122 template <
class ElementComparator>
125 subItems.sort (comparator);
140 bool isOpen() const noexcept;
155 void setOpen (
bool shouldBeOpen);
169 Openness getOpenness() const noexcept;
179 void setOpenness (Openness newOpenness);
185 bool isSelected() const noexcept;
192 void setSelected (
bool shouldBeSelected,
193 bool deselectOtherItemsFirst,
203 Rectangle<
int> getItemPosition (
bool relativeToTreeViewTopLeft) const noexcept;
209 void treeHasChanged() const noexcept;
216 void repaintItem() const;
224 int getRowNumberInTree() const noexcept;
230 bool areAllParentsOpen() const noexcept;
236 void setLinesDrawnForSubItems (
bool shouldDrawLines) noexcept;
245 virtual
bool mightContainSubItems() = 0;
257 virtual
String getUniqueName() const;
279 virtual
void itemOpennessChanged (
bool isNowOpen);
294 virtual
int getItemWidth()
const {
return -1; }
347 virtual void paintItem (
Graphics& g,
int width,
int height);
358 Colour backgroundColour,
bool isMouseOver);
400 virtual void itemDoubleClicked (
const MouseEvent&);
407 virtual void itemSelectionChanged (
bool isNowSelected);
410 virtual void ownerViewChanged (
TreeView* newOwner);
416 virtual String getTooltip();
427 virtual String getAccessibilityName();
445 virtual var getDragSourceDescription();
460 virtual bool isInterestedInFileDrag (
const StringArray& files);
471 virtual void filesDropped (
const StringArray& files,
int insertIndex);
508 void setDrawsInLeftMargin (
bool canDrawInLeftMargin)
noexcept;
521 void setDrawsInRightMargin (
bool canDrawInRightMargin)
noexcept;
554 void restoreOpennessState (
const XmlElement& xml);
558 int getIndexInParent() const noexcept;
561 bool isLastOfSiblings() const noexcept;
571 String getItemIdentifierString() const;
612 void updatePositions (
int);
613 int getIndentX() const noexcept;
614 void setOwnerView (
TreeView*) noexcept;
616 const
TreeViewItem* getDeepestOpenParentItem() const noexcept;
617 int getNumRows() const noexcept;
620 int countSelectedItemsRecursively (
int) const noexcept;
623 void restoreToDefaultOpenness();
624 bool isFullyOpen() const noexcept;
626 bool removeSubItemFromList (
int,
bool);
627 void removeAllSubItemsFromList();
628 bool areLinesDrawn() const;
637 int y = 0, itemHeight = 0, totalHeight = 0, itemWidth = 0, totalWidth = 0, uid = 0;
638 bool selected = false, redrawNeeded = true, drawLinesInside = false, drawLinesSet = false,
639 drawsInLeftMargin = false, drawsInRightMargin = false;
697 void deleteRootItem();
705 void setRootItemVisible (
bool shouldBeVisible);
720 void setDefaultOpenness (
bool isOpenByDefault);
738 void setMultiSelectEnabled (
bool canMultiSelect);
750 void setOpenCloseButtonsVisible (
bool shouldBeVisible);
760 void clearSelectedItems();
769 int getNumSelectedItems (
int maximumDepthToSearchTo = -1) const noexcept;
775 TreeViewItem* getSelectedItem (
int index) const noexcept;
778 void moveSelectedRow (
int deltaRows);
785 int getNumRowsInTree() const;
801 void scrollToKeepItemVisible (const
TreeViewItem* item);
804 Viewport* getViewport() const noexcept;
810 int getIndentSize() noexcept;
816 void setIndentSize (
int newIndentSize);
845 std::unique_ptr<
XmlElement> getOpennessState (
bool alsoIncludeScrollPosition) const;
858 void restoreOpennessState (const
XmlElement& newState,
bool restoreStoredSelection);
870 backgroundColourId = 0x1000500,
871 linesColourId = 0x1000501,
872 dragAndDropIndicatorColourId = 0x1000502,
873 selectedItemBackgroundColourId = 0x1000503,
874 oddItemsColourId = 0x1000504,
875 evenItemsColourId = 0x1000505
887 Colour backgroundColour,
bool isItemOpen,
bool isMouseOver) = 0;
889 virtual bool areLinesDrawnForTreeView (
TreeView&) = 0;
890 virtual int getTreeViewIndentSize (
TreeView&) = 0;
897 void resized()
override;
899 bool keyPressed (
const KeyPress&)
override;
901 void colourChanged()
override;
903 void enablementChanged()
override;
905 bool isInterestedInFileDrag (
const StringArray&)
override;
907 void fileDragEnter (
const StringArray&,
int,
int)
override;
909 void fileDragMove (
const StringArray&,
int,
int)
override;
913 void filesDropped (
const StringArray&,
int,
int)
override;
915 bool isInterestedInDragSource (
const SourceDetails&)
override;
935 class TreeAccessibilityHandler;
938 void itemsChanged() noexcept;
939 void updateVisibleItems (
std::optional<
Point<
int>> viewportPosition = {});
940 void updateButtonUnderMouse (
const MouseEvent&);
941 void showDragHighlight (
const InsertPoint&)
noexcept;
942 void hideDragHighlight() noexcept;
943 void handleDrag (const
StringArray&, const SourceDetails&);
944 void handleDrop (const
StringArray&, const SourceDetails&);
945 bool toggleOpenSelectedItem();
946 void moveOutOfSelectedItem();
947 void moveIntoSelectedItem();
948 void moveByPages (
int);
950 std::unique_ptr<TreeViewport> viewport;
952 std::unique_ptr<InsertPointHighlight> dragInsertPointHighlight;
953 std::unique_ptr<TargetGroupHighlight> dragTargetGroupHighlight;
955 bool defaultOpenness = false, rootItemVisible = true, multiSelectEnabled = false, openCloseButtonsVisible = true;
Represents a colour, also including a transparency value.
The base class for all JUCE user-interface objects.
Contains details about the source of a drag-and-drop operation.
Components derived from this class can have things dropped onto them by a DragAndDropContainer.
Components derived from this class can have files dropped onto them by an external application.
A graphics context, used for drawing a component or image.
Represents a key press, including any modifier keys that are needed.
Contains position and status information about a mouse event.
An array designed for holding objects.
A pair of (x, y) coordinates.
Manages a rectangle and allows geometric operations to be performed on it.
A special array for holding a list of strings.
This handy class takes a copy of a TreeViewItem's openness when you create it, and restores that open...
virtual bool canBeSelected() const
You can override this method to return false if you don't want to allow the user to select this item.
TreeView * getOwnerView() const noexcept
Returns the TreeView to which this item belongs.
void sortSubItems(ElementComparator &comparator)
Sorts the list of sub-items using a standard array comparator.
void addSubItemSorted(ElementComparator &comparator, TreeViewItem *newItem)
Adds a sub-item with a sort-comparator, assuming that the existing items are already sorted.
virtual std::unique_ptr< Component > createItemComponent()
Creates a component that will be used to represent this item.
virtual int getItemHeight() const
Must return the height required by this item.
virtual bool customComponentUsesTreeViewMouseHandler() const
This should return true if you want to use a custom component, and also use the TreeView's built-in m...
TreeViewItem * getParentItem() const noexcept
Returns the item within which this item is contained.
Openness
An enum of states to describe the explicit or implicit openness of an item.
ColourIds
A set of colour IDs to use to change the colour of various aspects of the TreeView.
TreeViewItem * getRootItem() const noexcept
Returns the tree's root item.
bool areOpenCloseButtonsVisible() const noexcept
Returns whether open/close buttons are shown.
bool isMultiSelectEnabled() const noexcept
Returns whether multi-select has been enabled for the tree.
bool areItemsOpenByDefault() const noexcept
Returns true if the tree's items default to being open.
bool isRootItemVisible() const noexcept
Returns true if the root item is visible.
A Viewport is used to contain a larger child component, and allows the child to be automatically scro...
Used to build a tree of elements representing an XML document.
A variant class, that can be used to hold a range of primitive values.
NotificationType
These enums are used in various classes to indicate whether a notification event should be sent out.
This abstract base class is implemented by LookAndFeel classes to provide TreeView drawing functional...