| @@ -107,7 +107,7 @@ public: | |||||
| void mouseDrag (const MouseEvent& e) override | void mouseDrag (const MouseEvent& e) override | ||||
| { | { | ||||
| if (auto* m = getOwner().getModel()) | |||||
| if (auto* m = getModel (getOwner())) | |||||
| { | { | ||||
| if (asBase().isEnabled() && e.mouseWasDraggedSinceMouseDown() && ! isDragging) | if (asBase().isEnabled() && e.mouseWasDraggedSinceMouseDown() && ! isDragging) | ||||
| { | { | ||||
| @@ -143,6 +143,9 @@ private: | |||||
| const Base& asBase() const { return *static_cast<const Base*> (this); } | const Base& asBase() const { return *static_cast<const Base*> (this); } | ||||
| Base& asBase() { return *static_cast< Base*> (this); } | Base& asBase() { return *static_cast< Base*> (this); } | ||||
| static TableListBoxModel* getModel (TableListBox& x) { return x.getTableListBoxModel(); } | |||||
| static ListBoxModel* getModel (ListBox& x) { return x.getListBoxModel(); } | |||||
| int row = -1; | int row = -1; | ||||
| bool selected = false, isDragging = false, isDraggingToScroll = false, selectRowOnMouseUp = false; | bool selected = false, isDragging = false, isDraggingToScroll = false, selectRowOnMouseUp = false; | ||||
| }; | }; | ||||
| @@ -156,7 +159,7 @@ public: | |||||
| void paint (Graphics& g) override | void paint (Graphics& g) override | ||||
| { | { | ||||
| if (auto* m = owner.getModel()) | |||||
| if (auto* m = owner.getListBoxModel()) | |||||
| m->paintListBoxItem (getRow(), g, getWidth(), getHeight(), isSelected()); | m->paintListBoxItem (getRow(), g, getWidth(), getHeight(), isSelected()); | ||||
| } | } | ||||
| @@ -164,7 +167,7 @@ public: | |||||
| { | { | ||||
| updateRowAndSelection (newRow, nowSelected); | updateRowAndSelection (newRow, nowSelected); | ||||
| if (auto* m = owner.getModel()) | |||||
| if (auto* m = owner.getListBoxModel()) | |||||
| { | { | ||||
| setMouseCursor (m->getMouseCursorForRow (getRow())); | setMouseCursor (m->getMouseCursorForRow (getRow())); | ||||
| @@ -188,14 +191,14 @@ public: | |||||
| { | { | ||||
| owner.selectRowsBasedOnModifierKeys (getRow(), e.mods, isMouseUp); | owner.selectRowsBasedOnModifierKeys (getRow(), e.mods, isMouseUp); | ||||
| if (auto* m = owner.getModel()) | |||||
| if (auto* m = owner.getListBoxModel()) | |||||
| m->listBoxItemClicked (getRow(), e); | m->listBoxItemClicked (getRow(), e); | ||||
| } | } | ||||
| void mouseDoubleClick (const MouseEvent& e) override | void mouseDoubleClick (const MouseEvent& e) override | ||||
| { | { | ||||
| if (isEnabled()) | if (isEnabled()) | ||||
| if (auto* m = owner.getModel()) | |||||
| if (auto* m = owner.getListBoxModel()) | |||||
| m->listBoxItemDoubleClicked (getRow(), e); | m->listBoxItemDoubleClicked (getRow(), e); | ||||
| } | } | ||||
| @@ -207,7 +210,7 @@ public: | |||||
| String getTooltip() override | String getTooltip() override | ||||
| { | { | ||||
| if (auto* m = owner.getModel()) | |||||
| if (auto* m = owner.getListBoxModel()) | |||||
| return m->getTooltipForRow (getRow()); | return m->getTooltipForRow (getRow()); | ||||
| return {}; | return {}; | ||||
| @@ -238,7 +241,7 @@ private: | |||||
| String getTitle() const override | String getTitle() const override | ||||
| { | { | ||||
| if (auto* m = rowComponent.owner.getModel()) | |||||
| if (auto* m = rowComponent.owner.getListBoxModel()) | |||||
| return m->getNameForRow (rowComponent.getRow()); | return m->getNameForRow (rowComponent.getRow()); | ||||
| return {}; | return {}; | ||||
| @@ -248,7 +251,7 @@ private: | |||||
| AccessibleState getCurrentState() const override | AccessibleState getCurrentState() const override | ||||
| { | { | ||||
| if (auto* m = rowComponent.owner.getModel()) | |||||
| if (auto* m = rowComponent.owner.getListBoxModel()) | |||||
| if (rowComponent.getRow() >= m->getNumRows()) | if (rowComponent.getRow() >= m->getNumRows()) | ||||
| return AccessibleState().withIgnored(); | return AccessibleState().withIgnored(); | ||||
| @@ -345,7 +348,7 @@ public: | |||||
| { | { | ||||
| updateVisibleArea (true); | updateVisibleArea (true); | ||||
| if (auto* m = owner.getModel()) | |||||
| if (auto* m = owner.getListBoxModel()) | |||||
| m->listWasScrolled(); | m->listWasScrolled(); | ||||
| startTimer (50); | startTimer (50); | ||||
| @@ -221,7 +221,7 @@ public: | |||||
| void setModel (ListBoxModel* newModel); | void setModel (ListBoxModel* newModel); | ||||
| /** Returns the current list model. */ | /** Returns the current list model. */ | ||||
| ListBoxModel* getModel() const noexcept | |||||
| ListBoxModel* getListBoxModel() const noexcept | |||||
| { | { | ||||
| #if ! JUCE_DISABLE_ASSERTIONS | #if ! JUCE_DISABLE_ASSERTIONS | ||||
| checkModelPtrIsValid(); | checkModelPtrIsValid(); | ||||
| @@ -612,6 +612,9 @@ public: | |||||
| void setSelectedRows (const SparseSet<int>&, bool); | void setSelectedRows (const SparseSet<int>&, bool); | ||||
| #endif | #endif | ||||
| [[deprecated ("The name of this function is ambiguous if derived classes supply their own models, use getListBoxModel instead")]] | |||||
| ListBoxModel* getModel() const noexcept { return getListBoxModel(); } | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| JUCE_PUBLIC_IN_DLL_BUILD (class ListViewport) | JUCE_PUBLIC_IN_DLL_BUILD (class ListViewport) | ||||
| @@ -41,7 +41,7 @@ public: | |||||
| void paint (Graphics& g) override | void paint (Graphics& g) override | ||||
| { | { | ||||
| if (auto* tableModel = owner.getModel()) | |||||
| if (auto* tableModel = owner.getTableListBoxModel()) | |||||
| { | { | ||||
| tableModel->paintRowBackground (g, getRow(), getWidth(), getHeight(), isSelected()); | tableModel->paintRowBackground (g, getRow(), getWidth(), getHeight(), isSelected()); | ||||
| @@ -80,7 +80,7 @@ public: | |||||
| updateRowAndSelection (newRow, isNowSelected); | updateRowAndSelection (newRow, isNowSelected); | ||||
| auto* tableModel = owner.getModel(); | |||||
| auto* tableModel = owner.getTableListBoxModel(); | |||||
| if (tableModel != nullptr && getRow() < owner.getNumRows()) | if (tableModel != nullptr && getRow() < owner.getNumRows()) | ||||
| { | { | ||||
| @@ -171,7 +171,7 @@ public: | |||||
| auto columnId = owner.getHeader().getColumnIdAtX (e.x); | auto columnId = owner.getHeader().getColumnIdAtX (e.x); | ||||
| if (columnId != 0) | if (columnId != 0) | ||||
| if (auto* m = owner.getModel()) | |||||
| if (auto* m = owner.getTableListBoxModel()) | |||||
| m->cellClicked (getRow(), columnId, e); | m->cellClicked (getRow(), columnId, e); | ||||
| } | } | ||||
| @@ -183,7 +183,7 @@ public: | |||||
| const auto columnId = owner.getHeader().getColumnIdAtX (e.x); | const auto columnId = owner.getHeader().getColumnIdAtX (e.x); | ||||
| if (columnId != 0) | if (columnId != 0) | ||||
| if (auto* m = owner.getModel()) | |||||
| if (auto* m = owner.getTableListBoxModel()) | |||||
| m->cellDoubleClicked (getRow(), columnId, e); | m->cellDoubleClicked (getRow(), columnId, e); | ||||
| } | } | ||||
| @@ -192,7 +192,7 @@ public: | |||||
| auto columnId = owner.getHeader().getColumnIdAtX (getMouseXYRelative().getX()); | auto columnId = owner.getHeader().getColumnIdAtX (getMouseXYRelative().getX()); | ||||
| if (columnId != 0) | if (columnId != 0) | ||||
| if (auto* m = owner.getModel()) | |||||
| if (auto* m = owner.getTableListBoxModel()) | |||||
| return m->getCellTooltip (getRow(), columnId); | return m->getCellTooltip (getRow(), columnId); | ||||
| return {}; | return {}; | ||||
| @@ -219,7 +219,7 @@ public: | |||||
| return std::make_unique<RowAccessibilityHandler> (*this); | return std::make_unique<RowAccessibilityHandler> (*this); | ||||
| } | } | ||||
| ListBox& getOwner() const { return owner; } | |||||
| TableListBox& getOwner() const { return owner; } | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -247,7 +247,7 @@ private: | |||||
| AccessibleState getCurrentState() const override | AccessibleState getCurrentState() const override | ||||
| { | { | ||||
| if (auto* m = rowComponent.owner.getModel()) | |||||
| if (auto* m = rowComponent.owner.getTableListBoxModel()) | |||||
| if (rowComponent.getRow() >= m->getNumRows()) | if (rowComponent.getRow() >= m->getNumRows()) | ||||
| return AccessibleState().withIgnored(); | return AccessibleState().withIgnored(); | ||||
| @@ -578,7 +578,7 @@ std::unique_ptr<AccessibilityHandler> TableListBox::createAccessibilityHandler() | |||||
| int getNumRows() const override | int getNumRows() const override | ||||
| { | { | ||||
| if (auto* tableModel = tableListBox.getModel()) | |||||
| if (auto* tableModel = tableListBox.getTableListBoxModel()) | |||||
| return tableModel->getNumRows(); | return tableModel->getNumRows(); | ||||
| return 0; | return 0; | ||||
| @@ -233,7 +233,7 @@ public: | |||||
| void setModel (TableListBoxModel* newModel); | void setModel (TableListBoxModel* newModel); | ||||
| /** Returns the model currently in use. */ | /** Returns the model currently in use. */ | ||||
| TableListBoxModel* getModel() const noexcept { return model; } | |||||
| TableListBoxModel* getTableListBoxModel() const noexcept { return model; } | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Returns the header component being used in this table. */ | /** Returns the header component being used in this table. */ | ||||
| @@ -334,6 +334,10 @@ public: | |||||
| /** @internal */ | /** @internal */ | ||||
| std::unique_ptr<AccessibilityHandler> createAccessibilityHandler() override; | std::unique_ptr<AccessibilityHandler> createAccessibilityHandler() override; | ||||
| /** Returns the model currently in use. */ | |||||
| [[deprecated ("This function hides the non-virtual ListBox::getModel, use getTableListBoxModel instead")]] | |||||
| TableListBoxModel* getModel() const noexcept { return getTableListBoxModel(); } | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| class Header; | class Header; | ||||