| GCC Code Coverage Report | |||||||||||||||||||||
        
  | 
    |||||||||||||||||||||
| Line | Branch | Exec | Source | 
1  | 
    /*  | 
    ||
2  | 
    * The ManaPlus Client  | 
    ||
3  | 
    * Copyright (C) 2012-2019 The ManaPlus Developers  | 
    ||
4  | 
    * Copyright (C) 2019-2021 Andrei Karas  | 
    ||
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  | 
    #ifndef GUI_WIDGETS_WIDGET2_H  | 
    ||
23  | 
    #define GUI_WIDGETS_WIDGET2_H  | 
    ||
24  | 
    |||
25  | 
    #include "const/gui/theme.h"  | 
    ||
26  | 
    |||
27  | 
    #include "enums/render/rendertype.h"  | 
    ||
28  | 
    |||
29  | 
    #include "gui/themecolorsidoperators.h"  | 
    ||
30  | 
    #include "gui/theme.h"  | 
    ||
31  | 
    |||
32  | 
    #include "localconsts.h"  | 
    ||
33  | 
    |||
34  | 
    class Widget;  | 
    ||
35  | 
    |||
36  | 
    class Widget2 notfinal  | 
    ||
37  | 
    { | 
    ||
38  | 
    public:  | 
    ||
39  | 
    A_DEFAULT_COPY(Widget2)  | 
    ||
40  | 
    |||
41  | 
    virtual ~Widget2()  | 
    ||
42  | 
            { | 
    ||
43  | 
    }  | 
    ||
44  | 
    |||
45  | 
    inline const Color &getThemeColor(const ThemeColorIdT type,  | 
    ||
46  | 
    const unsigned int alpha)  | 
    ||
47  | 
    const A_WARN_UNUSED A_INLINE  | 
    ||
48  | 
            { | 
    ||
49  | 
    ✓✗✓✓ ✓✓✓✓ ✓✓✓✓ ✓✓✓✓ ✗✓✓✗ ✗✓✗✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗  | 
    7550  | 
    return theme->getColor(type + mPaletteOffset, alpha);  | 
    
50  | 
    }  | 
    ||
51  | 
    |||
52  | 
    inline const Color &getThemeCharColor(const signed char c,  | 
    ||
53  | 
    bool &valid)  | 
    ||
54  | 
    const A_WARN_UNUSED A_INLINE  | 
    ||
55  | 
            { | 
    ||
56  | 
    ✓✗✓✗ | 
    4  | 
    if (theme == nullptr)  | 
    
57  | 
    return Palette::BLACK;  | 
    ||
58  | 
    ✓✗✓✗ | 
    4  | 
    const ThemeColorIdT colorId = theme->getIdByChar(c, valid);  | 
    
59  | 
    ✓✓✓✓ | 
    4  | 
    if (valid)  | 
    
60  | 
    ✓✗✓✗ ✓✗✓✗  | 
    2  | 
    return theme->getColor(colorId + mPaletteOffset, 255U);  | 
    
61  | 
    return Palette::BLACK;  | 
    ||
62  | 
    }  | 
    ||
63  | 
    |||
64  | 
    243  | 
    virtual void setWidget2(const Widget2 *const widget)  | 
    |
65  | 
            { | 
    ||
66  | 
    ✓✗ | 243  | 
    mPaletteOffset = widget != nullptr ? widget->mPaletteOffset : 0;  | 
    
67  | 
    243  | 
    }  | 
    |
68  | 
    |||
69  | 
    void setPalette(int palette)  | 
    ||
70  | 
            { | 
    ||
71  | 
    242  | 
    mPaletteOffset = palette * CAST_S32(  | 
    |
72  | 
    ThemeColorId::THEME_COLORS_END);  | 
    ||
73  | 
    242  | 
    checkPalette();  | 
    |
74  | 
    242  | 
    setWidget2(this);  | 
    |
75  | 
    }  | 
    ||
76  | 
    |||
77  | 
    void checkPalette()  | 
    ||
78  | 
            { | 
    ||
79  | 
    ✗✓✗✓ | 
    3242  | 
    if (mPaletteOffset < 0 ||  | 
    
80  | 
    mPaletteOffset >= THEME_PALETTES * CAST_S32(  | 
    ||
81  | 
    ThemeColorId::THEME_COLORS_END))  | 
    ||
82  | 
                { | 
    ||
83  | 
    mPaletteOffset = 0;  | 
    ||
84  | 
    }  | 
    ||
85  | 
    }  | 
    ||
86  | 
    |||
87  | 
    void setForegroundColor2(const Color &color) noexcept2  | 
    ||
88  | 
            { | 
    ||
89  | 
    mForegroundColor2 = color;  | 
    ||
90  | 
    }  | 
    ||
91  | 
    |||
92  | 
    Widget* getWindow() const noexcept2 A_WARN_UNUSED  | 
    ||
93  | 
            { | 
    ||
94  | 
    2686  | 
    return mWindow;  | 
    |
95  | 
    }  | 
    ||
96  | 
    |||
97  | 
    73  | 
    virtual void setWindow(Widget *const window)  | 
    |
98  | 
            { | 
    ||
99  | 
    79  | 
    mWindow = window;  | 
    |
100  | 
    73  | 
    }  | 
    |
101  | 
    |||
102  | 
    protected:  | 
    ||
103  | 
    3000  | 
    explicit Widget2(const Widget2 *const widget) :  | 
    |
104  | 
    ✓✓✓✗ | 
    3000  | 
    mPaletteOffset(widget != nullptr ? widget->mPaletteOffset : 0),  | 
    
105  | 
    ✓✓✓✗ | 
    5680  | 
    mWindow(widget != nullptr ? widget->getWindow() : nullptr),  | 
    
106  | 
    12000  | 
    mForegroundColor2()  | 
    |
107  | 
            { | 
    ||
108  | 
    3000  | 
    checkPalette();  | 
    |
109  | 
    }  | 
    ||
110  | 
    |||
111  | 
    int mPaletteOffset;  | 
    ||
112  | 
    Widget *mWindow;  | 
    ||
113  | 
    Color mForegroundColor2;  | 
    ||
114  | 
    };  | 
    ||
115  | 
    |||
116  | 
    extern RenderType openGLMode;  | 
    ||
117  | 
    |||
118  | 
    #endif // GUI_WIDGETS_WIDGET2_H  | 
    
| Generated by: GCOVR (Version 3.3) |