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-2019 The ManaPlus Developers
6  * Copyright (C) 2019-2021 Andrei Karas
7  * Copyright (C) 2009 Aethyra Development Team
8  *
9  * This file is part of The ManaPlus Client.
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see <http://www.gnu.org/licenses/>.
23  */
24 
25 #ifndef GUI_WIDGETS_STATICBROWSERBOX_H
26 #define GUI_WIDGETS_STATICBROWSERBOX_H
27 
29 
30 #include "enums/gui/colorname.h"
31 
32 #include "gui/browserlink.h"
33 
34 #include "gui/widgets/linepart.h"
35 #include "gui/widgets/widget.h"
36 
38 
39 #include "localconsts.h"
40 
41 class LinkHandler;
42 
47 class StaticBrowserBox final : public Widget,
48  public MouseListener
49 {
50  public:
54  StaticBrowserBox(const Widget2 *const widget,
55  const Opaque opaque,
56  const std::string &skin);
57 
59 
60 
63  ~StaticBrowserBox() override final;
64 
68  void setLinkHandler(LinkHandler *linkHandler);
69 
73  void setOpaque(Opaque opaque)
74  { mOpaque = opaque; }
75 
76  void addSeparator(const std::string &row);
77 
81  void addRow(const std::string &row,
82  const bool atTop);
83 
87  void addRow(const std::string &cmd,
88  const char *const text);
89 
90  void addImage(const std::string &path);
91 
95  void clearRows();
96 
100  void mousePressed(MouseEvent &event) override final;
101 
102  void mouseMoved(MouseEvent &event) override final;
103 
104  void mouseExited(MouseEvent& event) override final;
105 
109  void draw(Graphics *const graphics) override final A_NONNULL(2);
110 
111  void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
112 
113  void updateHeight();
114 
115  void updateSize();
116 
117  typedef std::list<std::string> TextRows;
118 
120  { return mTextRows; }
121 
123  { return !mTextRows.empty(); }
124 
125  void setProcessVars(const bool n) noexcept2
126  { mProcessVars = n; }
127 
128  void setEnableImages(const bool n) noexcept2
129  { mEnableImages = n; }
130 
131  void setEnableKeys(const bool n) noexcept2
132  { mEnableKeys = n; }
133 
134  void setEnableTabs(const bool n) noexcept2
135  { mEnableTabs = n; }
136 
137  std::string getTextAtPos(const int x,
138  const int y) const A_WARN_UNUSED;
139 
141  { return mPadding; }
142 
143  void setForegroundColorAll(const Color &color1,
144  const Color &color2);
145 
146  void moveSelectionUp();
147 
148  void moveSelectionDown();
149 
150  void selectSelection();
151 
152  private:
153  typedef TextRows::iterator TextRowIterator;
154  typedef TextRows::const_iterator TextRowCIter;
156  std::list<int> mTextRowLinksCount;
157 
158  typedef STD_VECTOR<LinePart> LinePartList;
159  typedef LinePartList::iterator LinePartIterator;
160  typedef LinePartList::const_iterator LinePartCIter;
162 
163  typedef STD_VECTOR<BrowserLink> Links;
164  typedef Links::iterator LinkIterator;
166 
169  unsigned int mHighlightMode;
171  int mHeight;
172  int mWidth;
173  int mYStart;
174  int mPadding;
175  unsigned int mNewLinePadding;
177 
181 
190 
191  static ImageSet *mEmotes;
192  static int mInstances;
193 };
194 
195 #endif // GUI_WIDGETS_STATICBROWSERBOX_H
Definition: color.h:76
Definition: skin.h:37
std::vector< LinePart > LinePartList
TextRows::iterator TextRowIterator
void addRow(const std::string &row, const bool atTop)
Links::iterator LinkIterator
void setForegroundColorAll(const Color &color1, const Color &color2)
std::list< int > mTextRowLinksCount
void setOpaque(Opaque opaque)
void mouseExited(MouseEvent &event)
void mouseMoved(MouseEvent &event)
unsigned int mNewLinePadding
static ImageSet * mEmotes
Color mColors[2][ColorName::COLORS_MAX]
StaticBrowserBox(const Widget2 *const widget, const Opaque opaque, const std::string &skin)
std::vector< BrowserLink > Links
unsigned int mHighlightMode
LinkHandler * mLinkHandler
LinePartList::const_iterator LinePartCIter
void draw(Graphics *const graphics)
TextRows & getRows()
void mousePressed(MouseEvent &event)
void setEnableKeys(const bool n)
void setEnableImages(const bool n)
LinePartList mLineParts
LinePartList::iterator LinePartIterator
std::string getTextAtPos(const int x, const int y) const
void addImage(const std::string &path)
TextRows::const_iterator TextRowCIter
void addSeparator(const std::string &row)
void setEnableTabs(const bool n)
void safeDraw(Graphics *const graphics)
int getPadding() const
void setProcessVars(const bool n)
void setLinkHandler(LinkHandler *linkHandler)
bool hasRows() const
std::list< std::string > TextRows
Definition: widget.h:99
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define A_NONNULL(...)
Definition: localconsts.h:168
#define noexcept2
Definition: localconsts.h:50
#define final
Definition: localconsts.h:46
#define A_DELETE_COPY(func)
Definition: localconsts.h:53
@ COLORS_MAX
Definition: colorname.h:42
bool Opaque
Definition: opaque.h:30