GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/widgets/containerplacer.h Lines: 3 3 100.0 %
Date: 2017-11-29 Branches: 0 0 0.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2007-2009  The Mana World Development Team
4
 *  Copyright (C) 2009-2010  The Mana Developers
5
 *  Copyright (C) 2011-2017  The ManaPlus Developers
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
#ifndef GUI_WIDGETS_CONTAINERPLACER_H
24
#define GUI_WIDGETS_CONTAINERPLACER_H
25
26
#include "localconsts.h"
27
28
class BasicContainer2;
29
class LayoutCell;
30
class Widget;
31
32
/**
33
 * This class is a helper for adding widgets to nested tables in a window.
34
 */
35
class ContainerPlacer final
36
{
37
    public:
38
        explicit ContainerPlacer(BasicContainer2 *const c = nullptr,
39
32
                                 LayoutCell *const lc = nullptr) :
40
            mContainer(c),
41
32
            mCell(lc)
42
        {}
43
44
        A_DEFAULT_COPY(ContainerPlacer)
45
46
        /**
47
         * Gets the pointed cell.
48
         */
49
        LayoutCell &getCell() A_WARN_UNUSED
50
12
        { return *mCell; }
51
52
        /**
53
         * Returns a placer for the same container but to an inner cell.
54
         */
55
        ContainerPlacer at(const int x,
56
                           const int y) A_WARN_UNUSED;
57
58
        /**
59
         * Adds the given widget to the container and places it in the layout.
60
         * @see LayoutArray::place
61
         */
62
        LayoutCell &operator()(const int x,
63
                               const int y,
64
                               Widget *const wg,
65
                               const int w = 1,
66
                               const int h = 1);
67
68
    private:
69
        BasicContainer2 *mContainer;
70
        LayoutCell *mCell;
71
};
72
73
#endif  // GUI_WIDGETS_CONTAINERPLACER_H