tbx  0.7.3
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
tbx::view::IconItemRenderer Class Reference

Class to render an icon with text similar to the normal view in the filer. More...

#include <iconitemrenderer.h>

Inheritance diagram for tbx::view::IconItemRenderer:
tbx::view::TypedItemRenderer< std::string > tbx::view::ItemRenderer

Public Member Functions

 IconItemRenderer (ItemViewValue< std::string > *np, bool use_client=true)
 Constructor for IconItemRenderer that uses the same value provider to give the text and sprite name. More...
 
 IconItemRenderer (ItemViewValue< std::string > *np, ItemViewValue< std::string > *sp, bool use_client=true)
 Constructor for IconItemRenderer that uses the different value providers to give the text and sprite name. More...
 
virtual std::string text (unsigned int index) const
 Return the text for the icon. More...
 
virtual std::string sprite_name (unsigned int index) const
 Return the sprite name for the icon. More...
 
virtual bool use_client_sprite_area (unsigned int index) const
 Returns true to use the client sprite area to retrieve the sprite to display, or false for the wimp sprite area. More...
 
virtual void render (const ItemRenderer::Info &info)
 Called to render each item that needs drawing. More...
 
virtual unsigned int width (unsigned int index) const
 Return the width of the given item.
 
virtual unsigned int height (unsigned int index) const
 Return height of item.
 
virtual Size size (unsigned int index) const
 Called to get the size of the item. More...
 
virtual bool hit_test (unsigned int index, const Size &size, const Point &pos) const
 Check if the point given hits content of the cell rather then a margin or background. More...
 
virtual bool intersects (unsigned int index, const Size &size, const BBox &box) const
 Check if the given rectangle intersects the content of the cell rather than a margin or background. More...
 
void get_sprite_box (unsigned int index, const Size &size, BBox &sbox) const
 Gets sprite box relative to bottom left corner.
 
void get_text_box (unsigned int index, const Size &size, BBox &sbox) const
 Get text box relative to bottom left corner.
 
- Public Member Functions inherited from tbx::view::TypedItemRenderer< std::string >
 TypedItemRenderer (ItemViewValue< std::string > *vp)
 Construct the item view renderer. More...
 

Static Public Member Functions

static tbx::Size standard_size (unsigned int width=160, unsigned int sprite_height=68)
 Return standard size for an icon with the given text width and sprite height. More...
 

Protected Member Functions

 IconItemRenderer (bool use_client=true)
 Protected constructor for derived renderer which must provide the text() and sprite_name() overrides. More...
 

Additional Inherited Members

- Protected Attributes inherited from tbx::view::TypedItemRenderer< std::string >
ItemViewValue< std::string > * _value_provider
 Object to retrieve the value for a rendered.
 

Detailed Description

Class to render an icon with text similar to the normal view in the filer.

i.e. An icon centered above some text.

Construct with ItemViewValue<std::string> value providers to the return the text and sprite name to render or derive from this class and override the text() and sprite_name() members.

Constructor & Destructor Documentation

tbx::view::IconItemRenderer::IconItemRenderer ( bool  use_client = true)
protected

Protected constructor for derived renderer which must provide the text() and sprite_name() overrides.

Parameters
use_clienttrue to use client sprite area, false for wimp sprite area (default true)
tbx::view::IconItemRenderer::IconItemRenderer ( ItemViewValue< std::string > *  np,
bool  use_client = true 
)

Constructor for IconItemRenderer that uses the same value provider to give the text and sprite name.

i.e. They are the same.

Parameters
npvalue provider to return the name used for the text and sprite
use_clienttrue to use client sprite area, false for wimp sprite area (default true)
tbx::view::IconItemRenderer::IconItemRenderer ( ItemViewValue< std::string > *  np,
ItemViewValue< std::string > *  sp,
bool  use_client = true 
)

Constructor for IconItemRenderer that uses the different value providers to give the text and sprite name.

Parameters
npvalue provider to return the text
spvalue provider to return the sprite name
use_clienttrue to use client sprite area, false for wimp sprite area (default true)

Member Function Documentation

bool tbx::view::IconItemRenderer::hit_test ( unsigned int  index,
const Size size,
const Point pos 
) const
virtual

Check if the point given hits content of the cell rather then a margin or background.

Parameters
indexindex of item to check
sizeof area item is rendered in
poslocation to check relative to bottom left of cell
Returns
true if content is at that location, otherwise false

Reimplemented from tbx::view::ItemRenderer.

bool tbx::view::IconItemRenderer::intersects ( unsigned int  index,
const Size size,
const BBox box 
) const
virtual

Check if the given rectangle intersects the content of the cell rather than a margin or background.

Parameters
indexindex of item to check
sizeof area item is rendered in
boxbox to check if it intersect the cell
Returns
true if some contents are in the box, otherwise false

Reimplemented from tbx::view::ItemRenderer.

void tbx::view::IconItemRenderer::render ( const ItemRenderer::Info info)
virtual

Called to render each item that needs drawing.

The item is only clipped to the containing Windows visible area, not to the cell bounds so the content must be drawn entirely inside the cell bounding box or the clip area should be set before drawing.

Parameters
infoInformation on redraw event and item to be redrawn

Implements tbx::view::ItemRenderer.

Size tbx::view::IconItemRenderer::size ( unsigned int  index) const
virtual

Called to get the size of the item.

Should return the equivalent of Size(width(index), height(index))

Implements tbx::view::ItemRenderer.

std::string tbx::view::IconItemRenderer::sprite_name ( unsigned int  index) const
virtual

Return the sprite name for the icon.

By default uses the value provider from the constructor Override to get the value in a different way

tbx::Size tbx::view::IconItemRenderer::standard_size ( unsigned int  text_width = 160,
unsigned int  sprite_height = 68 
)
static

Return standard size for an icon with the given text width and sprite height.

text_width width of text in os units. Defaults to 160 (approx 10 chars) sprite_height height of sprite in os units. Defaults to 68 (standard height in filer)

std::string tbx::view::IconItemRenderer::text ( unsigned int  index) const
virtual

Return the text for the icon.

By default uses the value provider from the constructor Override to get the value in a different way

virtual bool tbx::view::IconItemRenderer::use_client_sprite_area ( unsigned int  index) const
inlinevirtual

Returns true to use the client sprite area to retrieve the sprite to display, or false for the wimp sprite area.

default value is given in the constructor

Override if the location of the sprite can vary between the two


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