tbx  0.7.3
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tbx::view::ListView Class Reference

Class to show items in a list down the window. More...

#include <listview.h>

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

Public Member Functions

 ListView (tbx::Window window, ItemRenderer *item_renderer=0)
 Constructor.
 
virtual ~ListView ()
 Destructor.
 
void item_renderer (ItemRenderer *ir)
 Change the item renderer. More...
 
void row_height (unsigned int height)
 Change the row height. More...
 
unsigned int row_height () const
 Return the row height.
 
virtual void auto_size (bool on)
 Turn on or off auto sizing. More...
 
void width (unsigned int width)
 Set the width. More...
 
unsigned int width () const
 Return the current width of the ListView.
 
unsigned int max_width (unsigned int from, unsigned int end)
 Measure the maximum width for a range of rows. More...
 
unsigned int check_width (unsigned int from, unsigned int end)
 Check if width has been reduced to less then _width. More...
 
void size_to_width (unsigned int min_width=0, unsigned int max_width=0xFFFFFFFF)
 Size width to match content. More...
 
virtual void redraw (const tbx::RedrawEvent &event)
 Redraw the List view.
 
virtual void update_window_extent ()
 Called to update the window extent needed to contain this view. More...
 
virtual void refresh ()
 Called to refresh the entire views contents. 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
 Return the index for inserting an item from a screen point.
 
virtual unsigned int screen_index (const Point &scr_pt) const
 Return the index under the screen point, does not check if it hits content of the item renderer.
 
virtual unsigned int hit_test (const Point &scr_pt) const
 Return the index under the screen point, checks if it hits content of the item renderer. More...
 
virtual void get_bounds (BBox &bounds, unsigned int index) const
 Get bounding box of the given index in work area coordinates.
 
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...
 
- 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
 Object used to render itesm.
 
unsigned int _height
 Height of one item.
 
unsigned int _width
 Width of list view.
 
- 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 in a list down the window.

Member Function Documentation

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

Turn on or off auto sizing.

When auto sizing is on the item width 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.

void tbx::view::ListView::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.

void tbx::view::ListView::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.

unsigned int tbx::view::ListView::check_width ( unsigned int  from,
unsigned int  end 
)

Check if width has been reduced to less then _width.

Measures from first to end-1

Parameters
fromfirst row to measure (inclusive)
endlast row to measure (not inclusive)
Returns
maximum width in the range.
unsigned int tbx::view::ListView::hit_test ( const Point scr_pt) const
virtual

Return the index under the screen point, checks if it hits content of the item renderer.

Returns: NO_INDEX if doesn't hit content

Implements tbx::view::ItemView.

void tbx::view::ListView::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.

void tbx::view::ListView::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.

unsigned int tbx::view::ListView::max_width ( unsigned int  from,
unsigned int  end 
)

Measure the maximum width for a range of rows.

Measures from first to end-1

Parameters
fromfirst row to measure (inclusive)
endlast row to measure (not inclusive)
void tbx::view::ListView::process_drag_selection ( const BBox drag_box,
bool  adjust 
)
protectedvirtual

Override this method to 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.

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

Called to refresh the entire views contents.

Refresh the whole report view.

It should also be called if all the data changes.

Implements tbx::view::ItemView.

void tbx::view::ListView::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.

void tbx::view::ListView::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.

void tbx::view::ListView::row_height ( unsigned int  height)

Change the row height.

If the row height is 0. It will take the height from the first item in the list. This is how the view starts up.

void tbx::view::ListView::size_to_width ( unsigned int  min = 0,
unsigned int  max = 0xFFFFFFFF 
)

Size width to match content.

Does nothing if there is no content

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

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

Called to update the window extent needed to contain this view.

Update the Window extent after a change in size.

Implements tbx::view::ItemView.

void tbx::view::ListView::width ( unsigned int  width)

Set the width.

Setting the width automatically turns of auto sizing


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