ManaPlus
horizontcontainer.cpp
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2009-2010 The Mana Developers
4  * Copyright (C) 2011-2018 The ManaPlus Developers
5  *
6  * This file is part of The ManaPlus 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 
24 #include "debug.h"
25 
27  const int height,
28  const int spacing) :
29  Container(widget),
32  mSpacing(spacing),
33  mCount(0),
34  mLastX(spacing)
35 {
36  setHeight(height);
37  addWidgetListener(this);
38  addMouseListener(this);
39 }
40 
41 void HorizontContainer::add(Widget *const widget)
42 {
43  add(widget, mSpacing);
44 }
45 
46 void HorizontContainer::add(Widget *const widget, const int spacing)
47 {
48  if (widget == nullptr)
49  return;
50 
51  Container::add(widget);
52  widget->setPosition(mLastX, spacing);
53  mCount++;
54  mLastX += widget->getWidth() + 2 * mSpacing;
55 }
56 
58 {
60 
61  mCount = 0;
62 }
63 
65 {
66 }
int getWidth() const
Definition: widget.h:220
virtual void clear()
virtual void add(Widget *const widget)
void addMouseListener(MouseListener *const mouseListener)
Definition: widget.cpp:291
void setPosition(const int x, const int y)
Definition: widget.cpp:160
void add(Widget *const widget)
void setHeight(const int height)
Definition: widget.cpp:139
void addWidgetListener(WidgetListener *const widgetListener)
Definition: widget.cpp:301
#define A_UNUSED
Definition: localconsts.h:159
Definition: widget.h:97
Definition: event.h:77
HorizontContainer(const Widget2 *const widget, const int height, const int spacing)
void widgetResized(const Event &event)