JUCE  v6.1.6 (6.0.8-1114)
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::TableListBoxModel Class Referenceabstract

One of these is used by a TableListBox as the data model for the table's contents. More...

#include <juce_Doxygen_notes.h>

Public Member Functions

 TableListBoxModel ()=default
 
virtual ~TableListBoxModel ()=default
 Destructor. More...
 
virtual void backgroundClicked (const MouseEvent &)
 This can be overridden to react to the user double-clicking on a part of the list where there are no rows. More...
 
virtual void cellClicked (int rowNumber, int columnId, const MouseEvent &)
 This callback is made when the user clicks on one of the cells in the table. More...
 
virtual void cellDoubleClicked (int rowNumber, int columnId, const MouseEvent &)
 This callback is made when the user clicks on one of the cells in the table. More...
 
virtual void deleteKeyPressed (int lastRowSelected)
 Override this to be informed when the delete key is pressed. More...
 
virtual String getCellTooltip (int rowNumber, int columnId)
 Returns a tooltip for a particular cell in the table. More...
 
virtual int getColumnAutoSizeWidth (int columnId)
 Returns the best width for one of the columns. More...
 
virtual var getDragSourceDescription (const SparseSet< int > &currentlySelectedRows)
 To allow rows from your table to be dragged-and-dropped, implement this method. More...
 
virtual int getNumRows ()=0
 This must return the number of rows currently in the table. More...
 
virtual void listWasScrolled ()
 Override this to be informed when the list is scrolled. More...
 
virtual void paintCell (Graphics &, int rowNumber, int columnId, int width, int height, bool rowIsSelected)=0
 This must draw one of the cells. More...
 
virtual void paintRowBackground (Graphics &, int rowNumber, int width, int height, bool rowIsSelected)=0
 This must draw the background behind one of the rows in the table. More...
 
virtual ComponentrefreshComponentForCell (int rowNumber, int columnId, bool isRowSelected, Component *existingComponentToUpdate)
 This is used to create or update a custom component to go in a cell. More...
 
virtual void returnKeyPressed (int lastRowSelected)
 Override this to be informed when the return key is pressed. More...
 
virtual void selectedRowsChanged (int lastRowSelected)
 Override this to be informed when rows are selected or deselected. More...
 
virtual void sortOrderChanged (int newSortColumnId, bool isForwards)
 This callback is made when the table's sort order is changed. More...
 

Detailed Description

One of these is used by a TableListBox as the data model for the table's contents.

The virtual methods that you override in this class take care of drawing the table cells, and reacting to events.

See also
TableListBox

@tags{GUI}

Example of a juce::DocumentWindow with a component that inherits from juce::TableListBox and juce::TableListBoxModel.
See also
juce::TableListBox for example code showing how juce::TableListBox and juce::TableListBoxModel work together to define and display a table.

Constructor & Destructor Documentation

◆ TableListBoxModel()

juce::TableListBoxModel::TableListBoxModel ( )
default

◆ ~TableListBoxModel()

virtual juce::TableListBoxModel::~TableListBoxModel ( )
virtualdefault

Destructor.

Member Function Documentation

◆ backgroundClicked()

virtual void juce::TableListBoxModel::backgroundClicked ( const MouseEvent )
virtual

This can be overridden to react to the user double-clicking on a part of the list where there are no rows.

See also
cellClicked

◆ cellClicked()

virtual void juce::TableListBoxModel::cellClicked ( int  rowNumber,
int  columnId,
const MouseEvent  
)
virtual

This callback is made when the user clicks on one of the cells in the table.

The mouse event's coordinates will be relative to the entire table row.

See also
cellDoubleClicked, backgroundClicked

◆ cellDoubleClicked()

virtual void juce::TableListBoxModel::cellDoubleClicked ( int  rowNumber,
int  columnId,
const MouseEvent  
)
virtual

This callback is made when the user clicks on one of the cells in the table.

The mouse event's coordinates will be relative to the entire table row.

See also
cellClicked, backgroundClicked

◆ deleteKeyPressed()

virtual void juce::TableListBoxModel::deleteKeyPressed ( int  lastRowSelected)
virtual

Override this to be informed when the delete key is pressed.

See also
ListBox::deleteKeyPressed()

◆ getCellTooltip()

virtual String juce::TableListBoxModel::getCellTooltip ( int  rowNumber,
int  columnId 
)
virtual

Returns a tooltip for a particular cell in the table.

◆ getColumnAutoSizeWidth()

virtual int juce::TableListBoxModel::getColumnAutoSizeWidth ( int  columnId)
virtual

Returns the best width for one of the columns.

If you implement this method, you should measure the width of all the items in this column, and return the best size.

Returning 0 means that the column shouldn't be changed.

This is used by TableListBox::autoSizeColumn() and TableListBox::autoSizeAllColumns().

◆ getDragSourceDescription()

virtual var juce::TableListBoxModel::getDragSourceDescription ( const SparseSet< int > &  currentlySelectedRows)
virtual

To allow rows from your table to be dragged-and-dropped, implement this method.

If this returns a non-null variant then when the user drags a row, the table will try to find a DragAndDropContainer in its parent hierarchy, and will use it to trigger a drag-and-drop operation, using this string as the source description, and the listbox itself as the source component.

See also
getDragSourceCustomData, DragAndDropContainer::startDragging

◆ getNumRows()

virtual int juce::TableListBoxModel::getNumRows ( )
pure virtual

This must return the number of rows currently in the table.

If the number of rows changes, you must call TableListBox::updateContent() to cause it to refresh the list.

◆ listWasScrolled()

virtual void juce::TableListBoxModel::listWasScrolled ( )
virtual

Override this to be informed when the list is scrolled.

This might be caused by the user moving the scrollbar, or by programmatic changes to the list position.

◆ paintCell()

virtual void juce::TableListBoxModel::paintCell ( Graphics ,
int  rowNumber,
int  columnId,
int  width,
int  height,
bool  rowIsSelected 
)
pure virtual

This must draw one of the cells.

The graphics context's origin will already be set to the top-left of the cell, whose size is specified by (width, height).

Note that the rowNumber value may be greater than the number of rows in your list, so be careful that you don't assume it's less than getNumRows().

◆ paintRowBackground()

virtual void juce::TableListBoxModel::paintRowBackground ( Graphics ,
int  rowNumber,
int  width,
int  height,
bool  rowIsSelected 
)
pure virtual

This must draw the background behind one of the rows in the table.

The graphics context has its origin at the row's top-left, and your method should fill the area specified by the width and height parameters.

Note that the rowNumber value may be greater than the number of rows in your list, so be careful that you don't assume it's less than getNumRows().

◆ refreshComponentForCell()

virtual Component* juce::TableListBoxModel::refreshComponentForCell ( int  rowNumber,
int  columnId,
bool  isRowSelected,
Component existingComponentToUpdate 
)
virtual

This is used to create or update a custom component to go in a cell.

Any cell may contain a custom component, or can just be drawn with the paintCell() method and handle mouse clicks with cellClicked().

This method will be called whenever a custom component might need to be updated - e.g. when the table is changed, or TableListBox::updateContent() is called.

If you don't need a custom component for the specified cell, then return nullptr. (Bear in mind that even if you're not creating a new component, you may still need to delete existingComponentToUpdate if it's non-null).

If you do want a custom component, and the existingComponentToUpdate is null, then this method must create a new component suitable for the cell, and return it.

If the existingComponentToUpdate is non-null, it will be a pointer to a component previously created by this method. In this case, the method must either update it to make sure it's correctly representing the given cell (which may be different from the one that the component was created for), or it can delete this component and return a new one.

◆ returnKeyPressed()

virtual void juce::TableListBoxModel::returnKeyPressed ( int  lastRowSelected)
virtual

Override this to be informed when the return key is pressed.

See also
ListBox::returnKeyPressed()

◆ selectedRowsChanged()

virtual void juce::TableListBoxModel::selectedRowsChanged ( int  lastRowSelected)
virtual

Override this to be informed when rows are selected or deselected.

See also
ListBox::selectedRowsChanged()

◆ sortOrderChanged()

virtual void juce::TableListBoxModel::sortOrderChanged ( int  newSortColumnId,
bool  isForwards 
)
virtual

This callback is made when the table's sort order is changed.

This could be because the user has clicked a column header, or because the TableHeaderComponent::setSortColumnId() method was called.

If you implement this, your method should re-sort the table using the given column as the key.


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