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.h
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
29//==============================================================================
40class JUCE_API TableListBoxModel
41{
42public:
43 //==============================================================================
44 TableListBoxModel() = default;
45
47 virtual ~TableListBoxModel() = default;
48
49 //==============================================================================
55 virtual int getNumRows() = 0;
56
66 int rowNumber,
67 int width, int height,
68 bool rowIsSelected) = 0;
69
78 virtual void paintCell (Graphics&,
79 int rowNumber,
80 int columnId,
81 int width, int height,
82 bool rowIsSelected) = 0;
83
84 //==============================================================================
105 virtual Component* refreshComponentForCell (int rowNumber, int columnId, bool isRowSelected,
106 Component* existingComponentToUpdate);
107
108 //==============================================================================
114 virtual void cellClicked (int rowNumber, int columnId, const MouseEvent&);
115
121 virtual void cellDoubleClicked (int rowNumber, int columnId, const MouseEvent&);
122
128 virtual void backgroundClicked (const MouseEvent&);
129
130 //==============================================================================
139 virtual void sortOrderChanged (int newSortColumnId, bool isForwards);
140
141 //==============================================================================
151 virtual int getColumnAutoSizeWidth (int columnId);
152
154 virtual String getCellTooltip (int rowNumber, int columnId);
155
156 //==============================================================================
160 virtual void selectedRowsChanged (int lastRowSelected);
161
165 virtual void deleteKeyPressed (int lastRowSelected);
166
170 virtual void returnKeyPressed (int lastRowSelected);
171
177 virtual void listWasScrolled();
178
188 virtual var getDragSourceDescription (const SparseSet<int>& currentlySelectedRows);
189
193 virtual bool mayDragToExternalWindows() const { return true; }
194};
195
196
197//==============================================================================
209class JUCE_API TableListBox : public ListBox,
210 private ListBoxModel,
212{
213public:
214 //==============================================================================
222 TableListBox (const String& componentName = String(),
223 TableListBoxModel* model = nullptr);
224
226 ~TableListBox() override;
227
228 //==============================================================================
233 void setModel (TableListBoxModel* newModel);
234
236 TableListBoxModel* getTableListBoxModel() const noexcept { return model; }
237
238 //==============================================================================
240 TableHeaderComponent& getHeader() const noexcept { return *header; }
241
247 void setHeader (std::unique_ptr<TableHeaderComponent> newHeader);
248
252 void setHeaderHeight (int newHeight);
253
257 int getHeaderHeight() const noexcept;
258
259 //==============================================================================
267 void autoSizeColumn (int columnId);
268
270 void autoSizeAllColumns();
271
275 void setAutoSizeMenuOptionShown (bool shouldBeShown) noexcept;
276
280 bool isAutoSizeMenuOptionShown() const noexcept { return autoSizeOptionsShown; }
281
291 Rectangle<int> getCellPosition (int columnId, int rowNumber,
292 bool relativeToComponentTopLeft) const;
293
299 Component* getCellComponent (int columnId, int rowNumber) const;
300
305 void scrollToEnsureColumnIsOnscreen (int columnId);
306
307 //==============================================================================
309 int getNumRows() override;
311 void paintListBoxItem (int, Graphics&, int, int, bool) override;
313 Component* refreshComponentForRow (int rowNumber, bool isRowSelected, Component* existingComponentToUpdate) override;
315 void selectedRowsChanged (int row) override;
317 void deleteKeyPressed (int currentSelectedRow) override;
319 void returnKeyPressed (int currentSelectedRow) override;
321 void backgroundClicked (const MouseEvent&) override;
323 void listWasScrolled() override;
325 void tableColumnsChanged (TableHeaderComponent*) override;
327 void tableColumnsResized (TableHeaderComponent*) override;
329 void tableSortOrderChanged (TableHeaderComponent*) override;
331 void tableColumnDraggingChanged (TableHeaderComponent*, int) override;
333 void resized() override;
335 std::unique_ptr<AccessibilityHandler> createAccessibilityHandler() override;
336
338 [[deprecated ("This function hides the non-virtual ListBox::getModel, use getTableListBoxModel instead")]]
339 TableListBoxModel* getModel() const noexcept { return getTableListBoxModel(); }
340
341private:
342 //==============================================================================
343 class Header;
344 class RowComp;
345
346 TableHeaderComponent* header = nullptr;
347 TableListBoxModel* model;
348 int columnIdNowBeingDragged = 0;
349 bool autoSizeOptionsShown = true;
350
351 void updateColumnComponents() const;
352
354};
355
356} // namespace juce
The base class for all JUCE user-interface objects.
A graphics context, used for drawing a component or image.
A subclass of this is used to drive a ListBox.
A list of items that can be scrolled vertically.
Contains position and status information about a mouse event.
Manages a rectangle and allows geometric operations to be performed on it.
Holds a set of primitive values, storing them as a set of ranges.
The JUCE String class!
Definition juce_String.h:53
Receives events from a TableHeaderComponent when columns are resized, moved, etc.
A component that displays a strip of column headings for a table, and allows these to be resized,...
One of these is used by a TableListBox as the data model for the table's contents.
virtual ~TableListBoxModel()=default
Destructor.
virtual void paintCell(Graphics &, int rowNumber, int columnId, int width, int height, bool rowIsSelected)=0
This must draw one of the cells.
virtual bool mayDragToExternalWindows() const
Called when starting a drag operation on a list row to determine whether the item may be dragged to o...
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.
virtual int getNumRows()=0
This must return the number of rows currently in the table.
A table of cells, using a TableHeaderComponent as its header.
TableListBoxModel * getTableListBoxModel() const noexcept
Returns the model currently in use.
TableHeaderComponent & getHeader() const noexcept
Returns the header component being used in this table.
TableListBoxModel * getModel() const noexcept
Returns the model currently in use.
A variant class, that can be used to hold a range of primitive values.
#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 ...
JUCE Namespace.