JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_TableListBox.cpp
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29static const Identifier tableColumnProperty { "_tableColumnId" };
30static const Identifier tableAccessiblePlaceholderProperty { "_accessiblePlaceholder" };
31
34{
35public:
36 explicit RowComp (TableListBox& tlb)
37 : owner (tlb)
38 {
40 }
41
42 void paint (Graphics& g) override
43 {
44 if (auto* tableModel = owner.getTableListBoxModel())
45 {
46 tableModel->paintRowBackground (g, getRow(), getWidth(), getHeight(), isSelected());
47
48 auto& headerComp = owner.getHeader();
49 const auto numColumns = jmin ((int) columnComponents.size(), headerComp.getNumColumns (true));
50 const auto clipBounds = g.getClipBounds();
51
52 for (int i = 0; i < numColumns; ++i)
53 {
54 if (columnComponents[(size_t) i]->getProperties().contains (tableAccessiblePlaceholderProperty))
55 {
56 auto columnRect = headerComp.getColumnPosition (i).withHeight (getHeight());
57
58 if (columnRect.getX() >= clipBounds.getRight())
59 break;
60
61 if (columnRect.getRight() > clipBounds.getX())
62 {
64
66 {
67 g.setOrigin (columnRect.getX(), 0);
68 tableModel->paintCell (g, getRow(), headerComp.getColumnIdOfIndex (i, true),
69 columnRect.getWidth(), columnRect.getHeight(), isSelected());
70 }
71 }
72 }
73 }
74 }
75 }
76
77 void update (int newRow, bool isNowSelected)
78 {
79 jassert (newRow >= 0);
80
81 updateRowAndSelection (newRow, isNowSelected);
82
83 auto* tableModel = owner.getTableListBoxModel();
84
85 if (tableModel != nullptr && getRow() < owner.getNumRows())
86 {
87 const ComponentDeleter deleter { columnForComponent };
88 const auto numColumns = owner.getHeader().getNumColumns (true);
89
90 while (numColumns < (int) columnComponents.size())
91 columnComponents.pop_back();
92
93 while ((int) columnComponents.size() < numColumns)
94 columnComponents.emplace_back (nullptr, deleter);
95
96 for (int i = 0; i < numColumns; ++i)
97 {
98 auto columnId = owner.getHeader().getColumnIdOfIndex (i, true);
99 auto originalComp = std::move (columnComponents[(size_t) i]);
100 auto oldCustomComp = originalComp != nullptr && ! originalComp->getProperties().contains (tableAccessiblePlaceholderProperty)
101 ? std::move (originalComp)
102 : std::unique_ptr<Component, ComponentDeleter> { nullptr, deleter };
103 auto compToRefresh = oldCustomComp != nullptr && columnId == static_cast<int> (oldCustomComp->getProperties()[tableColumnProperty])
104 ? std::move (oldCustomComp)
106
107 columnForComponent.erase (compToRefresh.get());
108 std::unique_ptr<Component, ComponentDeleter> newCustomComp { tableModel->refreshComponentForCell (getRow(),
109 columnId,
110 isSelected(),
111 compToRefresh.release()),
112 deleter };
113
114 auto columnComp = [&]
115 {
116 // We got a result from refreshComponentForCell, so use that
117 if (newCustomComp != nullptr)
118 return std::move (newCustomComp);
119
120 // There was already a placeholder component for this column
121 if (originalComp != nullptr)
122 return std::move (originalComp);
123
124 // Create a new placeholder component to use
126 comp->setInterceptsMouseClicks (false, false);
127 comp->getProperties().set (tableAccessiblePlaceholderProperty, true);
128 return comp;
129 }();
130
131 columnForComponent.emplace (columnComp.get(), i);
132
133 // In order for navigation to work correctly on macOS, the number of child
134 // accessibility elements on each row must match the number of header accessibility
135 // elements.
136 columnComp->setFocusContainerType (FocusContainerType::focusContainer);
137 columnComp->getProperties().set (tableColumnProperty, columnId);
139
140 columnComponents[(size_t) i] = std::move (columnComp);
141 resizeCustomComp (i);
142 }
143 }
144 else
145 {
146 columnComponents.clear();
147 }
148 }
149
150 void resized() override
151 {
152 for (auto i = (int) columnComponents.size(); --i >= 0;)
153 resizeCustomComp (i);
154 }
155
156 void resizeCustomComp (int index)
157 {
158 if (auto& c = columnComponents[(size_t) index])
159 {
160 c->setBounds (owner.getHeader()
161 .getColumnPosition (index)
162 .withY (0)
163 .withHeight (getHeight()));
164 }
165 }
166
167 void performSelection (const MouseEvent& e, bool isMouseUp)
168 {
169 owner.selectRowsBasedOnModifierKeys (getRow(), e.mods, isMouseUp);
170
171 auto columnId = owner.getHeader().getColumnIdAtX (e.x);
172
173 if (columnId != 0)
174 if (auto* m = owner.getTableListBoxModel())
175 m->cellClicked (getRow(), columnId, e);
176 }
177
178 void mouseDoubleClick (const MouseEvent& e) override
179 {
180 if (! isEnabled())
181 return;
182
183 const auto columnId = owner.getHeader().getColumnIdAtX (e.x);
184
185 if (columnId != 0)
186 if (auto* m = owner.getTableListBoxModel())
187 m->cellDoubleClicked (getRow(), columnId, e);
188 }
189
191 {
192 auto columnId = owner.getHeader().getColumnIdAtX (getMouseXYRelative().getX());
193
194 if (columnId != 0)
195 if (auto* m = owner.getTableListBoxModel())
196 return m->getCellTooltip (getRow(), columnId);
197
198 return {};
199 }
200
201 Component* findChildComponentForColumn (int columnId) const
202 {
203 const auto index = (size_t) owner.getHeader().getIndexOfColumnId (columnId, true);
204
205 if (isPositiveAndBelow (index, columnComponents.size()))
206 return columnComponents[index].get();
207
208 return nullptr;
209 }
210
211 int getColumnNumberOfComponent (const Component* comp) const
212 {
213 const auto iter = columnForComponent.find (comp);
214 return iter != columnForComponent.cend() ? iter->second : -1;
215 }
216
218 {
219 return std::make_unique<RowAccessibilityHandler> (*this);
220 }
221
222 TableListBox& getOwner() const { return owner; }
223
224private:
225 //==============================================================================
226 class RowAccessibilityHandler final : public AccessibilityHandler
227 {
228 public:
229 RowAccessibilityHandler (RowComp& rowComp)
230 : AccessibilityHandler (rowComp,
232 getListRowAccessibilityActions (rowComp),
233 { std::make_unique<RowComponentCellInterface> (*this) }),
234 rowComponent (rowComp)
235 {
236 }
237
238 String getTitle() const override
239 {
240 if (auto* m = rowComponent.owner.ListBox::model)
241 return m->getNameForRow (rowComponent.getRow());
242
243 return {};
244 }
245
246 String getHelp() const override { return rowComponent.getTooltip(); }
247
248 AccessibleState getCurrentState() const override
249 {
250 if (auto* m = rowComponent.owner.getTableListBoxModel())
251 if (rowComponent.getRow() >= m->getNumRows())
252 return AccessibleState().withIgnored();
253
254 auto state = AccessibilityHandler::getCurrentState();
255
256 if (rowComponent.owner.multipleSelection)
257 state = state.withMultiSelectable();
258 else
259 state = state.withSelectable();
260
261 if (rowComponent.isSelected())
262 return state.withSelected();
263
264 return state;
265 }
266
267 private:
268 class RowComponentCellInterface final : public AccessibilityCellInterface
269 {
270 public:
271 RowComponentCellInterface (RowAccessibilityHandler& handler)
272 : owner (handler)
273 {
274 }
275
276 int getDisclosureLevel() const override { return 0; }
277
278 const AccessibilityHandler* getTableHandler() const override { return owner.rowComponent.owner.getAccessibilityHandler(); }
279
280 private:
281 RowAccessibilityHandler& owner;
282 };
283
284 private:
285 RowComp& rowComponent;
286 };
287
288 //==============================================================================
289 class ComponentDeleter
290 {
291 public:
292 explicit ComponentDeleter (std::map<const Component*, int>& locations)
293 : columnForComponent (&locations) {}
294
295 void operator() (Component* comp) const
296 {
297 columnForComponent->erase (comp);
298
299 if (comp != nullptr)
300 delete comp;
301 }
302
303 private:
304 std::map<const Component*, int>* columnForComponent;
305 };
306
307 TableListBox& owner;
308 std::map<const Component*, int> columnForComponent;
310
312};
313
314
315//==============================================================================
317{
318public:
319 Header (TableListBox& tlb) : owner (tlb) {}
320
322 {
323 if (owner.isAutoSizeMenuOptionShown())
324 {
325 menu.addItem (autoSizeColumnId, TRANS ("Auto-size this column"), columnIdClicked != 0);
326 menu.addItem (autoSizeAllId, TRANS ("Auto-size all columns"), owner.getHeader().getNumColumns (true) > 0);
327 menu.addSeparator();
328 }
329
331 }
332
334 {
335 switch (menuReturnId)
336 {
337 case autoSizeColumnId: owner.autoSizeColumn (columnIdClicked); break;
338 case autoSizeAllId: owner.autoSizeAllColumns(); break;
340 }
341 }
342
343private:
344 TableListBox& owner;
345
346 enum { autoSizeColumnId = 0xf836743, autoSizeAllId = 0xf836744 };
347
349};
350
351//==============================================================================
352TableListBox::TableListBox (const String& name, TableListBoxModel* const m)
353 : ListBox (name, nullptr), model (m)
354{
355 ListBox::assignModelPtr (this);
356
357 setHeader (std::make_unique<Header> (*this));
358}
359
363
365{
366 if (model != newModel)
367 {
368 model = newModel;
370 }
371}
372
374{
375 if (newHeader == nullptr)
376 {
377 jassertfalse; // you need to supply a real header for a table!
378 return;
379 }
380
381 Rectangle<int> newBounds (100, 28);
382
383 if (header != nullptr)
384 newBounds = header->getBounds();
385
386 header = newHeader.get();
387 header->setBounds (newBounds);
388
389 setHeaderComponent (std::move (newHeader));
390
391 header->addListener (this);
392}
393
395{
396 return header->getHeight();
397}
398
400{
401 header->setSize (header->getWidth(), newHeight);
402 resized();
403}
404
406{
407 auto width = model != nullptr ? model->getColumnAutoSizeWidth (columnId) : 0;
408
409 if (width > 0)
410 header->setColumnWidth (columnId, width);
411}
412
414{
415 for (int i = 0; i < header->getNumColumns (true); ++i)
416 autoSizeColumn (header->getColumnIdOfIndex (i, true));
417}
418
419void TableListBox::setAutoSizeMenuOptionShown (bool shouldBeShown) noexcept
420{
421 autoSizeOptionsShown = shouldBeShown;
422}
423
435
437{
438 if (auto* rowComp = dynamic_cast<RowComp*> (getComponentForRowNumber (rowNumber)))
439 return rowComp->findChildComponentForColumn (columnId);
440
441 return nullptr;
442}
443
445{
447 auto pos = header->getColumnPosition (header->getIndexOfColumnId (columnId, true));
448
449 auto x = scrollbar.getCurrentRangeStart();
450 auto w = scrollbar.getCurrentRangeSize();
451
452 if (pos.getX() < x)
453 x = pos.getX();
454 else if (pos.getRight() > x + w)
455 x += jmax (0.0, pos.getRight() - (x + w));
456
457 scrollbar.setCurrentRangeStart (x);
458}
459
461{
462 return model != nullptr ? model->getNumRows() : 0;
463}
464
465void TableListBox::paintListBoxItem (int, Graphics&, int, int, bool)
466{
467}
468
478
480{
481 if (model != nullptr)
482 model->selectedRowsChanged (row);
483}
484
486{
487 if (model != nullptr)
488 model->deleteKeyPressed (row);
489}
490
492{
493 if (model != nullptr)
494 model->returnKeyPressed (row);
495}
496
498{
499 if (model != nullptr)
500 model->backgroundClicked (e);
501}
502
504{
505 if (model != nullptr)
506 model->listWasScrolled();
507}
508
510{
512 repaint();
513 updateColumnComponents();
514}
515
517{
519 repaint();
520 updateColumnComponents();
521}
522
524{
525 if (model != nullptr)
526 model->sortOrderChanged (header->getSortColumnId(),
527 header->isSortedForwards());
528}
529
535
543
544void TableListBox::updateColumnComponents() const
545{
547
548 for (int i = firstRow + getNumRowsOnScreen() + 2; --i >= firstRow;)
549 if (auto* rowComp = dynamic_cast<RowComp*> (getComponentForRowNumber (i)))
550 rowComp->resized();
551}
552
553template <typename FindIndex>
554Optional<AccessibilityTableInterface::Span> findRecursively (const AccessibilityHandler& handler,
555 Component* outermost,
557{
558 for (auto* comp = &handler.getComponent(); comp != outermost; comp = comp->getParentComponent())
559 {
560 const auto result = findIndexOfComponent (comp);
561
562 if (result != -1)
563 return AccessibilityTableInterface::Span { result, 1 };
564 }
565
566 return nullopt;
567}
568
570{
572 {
573 public:
574 explicit TableInterface (TableListBox& tableListBoxToWrap)
575 : tableListBox (tableListBoxToWrap)
576 {
577 }
578
579 int getNumRows() const override
580 {
581 if (auto* tableModel = tableListBox.getTableListBoxModel())
582 return tableModel->getNumRows();
583
584 return 0;
585 }
586
587 int getNumColumns() const override
588 {
589 return tableListBox.getHeader().getNumColumns (true);
590 }
591
592 const AccessibilityHandler* getRowHandler (int row) const override
593 {
594 if (isPositiveAndBelow (row, getNumRows()))
595 if (auto* rowComp = tableListBox.getComponentForRowNumber (row))
596 return rowComp->getAccessibilityHandler();
597
598 return nullptr;
599 }
600
601 const AccessibilityHandler* getCellHandler (int row, int column) const override
602 {
603 if (isPositiveAndBelow (row, getNumRows()) && isPositiveAndBelow (column, getNumColumns()))
604 if (auto* cellComponent = tableListBox.getCellComponent (tableListBox.getHeader().getColumnIdOfIndex (column, true), row))
605 return cellComponent->getAccessibilityHandler();
606
607 return nullptr;
608 }
609
610 const AccessibilityHandler* getHeaderHandler() const override
611 {
612 if (tableListBox.hasAccessibleHeaderComponent())
613 return tableListBox.headerComponent->getAccessibilityHandler();
614
615 return nullptr;
616 }
617
618 Optional<Span> getRowSpan (const AccessibilityHandler& handler) const override
619 {
620 if (tableListBox.isParentOf (&handler.getComponent()))
621 return findRecursively (handler, &tableListBox, [&] (auto* c) { return tableListBox.getRowNumberOfComponent (c); });
622
623 return nullopt;
624 }
625
626 Optional<Span> getColumnSpan (const AccessibilityHandler& handler) const override
627 {
628 if (const auto rowSpan = getRowSpan (handler))
629 if (auto* rowComponent = dynamic_cast<RowComp*> (tableListBox.getComponentForRowNumber (rowSpan->begin)))
630 return findRecursively (handler, &tableListBox, [&] (auto* c) { return rowComponent->getColumnNumberOfComponent (c); });
631
632 return nullopt;
633 }
634
635 void showCell (const AccessibilityHandler& handler) const override
636 {
637 const auto row = getRowSpan (handler);
638 const auto col = getColumnSpan (handler);
639
640 if (row.hasValue() && col.hasValue())
641 {
642 tableListBox.scrollToEnsureRowIsOnscreen (row->begin);
643 tableListBox.scrollToEnsureColumnIsOnscreen (col->begin);
644 }
645 }
646
647 private:
648 TableListBox& tableListBox;
649
651 };
652
653 return std::make_unique<AccessibilityHandler> (*this,
654 AccessibilityRole::table,
656 AccessibilityHandler::Interfaces { std::make_unique<TableInterface> (*this) });
657}
658
659//==============================================================================
669
670String TableListBoxModel::getCellTooltip (int /*rowNumber*/, int /*columnId*/) { return {}; }
672
674{
675 jassert (existingComponentToUpdate == nullptr); // indicates a failure in the code that recycles the components
676 return nullptr;
677}
678
679} // namespace juce
A simple wrapper for building a collection of supported accessibility actions and corresponding callb...
Base class for accessible Components.
const Component & getComponent() const noexcept
Returns the Component that this handler represents.
An abstract interface which represents a UI element that supports a table interface.
The base class for all JUCE user-interface objects.
bool contains(Point< int > localPoint)
Returns true if a given point lies within this component or one of its children.
Component * getParentComponent() const noexcept
Returns the component which this component is inside.
void setFocusContainerType(FocusContainerType containerType) noexcept
Sets whether this component is a container for components that can have their focus traversed,...
int getHeight() const noexcept
Returns the component's height in pixels.
int getX() const noexcept
Returns the x coordinate of the component's left edge.
void addAndMakeVisible(Component *child, int zOrder=-1)
Adds a child component to this one, and also makes the child visible if it isn't already.
Rectangle< int > getBounds() const noexcept
Returns this component's bounding box.
void repaint()
Marks the whole component as needing to be redrawn.
Component() noexcept
Creates a component.
@ focusContainer
The component will act as a top-level component within which focus is passed around.
Point< int > getMouseXYRelative() const
Returns the mouse's current position, relative to this component.
NamedValueSet & getProperties() noexcept
Returns the set of properties that belong to this component.
void setBounds(int x, int y, int width, int height)
Changes the component's position and size.
void setSize(int newWidth, int newHeight)
Changes the size of the component.
int getWidth() const noexcept
Returns the component's width in pixels.
bool isEnabled() const noexcept
Returns true if the component (and all its parents) are enabled.
Uses RAII to save and restore the state of a graphics context.
A graphics context, used for drawing a component or image.
bool reduceClipRegion(int x, int y, int width, int height)
Intersects the current clipping region with another region.
Rectangle< int > getClipBounds() const
Returns the position of the bounding box for the current clipping region.
void setOrigin(Point< int > newOrigin)
Moves the position of the context's origin.
A list of items that can be scrolled vertically.
int getRowContainingPosition(int x, int y) const noexcept
Finds the row index that contains a given x,y position.
void setMinimumContentWidth(int newMinimumWidth)
Changes the width of the rows in the list.
Component * getComponentForRowNumber(int rowNumber) const noexcept
Finds the row component for a given row in the list.
int getVisibleContentWidth() const noexcept
Returns the space currently available for the row items, taking into account borders,...
ScrollBar & getHorizontalScrollBar() const noexcept
Returns a reference to the horizontal scrollbar.
Rectangle< int > getRowPosition(int rowNumber, bool relativeToComponentTopLeft) const noexcept
Returns the position of one of the rows, relative to the top-left of the listbox.
int getNumRowsOnScreen() const noexcept
Returns the number of rows actually visible.
void updateContent()
Causes the list to refresh its content.
void setHeaderComponent(std::unique_ptr< Component > newHeaderComponent)
Sets a component that the list should use as a header.
void resized() override
Called when this component's size has been changed.
Contains position and status information about a mouse event.
const int x
The x-position of the mouse when the event occurred.
A simple optional type.
Creates and displays a popup-menu.
Manages a rectangle and allows geometric operations to be performed on it.
Rectangle withX(ValueType newX) const noexcept
Returns a rectangle which has the same size and y-position as this one, but with a different x-positi...
Rectangle withHeight(ValueType newHeight) const noexcept
Returns a rectangle which has the same position and width as this one, but with a different height.
ValueType getX() const noexcept
Returns the x coordinate of the rectangle's left-hand-side.
void translate(ValueType deltaX, ValueType deltaY) noexcept
Moves the rectangle's position by adding amount to its x and y coordinates.
Rectangle withWidth(ValueType newWidth) const noexcept
Returns a rectangle which has the same position and height as this one, but with a different width.
Holds a set of primitive values, storing them as a set of ranges.
The JUCE String class!
Definition juce_String.h:53
A component that displays a strip of column headings for a table, and allows these to be resized,...
int getIndexOfColumnId(int columnId, bool onlyCountVisibleColumns) const
Returns the index of a given column.
int getColumnIdOfIndex(int index, bool onlyCountVisibleColumns) const
Returns the ID of the column at a given index.
virtual void addMenuItems(PopupMenu &menu, int columnIdClicked)
This can be overridden to add custom items to the pop-up menu.
virtual void reactToMenuItem(int menuReturnId, int columnIdClicked)
Override this to handle any custom items that you have added to the pop-up menu with an addMenuItems(...
void resizeAllColumnsToFit(int targetTotalWidth)
If stretch-to-fit is enabled, this will resize all the columns to make them fit into the specified wi...
int getSortColumnId() const
Returns the column ID by which the table is currently sorted, or 0 if it is unsorted.
int getNumColumns(bool onlyCountVisibleColumns) const
Returns the number of columns in the table.
Rectangle< int > getColumnPosition(int index) const
Returns the rectangle containing of one of the columns.
int getTotalWidth() const
Returns the total width of all the visible columns in the table.
void addListener(Listener *newListener)
Adds a listener to be informed about things that happen to the header.
bool isSortedForwards() const
Returns true if the table is currently sorted forwards, or false if it's backwards.
void setColumnWidth(int columnId, int newWidth)
Changes the width of a column.
One of these is used by a TableListBox as the data model for the table's contents.
virtual String getCellTooltip(int rowNumber, int columnId)
Returns a tooltip for a particular cell in the table.
virtual int getColumnAutoSizeWidth(int columnId)
Returns the best width for one of the columns.
virtual var getDragSourceDescription(const SparseSet< int > &currentlySelectedRows)
To allow rows from your table to be dragged-and-dropped, implement this method.
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.
virtual void sortOrderChanged(int newSortColumnId, bool isForwards)
This callback is made when the table's sort order is changed.
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.
virtual void selectedRowsChanged(int lastRowSelected)
Override this to be informed when rows are selected or deselected.
virtual void returnKeyPressed(int lastRowSelected)
Override this to be informed when the return key is pressed.
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 ...
virtual void listWasScrolled()
Override this to be informed when the list is scrolled.
virtual Component * refreshComponentForCell(int rowNumber, int columnId, bool isRowSelected, Component *existingComponentToUpdate)
This is used to create or update a custom component to go in a cell.
virtual int getNumRows()=0
This must return the number of rows currently in the table.
virtual void deleteKeyPressed(int lastRowSelected)
Override this to be informed when the delete key is pressed.
void addMenuItems(PopupMenu &menu, int columnIdClicked) override
This can be overridden to add custom items to the pop-up menu.
void reactToMenuItem(int menuReturnId, int columnIdClicked) override
Override this to handle any custom items that you have added to the pop-up menu with an addMenuItems(...
void resized() override
Called when this component's size has been changed.
String getTooltip() override
Returns the string that this object wants to show as its tooltip.
void mouseDoubleClick(const MouseEvent &e) override
Called when a mouse button has been double-clicked on a component.
void paint(Graphics &g) override
Components can override this method to draw their content.
std::unique_ptr< AccessibilityHandler > createAccessibilityHandler() override
Override this method to return a custom AccessibilityHandler for this component.
A table of cells, using a TableHeaderComponent as its header.
void tableColumnsChanged(TableHeaderComponent *) override
This is called when some of the table's columns are added, removed, hidden, or rearranged.
void autoSizeAllColumns()
Calls autoSizeColumn() for all columns in the table.
void setModel(TableListBoxModel *newModel)
Changes the TableListBoxModel that is being used for this table.
int getHeaderHeight() const noexcept
Returns the height of the table header.
std::unique_ptr< AccessibilityHandler > createAccessibilityHandler() override
Override this method to return a custom AccessibilityHandler for this component.
TableListBoxModel * getTableListBoxModel() const noexcept
Returns the model currently in use.
void scrollToEnsureColumnIsOnscreen(int columnId)
Scrolls horizontally if necessary to make sure that a particular column is visible.
void paintListBoxItem(int, Graphics &, int, int, bool) override
This method must be implemented to draw a row of the list.
bool isAutoSizeMenuOptionShown() const noexcept
True if the auto-size options should be shown on the menu.
void setHeaderHeight(int newHeight)
Changes the height of the table header component.
TableListBox(const String &componentName=String(), TableListBoxModel *model=nullptr)
Creates a TableListBox.
void autoSizeColumn(int columnId)
Resizes a column to fit its contents.
Component * getCellComponent(int columnId, int rowNumber) const
Returns the component that currently represents a given cell.
void deleteKeyPressed(int currentSelectedRow) override
Override this to be informed when the delete key is pressed.
void setHeader(std::unique_ptr< TableHeaderComponent > newHeader)
Sets the header component to use for the table.
void tableColumnsResized(TableHeaderComponent *) override
This is called when one or more of the table's columns are resized.
void setAutoSizeMenuOptionShown(bool shouldBeShown) noexcept
Enables or disables the auto size options on the popup menu.
Component * refreshComponentForRow(int rowNumber, bool isRowSelected, Component *existingComponentToUpdate) override
This is used to create or update a custom component to go in a row of the list.
void listWasScrolled() override
Override this to be informed when the list is scrolled.
void resized() override
Called when this component's size has been changed.
int getNumRows() override
This has to return the number of items in the list.
void selectedRowsChanged(int row) override
Override this to be informed when rows are selected or deselected.
~TableListBox() override
Destructor.
TableHeaderComponent & getHeader() const noexcept
Returns the header component being used in this table.
Rectangle< int > getCellPosition(int columnId, int rowNumber, bool relativeToComponentTopLeft) const
Returns the position of one of the cells in the table.
void returnKeyPressed(int currentSelectedRow) override
Override this to be informed when the return key is pressed.
void tableSortOrderChanged(TableHeaderComponent *) override
This is called when the column by which the table should be sorted is changed.
void tableColumnDraggingChanged(TableHeaderComponent *, int) override
This is called when the user begins or ends dragging one of the columns around.
void backgroundClicked(const MouseEvent &) override
This can be overridden to react to the user clicking on a part of the list where there are no rows.
Components that want to use pop-up tooltips should implement this interface.
A variant class, that can be used to hold a range of primitive values.
#define TRANS(stringLiteral)
Uses the LocalisedStrings class to translate the given string literal.
#define jassert(expression)
Platform-independent assertion macro.
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
This is a shorthand way of writing both a JUCE_DECLARE_NON_COPYABLE and JUCE_LEAK_DETECTOR macro for ...
#define jassertfalse
This will always cause an assertion failure.
JUCE Namespace.
constexpr Type jmin(Type a, Type b)
Returns the smaller of two values.
constexpr Type jmax(Type a, Type b)
Returns the larger of two values.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88
bool isPositiveAndBelow(Type1 valueToTest, Type2 upperLimit) noexcept
Returns true if a value is at least zero, and also below a specified upper limit.
AccessibilityRole
The list of available roles for an AccessibilityHandler object.
Utility struct which holds one or more accessibility interfaces.
typedef size_t