00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "gui/widgets/layouthelper.h"
00023
00024 LayoutHelper::LayoutHelper(gcn::Container *container):
00025 mContainer(container)
00026 {
00027 mContainer->addWidgetListener(this);
00028 }
00029
00030 LayoutHelper::~LayoutHelper()
00031 {
00032 mContainer->removeWidgetListener(this);
00033 }
00034
00035 Layout &LayoutHelper::getLayout()
00036 {
00037 return mLayout;
00038 }
00039
00040 LayoutCell &LayoutHelper::place(int x, int y, gcn::Widget *wg, int w, int h)
00041 {
00042 mContainer->add(wg);
00043 return mLayout.place(wg, x, y, w, h);
00044 }
00045
00046 ContainerPlacer LayoutHelper::getPlacer(int x, int y)
00047 {
00048 return ContainerPlacer(mContainer, &mLayout.at(x, y));
00049 }
00050
00051 void LayoutHelper::reflowLayout(int w, int h)
00052 {
00053 mLayout.reflow(w, h);
00054 mContainer->setSize(w, h);
00055 }
00056
00057 void LayoutHelper::widgetResized(const gcn::Event &event)
00058 {
00059 const gcn::Rectangle area = mContainer->getChildrenArea();
00060 int w = area.width;
00061 int h = area.height;
00062 mLayout.reflow(w, h);
00063 }