Mana
Loading...
Searching...
No Matches
layouthelper.cpp
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2009 The Mana World Development Team
4 * Copyright (C) 2009-2012 The Mana Developers
5 *
6 * This file is part of The Mana Client.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
23
24LayoutHelper::LayoutHelper(gcn::Container *container):
25 mContainer(container)
26{
27 mContainer->addWidgetListener(this);
28}
29
31{
32 mContainer->removeWidgetListener(this);
33}
34
35LayoutCell &LayoutHelper::place(int x, int y, gcn::Widget *wg, int w, int h)
36{
37 mContainer->add(wg);
38 return mLayout.place(wg, x, y, w, h);
39}
40
45
47{
48 mLayout.reflow(w, h);
49 mContainer->setSize(w, h);
50}
51
52void LayoutHelper::widgetResized(const gcn::Event &event)
53{
54 const gcn::Rectangle area = mContainer->getChildrenArea();
55 int w = area.width;
56 int h = area.height;
57 mLayout.reflow(w, h);
58}
This class is a helper for adding widgets to nested tables in a window.
Definition layout.h:34
This class describes the formatting of a widget in the cell of a layout table.
Definition layout.h:159
LayoutCell & place(gcn::Widget *wg, int x, int y, int w=1, int h=1)
Definition layout.h:203
LayoutCell & at(int x, int y)
Definition layout.h:197
LayoutCell & place(int x, int y, gcn::Widget *, int w=1, int h=1)
Adds a widget to the container and sets it at given cell.
ContainerPlacer getPlacer(int x, int y)
Returns a proxy for adding widgets in an inner table of the layout.
void reflowLayout(int w=0, int h=0)
Computes the position of the widgets according to the current layout.
LayoutHelper(gcn::Container *container)
gcn::Container * mContainer
Managed container.
~LayoutHelper() override
Layout mLayout
Layout handler.
void widgetResized(const gcn::Event &event) override
Called whenever the managed container changes size.
void reflow(int &nW, int &nH)
Sets the positions of all the widgets.
Definition layout.cpp:321