tbx  0.7.6
Public Member Functions | List of all members
tbx::view::GadgetListView Class Reference

Class to create a list view with each line made up of one or more gadgets. More...

#include <gadgetlistview.h>

Public Member Functions

void setup (tbx::Window window, tbx::res::ResWindow &res_window, tbx::ComponentId first_gadget_id, tbx::ComponentId last_gadget_id, unsigned int spacing, bool first_row_created)
 Setup the gadget list view. More...
 
unsigned int num_gadgets () const
 Return the number of gadgets in a row.
 
unsigned int count () const
 Return the number of rows.
 
tbx::Windowwindow ()
 Return the window this view is attached to.
 
const tbx::Marginmargin () const
 Return the margin around the data in the window.
 
void margin (const tbx::Margin &margin)
 Set the margin around the view to the edge of the extent. More...
 
void copy_interface (GadgetListCopyRow *copy)
 Set object that implement the copy row interface to copy data from one row to another. More...
 
bool updates_enabled () const
 Check if updating of the window extent is enabled. More...
 
void updates_enabled (bool enabled)
 Set if updating of the window extent is enabled. More...
 
void update_window_extent ()
 Update the windows extents to fit the current size of the list and its margin.
 
tbx::ComponentId gadget_id (int row, int col) const
 Return the gadget_id for a specific row and column. More...
 
tbx::Gadget gadget (int row, int col)
 Return the gadget for a specified row and column.
 
tbx::ComponentId add (unsigned int count=1)
 Add row(s) to the end of the list. More...
 
tbx::ComponentId insert (unsigned int row, unsigned int count=1)
 Insert row(s) before the given row number. More...
 
void remove (unsigned int row, unsigned int count=1)
 Remove row(s) from the list. More...
 
void clear ()
 Clear all gadgets from the list.
 
void copy (unsigned int from_row, unsigned int to_row)
 Use currently assigned copy function to copy from one row to another. More...
 

Detailed Description

Class to create a list view with each line made up of one or more gadgets.

Member Function Documentation

◆ add()

tbx::ComponentId tbx::view::GadgetListView::add ( unsigned int  count = 1)

Add row(s) to the end of the list.

Parameters
countnumber of rows to add (default 1)
Returns
id of the first component in the new rows
Exceptions
std::invalid_argumentif count is 0

◆ copy()

void tbx::view::GadgetListView::copy ( unsigned int  from_row,
unsigned int  to_row 
)

Use currently assigned copy function to copy from one row to another.

Parameters
from_rowrow to copy from
to_rowrow to copy to

◆ copy_interface()

void tbx::view::GadgetListView::copy_interface ( GadgetListCopyRow copy)

Set object that implement the copy row interface to copy data from one row to another.

If not set the default will copy the "value/text" property for some of the standard gadgets.

Parameters
copyobject implementing the GadgetListCopyRow interface or 0 to restore it to the default.

◆ gadget_id()

tbx::ComponentId tbx::view::GadgetListView::gadget_id ( int  row,
int  col 
) const
inline

Return the gadget_id for a specific row and column.

Parameters
rowthe 0 based row number
colthe 0 based column number
Returns
component id at the given row or column

◆ insert()

tbx::ComponentId tbx::view::GadgetListView::insert ( unsigned int  row,
unsigned int  count = 1 
)

Insert row(s) before the given row number.

The new rows are not cleared or initialised, so must be initialised after calling this function.

Parameters
rowthe number of the row to insert before. Can be the value of count() to insert at the end.
countthe number of rows to insert (default 1)
Returns
id of the first component in the first new row
Exceptions
std::out_of_rangeif row is greater than count()
std::invalid_argumentif count is 0

◆ margin()

void tbx::view::GadgetListView::margin ( const tbx::Margin margin)

Set the margin around the view to the edge of the extent.

Changing the top or left will move any gadgets already added to the list

Parameters
marginthe new margin

◆ remove()

void tbx::view::GadgetListView::remove ( unsigned int  row,
unsigned int  count = 1 
)

Remove row(s) from the list.

Parameters
rowfirst row to remove
countnumber of rows to remove (default 1)
Exceptions
std::out_of_rangeif row >= count() or row + count > count()
std::invalid_argumentif count == 0

◆ setup()

void tbx::view::GadgetListView::setup ( tbx::Window  window,
tbx::res::ResWindow res_window,
tbx::ComponentId  first_gadget_id,
tbx::ComponentId  last_gadget_id,
unsigned int  spacing,
bool  first_row_created 
)

Setup the gadget list view.

The margin is calculated from the bounding box of the gadget compared to the window extent. first_gadget_id to last_gadget_id must be a continuos range new rows are created with ids from last_gadget_id + 1

Parameters
window- the window gadgets will be created on
res_window- The resource to get the gadget templates from and calculate the margin
first_gadget_id- id of first gadget for list in resource
last_gadget_id- id of last gadget for list in resource
spacingvertical spacing between rows
first_row_createdtrue if the first row of the list has already been created

◆ updates_enabled() [1/2]

bool tbx::view::GadgetListView::updates_enabled ( ) const
inline

Check if updating of the window extent is enabled.

Returns
true if updates are enabled

◆ updates_enabled() [2/2]

void tbx::view::GadgetListView::updates_enabled ( bool  enabled)
inline

Set if updating of the window extent is enabled.

After turning on updates call update_window_extent to refresh the windows extent &

Parameters
enabledtrue to turn on extent updates

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