tbx
0.7.5
|
Base class for selections of one or more indices from a zero based range. More...
#include <selection.h>
Classes | |
class | Iterator |
Class to iterate through all the selected indices. More... | |
class | IteratorImpl |
Class derived from in subclasses to actually provided the iterator implementation. More... | |
Public Types | |
enum | Type { NONE, SINGLE, MULTIPLE } |
Type of selection. | |
Public Member Functions | |
void | add_listener (SelectionListener *listener) |
Add listeners. More... | |
void | remove_listener (SelectionListener *listener) |
Remove listener for selection changes. | |
virtual Type | type () const =0 |
Override to return the type of this selection class. | |
virtual bool | selected (unsigned int index) const =0 |
Override to return true if an item is selected. More... | |
virtual unsigned int | first () const =0 |
Override to return first selected item. More... | |
virtual unsigned int | last () const =0 |
Override to return last selected item. | |
virtual bool | empty () const =0 |
Override to return true if selection is empty. | |
virtual unsigned int | count () const =0 |
Override to return the number of selected items. More... | |
virtual bool | any () const =0 |
Override to return true if one or more items are selected. | |
virtual bool | one () const =0 |
Override to return true if only one item is selected. | |
virtual bool | many () const =0 |
Override to return true if more than one item is selected. | |
virtual void | inserted (unsigned int index, unsigned int count)=0 |
Override called by the object selection is on when new items have been inserted and selected items need to be moved. More... | |
virtual void | removed (unsigned int index, unsigned int count)=0 |
Override called by the object selection is on when items have been removed and selected items to be deleted or moved. More... | |
virtual void | clear ()=0 |
Override to clear the current selection. | |
virtual void | set (unsigned int index)=0 |
Override to change selection to given item. More... | |
virtual void | select (unsigned int index)=0 |
Override to select an item. More... | |
virtual void | deselect (unsigned int index)=0 |
Override to clear the selection for an item. More... | |
virtual void | toggle (unsigned int index)=0 |
Override to toggle the selection for an item. More... | |
virtual void | set (unsigned int from, unsigned int to)=0 |
Override to change selection to given item. More... | |
virtual void | select (unsigned int from, unsigned int to)=0 |
Override to selection a range of items. More... | |
virtual void | deselect (unsigned int from, unsigned int to)=0 |
Override to deselect a range of items. More... | |
virtual void | toggle (unsigned int from, unsigned int to)=0 |
Override to toggle the selection of a range of items. More... | |
Iterator | begin () const |
Get iterator to first selected item. More... | |
Iterator | end () const |
Get iterator to end of selection. More... | |
Static Public Attributes | |
static const unsigned int | NO_SELECTION = -1 |
Constant for indices when there is no selection. | |
Protected Member Functions | |
Selection () | |
Protected constructor, must always use a subclass. | |
void | fire_event (const SelectionChangedEvent &event) |
Helper for subclasses to fire Selection Changed Events. | |
void | fire_event (unsigned int index, bool selected, bool final) |
Helper for subclasses to fire Selection Changed Events. | |
void | fire_event (unsigned int from, unsigned int to, bool selected, bool final) |
Helper for subclasses to fire Selection Changed Events. | |
virtual IteratorImpl * | get_iterator_impl () const =0 |
Override to return the iterator implementation for the selection iterator to used. More... | |
Base class for selections of one or more indices from a zero based range.
void tbx::view::Selection::add_listener | ( | SelectionListener * | listener | ) |
Add listeners.
Add listener for selection changes.
Selection::Iterator tbx::view::Selection::begin | ( | ) | const |
Get iterator to first selected item.
|
pure virtual |
Override to return the number of selected items.
Note: If the exact number is not needed it is usually quicker to use empty(), any(), one() or many(),
Implemented in tbx::view::MultiSelection, and tbx::view::SingleSelection.
|
pure virtual |
Override to clear the selection for an item.
index | to deselect |
Implemented in tbx::view::MultiSelection, and tbx::view::SingleSelection.
|
pure virtual |
Override to deselect a range of items.
from | first index to deselect |
to | last index to deselect |
Implemented in tbx::view::MultiSelection, and tbx::view::SingleSelection.
Selection::Iterator tbx::view::Selection::end | ( | ) | const |
Get iterator to end of selection.
|
pure virtual |
Override to return first selected item.
Note not all items between the first and last are necessarily selected.
Implemented in tbx::view::MultiSelection, and tbx::view::SingleSelection.
|
protectedpure virtual |
Override to return the iterator implementation for the selection iterator to used.
Implemented in tbx::view::MultiSelection, and tbx::view::SingleSelection.
|
pure virtual |
Override called by the object selection is on when new items have been inserted and selected items need to be moved.
index | of the insertion |
count | of items inserted |
Implemented in tbx::view::MultiSelection, and tbx::view::SingleSelection.
|
pure virtual |
Override called by the object selection is on when items have been removed and selected items to be deleted or moved.
index | of the insertion |
count | of items inserted |
Implemented in tbx::view::MultiSelection, and tbx::view::SingleSelection.
|
pure virtual |
Override to select an item.
index | to select |
Implemented in tbx::view::MultiSelection, and tbx::view::SingleSelection.
|
pure virtual |
Override to selection a range of items.
from | first index to select |
to | last index to select |
Implemented in tbx::view::MultiSelection, and tbx::view::SingleSelection.
|
pure virtual |
Override to return true if an item is selected.
index | of item to text |
Implemented in tbx::view::MultiSelection, and tbx::view::SingleSelection.
|
pure virtual |
Override to change selection to given item.
This will automatically deselect any existing selection
index | to select |
Implemented in tbx::view::MultiSelection, and tbx::view::SingleSelection.
|
pure virtual |
Override to change selection to given item.
This will automatically deselect any existing selection outside the range
from | first index to select |
to | last index to select |
Implemented in tbx::view::MultiSelection, and tbx::view::SingleSelection.
|
pure virtual |
Override to toggle the selection for an item.
index | to toggle |
Implemented in tbx::view::MultiSelection, and tbx::view::SingleSelection.
|
pure virtual |
Override to toggle the selection of a range of items.
from | first index to toggle |
to | last index to toggle |
Implemented in tbx::view::MultiSelection, and tbx::view::SingleSelection.