ManaPlus
Public Member Functions | Private Attributes
ContainerPlacer Class Reference

#include <containerplacer.h>

Public Member Functions

 ContainerPlacer (BasicContainer2 *const c=0, LayoutCell *const lc=0)
 
LayoutCellgetCell ()
 
ContainerPlacer at (const int x, const int y)
 
LayoutCelloperator() (const int x, const int y, Widget *const wg, const int w=1, const int h=1)
 

Private Attributes

BasicContainer2mContainer
 
LayoutCellmCell
 

Detailed Description

This class is a helper for adding widgets to nested tables in a window.

Definition at line 35 of file containerplacer.h.

Constructor & Destructor Documentation

◆ ContainerPlacer()

ContainerPlacer::ContainerPlacer ( BasicContainer2 *const  c = 0,
LayoutCell *const  lc = 0 
)
inlineexplicit

Definition at line 38 of file containerplacer.h.

References A_DEFAULT_COPY.

Referenced by at().

39  :
40  mContainer(c),
41  mCell(lc)
42  {}
LayoutCell * mCell
BasicContainer2 * mContainer

Member Function Documentation

◆ at()

ContainerPlacer ContainerPlacer::at ( const int  x,
const int  y 
)

Returns a placer for the same container but to an inner cell.

Definition at line 30 of file containerplacer.cpp.

References LayoutCell::at(), ContainerPlacer(), mCell, and mContainer.

Referenced by getCell().

31 {
33  mCell != nullptr ? &mCell->at(x, y) : nullptr);
34 }
LayoutCell * mCell
LayoutCell & at(const int x, const int y)
Definition: layoutcell.cpp:105
BasicContainer2 * mContainer
ContainerPlacer(BasicContainer2 *const c=0, LayoutCell *const lc=0)

◆ getCell()

LayoutCell& ContainerPlacer::getCell ( )
inline

Gets the pointed cell.

Definition at line 49 of file containerplacer.h.

References A_WARN_UNUSED, at(), mCell, operator()(), x, and y.

Referenced by MapDebugTab::MapDebugTab(), NetDebugTab::NetDebugTab(), and TargetDebugTab::TargetDebugTab().

50  { return *mCell; }
LayoutCell * mCell

◆ operator()()

LayoutCell & ContainerPlacer::operator() ( const int  x,
const int  y,
Widget *const  wg,
const int  w = 1,
const int  h = 1 
)

Adds the given widget to the container and places it in the layout.

See also
LayoutArray::place

Definition at line 37 of file containerplacer.cpp.

References BasicContainer2::add(), LayoutCell::emptyCell, mCell, mContainer, LayoutCell::place(), x, and y.

Referenced by getCell().

38 {
39  if (mContainer != nullptr)
40  mContainer->add(wg);
41  if (mCell != nullptr)
42  return mCell->place(wg, x, y, w, h);
43  return LayoutCell::emptyCell;
44 }
LayoutCell * mCell
static LayoutCell emptyCell
Definition: layoutcell.h:147
LayoutCell & place(Widget *const wg, const int x, const int y, const int w=1, const int h=1)
Definition: layoutcell.cpp:110
virtual void add(Widget *const widget)
BasicContainer2 * mContainer

Field Documentation

◆ mCell

LayoutCell* ContainerPlacer::mCell
private

Definition at line 70 of file containerplacer.h.

Referenced by at(), getCell(), and operator()().

◆ mContainer

BasicContainer2* ContainerPlacer::mContainer
private

Definition at line 69 of file containerplacer.h.

Referenced by at(), and operator()().


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