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-2019 The ManaPlus Developers
5  * Copyright (C) 2019-2021 Andrei Karas
6  *
7  * This file is part of The ManaPlus Client.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
24 
25 #include "debug.h"
26 
28  const int height,
29  const int spacing) :
30  Container(widget),
33  mSpacing(spacing),
34  mCount(0),
35  mLastX(spacing)
36 {
37  setHeight(height);
38  addWidgetListener(this);
39  addMouseListener(this);
40 }
41 
42 void HorizontContainer::add(Widget *const widget)
43 {
44  add(widget, mSpacing);
45 }
46 
47 void HorizontContainer::add(Widget *const widget, const int spacing)
48 {
49  if (widget == nullptr)
50  return;
51 
52  Container::add(widget);
53  widget->setPosition(mLastX, spacing);
54  mCount++;
55  mLastX += widget->getWidth() + 2 * mSpacing;
56 }
57 
59 {
61 
62  mCount = 0;
63 }
64 
66 {
67 }
virtual void add(Widget *const widget)
virtual void clear()
Definition: event.h:79
void add(Widget *const widget)
HorizontContainer(const Widget2 *const widget, const int height, const int spacing)
void widgetResized(const Event &event)
Definition: widget.h:99
void addMouseListener(MouseListener *const mouseListener)
Definition: widget.cpp:292
void addWidgetListener(WidgetListener *const widgetListener)
Definition: widget.cpp:302
void setHeight(const int height)
Definition: widget.cpp:140
void setPosition(const int x, const int y)
Definition: widget.cpp:161
int getWidth() const
Definition: widget.h:221
#define A_UNUSED
Definition: localconsts.h:160