GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/widgets/horizontcontainer.cpp Lines: 18 21 85.7 %
Date: 2017-11-29 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-2017  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
22
#include "gui/widgets/horizontcontainer.h"
23
24
#include "debug.h"
25
26
256
HorizontContainer::HorizontContainer(const Widget2 *const widget,
27
                                     const int height,
28
256
                                     const int spacing) :
29
    Container(widget),
30
    WidgetListener(),
31
    ToolTipListener(),
32
    mSpacing(spacing),
33
    mCount(0),
34
512
    mLastX(spacing)
35
{
36
256
    setHeight(height);
37
256
    addWidgetListener(this);
38
256
    addMouseListener(this);
39
256
}
40
41
564
void HorizontContainer::add(Widget *const widget)
42
{
43
564
    add(widget, mSpacing);
44
564
}
45
46
632
void HorizontContainer::add(Widget *const widget, const int spacing)
47
{
48
632
    if (widget == nullptr)
49
        return;
50
51
632
    Container::add(widget);
52
632
    widget->setPosition(mLastX, spacing);
53
632
    mCount++;
54
632
    mLastX += widget->getWidth() + 2 * mSpacing;
55
}
56
57
void HorizontContainer::clear()
58
{
59
    Container::clear();
60
61
    mCount = 0;
62
}
63
64
512
void HorizontContainer::widgetResized(const Event &event A_UNUSED)
65
{
66
512
}