openshot-audio  0.1.6
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) 2015 - ROLI Ltd.
6 
7  Permission is granted to use this software under the terms of either:
8  a) the GPL v2 (or any later version)
9  b) the Affero GPL v3
10 
11  Details of these licenses can be found at: www.gnu.org/licenses
12 
13  JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15  A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17  ------------------------------------------------------------------------------
18 
19  To release a closed-source product which uses JUCE, commercial licenses are
20  available: visit www.juce.com for more information.
21 
22  ==============================================================================
23 */
24 
25 #ifndef JUCE_TABLELISTBOX_H_INCLUDED
26 #define JUCE_TABLELISTBOX_H_INCLUDED
27 
28 
29 //==============================================================================
39 {
40 public:
41  //==============================================================================
43 
45  virtual ~TableListBoxModel() {}
46 
47  //==============================================================================
53  virtual int getNumRows() = 0;
54 
63  virtual void paintRowBackground (Graphics&,
64  int rowNumber,
65  int width, int height,
66  bool rowIsSelected) = 0;
67 
76  virtual void paintCell (Graphics&,
77  int rowNumber,
78  int columnId,
79  int width, int height,
80  bool rowIsSelected) = 0;
81 
82  //==============================================================================
103  virtual Component* refreshComponentForCell (int rowNumber, int columnId, bool isRowSelected,
104  Component* existingComponentToUpdate);
105 
106  //==============================================================================
112  virtual void cellClicked (int rowNumber, int columnId, const MouseEvent&);
113 
119  virtual void cellDoubleClicked (int rowNumber, int columnId, const MouseEvent&);
120 
126  virtual void backgroundClicked (const MouseEvent&);
127 
128  //==============================================================================
137  virtual void sortOrderChanged (int newSortColumnId, bool isForwards);
138 
139  //==============================================================================
149  virtual int getColumnAutoSizeWidth (int columnId);
150 
152  virtual String getCellTooltip (int rowNumber, int columnId);
153 
154  //==============================================================================
158  virtual void selectedRowsChanged (int lastRowSelected);
159 
163  virtual void deleteKeyPressed (int lastRowSelected);
164 
168  virtual void returnKeyPressed (int lastRowSelected);
169 
175  virtual void listWasScrolled();
176 
186  virtual var getDragSourceDescription (const SparseSet<int>& currentlySelectedRows);
187 
188 private:
189  #if JUCE_CATCH_DEPRECATED_CODE_MISUSE
190  // This method's signature has changed to take a MouseEvent parameter - please update your code!
191  JUCE_DEPRECATED_WITH_BODY (virtual int backgroundClicked(), { return 0; })
192  #endif
193 };
194 
195 
196 //==============================================================================
207  private ListBoxModel,
209 {
210 public:
211  //==============================================================================
219  TableListBox (const String& componentName = String(),
220  TableListBoxModel* model = nullptr);
221 
223  ~TableListBox();
224 
225  //==============================================================================
230  void setModel (TableListBoxModel* newModel);
231 
234 
235  //==============================================================================
238 
244  void setHeader (TableHeaderComponent* newHeader);
245 
249  void setHeaderHeight (int newHeight);
250 
254  int getHeaderHeight() const noexcept;
255 
256  //==============================================================================
264  void autoSizeColumn (int columnId);
265 
267  void autoSizeAllColumns();
268 
272  void setAutoSizeMenuOptionShown (bool shouldBeShown) noexcept;
273 
277  bool isAutoSizeMenuOptionShown() const noexcept { return autoSizeOptionsShown; }
278 
288  Rectangle<int> getCellPosition (int columnId, int rowNumber,
289  bool relativeToComponentTopLeft) const;
290 
296  Component* getCellComponent (int columnId, int rowNumber) const;
297 
302  void scrollToEnsureColumnIsOnscreen (int columnId);
303 
304  //==============================================================================
306  int getNumRows() override;
308  void paintListBoxItem (int, Graphics&, int, int, bool) override;
310  Component* refreshComponentForRow (int rowNumber, bool isRowSelected, Component* existingComponentToUpdate) override;
312  void selectedRowsChanged (int lastRowSelected) override;
314  void deleteKeyPressed (int currentSelectedRow) override;
316  void returnKeyPressed (int currentSelectedRow) override;
318  void backgroundClicked (const MouseEvent&) override;
320  void listWasScrolled() override;
322  void tableColumnsChanged (TableHeaderComponent*) override;
324  void tableColumnsResized (TableHeaderComponent*) override;
328  void tableColumnDraggingChanged (TableHeaderComponent*, int) override;
330  void resized() override;
331 
332 
333 private:
334  //==============================================================================
335  class Header;
336  class RowComp;
337 
338  TableHeaderComponent* header;
339  TableListBoxModel* model;
340  int columnIdNowBeingDragged;
341  bool autoSizeOptionsShown;
342 
343  void updateColumnComponents() const;
344 
346 };
347 
348 
349 #endif // JUCE_TABLELISTBOX_H_INCLUDED
Definition: juce_Variant.h:46
TableHeaderComponent & getHeader() const noexcept
Definition: juce_TableListBox.h:237
Definition: juce_TableListBox.h:38
Definition: juce_TableListBox.h:206
void setModel(ListBoxModel *newModel)
Definition: juce_ListBox.cpp:393
TableListBoxModel * getModel() const noexcept
Definition: juce_TableListBox.h:233
Definition: juce_ListBox.h:177
virtual void tableSortOrderChanged(TableHeaderComponent *tableHeader)=0
virtual void tableColumnsResized(TableHeaderComponent *tableHeader)=0
#define noexcept
Definition: juce_CompilerSupport.h:141
TableListBoxModel()
Definition: juce_TableListBox.h:42
friend class TableListBox
Definition: juce_ListBox.h:572
virtual void returnKeyPressed(int lastRowSelected)
Definition: juce_ListBox.cpp:964
virtual void listWasScrolled()
Definition: juce_ListBox.cpp:965
Definition: juce_String.h:43
void resized() override
Definition: juce_ListBox.cpp:438
virtual ~TableListBoxModel()
Definition: juce_TableListBox.h:45
bool isAutoSizeMenuOptionShown() const noexcept
Definition: juce_TableListBox.h:277
#define JUCE_API
Definition: juce_StandardHeader.h:139
#define const
Definition: juce_Rectangle.h:36
Definition: juce_TableHeaderComponent.h:43
virtual int getNumRows()=0
Definition: juce_Component.h:33
virtual void backgroundClicked(const MouseEvent &)
Definition: juce_ListBox.cpp:961
virtual void tableColumnDraggingChanged(TableHeaderComponent *tableHeader, int columnIdNowBeingDragged)
Definition: juce_TableHeaderComponent.cpp:924
virtual void paintListBoxItem(int rowNumber, Graphics &g, int width, int height, bool rowIsSelected)=0
png_const_structrp png_const_inforp int png_fixed_point * width
Definition: juce_PNGLoader.cpp:2339
virtual void selectedRowsChanged(int lastRowSelected)
Definition: juce_ListBox.cpp:962
virtual Component * refreshComponentForRow(int rowNumber, bool isRowSelected, Component *existingComponentToUpdate)
Definition: juce_ListBox.cpp:952
virtual void tableColumnsChanged(TableHeaderComponent *tableHeader)=0
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition: juce_PlatformDefs.h:198
Definition: juce_GraphicsContext.h:42
Definition: juce_TableListBox.cpp:25
virtual void deleteKeyPressed(int lastRowSelected)
Definition: juce_ListBox.cpp:963
Definition: juce_TableHeaderComponent.h:302
#define JUCE_DEPRECATED_WITH_BODY(functionDef, body)
Definition: juce_PlatformDefs.h:320
Definition: juce_MouseEvent.h:36
Definition: juce_ListBox.h:35
Definition: juce_TableListBox.cpp:219