1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Added methods TreeViewItem::sortSubItems() and PopupMenu::MenuItemIterator::addItemTo().

This commit is contained in:
jules 2012-09-30 13:39:50 +01:00
parent 9077ba817d
commit 5d7622ade5
5 changed files with 36 additions and 2 deletions

View file

@ -1681,3 +1681,11 @@ bool PopupMenu::MenuItemIterator::next()
return true;
}
void PopupMenu::MenuItemIterator::addItemTo (PopupMenu& targetMenu)
{
targetMenu.items.add (new Item (itemId, itemName, isEnabled, isTicked, customImage,
customColour != nullptr ? *customColour : Colours::black, customColour != nullptr,
nullptr,
subMenu, commandManager));
}

View file

@ -397,6 +397,9 @@ public:
*/
bool next();
/** Adds an item to the target menu which has all the properties of this item. */
void addItemTo (PopupMenu& targetMenu);
//==============================================================================
String itemName;
const PopupMenu* subMenu;

View file

@ -127,6 +127,9 @@ public:
/** The time that this mouse-event occurred. */
const Time eventTime;
/** The time that the corresponding mouse-down event occurred. */
const Time mouseDownTime;
/** The source device that generated this event. */
MouseInputSource& source;
@ -312,7 +315,6 @@ public:
private:
//==============================================================================
const Point<int> mouseDownPos;
const Time mouseDownTime;
const uint8 numberOfClicks, wasMovedSinceMouseDown;
MouseEvent& operator= (const MouseEvent&);

View file

@ -242,7 +242,7 @@ public:
String getTooltip()
{
Rectangle<int> pos;
if (TreeViewItem* const item = findItemAt (getMouseXYRelative().getY(), pos))
if (TreeViewItem* const item = findItemAt (getMouseXYRelative().y, pos))
return item->getTooltip();
return owner.getTooltip();

View file

@ -94,6 +94,27 @@ public:
*/
void removeSubItem (int index, bool deleteItem = true);
/** Sorts the list of sub-items using a standard array comparator.
This will use a comparator object to sort the elements into order. The comparator
object must have a method of the form:
@code
int compareElements (TreeViewItem* first, TreeViewItem* second);
@endcode
..and this method must return:
- a value of < 0 if the first comes before the second
- a value of 0 if the two objects are equivalent
- a value of > 0 if the second comes before the first
To improve performance, the compareElements() method can be declared as static or const.
*/
template <class ElementComparator>
void sortSubItems (ElementComparator& comparator)
{
subItems.sort (comparator);
}
//==============================================================================
/** Returns the TreeView to which this item belongs. */
TreeView* getOwnerView() const noexcept { return ownerView; }