GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/widgets/basiccontainer2.h Lines: 1 1 100.0 %
Date: 2018-11-12 Branches: 0 0 0.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2011-2018  The ManaPlus Developers
4
 *
5
 *  This file is part of The ManaPlus Client.
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License
18
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
/*      _______   __   __   __   ______   __   __   _______   __   __
22
 *     / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___  /\ /  |\/ /\
23
 *    / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
24
 *   / / /__   / / // / // / // / /    / ___  / // ___  / // /| ' / /
25
 *  / /_// /\ / /_// / // / // /_/_   / / // / // /\_/ / // / |  / /
26
 * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
27
 * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
28
 *
29
 * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
30
 *
31
 *
32
 * Per Larsson a.k.a finalman
33
 * Olof Naessén a.k.a jansem/yakslem
34
 *
35
 * Visit: http://guichan.sourceforge.net
36
 *
37
 * License: (BSD)
38
 * Redistribution and use in source and binary forms, with or without
39
 * modification, are permitted provided that the following conditions
40
 * are met:
41
 * 1. Redistributions of source code must retain the above copyright
42
 *    notice, this list of conditions and the following disclaimer.
43
 * 2. Redistributions in binary form must reproduce the above copyright
44
 *    notice, this list of conditions and the following disclaimer in
45
 *    the documentation and/or other materials provided with the
46
 *    distribution.
47
 * 3. Neither the name of Guichan nor the names of its contributors may
48
 *    be used to endorse or promote products derived from this software
49
 *    without specific prior written permission.
50
 *
51
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
52
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
53
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
54
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
55
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
56
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
57
 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
58
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
59
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
60
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
61
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62
 */
63
64
#ifndef GUI_WIDGETS_BASICCONTAINER2_H
65
#define GUI_WIDGETS_BASICCONTAINER2_H
66
67
#include "gui/widgets/basiccontainer.h"
68
69
#include "enums/simpletypes/opaque.h"
70
71
/**
72
  * An implementation of a container able to contain other widgets. A widget's
73
  * position in the container is relative to the container itself and not the screen.
74
  * A container is the most common widget to use as the Gui's top widget as makes the Gui
75
  * able to contain more than one widget.
76
  *
77
  * @see Gui::setTop
78
  */
79
class BasicContainer2 notfinal : public BasicContainer
80
{
81
    public:
82
        /**
83
          * Constructor. A container is opauqe as default, if you want a
84
          * none opaque container call setQpaque(false).
85
          *
86
          * @see setOpaque, isOpaque
87
          */
88
        explicit BasicContainer2(const Widget2 *const widget);
89
90
        /**
91
          * Destructor.
92
          */
93
        ~BasicContainer2() override;
94
95
        A_DEFAULT_COPY(BasicContainer2)
96
97
        /**
98
          * Sets the container to be opaque or not. If the container
99
          * is opaque its background will be drawn, if it's not opaque
100
          * its background will not be drawn, and thus making the container
101
          * completely transparent.
102
          *
103
          * NOTE: This is not the same as to set visibility. A non visible
104
          *       container will not itself nor will it draw its content.
105
          *
106
          * @param opaque True if the container should be opaque, false otherwise.
107
          * @see isOpaque
108
          */
109
        void setOpaque(Opaque opaque)
110
647
        { mOpaque = opaque; }
111
112
        /**
113
          * Checks if the container is opaque or not.
114
          *
115
          * @return True if the container is opaque, false otherwise.
116
          * @see setOpaque
117
          */
118
        bool isOpaque() const
119
        { return mOpaque == Opaque_true; }
120
121
        /**
122
          * Adds a widget to the container.
123
          *
124
          * @param widget The widget to add.
125
          * @see remove, clear
126
          */
127
        virtual void add(Widget *const widget);
128
129
        /**
130
          * Adds a widget to the container and also specifies the widget's
131
          * position in the container. The position is relative to the container
132
          * and not relative to the screen.
133
          *
134
          * @param widget The widget to add.
135
          * @param x The x coordinate for the widget.
136
          * @param y The y coordinate for the widget.
137
          * @see remove, clear
138
          */
139
        void addXY(Widget *const widget,
140
                   const int x, const int y);
141
142
        // Inherited from Widget
143
144
        void draw(Graphics *const graphics) override A_NONNULL(2);
145
146
        void safeDraw(Graphics *const graphics) override A_NONNULL(2);
147
148
    protected:
149
        /**
150
          * True if the container is opaque, false otherwise.
151
          */
152
        Opaque mOpaque;
153
};
154
155
#endif  // GUI_WIDGETS_BASICCONTAINER2_H