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 |
|
|
|
23 |
|
|
#include "gui/widgets/horizontcontainer.h" |
24 |
|
|
|
25 |
|
|
#include "debug.h" |
26 |
|
|
|
27 |
|
134 |
HorizontContainer::HorizontContainer(const Widget2 *const widget, |
28 |
|
|
const int height, |
29 |
|
134 |
const int spacing) : |
30 |
|
|
Container(widget), |
31 |
|
|
WidgetListener(), |
32 |
|
|
ToolTipListener(), |
33 |
|
|
mSpacing(spacing), |
34 |
|
|
mCount(0), |
35 |
✓✗ |
268 |
mLastX(spacing) |
36 |
|
|
{ |
37 |
✓✗ |
134 |
setHeight(height); |
38 |
✓✗ |
134 |
addWidgetListener(this); |
39 |
✓✗ |
134 |
addMouseListener(this); |
40 |
|
134 |
} |
41 |
|
|
|
42 |
|
296 |
void HorizontContainer::add(Widget *const widget) |
43 |
|
|
{ |
44 |
|
296 |
add(widget, mSpacing); |
45 |
|
296 |
} |
46 |
|
|
|
47 |
|
334 |
void HorizontContainer::add(Widget *const widget, const int spacing) |
48 |
|
|
{ |
49 |
✓✗ |
334 |
if (widget == nullptr) |
50 |
|
|
return; |
51 |
|
|
|
52 |
|
334 |
Container::add(widget); |
53 |
|
334 |
widget->setPosition(mLastX, spacing); |
54 |
|
334 |
mCount++; |
55 |
|
334 |
mLastX += widget->getWidth() + 2 * mSpacing; |
56 |
|
|
} |
57 |
|
|
|
58 |
|
|
void HorizontContainer::clear() |
59 |
|
|
{ |
60 |
|
|
Container::clear(); |
61 |
|
|
|
62 |
|
|
mCount = 0; |
63 |
|
|
} |
64 |
|
|
|
65 |
|
268 |
void HorizontContainer::widgetResized(const Event &event A_UNUSED) |
66 |
|
|
{ |
67 |
|
268 |
} |