tbx  0.7.6
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tbx::view::TileView Class Reference

Class to show items tiled in a window. More...

#include <tileview.h>

Inheritance diagram for tbx::view::TileView:
tbx::view::ItemView tbx::OpenWindowListener tbx::RedrawListener tbx::ScrollRequestListener tbx::MouseClickListener tbx::view::SelectionListener tbx::Listener tbx::Listener tbx::Listener tbx::Listener

Public Member Functions

 TileView (tbx::Window window, ItemRenderer *item_renderer=0)
 Construct a tile view for specific Window using the given item renderer.
 
void item_renderer (ItemRenderer *ir)
 Change the item renderer. More...
 
const tbx::Sizetile_size () const
 Return the size of a tile.
 
void tile_size (tbx::Size new_size)
 Set the size of a tile in the tile view. More...
 
tbx::Size max_size (unsigned int from, unsigned int end)
 Measure the maximum tile size for a range of items. More...
 
tbx::Size check_size (unsigned int from, unsigned int end)
 Check if size has been reduced to less than tile_size. More...
 
void size_to_tiles ()
 Size to match content. More...
 
virtual void auto_size (bool on)
 Turn on or off auto sizing. More...
 
virtual void redraw (const tbx::RedrawEvent &event)
 Redraw the window.
 
virtual void open_window (tbx::OpenWindowEvent &event)
 Window has been opened or resized, so re do layout.
 
virtual void update_window_extent ()
 Update the Window extent after a change in size. More...
 
virtual void refresh ()
 Refresh the whole report view. More...
 
virtual void inserted (unsigned int where, unsigned int how_many)
 Inform the view that items have been inserted. More...
 
virtual void removing (unsigned int where, unsigned int how_many)
 Inform the view that items are about to be removed. More...
 
virtual void removed (unsigned int where, unsigned int how_many)
 Inform the view that items have been removed. More...
 
virtual void changing (unsigned int where, unsigned int how_many)
 Inform the view that items are about to be changed. More...
 
virtual void changed (unsigned int where, unsigned int how_many)
 Inform the view that items have been changed. More...
 
virtual void cleared ()
 Whole view has been cleared.
 
virtual unsigned int insert_index (const Point &scr_pt) const
 Find the index to insert an item based on the screen coordinates given. More...
 
virtual unsigned int screen_index (const Point &scr_pt) const
 Get item index for the screen location (if any) More...
 
virtual unsigned int hit_test (const Point &scr_pt) const
 Hit test the given screen point. More...
 
virtual void get_bounds (BBox &bounds, unsigned int index) const
 Get the cell bounds for the specified index. More...
 
virtual void get_bounds (BBox &bounds, unsigned int first, unsigned int last) const
 Get bounding box of the range of indices in work area coordinates.
 
- Public Member Functions inherited from tbx::view::ItemView
 ItemView (Window window)
 Construct the item view with the given renderer. More...
 
virtual ~ItemView ()
 Destructor removed any listeners.
 
tbx::Windowwindow ()
 Return the Window that this item view is attached to.
 
const tbx::Marginmargin () const
 Return the margin around the data in the window.
 
void margin (const tbx::Margin &margin)
 Change the margin.
 
bool auto_size () const
 Returns true if auto size is on.
 
void updates_enabled (bool updates)
 Enable/disable updating of attached window. More...
 
bool updates_enabled () const
 Check if updates of the attached window are enabled. More...
 
unsigned int count () const
 Returns number of items being displayed.
 
void selection (Selection *selection)
 Set the selection model to use for the item view. More...
 
Selectionselection () const
 Get the selection model used for selecting items in the list. More...
 
Selectionselection ()
 Get the selection model used for selecting items in the list. More...
 
void add_click_listener (ItemViewClickListener *listener)
 Add a listener for a click on the item view. More...
 
void remove_click_listener (ItemViewClickListener *listener)
 Remove a listener for a click on the item view.
 
void allow_drag_selection (bool on, bool on_item=false)
 Allow selection of multiple items by using a drag box. More...
 
void menu_selects (bool on)
 Turn on/off selection of an item when the menu button is pressed over an item and no other item is selected. More...
 
bool menu_selects () const
 Returns true if the menu button selects an item.
 
void clear_menu_selection ()
 Clear the current selection if it was made by the menu button.
 
bool last_selection_menu () const
 Returns true if the last selection was made by the menu button.
 
virtual void scroll_request (const tbx::ScrollRequestEvent &event)
 Process scroll requests. More...
 
virtual void mouse_click (tbx::MouseClickEvent &event)
 Mouse clicked on window containing list view. More...
 
virtual void selection_changed (const SelectionChangedEvent &event)
 Selection has changed event handling. More...
 
- Public Member Functions inherited from tbx::Listener
virtual ~Listener ()
 Destroy the listener object.
 
- Public Member Functions inherited from tbx::MouseClickListener
virtual ~MouseClickListener ()
 Destructor.
 

Protected Member Functions

virtual void process_drag_selection (const BBox &drag_box, bool adjust)
 Override this method to process selection by dragging. More...
 
bool recalc_layout (const BBox &visible_area)
 Recalculate the cell layout and update/refresh the window. More...
 
- Protected Member Functions inherited from tbx::view::ItemView
void process_mouse_click (int index, MouseClickEvent &event)
 Helper function to process mouse clicks.
 
- Protected Member Functions inherited from tbx::Listener
 Listener ()
 Construct the Listener object.
 

Protected Attributes

ItemRenderer_item_renderer
 Renderer for items in the tile view.
 
tbx::Size _tile_size
 Size of tiles.
 
int _cols_per_row
 Number of tiles in a row.
 
- Protected Attributes inherited from tbx::view::ItemView
Window _window
 Window displaying this view.
 
Margin _margin
 Margin around areas displaying items.
 
Selection_selection
 Selection model.
 
SafeList< ItemViewClickListener > * _click_listeners
 Listeners for a mouse click on the view.
 
unsigned int _count
 Number of items displayed in this view.
 
unsigned int _flags
 Internal view flags.
 

Additional Inherited Members

- Static Public Attributes inherited from tbx::view::ItemView
static const unsigned int NO_INDEX = -1
 Constant for invalid index. More...
 
- Protected Types inherited from tbx::view::ItemView
enum  ViewFlags {
  NONE = 0, AUTO_SIZE = 1, SELECT_DRAG = 2, SELECT_DRAG_ON_ITEM = 4,
  SELECT_MENU = 8, AUTO_SIZE_CHECKED = 0x100, WANT_AUTO_SIZE = 0x200, LAST_SELECT_MENU = 0x400,
  NO_UPDATES = 0x800
}
 Internal view flags enum, can be one or more of the following. More...
 

Detailed Description

Class to show items tiled in a window.

Each item is placed in a cell of the same size and the items are wrapped depending on the current width of the window.

Member Function Documentation

◆ auto_size()

void tbx::view::TileView::auto_size ( bool  on)
virtual

Turn on or off auto sizing.

When auto sizing is on the item size is checked whenever an item is added, changed or removed.

To prevent a scan of the whole list on removal call the removing method before actually doing a removal.

Implements tbx::view::ItemView.

◆ changed()

void tbx::view::TileView::changed ( unsigned int  where,
unsigned int  how_many 
)
virtual

Inform the view that items have been changed.

Parameters
wherelocation of first change
how_manynumber of items changed

Implements tbx::view::ItemView.

◆ changing()

void tbx::view::TileView::changing ( unsigned int  where,
unsigned int  how_many 
)
virtual

Inform the view that items are about to be changed.

This call is optional, but it stops the need for a full scan every time something an item is changed when auto size is on.

Parameters
wherelocation items will be changed from
how_manynumber of items that will be changed

Reimplemented from tbx::view::ItemView.

◆ check_size()

tbx::Size tbx::view::TileView::check_size ( unsigned int  from,
unsigned int  end 
)

Check if size has been reduced to less than tile_size.

Measures from first to end-1

Parameters
fromfirst row to measure (inclusive)
endlast row to measure (not inclusive)
Returns
maximum size in the range.

◆ get_bounds()

void tbx::view::TileView::get_bounds ( BBox bounds,
unsigned int  index 
) const
virtual

Get the cell bounds for the specified index.

Parameters
boundsbounding box to update (work area coordinates)
indexindex to retrieve the bounds for

Implements tbx::view::ItemView.

◆ hit_test()

unsigned int tbx::view::TileView::hit_test ( const Point scr_pt) const
virtual

Hit test the given screen point.

Unlike screen_index this uses the cell renderer to see if it has actually hit content rather than just somewhere in the cell.

returns: index of hit or -1 if none.

Implements tbx::view::ItemView.

◆ insert_index()

unsigned int tbx::view::TileView::insert_index ( const Point scr_pt) const
virtual

Find the index to insert an item based on the screen coordinates given.

Parameters
scr_ptposition to find the index for
Returns
index for insert.

Implements tbx::view::ItemView.

◆ inserted()

void tbx::view::TileView::inserted ( unsigned int  where,
unsigned int  how_many 
)
virtual

Inform the view that items have been inserted.

Parameters
wherelocation for insertion
how_manynumber of items inserted

Implements tbx::view::ItemView.

◆ item_renderer()

void tbx::view::TileView::item_renderer ( ItemRenderer ir)

Change the item renderer.

If there are items already defined it will resize or refresh the view depending on if auto_size is set.

◆ max_size()

tbx::Size tbx::view::TileView::max_size ( unsigned int  from,
unsigned int  end 
)

Measure the maximum tile size for a range of items.

Measures from first to end-1

Parameters
fromfirst row to measure (inclusive)
endlast row to measure (not inclusive)

◆ process_drag_selection()

void tbx::view::TileView::process_drag_selection ( const BBox drag_box,
bool  adjust 
)
protectedvirtual

Override this method to process selection by dragging.

Process selection by dragging.

allow_drag_selection must be set for this to be called.

Parameters
drag_boxFinal bounding box of drag
adjustadjust button was used for selection

Reimplemented from tbx::view::ItemView.

◆ recalc_layout()

bool tbx::view::TileView::recalc_layout ( const BBox visible_area)
protected

Recalculate the cell layout and update/refresh the window.

Parameters
visible_areavisible area of window on screen
Returns
true if the number of cols_per_row changed

◆ refresh()

void tbx::view::TileView::refresh ( )
virtual

Refresh the whole report view.

It should also be called if all the data changes.

Implements tbx::view::ItemView.

◆ removed()

void tbx::view::TileView::removed ( unsigned int  where,
unsigned int  how_many 
)
virtual

Inform the view that items have been removed.

Parameters
wherelocation for removal
how_manynumber of items removed

Implements tbx::view::ItemView.

◆ removing()

void tbx::view::TileView::removing ( unsigned int  where,
unsigned int  how_many 
)
virtual

Inform the view that items are about to be removed.

This call is optional, but it stops the need for a full scan every time something is removed when auto size is on.

Parameters
wherelocation items will be removed from
how_manynumber of items that will be removed

Reimplemented from tbx::view::ItemView.

◆ screen_index()

unsigned int tbx::view::TileView::screen_index ( const Point scr_pt) const
virtual

Get item index for the screen location (if any)

Parameters
scr_ptposition on screen (screen coordinates)
Returns
index of item under location or NO_INDEX if no item at location.

Implements tbx::view::ItemView.

◆ size_to_tiles()

void tbx::view::TileView::size_to_tiles ( )

Size to match content.

Does nothing if there is no content

Using this function to set the size automatically turns off auto sizing

◆ tile_size()

void tbx::view::TileView::tile_size ( tbx::Size  new_size)

Set the size of a tile in the tile view.

Calling this function automatically turns of auto sizing

Parameters
new_sizethe new size of a tile in the view

◆ update_window_extent()

void tbx::view::TileView::update_window_extent ( )
virtual

Update the Window extent after a change in size.

Note: TileView do not change the width of the extent, just the height.

Implements tbx::view::ItemView.


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