GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/widgets/horizontcontainer.cpp Lines: 18 21 85.7 %
Date: 2021-03-17 Branches: 5 10 50.0 %

Line Branch Exec Source
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
138
HorizontContainer::HorizontContainer(const Widget2 *const widget,
28
                                     const int height,
29
138
                                     const int spacing) :
30
    Container(widget),
31
    WidgetListener(),
32
    ToolTipListener(),
33
    mSpacing(spacing),
34
    mCount(0),
35
276
    mLastX(spacing)
36
{
37
138
    setHeight(height);
38
138
    addWidgetListener(this);
39
138
    addMouseListener(this);
40
138
}
41
42
304
void HorizontContainer::add(Widget *const widget)
43
{
44
304
    add(widget, mSpacing);
45
304
}
46
47
342
void HorizontContainer::add(Widget *const widget, const int spacing)
48
{
49
342
    if (widget == nullptr)
50
        return;
51
52
342
    Container::add(widget);
53
342
    widget->setPosition(mLastX, spacing);
54
342
    mCount++;
55
342
    mLastX += widget->getWidth() + 2 * mSpacing;
56
}
57
58
void HorizontContainer::clear()
59
{
60
    Container::clear();
61
62
    mCount = 0;
63
}
64
65
276
void HorizontContainer::widgetResized(const Event &event A_UNUSED)
66
{
67
276
}