JUCE
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines
Public Types | Public Member Functions
LassoComponent< SelectableItemType > Class Template Reference

A component that acts as a rectangular selection region, which you drag with the mouse to select groups of objects (in conjunction with a SelectedItemSet). More...

Inherits Component.

List of all members.

Public Types

enum  ColourIds { lassoFillColourId = 0x1000440, lassoOutlineColourId = 0x1000441 }
 A set of colour IDs to use to change the colour of various aspects of the label. More...

Public Member Functions

 LassoComponent (const int outlineThickness_=1)
 Creates a Lasso component.
 ~LassoComponent ()
 Destructor.
void beginLasso (const MouseEvent &e, LassoSource< SelectableItemType > *const lassoSource)
 Call this in your mouseDown event, to initialise a drag.
void dragLasso (const MouseEvent &e)
 Call this in your mouseDrag event, to update the lasso's position.
void endLasso ()
 Call this in your mouseUp event, after the lasso has been dragged.
void paint (Graphics &g)
bool hitTest (int, int)

Detailed Description

template<class SelectableItemType>
class LassoComponent< SelectableItemType >

A component that acts as a rectangular selection region, which you drag with the mouse to select groups of objects (in conjunction with a SelectedItemSet).

To use one of these:

The class takes into account the modifier keys that are being held down while the lasso is being dragged, so if shift is pressed, then any lassoed items will be added to the original selection; if ctrl or command is pressed, they will be xor'ed with any previously selected items.

See also:
LassoSource, SelectedItemSet

Member Enumeration Documentation

template<class SelectableItemType >
enum LassoComponent::ColourIds

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

These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() methods.

Note that you can also use the constants from TextEditor::ColourIds to change the colour of the text editor that is opened when a label is editable.

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

The colour to fill the lasso rectangle with.

lassoOutlineColourId 

The colour to draw the outline with.


Constructor & Destructor Documentation

template<class SelectableItemType >
LassoComponent< SelectableItemType >::LassoComponent ( const int  outlineThickness_ = 1) [explicit]

Creates a Lasso component.

The fill colour is used to fill the lasso'ed rectangle, and the outline colour is used to draw a line around its edge.

template<class SelectableItemType >
LassoComponent< SelectableItemType >::~LassoComponent ( )

Destructor.


Member Function Documentation

template<class SelectableItemType >
void LassoComponent< SelectableItemType >::beginLasso ( const MouseEvent e,
LassoSource< SelectableItemType > *const  lassoSource 
)

Call this in your mouseDown event, to initialise a drag.

Pass in a suitable LassoSource object which the lasso will use to find the items and change the selection.

After using this method to initialise the lasso, repeatedly call dragLasso() in your component's mouseDrag callback.

See also:
dragLasso, endLasso, LassoSource

References LassoSource< SelectableItemType >::getLassoSelection(), MouseEvent::getMouseDownPosition(), Component::getParentComponent(), jassert, and Component::setSize().

template<class SelectableItemType >
void LassoComponent< SelectableItemType >::dragLasso ( const MouseEvent e)

Call this in your mouseDrag event, to update the lasso's position.

This must be repeatedly calling when the mouse is dragged, after you've first initialised the lasso with beginLasso().

This method takes into account the modifier keys that are being held down, so if shift is pressed, then the lassoed items will be added to any that were previously selected; if ctrl or command is pressed, then they will be xor'ed with previously selected items.

See also:
beginLasso, endLasso

References Array< ElementType, TypeOfCriticalSectionToUse >::addArray(), Component::getBounds(), MouseEvent::getPosition(), ModifierKeys::isAltDown(), ModifierKeys::isCommandDown(), ModifierKeys::isShiftDown(), MouseEvent::mods, Array< ElementType, TypeOfCriticalSectionToUse >::removeValuesIn(), Component::setBounds(), and Component::setVisible().

template<class SelectableItemType >
void LassoComponent< SelectableItemType >::endLasso ( )

Call this in your mouseUp event, after the lasso has been dragged.

See also:
beginLasso, dragLasso

References Array< ElementType, TypeOfCriticalSectionToUse >::clear(), and Component::setVisible().

template<class SelectableItemType >
void LassoComponent< SelectableItemType >::paint ( Graphics g) [virtual]
template<class SelectableItemType >
bool LassoComponent< SelectableItemType >::hitTest ( int  ,
int   
) [virtual]

Reimplemented from Component.


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