GG::ListBox::Row Struct Reference

This is a single item in a listbox. More...

#include <ListBox.h>

Inheritance diagram for GG::ListBox::Row:

GG::Control GG::Wnd List of all members.

Structors

 Row ()
 Row (int w, int h, const std::string &drag_drop_data_type, Alignment align=ALIGN_VCENTER, int margin=2)

Accessors

SortKeyType SortKey (int column) const
size_t size () const
bool empty () const
Controloperator[] (size_t n) const
Controlat (size_t n) const
Alignment RowAlignment () const
Alignment ColAlignment (int n) const
int ColWidth (int n) const
int Margin () const
ControlCreateControl (const std::string &str, const boost::shared_ptr< Font > &font, Clr color) const
ControlCreateControl (const SubTexture &st) const

Mutators

virtual void Render ()
void push_back (Control *c)
void push_back (const std::string &str, const boost::shared_ptr< Font > &font, Clr color=CLR_BLACK)
void push_back (const std::string &str, const std::string &font_filename, int pts, Clr color=CLR_BLACK)
void push_back (const SubTexture &st)
void clear ()
void resize (size_t n)
void SetCell (int n, Control *c)
ControlRemoveCell (int n)
void SetRowAlignment (Alignment align)
void SetColAlignment (int n, Alignment align)
void SetColWidth (int n, int width)
void SetColAlignments (const std::vector< Alignment > &aligns)
void SetColWidths (const std::vector< int > &widths)
void SetMargin (int margin)

Public Types

typedef std::string SortKeyType

Detailed Description

This is a single item in a listbox.

A Row is primarily a container for Controls. Each cell in a Row contains pointer to a Control-derived object. As always, each such Control can be connected to arbitrary functionality using signals and slots. During dragging and dropping, the data type associated with a Row (DragDropDataType()) indicates to potential drop targets what type of data the Row represents; the target may accept or decline the drop based on the data type. Rows are stored in ListBoxes by reference, not copy; this means that you can subclass from Row to create your own custom Row types. This is the recommended method for associating a row with the non-GUI object that it represents. Note that all subclasses of Row must declare a SortKeyType, if it differs from std::string, and must provide a SortKey() method if it should differ from the default SortKey() that Row provides. Note that SortKey is not virtual; this part of its interface is used for compile-time polymorphism -- whatever sorter is used with a Row subclass must know the most-derived type of the Row subclass.

Note:
The margin, column alignment, and width cell data are included so that each Row has all the necessary information with which to render itself (this is primarily needed to facilitate drag-and-drop); these data are duplicates of the margin, alignment, and column widths data found in the owning ListBox, and may be overwritten by the ListBox at any time.

Definition at line 110 of file ListBox.h.


Member Typedef Documentation

typedef std::string GG::ListBox::Row::SortKeyType

the type of key used to sort rows

Definition at line 113 of file ListBox.h.


Constructor & Destructor Documentation

GG::ListBox::Row::Row (  ) 

default ctor

GG::ListBox::Row::Row ( int  w,
int  h,
const std::string &  drag_drop_data_type,
Alignment  align = ALIGN_VCENTER,
int  margin = 2 
)

ctor


Member Function Documentation

SortKeyType GG::ListBox::Row::SortKey ( int  column  )  const

returns the string by which this row may be sorted

size_t GG::ListBox::Row::size (  )  const

returns the number of Controls in this Row

bool GG::ListBox::Row::empty (  )  const

returns true iff there are 0 Controls in this Row

Control* GG::ListBox::Row::operator[] ( size_t  n  )  const

returns the Control in the nth cell of this Row; not range checked

Control* GG::ListBox::Row::at ( size_t  n  )  const

returns the Control in the nth cell of this Row

Exceptions:
std::range_error throws when size() <= n

Alignment GG::ListBox::Row::RowAlignment (  )  const

returns the vertical alignment of this Row

Alignment GG::ListBox::Row::ColAlignment ( int  n  )  const

returns the horizontal alignment of the Control in the nth cell of this Row; not range checked

int GG::ListBox::Row::ColWidth ( int  n  )  const

returns the width of the nth cell of this Row; not range checked

int GG::ListBox::Row::Margin (  )  const

returns the amount of space left between the contents of adjacent cells, in pixels

Control* GG::ListBox::Row::CreateControl ( const std::string &  str,
const boost::shared_ptr< Font > &  font,
Clr  color 
) const

creates a "shrink-fit" TextControl from text, font, and color parameters

Control* GG::ListBox::Row::CreateControl ( const SubTexture st  )  const

creates a "shrink-fit" StaticGraphic Control from a SubTexture parameter

virtual void GG::ListBox::Row::Render (  )  [virtual]

draws this Wnd.

Note that Wnds being dragged for a drag-and-drop operation are rendered twice -- once in-place as normal, once in the location of the drag operation, attached to the cursor. Such Wnds may wish to render themselves differently in those two cases. To determine which render is being performed, they can call GUI::GetGUI()->RenderingDragDropWnds().

Implements GG::Control.

void GG::ListBox::Row::push_back ( Control c  ) 

adds a given Control to the end of the Row; this Control becomes property of the Row

void GG::ListBox::Row::push_back ( const std::string &  str,
const boost::shared_ptr< Font > &  font,
Clr  color = CLR_BLACK 
)

overload of push_back that creates a TextControl and adds it to the Row

void GG::ListBox::Row::push_back ( const std::string &  str,
const std::string &  font_filename,
int  pts,
Clr  color = CLR_BLACK 
)

overload of push_back that creates a TextControl and adds it to the Row

void GG::ListBox::Row::push_back ( const SubTexture st  ) 

overload of push_back that creates a StaticGraphic Control and adds it to the Row

void GG::ListBox::Row::clear (  ) 

removes and deletes all cells in this Row

void GG::ListBox::Row::resize ( size_t  n  ) 

resizes the Row to have n cells

void GG::ListBox::Row::SetCell ( int  n,
Control c 
)

sets the Control in the nth cell of this Row, deleting any preexisting Control; not range checked

Control* GG::ListBox::Row::RemoveCell ( int  n  ) 

returns a pointer to the Control in the nth cell of this Row, and sets the contents of the cell to 0; not range checked

void GG::ListBox::Row::SetRowAlignment ( Alignment  align  ) 

sets the vertical alignment of this Row

void GG::ListBox::Row::SetColAlignment ( int  n,
Alignment  align 
)

sets the horizontal alignment of the Control in the nth cell of this Row; not range checked

void GG::ListBox::Row::SetColWidth ( int  n,
int  width 
)

sets the width of the nth cell of this Row; not range checked

void GG::ListBox::Row::SetColAlignments ( const std::vector< Alignment > &  aligns  ) 

sets the horizontal alignment of all the Controls in this Row; not range checked

void GG::ListBox::Row::SetColWidths ( const std::vector< int > &  widths  ) 

sets all the widths of the cells of this Row; not range checked

void GG::ListBox::Row::SetMargin ( int  margin  ) 

sets the amount of space left between the contents of adjacent cells, in pixels


The documentation for this struct was generated from the following file:
Generated on Wed Mar 26 14:35:42 2008 for GG by  doxygen 1.5.2