LMMS
Loading...
Searching...
No Matches
juce::TableHeaderComponent Class Reference

#include <juce_TableHeaderComponent.h>

Inheritance diagram for juce::TableHeaderComponent:
juce::Component juce::AsyncUpdater juce::MouseListener juce::TableListBox::Header

Classes

class  Listener
struct  LookAndFeelMethods
struct  ColumnInfo
class  DragOverlayComp

Public Types

enum  ColumnPropertyFlags {
  visible = 1 , resizable = 2 , draggable = 4 , appearsOnColumnMenu = 8 ,
  sortable = 16 , sortedForwards = 32 , sortedBackwards = 64 , defaultFlags = (visible | resizable | draggable | appearsOnColumnMenu | sortable) ,
  notResizable = (visible | draggable | appearsOnColumnMenu | sortable) , notResizableOrSortable = (visible | draggable | appearsOnColumnMenu) , notSortable = (visible | resizable | draggable | appearsOnColumnMenu)
}
enum  ColourIds { textColourId = 0x1003800 , backgroundColourId = 0x1003810 , outlineColourId = 0x1003820 , highlightColourId = 0x1003830 }
Public Types inherited from juce::Component
enum class  FocusContainerType { none , focusContainer , keyboardFocusContainer }
enum  FocusChangeType { focusChangedByMouseClick , focusChangedByTabKey , focusChangedDirectly }

Public Member Functions

 TableHeaderComponent ()
 ~TableHeaderComponent () override
void addColumn (const String &columnName, int columnId, int width, int minimumWidth=30, int maximumWidth=-1, int propertyFlags=defaultFlags, int insertIndex=-1)
void removeColumn (int columnIdToRemove)
void removeAllColumns ()
int getNumColumns (bool onlyCountVisibleColumns) const
String getColumnName (int columnId) const
void setColumnName (int columnId, const String &newName)
void moveColumn (int columnId, int newVisibleIndex)
int getColumnWidth (int columnId) const
void setColumnWidth (int columnId, int newWidth)
void setColumnVisible (int columnId, bool shouldBeVisible)
bool isColumnVisible (int columnId) const
void setSortColumnId (int columnId, bool sortForwards)
int getSortColumnId () const
bool isSortedForwards () const
void reSortTable ()
int getTotalWidth () const
int getIndexOfColumnId (int columnId, bool onlyCountVisibleColumns) const
int getColumnIdOfIndex (int index, bool onlyCountVisibleColumns) const
Rectangle< intgetColumnPosition (int index) const
int getColumnIdAtX (int xToFind) const
void setStretchToFitActive (bool shouldStretchToFit)
bool isStretchToFitActive () const
void resizeAllColumnsToFit (int targetTotalWidth)
void setPopupMenuActive (bool hasMenu)
bool isPopupMenuActive () const
String toString () const
void restoreFromString (const String &storedVersion)
void addListener (Listener *newListener)
void removeListener (Listener *listenerToRemove)
virtual void columnClicked (int columnId, const ModifierKeys &mods)
virtual void addMenuItems (PopupMenu &menu, int columnIdClicked)
virtual void reactToMenuItem (int menuReturnId, int columnIdClicked)
void paint (Graphics &) override
void mouseMove (const MouseEvent &) override
void mouseEnter (const MouseEvent &) override
void mouseExit (const MouseEvent &) override
void mouseDown (const MouseEvent &) override
void mouseDrag (const MouseEvent &) override
void mouseUp (const MouseEvent &) override
MouseCursor getMouseCursor () override
virtual void showColumnChooserMenu (int columnIdClicked)
Public Member Functions inherited from juce::Component
 Component () noexcept
 ~Component () override
 Component (const String &componentName) noexcept
String getName () const noexcept
virtual void setName (const String &newName)
String getComponentID () const noexcept
void setComponentID (const String &newID)
virtual void setVisible (bool shouldBeVisible)
bool isVisible () const noexcept
virtual void visibilityChanged ()
bool isShowing () const
virtual void addToDesktop (int windowStyleFlags, void *nativeWindowToAttachTo=nullptr)
void removeFromDesktop ()
bool isOnDesktop () const noexcept
ComponentPeergetPeer () const
virtual void userTriedToCloseWindow ()
virtual void minimisationStateChanged (bool isNowMinimised)
virtual float getDesktopScaleFactor () const
void toFront (bool shouldAlsoGainKeyboardFocus)
void toBack ()
void toBehind (Component *other)
void setAlwaysOnTop (bool shouldStayOnTop)
bool isAlwaysOnTop () const noexcept
int getX () const noexcept
int getY () const noexcept
int getWidth () const noexcept
int getHeight () const noexcept
int getRight () const noexcept
Point< intgetPosition () const noexcept
int getBottom () const noexcept
Rectangle< intgetBounds () const noexcept
Rectangle< intgetLocalBounds () const noexcept
Rectangle< intgetBoundsInParent () const noexcept
int getScreenX () const
int getScreenY () const
Point< intgetScreenPosition () const
Rectangle< intgetScreenBounds () const
Point< intgetLocalPoint (const Component *sourceComponent, Point< int > pointRelativeToSourceComponent) const
Point< float > getLocalPoint (const Component *sourceComponent, Point< float > pointRelativeToSourceComponent) const
Rectangle< intgetLocalArea (const Component *sourceComponent, Rectangle< int > areaRelativeToSourceComponent) const
Rectangle< float > getLocalArea (const Component *sourceComponent, Rectangle< float > areaRelativeToSourceComponent) const
Point< intlocalPointToGlobal (Point< int > localPoint) const
Point< float > localPointToGlobal (Point< float > localPoint) const
Rectangle< intlocalAreaToGlobal (Rectangle< int > localArea) const
Rectangle< float > localAreaToGlobal (Rectangle< float > localArea) const
void setTopLeftPosition (int x, int y)
void setTopLeftPosition (Point< int > newTopLeftPosition)
void setTopRightPosition (int x, int y)
void setSize (int newWidth, int newHeight)
void setBounds (int x, int y, int width, int height)
void setBounds (Rectangle< int > newBounds)
void setBoundsRelative (float proportionalX, float proportionalY, float proportionalWidth, float proportionalHeight)
void setBoundsRelative (Rectangle< float > proportionalArea)
void setBoundsInset (BorderSize< int > borders)
void setBoundsToFit (Rectangle< int > targetArea, Justification justification, bool onlyReduceInSize)
void setCentrePosition (int x, int y)
void setCentrePosition (Point< int > newCentrePosition)
void setCentreRelative (float x, float y)
void centreWithSize (int width, int height)
void setTransform (const AffineTransform &transform)
AffineTransform getTransform () const
bool isTransformed () const noexcept
int proportionOfWidth (float proportion) const noexcept
int proportionOfHeight (float proportion) const noexcept
int getParentWidth () const noexcept
int getParentHeight () const noexcept
Rectangle< intgetParentMonitorArea () const
int getNumChildComponents () const noexcept
ComponentgetChildComponent (int index) const noexcept
int getIndexOfChildComponent (const Component *child) const noexcept
const Array< Component * > & getChildren () const noexcept
ComponentfindChildWithID (StringRef componentID) const noexcept
void addChildComponent (Component *child, int zOrder=-1)
void addChildComponent (Component &child, int zOrder=-1)
void addAndMakeVisible (Component *child, int zOrder=-1)
void addAndMakeVisible (Component &child, int zOrder=-1)
void addChildAndSetID (Component *child, const String &componentID)
void removeChildComponent (Component *childToRemove)
ComponentremoveChildComponent (int childIndexToRemove)
void removeAllChildren ()
void deleteAllChildren ()
ComponentgetParentComponent () const noexcept
template<class TargetClass>
TargetClass * findParentComponentOfClass () const
ComponentgetTopLevelComponent () const noexcept
bool isParentOf (const Component *possibleChild) const noexcept
virtual void parentHierarchyChanged ()
virtual void childrenChanged ()
virtual bool hitTest (int x, int y)
void setInterceptsMouseClicks (bool allowClicksOnThisComponent, bool allowClicksOnChildComponents) noexcept
void getInterceptsMouseClicks (bool &allowsClicksOnThisComponent, bool &allowsClicksOnChildComponents) const noexcept
bool contains (Point< int > localPoint)
bool contains (Point< float > localPoint)
bool reallyContains (Point< int > localPoint, bool returnTrueIfWithinAChild)
bool reallyContains (Point< float > localPoint, bool returnTrueIfWithinAChild)
ComponentgetComponentAt (int x, int y)
ComponentgetComponentAt (Point< int > position)
ComponentgetComponentAt (Point< float > position)
void repaint ()
void repaint (int x, int y, int width, int height)
void repaint (Rectangle< int > area)
void setBufferedToImage (bool shouldBeBuffered)
Image createComponentSnapshot (Rectangle< int > areaToGrab, bool clipImageToComponentBounds=true, float scaleFactor=1.0f)
void paintEntireComponent (Graphics &context, bool ignoreAlphaLevel)
void setPaintingIsUnclipped (bool shouldPaintWithoutClipping) noexcept
bool isPaintingUnclipped () const noexcept
void setComponentEffect (ImageEffectFilter *newEffect)
ImageEffectFiltergetComponentEffect () const noexcept
LookAndFeelgetLookAndFeel () const noexcept
void setLookAndFeel (LookAndFeel *newLookAndFeel)
virtual void lookAndFeelChanged ()
void sendLookAndFeelChange ()
void setOpaque (bool shouldBeOpaque)
bool isOpaque () const noexcept
void setBroughtToFrontOnMouseClick (bool shouldBeBroughtToFront) noexcept
bool isBroughtToFrontOnMouseClick () const noexcept
void setExplicitFocusOrder (int newFocusOrderIndex)
int getExplicitFocusOrder () const
void setFocusContainerType (FocusContainerType containerType) noexcept
bool isFocusContainer () const noexcept
bool isKeyboardFocusContainer () const noexcept
ComponentfindFocusContainer () const
ComponentfindKeyboardFocusContainer () const
void setWantsKeyboardFocus (bool wantsFocus) noexcept
bool getWantsKeyboardFocus () const noexcept
void setMouseClickGrabsKeyboardFocus (bool shouldGrabFocus)
bool getMouseClickGrabsKeyboardFocus () const noexcept
void grabKeyboardFocus ()
void giveAwayKeyboardFocus ()
bool hasKeyboardFocus (bool trueIfChildIsFocused) const
void moveKeyboardFocusToSibling (bool moveToNext)
virtual std::unique_ptr< ComponentTraversercreateFocusTraverser ()
virtual std::unique_ptr< ComponentTraversercreateKeyboardFocusTraverser ()
void setHasFocusOutline (bool hasFocusOutline) noexcept
bool hasFocusOutline () const noexcept
bool isEnabled () const noexcept
void setEnabled (bool shouldBeEnabled)
virtual void enablementChanged ()
float getAlpha () const noexcept
void setAlpha (float newAlpha)
virtual void alphaChanged ()
void setMouseCursor (const MouseCursor &cursorType)
void updateMouseCursor () const
virtual void paintOverChildren (Graphics &g)
void mouseDoubleClick (const MouseEvent &event) override
void mouseWheelMove (const MouseEvent &event, const MouseWheelDetails &wheel) override
void mouseMagnify (const MouseEvent &event, float scaleFactor) override
void setRepaintsOnMouseActivity (bool shouldRepaint) noexcept
void addMouseListener (MouseListener *newListener, bool wantsEventsForAllNestedChildComponents)
void removeMouseListener (MouseListener *listenerToRemove)
void addKeyListener (KeyListener *newListener)
void removeKeyListener (KeyListener *listenerToRemove)
virtual bool keyPressed (const KeyPress &key)
virtual bool keyStateChanged (bool isKeyDown)
virtual void modifierKeysChanged (const ModifierKeys &modifiers)
virtual void focusGained (FocusChangeType cause)
virtual void focusLost (FocusChangeType cause)
virtual void focusOfChildComponentChanged (FocusChangeType cause)
bool isMouseOver (bool includeChildren=false) const
bool isMouseButtonDown (bool includeChildren=false) const
bool isMouseOverOrDragging (bool includeChildren=false) const
Point< intgetMouseXYRelative () const
virtual void resized ()
virtual void moved ()
virtual void childBoundsChanged (Component *child)
virtual void parentSizeChanged ()
virtual void broughtToFront ()
void addComponentListener (ComponentListener *newListener)
void removeComponentListener (ComponentListener *listenerToRemove)
void postCommandMessage (int commandId)
virtual void handleCommandMessage (int commandId)
void enterModalState (bool takeKeyboardFocus=true, ModalComponentManager::Callback *callback=nullptr, bool deleteWhenDismissed=false)
void exitModalState (int returnValue)
bool isCurrentlyModal (bool onlyConsiderForemostModalComponent=true) const noexcept
bool isCurrentlyBlockedByAnotherModalComponent () const
virtual bool canModalEventBeSentToComponent (const Component *targetComponent)
virtual void inputAttemptWhenModal ()
NamedValueSetgetProperties () noexcept
const NamedValueSetgetProperties () const noexcept
Colour findColour (int colourID, bool inheritFromParent=false) const
void setColour (int colourID, Colour newColour)
void removeColour (int colourID)
bool isColourSpecified (int colourID) const
void copyAllExplicitColoursTo (Component &target) const
virtual void colourChanged ()
voidgetWindowHandle () const
PositionergetPositioner () const noexcept
void setPositioner (Positioner *newPositioner)
void setCachedComponentImage (CachedComponentImage *newCachedImage)
CachedComponentImagegetCachedComponentImage () const noexcept
void setViewportIgnoreDragFlag (bool ignoreDrag) noexcept
bool getViewportIgnoreDragFlag () const noexcept
String getTitle () const noexcept
void setTitle (const String &newTitle)
String getDescription () const noexcept
void setDescription (const String &newDescription)
String getHelpText () const noexcept
void setHelpText (const String &newHelpText)
void setAccessible (bool shouldBeAccessible)
bool isAccessible () const noexcept
AccessibilityHandlergetAccessibilityHandler ()
void invalidateAccessibilityHandler ()
void setFocusContainer (bool shouldBeFocusContainer) noexcept
void contains (int, int)=delete
Public Member Functions inherited from juce::MouseListener
virtual ~MouseListener ()=default

Private Member Functions

std::unique_ptr< AccessibilityHandlercreateAccessibilityHandler () override
ColumnInfogetInfoForId (int columnId) const
int visibleIndexToTotalIndex (int visibleIndex) const
void sendColumnsChanged ()
void handleAsyncUpdate () override
void beginDrag (const MouseEvent &)
void endDrag (int finalIndex)
int getResizeDraggerAt (int mouseX) const
void updateColumnUnderMouse (const MouseEvent &)
void setColumnUnderMouse (int columnId)
void resizeColumnsToFit (int firstColumnIndex, int targetTotalWidth)
Private Member Functions inherited from juce::AsyncUpdater
 AsyncUpdater ()
virtual ~AsyncUpdater ()
void triggerAsyncUpdate ()
void cancelPendingUpdate () noexcept
void handleUpdateNowIfNeeded ()
bool isUpdatePending () const noexcept

Private Attributes

OwnedArray< ColumnInfocolumns
Array< Listener * > listeners
std::unique_ptr< ComponentdragOverlayComp
bool columnsChanged = false
bool columnsResized = false
bool sortChanged = false
bool menuActive = true
bool stretchToFit = false
int columnIdBeingResized = 0
int columnIdBeingDragged = 0
int initialColumnWidth = 0
int columnIdUnderMouse = 0
int draggingColumnOffset = 0
int draggingColumnOriginalIndex = 0
int lastDeliberateWidth = 0

Additional Inherited Members

Static Public Member Functions inherited from juce::Component
static float JUCE_CALLTYPE getApproximateScaleFactorForComponent (const Component *targetComponent)
static Component *JUCE_CALLTYPE getCurrentlyFocusedComponent () noexcept
static void JUCE_CALLTYPE unfocusAllComponents ()
static void JUCE_CALLTYPE beginDragAutoRepeat (int millisecondsBetweenCallbacks)
static bool JUCE_CALLTYPE isMouseButtonDownAnywhere () noexcept
static int JUCE_CALLTYPE getNumCurrentlyModalComponents () noexcept
static Component *JUCE_CALLTYPE getCurrentlyModalComponent (int index=0) noexcept
Protected Member Functions inherited from juce::Component
virtual ComponentPeercreateNewPeer (int styleFlags, void *nativeWindowToAttachTo)
Static Protected Member Functions inherited from juce::Component
static std::unique_ptr< AccessibilityHandlercreateIgnoredAccessibilityHandler (Component &)

Detailed Description

A component that displays a strip of column headings for a table, and allows these to be resized, dragged around, etc.

This is just the component that goes at the top of a table. You can use it directly for custom components, or to create a simple table, use the TableListBox class.

To use one of these, create it and use addColumn() to add all the columns that you need. Each column must be given a unique ID number that's used to refer to it.

See also
TableListBox, TableHeaderComponent::Listener

@tags{GUI}

Member Enumeration Documentation

◆ ColourIds

enum juce::TableHeaderComponent::ColourIds

A set of colour IDs to use to change the colour of various aspects of the TableHeaderComponent.

See also
Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
Enumerator
textColourId 

The colour for the text in the header.

backgroundColourId 

The colour of the table header background. It's up to the LookAndFeel how this is used.

outlineColourId 

The colour of the table header's outline.

highlightColourId 

The colour of the table header background when the mouse is over or down above the the table header. It's up to the LookAndFeel to use a variant of this colour to distinguish between the down and hover state.

◆ ColumnPropertyFlags

enum juce::TableHeaderComponent::ColumnPropertyFlags

A combination of these flags are passed into the addColumn() method to specify the properties of a column.

Enumerator
visible 

If this is set, the column will be shown; if not, it will be hidden until the user enables it with the pop-up menu.

resizable 

If this is set, the column can be resized by dragging it.

draggable 

If this is set, the column can be dragged around to change its order in the table.

appearsOnColumnMenu 

If this is set, the column will be shown on the pop-up menu allowing it to be hidden/shown.

sortable 

If this is set, then clicking on the column header will set it to be the sort column, and clicking again will reverse the order.

sortedForwards 

If this is set, the column is currently the one by which the table is sorted (forwards).

sortedBackwards 

If this is set, the column is currently the one by which the table is sorted (backwards).

defaultFlags 

This set of default flags is used as the default parameter value in addColumn().

notResizable 

A quick way of combining flags for a column that's not resizable.

notResizableOrSortable 

A quick way of combining flags for a column that's not resizable or sortable.

notSortable 

A quick way of combining flags for a column that's not sortable.

Constructor & Destructor Documentation

◆ TableHeaderComponent()

juce::TableHeaderComponent::TableHeaderComponent ( )

Creates an empty table header.

◆ ~TableHeaderComponent()

juce::TableHeaderComponent::~TableHeaderComponent ( )
override

Destructor.

Member Function Documentation

◆ addColumn()

void juce::TableHeaderComponent::addColumn ( const String & columnName,
int columnId,
int width,
int minimumWidth = 30,
int maximumWidth = -1,
int propertyFlags = defaultFlags,
int insertIndex = -1 )

Adds a column to the table.

This will add a column, and asynchronously call the tableColumnsChanged() method of any registered listeners.

Parameters
columnNamethe name of the new column. It's ok to have two or more columns with the same name
columnIdan ID for this column. The ID can be any number apart from 0, but every column must have a unique ID. This is used to identify the column later on, after the user may have changed the order that they appear in
widththe initial width of the column, in pixels
maximumWidtha maximum width that the column can take when the user is resizing it. This only applies if the 'resizable' flag is specified for this column
minimumWidtha minimum width that the column can take when the user is resizing it. This only applies if the 'resizable' flag is specified for this column
propertyFlagsa combination of some of the values from the ColumnPropertyFlags enum, to define the properties of this column
insertIndexthe index at which the column should be added. A value of 0 puts it at the start (left-hand side) and -1 puts it at the end (right-hand size) of the table. Note that the index the index within all columns, not just the index amongst those that are currently visible

◆ addListener()

void juce::TableHeaderComponent::addListener ( Listener * newListener)

Adds a listener to be informed about things that happen to the header.

◆ addMenuItems()

void juce::TableHeaderComponent::addMenuItems ( PopupMenu & menu,
int columnIdClicked )
virtual

This can be overridden to add custom items to the pop-up menu.

If you override this, you should call the superclass's method to add its column show/hide items, if you want them on the menu as well.

Then to handle the result, override reactToMenuItem().

See also
reactToMenuItem

Reimplemented in juce::TableListBox::Header.

◆ beginDrag()

void juce::TableHeaderComponent::beginDrag ( const MouseEvent & e)
private

◆ columnClicked()

void juce::TableHeaderComponent::columnClicked ( int columnId,
const ModifierKeys & mods )
virtual

This can be overridden to handle a mouse-click on one of the column headers.

The default implementation will use this click to call getSortColumnId() and change the sort order.

◆ createAccessibilityHandler()

std::unique_ptr< AccessibilityHandler > juce::TableHeaderComponent::createAccessibilityHandler ( )
overrideprivatevirtual

Override this method to return a custom AccessibilityHandler for this component.

The default implementation creates and returns a AccessibilityHandler object with an unspecified role, meaning that it will be visible to accessibility clients but without a specific role, action callbacks or interfaces. To control how accessibility clients see and interact with your component subclass AccessibilityHandler, implement the desired behaviours, and return an instance of it from this method in your component subclass.

The accessibility handler you return here is guaranteed to be destroyed before its Component, so it's safe to store and use a reference back to the Component inside the AccessibilityHandler if necessary.

See also
getAccessibilityHandler

Reimplemented from juce::Component.

◆ endDrag()

void juce::TableHeaderComponent::endDrag ( int finalIndex)
private

◆ getColumnIdAtX()

int juce::TableHeaderComponent::getColumnIdAtX ( int xToFind) const

Finds the column ID at a given x-position in the component. If there is a column at this point this returns its ID, or if not, it will return 0.

◆ getColumnIdOfIndex()

int juce::TableHeaderComponent::getColumnIdOfIndex ( int index,
bool onlyCountVisibleColumns ) const

Returns the ID of the column at a given index.

If onlyCountVisibleColumns is true, this will count the index amongst the visible columns; otherwise it'll count it amongst all the columns, including any hidden ones.

If the index is out-of-range, it'll return 0.

◆ getColumnName()

String juce::TableHeaderComponent::getColumnName ( int columnId) const

Returns the name for a column.

See also
setColumnName

◆ getColumnPosition()

Rectangle< int > juce::TableHeaderComponent::getColumnPosition ( int index) const

Returns the rectangle containing of one of the columns.

The index is an index from 0 to the number of columns that are currently visible (hidden ones are not counted). It returns a rectangle showing the position of the column relative to this component's top-left. If the index is out-of-range, an empty rectangle is returned.

◆ getColumnWidth()

int juce::TableHeaderComponent::getColumnWidth ( int columnId) const

Returns the width of one of the columns.

◆ getIndexOfColumnId()

int juce::TableHeaderComponent::getIndexOfColumnId ( int columnId,
bool onlyCountVisibleColumns ) const

Returns the index of a given column.

If there's no such column ID, this will return -1.

If onlyCountVisibleColumns is true, this will return the index amongst the visible columns; otherwise it'll return the index amongst all the columns, including any hidden ones.

◆ getInfoForId()

TableHeaderComponent::ColumnInfo * juce::TableHeaderComponent::getInfoForId ( int columnId) const
private

◆ getMouseCursor()

MouseCursor juce::TableHeaderComponent::getMouseCursor ( )
overridevirtual

Returns the mouse cursor shape to use when the mouse is over this component.

The default implementation will return the cursor that was set by setCursor() but can be overridden for more specialised purposes, e.g. returning different cursors depending on the mouse position.

See also
MouseCursor

Reimplemented from juce::Component.

◆ getNumColumns()

int juce::TableHeaderComponent::getNumColumns ( bool onlyCountVisibleColumns) const

Returns the number of columns in the table.

If onlyCountVisibleColumns is true, this will return the number of visible columns; otherwise it'll return the total number of columns, including hidden ones.

See also
isColumnVisible

◆ getResizeDraggerAt()

int juce::TableHeaderComponent::getResizeDraggerAt ( int mouseX) const
private

◆ getSortColumnId()

int juce::TableHeaderComponent::getSortColumnId ( ) const

Returns the column ID by which the table is currently sorted, or 0 if it is unsorted.

See also
setSortColumnId, isSortedForwards

◆ getTotalWidth()

int juce::TableHeaderComponent::getTotalWidth ( ) const

Returns the total width of all the visible columns in the table.

◆ handleAsyncUpdate()

void juce::TableHeaderComponent::handleAsyncUpdate ( )
overrideprivatevirtual

Called back to do whatever your class needs to do.

This method is called by the message thread at the next convenient time after the triggerAsyncUpdate() method has been called.

Implements juce::AsyncUpdater.

◆ isColumnVisible()

bool juce::TableHeaderComponent::isColumnVisible ( int columnId) const

Returns true if this column is currently visible.

See also
setColumnVisible

◆ isPopupMenuActive()

bool juce::TableHeaderComponent::isPopupMenuActive ( ) const

Returns true if the pop-up menu is enabled.

See also
setPopupMenuActive

◆ isSortedForwards()

bool juce::TableHeaderComponent::isSortedForwards ( ) const

Returns true if the table is currently sorted forwards, or false if it's backwards.

See also
setSortColumnId

◆ isStretchToFitActive()

bool juce::TableHeaderComponent::isStretchToFitActive ( ) const

Returns true if stretch-to-fit has been enabled.

See also
setStretchToFitActive

◆ mouseDown()

void juce::TableHeaderComponent::mouseDown ( const MouseEvent & event)
overridevirtual

Called when a mouse button is pressed.

The MouseEvent object passed in contains lots of methods for finding out which button was pressed, as well as which modifier keys (e.g. shift, ctrl) were held down at the time.

Once a button is held down, the mouseDrag method will be called when the mouse moves, until the button is released.

Parameters
Eventdetails about the position and status of the mouse event, including the source component in which it occurred
See also
mouseUp, mouseDrag, mouseDoubleClick, contains

Reimplemented from juce::Component.

◆ mouseDrag()

void juce::TableHeaderComponent::mouseDrag ( const MouseEvent & event)
overridevirtual

Called when the mouse is moved while a button is held down.

When a mouse button is pressed inside a component, that component receives mouseDrag callbacks each time the mouse moves, even if the mouse strays outside the component's bounds.

Parameters
Eventdetails about the position and status of the mouse event, including the source component in which it occurred
See also
mouseDown, mouseUp, mouseMove, contains, setDragRepeatInterval

Reimplemented from juce::Component.

◆ mouseEnter()

void juce::TableHeaderComponent::mouseEnter ( const MouseEvent & event)
overridevirtual

Called when the mouse first enters a component.

If the mouse button isn't pressed and the mouse moves into a component, this will be called to let the component react to this.

When the mouse button is pressed and held down while being moved in or out of a component, no mouseEnter or mouseExit callbacks are made - only mouseDrag messages are sent to the component that the mouse was originally clicked on, until the button is released.

Parameters
Eventdetails about the position and status of the mouse event, including the source component in which it occurred
See also
mouseExit, mouseDrag, mouseMove, contains

Reimplemented from juce::Component.

◆ mouseExit()

void juce::TableHeaderComponent::mouseExit ( const MouseEvent & event)
overridevirtual

Called when the mouse moves out of a component.

This will be called when the mouse moves off the edge of this component.

If the mouse button was pressed, and it was then dragged off the edge of the component and released, then this callback will happen when the button is released, after the mouseUp callback.

Parameters
Eventdetails about the position and status of the mouse event, including the source component in which it occurred
See also
mouseEnter, mouseDrag, mouseMove, contains

Reimplemented from juce::Component.

◆ mouseMove()

void juce::TableHeaderComponent::mouseMove ( const MouseEvent & event)
overridevirtual

Called when the mouse moves inside a component.

If the mouse button isn't pressed and the mouse moves over a component, this will be called to let the component react to this.

A component will always get a mouseEnter callback before a mouseMove.

Parameters
Eventdetails about the position and status of the mouse event, including the source component in which it occurred
See also
mouseEnter, mouseExit, mouseDrag, contains

Reimplemented from juce::Component.

◆ mouseUp()

void juce::TableHeaderComponent::mouseUp ( const MouseEvent & event)
overridevirtual

Called when a mouse button is released.

A mouseUp callback is sent to the component in which a button was pressed even if the mouse is actually over a different component when the button is released.

The MouseEvent object passed in contains lots of methods for finding out which buttons were down just before they were released.

Parameters
Eventdetails about the position and status of the mouse event, including the source component in which it occurred
See also
mouseDown, mouseDrag, mouseDoubleClick, contains

Reimplemented from juce::Component.

◆ moveColumn()

void juce::TableHeaderComponent::moveColumn ( int columnId,
int newVisibleIndex )

Moves a column to a different index in the table.

Parameters
columnIdthe column to move
newVisibleIndexthe target index for it, from 0 to the number of columns currently visible.

◆ paint()

void juce::TableHeaderComponent::paint ( Graphics & g)
overridevirtual

Components can override this method to draw their content.

The paint() method gets called when a region of a component needs redrawing, either because the component's repaint() method has been called, or because something has happened on the screen that means a section of a window needs to be redrawn.

Any child components will draw themselves over whatever this method draws. If you need to paint over the top of your child components, you can also implement the paintOverChildren() method to do this.

If you want to cause a component to redraw itself, this is done asynchronously - calling the repaint() method marks a region of the component as "dirty", and the paint() method will automatically be called sometime later, by the message thread, to paint any bits that need refreshing. In JUCE (and almost all modern UI frameworks), you never redraw something synchronously.

You should never need to call this method directly - to take a snapshot of the component you could use createComponentSnapshot() or paintEntireComponent().

Parameters
gthe graphics context that must be used to do the drawing operations.
See also
repaint, paintOverChildren, Graphics

Reimplemented from juce::Component.

◆ reactToMenuItem()

void juce::TableHeaderComponent::reactToMenuItem ( int menuReturnId,
int columnIdClicked )
virtual

Override this to handle any custom items that you have added to the pop-up menu with an addMenuItems() override.

If the menuReturnId isn't one of your own custom menu items, you'll need to call TableHeaderComponent::reactToMenuItem() to allow the base class to handle the items that it had added.

See also
addMenuItems

Reimplemented in juce::TableListBox::Header.

◆ removeAllColumns()

void juce::TableHeaderComponent::removeAllColumns ( )

Deletes all columns from the table.

If there are any columns to remove, this will asynchronously call the tableColumnsChanged() method of any registered listeners.

◆ removeColumn()

void juce::TableHeaderComponent::removeColumn ( int columnIdToRemove)

Removes a column with the given ID.

If there is such a column, this will asynchronously call the tableColumnsChanged() method of any registered listeners.

◆ removeListener()

void juce::TableHeaderComponent::removeListener ( Listener * listenerToRemove)

Removes a previously-registered listener.

◆ resizeAllColumnsToFit()

void juce::TableHeaderComponent::resizeAllColumnsToFit ( int targetTotalWidth)

If stretch-to-fit is enabled, this will resize all the columns to make them fit into the specified width, keeping their relative proportions the same.

If the minimum widths of the columns are too wide to fit into this space, it may actually end up wider.

◆ resizeColumnsToFit()

void juce::TableHeaderComponent::resizeColumnsToFit ( int firstColumnIndex,
int targetTotalWidth )
private

◆ reSortTable()

void juce::TableHeaderComponent::reSortTable ( )

Triggers a re-sort of the table according to the current sort-column.

If you modify the table's contents, you can call this to signal that the table needs to be re-sorted.

(This doesn't do any sorting synchronously - it just asynchronously sends a call to the tableSortOrderChanged() method of any listeners).

◆ restoreFromString()

void juce::TableHeaderComponent::restoreFromString ( const String & storedVersion)

Restores the state of the table, based on a string previously created with toString().

See also
toString

◆ sendColumnsChanged()

void juce::TableHeaderComponent::sendColumnsChanged ( )
private

◆ setColumnName()

void juce::TableHeaderComponent::setColumnName ( int columnId,
const String & newName )

Changes the name of a column.

◆ setColumnUnderMouse()

void juce::TableHeaderComponent::setColumnUnderMouse ( int columnId)
private

◆ setColumnVisible()

void juce::TableHeaderComponent::setColumnVisible ( int columnId,
bool shouldBeVisible )

Shows or hides a column.

This can cause an asynchronous callback to the tableColumnsChanged() method of any registered listeners.

See also
isColumnVisible

◆ setColumnWidth()

void juce::TableHeaderComponent::setColumnWidth ( int columnId,
int newWidth )

Changes the width of a column.

This will cause an asynchronous callback to the tableColumnsResized() method of any registered listeners.

◆ setPopupMenuActive()

void juce::TableHeaderComponent::setPopupMenuActive ( bool hasMenu)

Enables or disables the pop-up menu.

The default menu allows the user to show or hide columns. You can add custom items to this menu by overloading the addMenuItems() and reactToMenuItem() methods.

By default the menu is enabled.

See also
isPopupMenuActive, addMenuItems, reactToMenuItem

◆ setSortColumnId()

void juce::TableHeaderComponent::setSortColumnId ( int columnId,
bool sortForwards )

Changes the column which is the sort column.

This can cause an asynchronous callback to the tableSortOrderChanged() method of any registered listeners.

If this method doesn't actually change the column ID, then no re-sort will take place (you can call reSortTable() to force a re-sort to happen if you've modified the table's contents).

See also
getSortColumnId, isSortedForwards, reSortTable

◆ setStretchToFitActive()

void juce::TableHeaderComponent::setStretchToFitActive ( bool shouldStretchToFit)

If set to true, this indicates that the columns should be expanded or shrunk to fill the entire width of the component.

By default this is disabled. Turning it on also means that when resizing a column, those on the right will be squashed to fit.

◆ showColumnChooserMenu()

void juce::TableHeaderComponent::showColumnChooserMenu ( int columnIdClicked)
virtual

Can be overridden for more control over the pop-up menu behaviour.

◆ toString()

String juce::TableHeaderComponent::toString ( ) const

Returns a string that encapsulates the table's current layout.

This can be restored later using restoreFromString(). It saves the order of the columns, the currently-sorted column, and the widths.

See also
restoreFromString

◆ updateColumnUnderMouse()

void juce::TableHeaderComponent::updateColumnUnderMouse ( const MouseEvent & e)
private

◆ visibleIndexToTotalIndex()

int juce::TableHeaderComponent::visibleIndexToTotalIndex ( int visibleIndex) const
private

Member Data Documentation

◆ columnIdBeingDragged

int juce::TableHeaderComponent::columnIdBeingDragged = 0
private

◆ columnIdBeingResized

int juce::TableHeaderComponent::columnIdBeingResized = 0
private

◆ columnIdUnderMouse

int juce::TableHeaderComponent::columnIdUnderMouse = 0
private

◆ columns

OwnedArray<ColumnInfo> juce::TableHeaderComponent::columns
private

◆ columnsChanged

bool juce::TableHeaderComponent::columnsChanged = false
private

◆ columnsResized

bool juce::TableHeaderComponent::columnsResized = false
private

◆ draggingColumnOffset

int juce::TableHeaderComponent::draggingColumnOffset = 0
private

◆ draggingColumnOriginalIndex

int juce::TableHeaderComponent::draggingColumnOriginalIndex = 0
private

◆ dragOverlayComp

std::unique_ptr<Component> juce::TableHeaderComponent::dragOverlayComp
private

◆ initialColumnWidth

int juce::TableHeaderComponent::initialColumnWidth = 0
private

◆ lastDeliberateWidth

int juce::TableHeaderComponent::lastDeliberateWidth = 0
private

◆ listeners

Array<Listener*> juce::TableHeaderComponent::listeners
private

◆ menuActive

bool juce::TableHeaderComponent::menuActive = true
private

◆ sortChanged

bool juce::TableHeaderComponent::sortChanged = false
private

◆ stretchToFit

bool juce::TableHeaderComponent::stretchToFit = false
private

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