ManaPlus
staticbrowserbox.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2004-2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2018 The ManaPlus Developers
6  * Copyright (C) 2009 Aethyra Development Team
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 #ifndef GUI_WIDGETS_STATICBROWSERBOX_H
25 #define GUI_WIDGETS_STATICBROWSERBOX_H
26 
28 
29 #include "enums/gui/colorname.h"
30 
31 #include "gui/browserlink.h"
32 
33 #include "gui/widgets/linepart.h"
34 #include "gui/widgets/widget.h"
35 
37 
38 #include "localconsts.h"
39 
40 class LinkHandler;
41 
46 class StaticBrowserBox final : public Widget,
47  public MouseListener
48 {
49  public:
53  StaticBrowserBox(const Widget2 *const widget,
54  const Opaque opaque,
55  const std::string &skin);
56 
58 
59 
62  ~StaticBrowserBox() override final;
63 
67  void setLinkHandler(LinkHandler *linkHandler);
68 
72  void setOpaque(Opaque opaque)
73  { mOpaque = opaque; }
74 
75  void addSeparator(const std::string &row);
76 
80  void addRow(const std::string &row,
81  const bool atTop);
82 
86  void addRow(const std::string &cmd,
87  const char *const text);
88 
89  void addImage(const std::string &path);
90 
94  void clearRows();
95 
99  void mousePressed(MouseEvent &event) override final;
100 
101  void mouseMoved(MouseEvent &event) override final;
102 
103  void mouseExited(MouseEvent& event) override final;
104 
108  void draw(Graphics *const graphics) override final A_NONNULL(2);
109 
110  void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
111 
112  void updateHeight();
113 
114  void updateSize();
115 
116  typedef std::list<std::string> TextRows;
117 
119  { return mTextRows; }
120 
122  { return !mTextRows.empty(); }
123 
124  void setProcessVars(const bool n) noexcept2
125  { mProcessVars = n; }
126 
127  void setEnableImages(const bool n) noexcept2
128  { mEnableImages = n; }
129 
130  void setEnableKeys(const bool n) noexcept2
131  { mEnableKeys = n; }
132 
133  void setEnableTabs(const bool n) noexcept2
134  { mEnableTabs = n; }
135 
136  std::string getTextAtPos(const int x,
137  const int y) const A_WARN_UNUSED;
138 
139  int getPadding() const noexcept2 A_WARN_UNUSED
140  { return mPadding; }
141 
142  void setForegroundColorAll(const Color &color1,
143  const Color &color2);
144 
145  void moveSelectionUp();
146 
147  void moveSelectionDown();
148 
149  void selectSelection();
150 
151  private:
152  typedef TextRows::iterator TextRowIterator;
153  typedef TextRows::const_iterator TextRowCIter;
154  TextRows mTextRows;
155  std::list<int> mTextRowLinksCount;
156 
157  typedef STD_VECTOR<LinePart> LinePartList;
158  typedef LinePartList::iterator LinePartIterator;
159  typedef LinePartList::const_iterator LinePartCIter;
160  LinePartList mLineParts;
161 
162  typedef STD_VECTOR<BrowserLink> Links;
163  typedef Links::iterator LinkIterator;
164  Links mLinks;
165 
168  unsigned int mHighlightMode;
170  int mHeight;
171  int mWidth;
172  int mYStart;
173  int mPadding;
174  unsigned int mNewLinePadding;
176 
180 
189 
190  static ImageSet *mEmotes;
191  static int mInstances;
192 };
193 
194 #endif // GUI_WIDGETS_STATICBROWSERBOX_H
#define A_DELETE_COPY(func)
Definition: localconsts.h:52
Definition: skin.h:35
TextRows & getRows()
void setProcessVars(const bool n)
void mousePressed(MouseEvent &event)
void setEnableKeys(const bool n)
#define A_WARN_UNUSED
Definition: localconsts.h:152
#define final
Definition: localconsts.h:45
LinePartList mLineParts
std::vector< BrowserLink > Links
#define A_NONNULL(...)
Definition: localconsts.h:159
unsigned int mNewLinePadding
void addImage(const std::string &path)
Links::iterator LinkIterator
void setEnableImages(const bool n)
void addSeparator(const std::string &row)
unsigned int mHighlightMode
StaticBrowserBox(const Widget2 *const widget, const Opaque opaque, const std::string &skin)
void setLinkHandler(LinkHandler *linkHandler)
TextRows::iterator TextRowIterator
void mouseExited(MouseEvent &event)
std::vector< LinePart > LinePartList
void safeDraw(Graphics *const graphics)
int getPadding() const
void mouseMoved(MouseEvent &event)
static ImageSet * mEmotes
LinePartList::const_iterator LinePartCIter
std::list< int > mTextRowLinksCount
void setOpaque(Opaque opaque)
void setForegroundColorAll(const Color &color1, const Color &color2)
Definition: widget.h:97
bool hasRows() const
LinkHandler * mLinkHandler
void setEnableTabs(const bool n)
Definition: color.h:74
void draw(Graphics *const graphics)
TextRows::const_iterator TextRowCIter
#define noexcept2
Definition: localconsts.h:49
std::string getTextAtPos(const int x, const int y) const
void addRow(const std::string &row, const bool atTop)
std::list< std::string > TextRows
Color mColors[2][ColorName::COLORS_MAX]
LinePartList::iterator LinePartIterator