ManaPlus
tab.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2008-2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2019 The ManaPlus Developers
6  * Copyright (C) 2019-2021 Andrei Karas
7  *
8  * This file is part of The ManaPlus Client.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 /* _______ __ __ __ ______ __ __ _______ __ __
25  * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
26  * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
27  * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
28  * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
29  * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
30  * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
31  *
32  * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
33  *
34  *
35  * Per Larsson a.k.a finalman
36  * Olof Naessén a.k.a jansem/yakslem
37  *
38  * Visit: http://guichan.sourceforge.net
39  *
40  * License: (BSD)
41  * Redistribution and use in source and binary forms, with or without
42  * modification, are permitted provided that the following conditions
43  * are met:
44  * 1. Redistributions of source code must retain the above copyright
45  * notice, this list of conditions and the following disclaimer.
46  * 2. Redistributions in binary form must reproduce the above copyright
47  * notice, this list of conditions and the following disclaimer in
48  * the documentation and/or other materials provided with the
49  * distribution.
50  * 3. Neither the name of Guichan nor the names of its contributors may
51  * be used to endorse or promote products derived from this software
52  * without specific prior written permission.
53  *
54  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
55  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
56  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
57  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
58  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
59  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
60  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
61  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
62  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
63  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
64  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
65  */
66 
67 #ifndef GUI_WIDGETS_TABS_TAB_H
68 #define GUI_WIDGETS_TABS_TAB_H
69 
71 
74 
75 #include "localconsts.h"
76 
77 class ImageCollection;
78 class Label;
79 class Skin;
80 class TabbedArea;
81 
85 class Tab notfinal : public BasicContainer,
86  public MouseListener,
87  public WidgetListener
88 {
89  public:
90  explicit Tab(const Widget2 *const widget);
91 
93 
94  ~Tab() override;
95 
96  enum
97  {
102  TAB_COUNT = 4 // Must be last
103  };
104 
108  void updateAlpha();
109 
113  void draw(Graphics *const graphics) override final A_NONNULL(2);
114 
115  void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
116 
120  void setTabColor(const Color *const color1,
121  const Color *const color2)
122  {
123  mTabColor = color1;
124  mTabOutlineColor = color2;
125  mRedraw = true;
126  }
127 
131  void setHighlightedTabColor(const Color *const color1,
132  const Color *const color2)
133  {
134  mTabHighlightedColor = color1;
136  mRedraw = true;
137  }
138 
142  void setSelectedTabColor(const Color *const color1,
143  const Color *const color2)
144  {
145  mTabSelectedColor = color1;
146  mTabSelectedOutlineColor = color2;
147  mRedraw = true;
148  }
149 
153  void setFlashTabColor(const Color *const color1,
154  const Color *const color2)
155  {
156  mFlashColor = color1;
157  mFlashOutlineColor = color2;
158  mRedraw = true;
159  }
160 
164  void setPlayerFlashTabColor(const Color *const color1,
165  const Color *const color2)
166  {
167  mPlayerFlashColor = color1;
168  mPlayerFlashOutlineColor = color2;
169  mRedraw = true;
170  }
171 
175  void setFlash(const int flash)
176  { mFlash = flash; mRedraw = true; }
177 
179  { return mFlash; }
180 
181  void widgetResized(const Event &event) override final;
182 
183  void widgetMoved(const Event &event) override final;
184 
185  void setLabelFont(Font *const font);
186 
188  { return mLabel; }
189 
190  void adjustSize();
191 
192  void setTabbedArea(TabbedArea* tabbedArea);
193 
195 
196  void setCaption(const std::string& caption);
197 
198  const std::string &getCaption() const A_WARN_UNUSED;
199 
200  void mouseEntered(MouseEvent &event) override final;
201 
202  void mouseExited(MouseEvent &event) override final;
203 
204  void setImage(Image *const image);
205 
206  static void finalCleanup();
207 
208  protected:
209  friend class TabbedArea;
210 
211  virtual void setCurrent()
212  { }
213 
215 
217 
218  private:
220  void init();
221 
222  static Skin *tabImg[TAB_COUNT];
223  static int mInstances;
224  static float mAlpha;
225 
226  const Color *mTabColor;
236  int mFlash;
239  int mMode;
241 
242  protected:
243  bool mHasMouse;
244 };
245 
246 #endif // GUI_WIDGETS_TABS_TAB_H
Definition: color.h:76
Definition: event.h:79
Definition: font.h:90
Definition: label.h:91
Definition: skin.h:37
Definition: tab.h:88
void setHighlightedTabColor(const Color *const color1, const Color *const color2)
Definition: tab.h:131
int mMode
Definition: tab.h:239
const Color * mFlashColor
Definition: tab.h:232
const Color * mTabSelectedColor
Definition: tab.h:230
const Color * mTabColor
Definition: tab.h:226
void mouseEntered(MouseEvent &event)
Definition: tab.cpp:478
Tab(const Widget2 *const widget)
Definition: tab.cpp:103
void setPlayerFlashTabColor(const Color *const color1, const Color *const color2)
Definition: tab.h:164
const Color * mTabSelectedOutlineColor
Definition: tab.h:231
int mFlash
Definition: tab.h:236
void init()
Definition: tab.cpp:154
void adjustSize()
Definition: tab.cpp:426
const Color * mTabHighlightedColor
Definition: tab.h:228
void setFlash(const int flash)
Definition: tab.h:175
void updateAlpha()
Definition: tab.cpp:190
const Color * mTabOutlineColor
Definition: tab.h:227
void widgetMoved(const Event &event)
Definition: tab.cpp:409
void setTabbedArea(TabbedArea *tabbedArea)
Definition: tab.cpp:448
const std::string & getCaption() const
Definition: tab.cpp:473
static int mInstances
Definition: tab.h:223
Label * getLabel() const
Definition: tab.h:187
void safeDraw(Graphics *const graphics)
Definition: tab.cpp:318
const Color * mPlayerFlashColor
Definition: tab.h:234
int getFlash() const
Definition: tab.h:178
bool mHasMouse
Definition: tab.h:243
@ TAB_COUNT
Definition: tab.h:102
@ TAB_HIGHLIGHTED
Definition: tab.h:99
@ TAB_SELECTED
Definition: tab.h:100
@ TAB_STANDARD
Definition: tab.h:98
@ TAB_UNUSED
Definition: tab.h:101
TabbedArea * mTabbedArea
Definition: tab.h:216
const Color * mTabHighlightedOutlineColor
Definition: tab.h:229
static Skin * tabImg[TAB_COUNT]
Definition: tab.h:222
void setTabColor(const Color *const color1, const Color *const color2)
Definition: tab.h:120
void mouseExited(MouseEvent &event)
Definition: tab.cpp:483
void setCaption(const std::string &caption)
Definition: tab.cpp:458
~Tab()
Definition: tab.cpp:132
void setLabelFont(Font *const font)
Definition: tab.cpp:414
Image * mImage
Definition: tab.h:238
void setImage(Image *const image)
Definition: tab.cpp:465
void draw(Graphics *const graphics)
Definition: tab.cpp:215
Label * mLabel
Definition: tab.h:214
static void finalCleanup()
Definition: tab.cpp:488
void setFlashTabColor(const Color *const color1, const Color *const color2)
Definition: tab.h:153
const Color * mFlashOutlineColor
Definition: tab.h:233
static float mAlpha
Definition: tab.h:224
TabbedArea * getTabbedArea() const
Definition: tab.cpp:453
int mLabelMode
Definition: tab.h:240
ImageCollection * mVertexes
Definition: tab.h:237
const Color * mPlayerFlashOutlineColor
Definition: tab.h:235
void widgetResized(const Event &event)
Definition: tab.cpp:404
virtual void setCurrent()
Definition: tab.h:211
void setSelectedTabColor(const Color *const color1, const Color *const color2)
Definition: tab.h:142
bool mRedraw
Definition: widget.h:1164
#define override
Definition: localconsts.h:47
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define notfinal
Definition: localconsts.h:261
#define A_NONNULL(...)
Definition: localconsts.h:168
#define A_NONNULLPOINTER
Definition: localconsts.h:266
#define noexcept2
Definition: localconsts.h:50
#define final
Definition: localconsts.h:46
#define A_DELETE_COPY(func)
Definition: localconsts.h:53