ManaPlus
Public Types | Public Member Functions | Private Types | Private Attributes | Static Private Attributes
StaticBrowserBox Class Reference

#include <staticbrowserbox.h>

Inheritance diagram for StaticBrowserBox:
Widget MouseListener Widget2

Public Types

typedef std::list< std::string > TextRows
 

Public Member Functions

 StaticBrowserBox (const Widget2 *const widget, const Opaque opaque, const std::string &skin)
 
 ~StaticBrowserBox ()
 
void setLinkHandler (LinkHandler *linkHandler)
 
void setOpaque (Opaque opaque)
 
void addSeparator (const std::string &row)
 
void addRow (const std::string &row, const bool atTop)
 
void addRow (const std::string &cmd, const char *const text)
 
void addImage (const std::string &path)
 
void clearRows ()
 
void mousePressed (MouseEvent &event)
 
void mouseMoved (MouseEvent &event)
 
void mouseExited (MouseEvent &event)
 
void draw (Graphics *const graphics)
 
void safeDraw (Graphics *const graphics)
 
void updateHeight ()
 
void updateSize ()
 
TextRowsgetRows ()
 
bool hasRows () const
 
void setProcessVars (const bool n)
 
void setEnableImages (const bool n)
 
void setEnableKeys (const bool n)
 
void setEnableTabs (const bool n)
 
std::string getTextAtPos (const int x, const int y) const
 
int getPadding () const
 
void setForegroundColorAll (const Color &color1, const Color &color2)
 
void moveSelectionUp ()
 
void moveSelectionDown ()
 
void selectSelection ()
 
- Public Member Functions inherited from Widget
 Widget (const Widget2 *const widget)
 
 ~Widget ()
 
virtual void drawFrame (Graphics *graphics)
 
virtual void safeDrawFrame (Graphics *graphics)
 
void setFrameSize (const unsigned int frameSize)
 
unsigned int getFrameSize () const
 
virtual void logic ()
 
WidgetgetParent () const
 
void setWidth (const int width)
 
int getWidth () const
 
void setHeight (const int height)
 
int getHeight () const
 
void setSize (const int width, const int height)
 
void setX (const int x)
 
int getX () const
 
void setY (const int y)
 
int getY () const
 
void setPosition (const int x, const int y)
 
void setDimension (const Rect &dimension)
 
const RectgetDimension () const
 
void setFocusable (const bool focusable)
 
bool isFocusable () const
 
virtual bool isFocused () const
 
void setEnabled (const bool enabled)
 
bool isEnabled () const
 
void setVisible (Visible visible)
 
bool isVisible () const
 
void setBaseColor (const Color &color)
 
const ColorgetBaseColor () const
 
void setForegroundColor (const Color &color)
 
const ColorgetForegroundColor () const
 
void setBackgroundColor (const Color &color)
 
const ColorgetBackgroundColor () const
 
virtual void requestFocus ()
 
virtual void requestMoveToTop ()
 
virtual void requestMoveToBottom ()
 
virtual void setFocusHandler (FocusHandler *const focusHandler)
 
FocusHandlergetFocusHandler ()
 
void addActionListener (ActionListener *const actionListener)
 
void removeActionListener (ActionListener *const actionListener)
 
void addDeathListener (WidgetDeathListener *const deathListener)
 
void removeDeathListener (WidgetDeathListener *const deathListener)
 
void addMouseListener (MouseListener *const mouseListener)
 
void removeMouseListener (MouseListener *const mouseListener)
 
void addKeyListener (KeyListener *const keyListener)
 
void removeKeyListener (KeyListener *const keyListener)
 
void addFocusListener (FocusListener *const focusListener)
 
void removeFocusListener (FocusListener *const focusListener)
 
void addWidgetListener (WidgetListener *const widgetListener)
 
void removeWidgetListener (WidgetListener *const widgetListener)
 
void setActionEventId (const std::string &actionEventId)
 
const std::string & getActionEventId () const
 
virtual void getAbsolutePosition (int &x, int &y) const
 
virtual void setParent (Widget *parent)
 
FontgetFont () const
 
void setFont (Font *const font)
 
virtual void fontChanged ()
 
bool isTabInEnabled () const
 
void setTabInEnabled (const bool enabled)
 
bool isTabOutEnabled () const
 
void setTabOutEnabled (const bool enabled)
 
void requestModalFocus ()
 
virtual void requestModalMouseInputFocus ()
 
virtual void releaseModalFocus ()
 
virtual void releaseModalMouseInputFocus ()
 
virtual bool isModalFocused () const
 
virtual bool isModalMouseInputFocused () const
 
virtual WidgetgetWidgetAt (int x, int y)
 
const std::list< MouseListener * > & getMouseListeners () const A_CONST
 
const std::list< KeyListener * > & getKeyListeners () const A_CONST
 
const std::list< FocusListener * > & getFocusListeners () const A_CONST
 
virtual Rect getChildrenArea ()
 
virtual FocusHandlergetInternalFocusHandler ()
 
void setInternalFocusHandler (FocusHandler *const internalFocusHandler)
 
virtual void moveToTop (Widget *widget)
 
virtual void moveToBottom (Widget *widget)
 
virtual void focusNext ()
 
virtual void focusPrevious ()
 
virtual void showWidgetPart (Widget *const widget, const Rect &area)
 
void setId (const std::string &id)
 
const std::string & getId () const
 
virtual void showPart (const Rect &rectangle)
 
bool isAllowLogic () const
 
void setMouseConsume (const bool b)
 
bool isMouseConsume () const
 
void setRedraw (const bool b)
 
virtual bool isSelectable () const
 
void setSelectable (const bool selectable)
 
void windowResized ()
 
virtual void postInit ()
 
- Public Member Functions inherited from Widget2
virtual ~Widget2 ()
 
const ColorgetThemeColor (const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
 
const ColorgetThemeCharColor (const signed char c, bool &valid) const A_INLINE
 
virtual void setWidget2 (const Widget2 *const widget)
 
void setPalette (int palette)
 
void checkPalette ()
 
void setForegroundColor2 (const Color &color)
 
WidgetgetWindow () const
 
virtual void setWindow (Widget *const window)
 
- Public Member Functions inherited from MouseListener
virtual ~MouseListener ()
 
virtual void mouseEntered (MouseEvent &event)
 
virtual void mouseReleased (MouseEvent &event)
 
virtual void mouseClicked (MouseEvent &event)
 
virtual void mouseWheelMovedUp (MouseEvent &event)
 
virtual void mouseWheelMovedDown (MouseEvent &event)
 
virtual void mouseDragged (MouseEvent &event)
 

Private Types

typedef TextRows::iterator TextRowIterator
 
typedef TextRows::const_iterator TextRowCIter
 
typedef std::vector< LinePartLinePartList
 
typedef LinePartList::iterator LinePartIterator
 
typedef LinePartList::const_iterator LinePartCIter
 
typedef std::vector< BrowserLinkLinks
 
typedef Links::iterator LinkIterator
 

Private Attributes

TextRows mTextRows
 
std::list< int > mTextRowLinksCount
 
LinePartList mLineParts
 
Links mLinks
 
LinkHandlermLinkHandler
 
SkinmSkin
 
unsigned int mHighlightMode
 
int mSelectedLink
 
int mHeight
 
int mWidth
 
int mYStart
 
int mPadding
 
unsigned int mNewLinePadding
 
int mItemPadding
 
Color mHighlightColor
 
Color mHyperLinkColor
 
Color mColors [2][ColorName::COLORS_MAX]
 
Opaque mOpaque
 
bool mUseLinksAndUserColors
 
bool mUseEmotes
 
bool mProcessVars
 
bool mEnableImages
 
bool mEnableKeys
 
bool mEnableTabs
 
bool mSeparator
 

Static Private Attributes

static ImageSetmEmotes = 0
 
static int mInstances = 0
 

Additional Inherited Members

- Static Public Member Functions inherited from Widget
static void setGlobalFont (Font *const font)
 
static FontgetGloablFont ()
 
static void cleanGlobalFont ()
 
static bool widgetExists (const Widget *const widget)
 
static void distributeWindowResizeEvent ()
 
static WidgetcallPostInit (Widget *const widget)
 
- Data Fields inherited from Widget
Visible mVisible
 
- Protected Types inherited from Widget
typedef std::list< MouseListener * > MouseListenerList
 
typedef MouseListenerList::iterator MouseListenerIterator
 
typedef std::list< KeyListener * > KeyListenerList
 
typedef KeyListenerList::iterator KeyListenerIterator
 
typedef std::list< ActionListener * > ActionListenerList
 
typedef ActionListenerList::iterator ActionListenerIterator
 
typedef std::list< WidgetDeathListener * > WidgetDeathListenerList
 
typedef WidgetDeathListenerList::iterator WidgetDeathListenerIterator
 
typedef std::list< FocusListener * > FocusListenerList
 
typedef FocusListenerList::iterator FocusListenerIterator
 
typedef std::list< WidgetListener * > WidgetListenerList
 
typedef WidgetListenerList::iterator WidgetListenerIterator
 
- Protected Member Functions inherited from Widget
void distributeActionEvent ()
 
void distributeResizedEvent ()
 
void distributeMovedEvent ()
 
void distributeHiddenEvent ()
 
void distributeShownEvent ()
 
- Protected Member Functions inherited from Widget2
 Widget2 (const Widget2 *const widget)
 
- Protected Member Functions inherited from MouseListener
 MouseListener ()
 
- Protected Attributes inherited from Widget
MouseListenerList mMouseListeners
 
KeyListenerList mKeyListeners
 
ActionListenerList mActionListeners
 
WidgetDeathListenerList mDeathListeners
 
FocusListenerList mFocusListeners
 
WidgetListenerList mWidgetListeners
 
Color mForegroundColor
 
Color mBackgroundColor
 
Color mBaseColor
 
Rect mDimension
 
std::string mActionEventId
 
std::string mId
 
FocusHandlermFocusHandler
 
FocusHandlermInternalFocusHandler
 
WidgetmParent
 
FontmCurrentFont
 
unsigned int mFrameSize
 
bool mFocusable
 
bool mTabIn
 
bool mTabOut
 
bool mEnabled
 
bool mAllowLogic
 
bool mMouseConsume
 
bool mRedraw
 
bool mSelectable
 
- Protected Attributes inherited from Widget2
int mPaletteOffset
 
WidgetmWindow
 
Color mForegroundColor2
 
- Static Protected Attributes inherited from Widget
static FontmGlobalFont = 0
 

Detailed Description

A simple browser box able to handle links and forward events to the parent conteiner.

Definition at line 46 of file staticbrowserbox.h.

Member Typedef Documentation

◆ LinePartCIter

typedef LinePartList::const_iterator StaticBrowserBox::LinePartCIter
private

Definition at line 159 of file staticbrowserbox.h.

◆ LinePartIterator

typedef LinePartList::iterator StaticBrowserBox::LinePartIterator
private

Definition at line 158 of file staticbrowserbox.h.

◆ LinePartList

typedef std::vector<LinePart> StaticBrowserBox::LinePartList
private

Definition at line 157 of file staticbrowserbox.h.

◆ LinkIterator

typedef Links::iterator StaticBrowserBox::LinkIterator
private

Definition at line 163 of file staticbrowserbox.h.

◆ Links

typedef std::vector<BrowserLink> StaticBrowserBox::Links
private

Definition at line 162 of file staticbrowserbox.h.

◆ TextRowCIter

typedef TextRows::const_iterator StaticBrowserBox::TextRowCIter
private

Definition at line 153 of file staticbrowserbox.h.

◆ TextRowIterator

typedef TextRows::iterator StaticBrowserBox::TextRowIterator
private

Definition at line 152 of file staticbrowserbox.h.

◆ TextRows

typedef std::list<std::string> StaticBrowserBox::TextRows

Definition at line 116 of file staticbrowserbox.h.

Constructor & Destructor Documentation

◆ StaticBrowserBox()

StaticBrowserBox::StaticBrowserBox ( const Widget2 *const  widget,
const Opaque  opaque,
const std::string &  skin 
)

Constructor.

Definition at line 60 of file staticbrowserbox.cpp.

References Widget::addMouseListener(), LinkHighlightMode::BACKGROUND, ThemeColorId::BACKGROUND, ColorName::BLACK, ColorName::BLUE, ColorName::BROWN, ThemeColorId::BROWSERBOX, ThemeColorId::BROWSERBOX_OUTLINE, CAST_U32, Loader::getImageSet(), Skin::getOption(), Skin::getPadding(), Widget2::getThemeColor(), Theme::getThemePath(), ColorName::GRAY, ColorName::GREEN, Theme::load(), Widget::mAllowLogic, Widget::mBackgroundColor, mEmotes, Widget::mForegroundColor, Widget2::mForegroundColor2, mHighlightMode, mInstances, mItemPadding, mNewLinePadding, mPadding, mSkin, ColorName::ORANGE, ColorName::PINK, ColorName::PURPLE, readColor(), ColorName::RED, Widget::setFocusable(), theme, LinkHighlightMode::UNDERLINE, and ColorName::YELLOW.

62  :
63  Widget(widget),
64  MouseListener(),
65  mTextRows(),
67  mLineParts(),
68  mLinks(),
69  mLinkHandler(nullptr),
70  mSkin(nullptr),
71  mHighlightMode(0),
72  mSelectedLink(-1),
73  mHeight(0),
74  mWidth(0),
75  mYStart(0),
76  mPadding(0),
77  mNewLinePadding(15U),
78  mItemPadding(0),
81  mOpaque(opaque),
83  mUseEmotes(true),
84  mProcessVars(false),
85  mEnableImages(false),
86  mEnableKeys(false),
87  mEnableTabs(false),
88  mSeparator(false)
89 {
90  mAllowLogic = false;
91 
92  setFocusable(true);
93  addMouseListener(this);
94 
96 
97  if (theme != nullptr)
98  {
99  mSkin = theme->load(skin,
100  "browserbox.xml",
101  true,
103  }
104  if (mInstances == 0)
105  {
107  "graphics/sprites/chatemotes.png", 17, 18);
108  }
109  mInstances ++;
110 
111  if (mSkin != nullptr)
112  {
115  mSkin->getOption("newLinePadding", 15));
116  mItemPadding = mSkin->getOption("itemPadding");
117  if (mSkin->getOption("highlightBackground") != 0)
119  if (mSkin->getOption("highlightUnderline") != 0)
121  }
122 
123  readColor(BLACK);
124  readColor(RED);
125  readColor(GREEN);
126  readColor(BLUE);
127  readColor(ORANGE);
128  readColor(YELLOW);
129  readColor(PINK);
130  readColor(PURPLE);
131  readColor(GRAY);
132  readColor(BROWN);
133 
136 }
#define CAST_U32
Definition: cast.h:30
ImageSet * getImageSet(const std::string &imagePath, const int w, const int h)
static std::string getThemePath()
Definition: theme.h:66
LinePartList mLineParts
Skin * load(const std::string &filename, const std::string &filename2, const bool full, const std::string &defaultPath)
Definition: theme.cpp:178
Color mForegroundColor
Definition: widget.h:1085
unsigned int mNewLinePadding
int getOption(const std::string &name) const
Definition: skin.h:105
unsigned int mHighlightMode
int getPadding() const
Definition: skin.h:99
Color mBackgroundColor
Definition: widget.h:1090
static Color readColor(const std::string &description)
Definition: theme.cpp:696
Widget(const Widget2 *const widget)
Definition: widget.cpp:84
bool mAllowLogic
Definition: widget.h:1159
void addMouseListener(MouseListener *const mouseListener)
Definition: widget.cpp:291
static ImageSet * mEmotes
std::list< int > mTextRowLinksCount
Theme * theme
Definition: theme.cpp:61
void setFocusable(const bool focusable)
Definition: widget.cpp:191
Color mForegroundColor2
Definition: widget2.h:112
LinkHandler * mLinkHandler
const Color & getThemeColor(const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
Definition: widget2.h:44

◆ ~StaticBrowserBox()

StaticBrowserBox::~StaticBrowserBox ( )

Destructor.

Definition at line 138 of file staticbrowserbox.cpp.

References Resource::decRef(), gui, mEmotes, mInstances, mSkin, Gui::removeDragged(), theme, and Theme::unload().

139 {
140  if (gui != nullptr)
141  gui->removeDragged(this);
142 
143  if (theme != nullptr)
144  {
145  theme->unload(mSkin);
146  mSkin = nullptr;
147  }
148 
149  mInstances --;
150  if (mInstances == 0)
151  {
152  if (mEmotes != nullptr)
153  {
154  mEmotes->decRef();
155  mEmotes = nullptr;
156  }
157  }
158 }
void unload(Skin *const skin)
Definition: theme.cpp:249
Gui * gui
Definition: gui.cpp:110
virtual void decRef()
Definition: resource.cpp:49
static ImageSet * mEmotes
Theme * theme
Definition: theme.cpp:61
void removeDragged(const Widget *const widget)
Definition: gui.cpp:1160

Member Function Documentation

◆ addImage()

void StaticBrowserBox::addImage ( const std::string &  path)

Definition at line 303 of file staticbrowserbox.cpp.

References mEnableImages, mTextRowLinksCount, and mTextRows.

Referenced by setOpaque().

304 {
305  if (!mEnableImages)
306  return;
307 
308  mTextRows.push_back("~~~" + path);
309  mTextRowLinksCount.push_back(0);
310 }
std::list< int > mTextRowLinksCount

◆ addRow() [1/2]

void StaticBrowserBox::addRow ( const std::string &  row,
const bool  atTop 
)

Adds a text row to the browser.

Definition at line 173 of file staticbrowserbox.cpp.

References boldFont, BrowserLink::caption, CAST_S32, CAST_U32, ServerCommandType::font, Widget::getFont(), Font::getHeight(), PoDict::getStr(), Font::getWidth(), Widget::getWidth(), BrowserLink::link, mEnableKeys, mEnableTabs, mLinks, mPadding, mProcessVars, mSeparator, mTextRowLinksCount, mTextRows, mUseLinksAndUserColors, BrowserBoxTools::replaceKeys(), BrowserBoxTools::replaceLinkCommands(), BrowserBoxTools::replaceTabs(), BrowserBoxTools::replaceVars(), Widget::setWidth(), STD_MOVE, translator, BrowserLink::x1, BrowserLink::x2, BrowserLink::y1, and BrowserLink::y2.

Referenced by PopupMenu::addBeingMenu(), PopupMenu::addBuySell(), PopupMenu::addBuySellDefault(), PopupMenu::addCatchPetCommands(), PopupMenu::addChat(), PopupMenu::addDrop(), PopupMenu::addFollow(), PopupMenu::addGmCommands(), PopupMenu::addItemMenu(), PopupMenu::addMailCommands(), PopupMenu::addNormalRelations(), PopupMenu::addParty(), PopupMenu::addPartyName(), PopupMenu::addPickupFilter(), PopupMenu::addPlayerMisc(), PopupMenu::addPlayerRelation(), PopupMenu::addProtection(), addRow(), addSeparator(), ServerInfoWindow::addServerComment(), PopupMenu::addSocialMenu(), ServerInfoWindow::addSourcesList(), PopupMenu::addUse(), PopupMenu::addWindowMenu(), Desktop::Desktop(), DidYouKnowWindow::loadFile(), HelpWindow::loadFile(), UpdaterWindow::loadFile(), UpdaterWindow::loadNews(), UpdaterWindow::loadPatch(), UpdaterWindow::logic(), HelpWindow::search(), setOpaque(), SpeechBubble::setText(), PopupMenu::showAdoptCommands(), PopupMenu::showAttackMonsterPopup(), PopupMenu::showAttackPopup(), PopupMenu::showChangePos(), PopupMenu::showChatPopup(), PopupMenu::showCraftPopup(), PopupMenu::showDropPopup(), PopupMenu::showEmoteType(), PopupMenu::showFloorItemGMCommands(), PopupMenu::showFriendsPopup(), PopupMenu::showGMPopup(), PopupMenu::showGuildPopup(), PopupMenu::showItemGMCommands(), PopupMenu::showItemPopup(), PopupMenu::showLinkPopup(), PopupMenu::showMapPopup(), PopupMenu::showMonsterGMCommands(), PopupMenu::showMuteCommands(), PopupMenu::showNavigationPopup(), PopupMenu::showNpcDialogPopup(), PopupMenu::showNpcGMCommands(), PopupMenu::showOutfitsWindowPopup(), PopupMenu::showPartyPopup(), PopupMenu::showPickupItemPopup(), PopupMenu::showPickupPopup(), PopupMenu::showPlayerGMCommands(), PopupMenu::showPlayerMenu(), PopupMenu::showPlayerPopup(), PopupMenu::showPlayersPopup(), PopupMenu::showPopup(), ServerInfoWindow::showServerInfo(), PopupMenu::showSkillLevelPopup(), PopupMenu::showSkillOffsetPopup(), PopupMenu::showSkillPopup(), PopupMenu::showSkillTypePopup(), PopupMenu::showSpellPopup(), PopupMenu::showTextFieldPopup(), PopupMenu::showUndressPopup(), PopupMenu::showWindowPopup(), PopupMenu::showWindowsPopup(), and WhoIsOnline::updateWindow().

175 {
176  std::string tmp = row;
177  std::string newRow;
178  size_t idx1;
179  const Font *const font = getFont();
180  int linksCount = 0;
181 
182  if (getWidth() < 0)
183  return;
184 
185  mSeparator = false;
186 
187  if (mProcessVars)
188  {
190  }
191 
192  // Use links and user defined colors
194  {
195  BrowserLink bLink;
196 
197  // Check for links in format "@@link|[email protected]@"
198  const uint32_t sz = CAST_U32(mTextRows.size());
199 
200  if (mEnableKeys)
201  {
203  }
204 
205  idx1 = tmp.find("@@");
206  while (idx1 != std::string::npos)
207  {
208  const size_t idx2 = tmp.find('|', idx1);
209  const size_t idx3 = tmp.find("@@", idx2);
210 
211  if (idx2 == std::string::npos || idx3 == std::string::npos)
212  break;
213  bLink.link = tmp.substr(idx1 + 2, idx2 - (idx1 + 2));
214  bLink.caption = tmp.substr(idx2 + 1, idx3 - (idx2 + 1));
215  bLink.y1 = CAST_S32(sz) * font->getHeight();
216  bLink.y2 = bLink.y1 + font->getHeight();
217  if (bLink.caption.empty())
218  {
220  bLink.link);
221  if (translator != nullptr)
222  bLink.caption = translator->getStr(bLink.caption);
223  }
224 
225  newRow.append(tmp.substr(0, idx1));
226 
227  std::string tmp2 = newRow;
228  idx1 = tmp2.find("##");
229  while (idx1 != std::string::npos)
230  {
231  tmp2.erase(idx1, 3);
232  idx1 = tmp2.find("##");
233  }
234  bLink.x1 = font->getWidth(tmp2) - 1;
235  bLink.x2 = bLink.x1 + font->getWidth(bLink.caption) + 1;
236 
237  if (atTop)
238  mLinks.insert(mLinks.begin(), bLink);
239  else
240  mLinks.push_back(bLink);
241  linksCount ++;
242 
243  newRow.append("##<").append(bLink.caption);
244 
245  tmp.erase(0, idx3 + 2);
246  if (!tmp.empty())
247  newRow.append("##>");
248 
249  idx1 = tmp.find("@@");
250  }
251 
252  newRow.append(tmp);
253  }
254  // Don't use links and user defined colors
255  else
256  {
257  newRow = row;
258  }
259 
260  if (mEnableTabs)
261  {
263  }
264 
265  if (atTop)
266  {
267  mTextRows.push_front(newRow);
268  mTextRowLinksCount.push_front(linksCount);
269  }
270  else
271  {
272  mTextRows.push_back(newRow);
273  mTextRowLinksCount.push_back(linksCount);
274  }
275 
276  std::string plain = STD_MOVE(newRow);
277  // workaround if used only one string started from bold
278  // width for this string can be calculated wrong
279  // this workaround fix width if string start from bold sign
280  const bool startBold = (plain.find("##B") == 0);
281  for (idx1 = plain.find("##");
282  idx1 != std::string::npos;
283  idx1 = plain.find("##"))
284  {
285  plain.erase(idx1, 3);
286  }
287 
288  // Adjust the StaticBrowserBox size. This need only for implementing "---"
289  const int w = startBold ?
290  boldFont->getWidth(plain) : font->getWidth(plain) + 2 * mPadding;
291  if (w > getWidth())
292  setWidth(w);
293 }
#define CAST_U32
Definition: cast.h:30
Font * getFont() const
Definition: widget.cpp:330
int getWidth() const
Definition: widget.h:220
Font * boldFont
Definition: gui.cpp:111
void setWidth(const int width)
Definition: widget.cpp:132
Definition: font.h:88
void replaceVars(std::string &data)
#define CAST_S32
Definition: cast.h:29
std::list< int > mTextRowLinksCount
#define STD_MOVE(var)
Definition: stdmove.h:27
std::string replaceLinkCommands(const std::string &link)
int getWidth(const std::string &text) const
Definition: font.cpp:333
void replaceTabs(std::string &data)
int getHeight() const
Definition: font.cpp:360
void replaceKeys(std::string &data)
const std::string getStr(const std::string &str)
Definition: podict.cpp:44
PoDict * translator
Definition: podict.cpp:27

◆ addRow() [2/2]

void StaticBrowserBox::addRow ( const std::string &  cmd,
const char *const  text 
)

Adds a menu line to the browser.

Definition at line 295 of file staticbrowserbox.cpp.

References addRow(), encodeLinkText(), and strprintf().

297 {
298  addRow(strprintf("@@%s|%[email protected]@", encodeLinkText(cmd).c_str(),
299  encodeLinkText(text).c_str()),
300  false);
301 }
std::string encodeLinkText(std::string data)
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
void addRow(const std::string &row, const bool atTop)

◆ addSeparator()

void StaticBrowserBox::addSeparator ( const std::string &  row)

◆ clearRows()

void StaticBrowserBox::clearRows ( )

Remove all rows.

Definition at line 312 of file staticbrowserbox.cpp.

References mLinks, mSelectedLink, mTextRowLinksCount, mTextRows, Widget::setHeight(), and Widget::setWidth().

Referenced by PopupMenu::addSocialMenu(), DidYouKnowWindow::loadData(), UpdaterWindow::loadFile(), HelpWindow::loadHelp(), HelpWindow::loadHelpSimple(), WhoIsOnline::loadList(), UpdaterWindow::loadNews(), WhoIsOnline::loadWebList(), HelpWindow::search(), setOpaque(), SpeechBubble::setText(), PopupMenu::showAttackMonsterPopup(), PopupMenu::showChangePos(), PopupMenu::showChatPopup(), PopupMenu::showCraftPopup(), PopupMenu::showDropPopup(), PopupMenu::showEmoteType(), PopupMenu::showGMPopup(), PopupMenu::showItemPopup(), PopupMenu::showLinkPopup(), PopupMenu::showMapPopup(), PopupMenu::showMuteCommands(), PopupMenu::showNpcDialogPopup(), PopupMenu::showOutfitsWindowPopup(), PopupMenu::showPickupItemPopup(), PopupMenu::showPlayerMenu(), PopupMenu::showPlayerPopup(), PopupMenu::showPopup(), PopupMenu::showSkillLevelPopup(), PopupMenu::showSkillOffsetPopup(), PopupMenu::showSkillPopup(), PopupMenu::showSkillTypePopup(), PopupMenu::showSpellPopup(), PopupMenu::showTextFieldPopup(), PopupMenu::showUndressPopup(), PopupMenu::showWindowPopup(), and PopupMenu::showWindowsPopup().

313 {
314  mTextRows.clear();
315  mTextRowLinksCount.clear();
316  mLinks.clear();
317  setWidth(0);
318  setHeight(0);
319  mSelectedLink = -1;
320 }
void setWidth(const int width)
Definition: widget.cpp:132
std::list< int > mTextRowLinksCount
void setHeight(const int height)
Definition: widget.cpp:139

◆ draw()

void StaticBrowserBox::draw ( Graphics *const  graphics)
virtual

Draws the browser box.

Implements Widget.

Definition at line 351 of file staticbrowserbox.cpp.

References LinkHighlightMode::BACKGROUND, BLOCK_END, BLOCK_START, boldFont, CAST_S32, CAST_SIZE, Graphics::drawImage(), Graphics::drawLine(), Font::drawString(), Graphics::fillRectangle(), ServerCommandType::font, FOR_EACH, Widget::getFont(), Graphics::getTopClip(), Rect::height, Widget::mBackgroundColor, LinePart::mBold, LinePart::mColor, LinePart::mColor2, Widget::mDimension, mHighlightColor, mHighlightMode, mHyperLinkColor, LinePart::mImage, mLineParts, mLinks, mOpaque, mSelectedLink, LinePart::mText, LinePart::mType, mWidth, LinePart::mX, LinePart::mY, mYStart, Opaque_true, reportAlways, Graphics::setColor(), LinkHighlightMode::UNDERLINE, updateHeight(), Rect::width, BrowserLink::x1, BrowserLink::x2, Rect::y, BrowserLink::y1, BrowserLink::y2, and ClipRect::yOffset.

Referenced by safeDraw(), and setOpaque().

352 {
353  BLOCK_START("StaticBrowserBox::draw")
354  const ClipRect &cr = graphics->getTopClip();
355  mYStart = cr.y - cr.yOffset;
356  const int yEnd = mYStart + cr.height;
357  if (mYStart < 0)
358  mYStart = 0;
359 
360  if (mDimension.width != mWidth)
361  {
362  updateHeight();
363  reportAlways("browserbox resize in draw: %d, %d",
365  mWidth);
366  }
367 
368  if (mOpaque == Opaque_true)
369  {
370  graphics->setColor(mBackgroundColor);
371  graphics->fillRectangle(Rect(0, 0,
373  }
374 
375  if (mSelectedLink >= 0 &&
376  mSelectedLink < CAST_S32(mLinks.size()))
377  {
379  {
381  graphics->setColor(mHighlightColor);
382  graphics->fillRectangle(Rect(
383  link.x1,
384  link.y1,
385  link.x2 - link.x1,
386  link.y2 - link.y1));
387  }
388 
390  {
392  graphics->setColor(mHyperLinkColor);
393  graphics->drawLine(
394  link.x1,
395  link.y2,
396  link.x2,
397  link.y2);
398  }
399  }
400 
401  Font *const font = getFont();
402 
404  {
405  const LinePart &part = *i;
406  if (part.mY + 50 < mYStart)
407  continue;
408  if (part.mY > yEnd)
409  break;
410  if (part.mType == 0u)
411  {
412  if (part.mBold)
413  {
414  boldFont->drawString(graphics,
415  part.mColor,
416  part.mColor2,
417  part.mText,
418  part.mX, part.mY);
419  }
420  else
421  {
422  font->drawString(graphics,
423  part.mColor,
424  part.mColor2,
425  part.mText,
426  part.mX, part.mY);
427  }
428  }
429  else if (part.mImage != nullptr)
430  {
431  graphics->drawImage(part.mImage, part.mX, part.mY);
432  }
433  }
434 
435  BLOCK_END("StaticBrowserBox::draw")
436 }
Font * getFont() const
Definition: widget.cpp:330
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
int width
Definition: rect.h:218
bool mBold
Definition: linepart.h:99
Font * boldFont
Definition: gui.cpp:111
Definition: font.h:88
Definition: rect.h:72
#define BLOCK_START(name)
Definition: perfomance.h:78
LinePartList mLineParts
if(!vert) return
#define BLOCK_END(name)
Definition: perfomance.h:79
unsigned int mHighlightMode
Color mBackgroundColor
Definition: widget.h:1090
virtual void setColor(const Color &color)
Definition: graphics.h:319
#define CAST_S32
Definition: cast.h:29
Image * mImage
Definition: linepart.h:98
unsigned char mType
Definition: linepart.h:97
void drawString(Graphics *const graphics, Color col, const Color &col2, const std::string &text, const int x, const int y)
Definition: font.cpp:253
int mX
Definition: linepart.h:92
int height
Definition: rect.h:223
LinePartList::const_iterator LinePartCIter
virtual void fillRectangle(const Rect &rectangle)=0
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
Color mColor
Definition: linepart.h:94
virtual void drawLine(int x1, int y1, int x2, int y2)=0
const bool Opaque_true
Definition: opaque.h:29
#define CAST_SIZE
Definition: cast.h:33
Color mColor2
Definition: linepart.h:95
Rect mDimension
Definition: widget.h:1100
#define reportAlways(...)
Definition: checkutils.h:252
int mY
Definition: linepart.h:93
std::string mText
Definition: linepart.h:96

◆ getPadding()

int StaticBrowserBox::getPadding ( ) const
inline

◆ getRows()

TextRows& StaticBrowserBox::getRows ( )
inline

Definition at line 118 of file staticbrowserbox.h.

References mTextRows.

119  { return mTextRows; }

◆ getTextAtPos()

std::string StaticBrowserBox::getTextAtPos ( const int  x,
const int  y 
) const

Definition at line 718 of file staticbrowserbox.cpp.

References FOR_EACH, Widget::getAbsolutePosition(), mLineParts, LinePart::mText, LinePart::mY, mYStart, and ServerCommandType::str.

Referenced by setEnableTabs().

720 {
721  int textX = 0;
722  int textY = 0;
723 
724  getAbsolutePosition(textX, textY);
725  if (x < textX || y < textY)
726  return std::string();
727 
728  textY = y - textY;
729  std::string str;
730  int lastY = 0;
731 
733  {
734  const LinePart &part = *i;
735  if (part.mY + 50 < mYStart)
736  continue;
737  if (part.mY > textY)
738  break;
739 
740  if (part.mY > lastY)
741  {
742  str = part.mText;
743  lastY = part.mY;
744  }
745  else
746  {
747  str.append(part.mText);
748  }
749  }
750 
751  return str;
752 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
LinePartList mLineParts
virtual void getAbsolutePosition(int &x, int &y) const
Definition: widget.cpp:311
LinePartList::const_iterator LinePartCIter
int mY
Definition: linepart.h:93
std::string mText
Definition: linepart.h:96

◆ hasRows()

bool StaticBrowserBox::hasRows ( ) const
inline

Definition at line 121 of file staticbrowserbox.h.

References mTextRows.

122  { return !mTextRows.empty(); }

◆ mouseExited()

void StaticBrowserBox::mouseExited ( MouseEvent event)
virtual

Called when the mouse has exited the widget area.

Parameters
eventDescribes the event.

Reimplemented from MouseListener.

Definition at line 346 of file staticbrowserbox.cpp.

References mSelectedLink.

Referenced by setOpaque().

347 {
348  mSelectedLink = -1;
349 }

◆ mouseMoved()

void StaticBrowserBox::mouseMoved ( MouseEvent event)
virtual

Called when the mouse has moved in the widget area and no mouse button has been pressed (i.e no widget is being dragged).

Parameters
eventDescribes the event.

Reimplemented from MouseListener.

Definition at line 337 of file staticbrowserbox.cpp.

References CAST_S32, MouseEvent::getX(), mLinks, and mSelectedLink.

Referenced by setOpaque().

338 {
339  const LinkIterator i = std::find_if(mLinks.begin(), mLinks.end(),
340  MouseOverLink(event.getX(), event.getY()));
341 
342  mSelectedLink = (i != mLinks.end())
343  ? CAST_S32(i - mLinks.begin()) : -1;
344 }
Links::iterator LinkIterator
#define CAST_S32
Definition: cast.h:29
int getX() const
Definition: mouseevent.h:126

◆ mousePressed()

void StaticBrowserBox::mousePressed ( MouseEvent event)
virtual

Handles mouse actions.

Reimplemented from MouseListener.

Definition at line 322 of file staticbrowserbox.cpp.

References MouseEvent::getX(), LinkHandler::handleLink(), mLinkHandler, and mLinks.

Referenced by setOpaque().

323 {
324  if (mLinkHandler == nullptr)
325  return;
326 
327  const LinkIterator i = std::find_if(mLinks.begin(), mLinks.end(),
328  MouseOverLink(event.getX(), event.getY()));
329 
330  if (i != mLinks.end())
331  {
332  mLinkHandler->handleLink(i->link, &event);
333  event.consume();
334  }
335 }
Links::iterator LinkIterator
virtual void handleLink(const std::string &link, MouseEvent *event)=0
LinkHandler * mLinkHandler
int getX() const
Definition: mouseevent.h:126

◆ moveSelectionDown()

void StaticBrowserBox::moveSelectionDown ( )

Definition at line 769 of file staticbrowserbox.cpp.

References mLinks, and mSelectedLink.

Referenced by getPadding(), and PopupMenu::moveDown().

770 {
771  mSelectedLink ++;
772  if (mSelectedLink >= static_cast<signed int>(mLinks.size()))
773  mSelectedLink = 0;
774 }

◆ moveSelectionUp()

void StaticBrowserBox::moveSelectionUp ( )

Definition at line 761 of file staticbrowserbox.cpp.

References CAST_S32, mLinks, and mSelectedLink.

Referenced by getPadding(), and PopupMenu::moveUp().

762 {
763  if (mSelectedLink <= 0)
764  mSelectedLink = CAST_S32(mLinks.size()) - 1;
765  else
766  mSelectedLink --;
767 }
#define CAST_S32
Definition: cast.h:29

◆ safeDraw()

void StaticBrowserBox::safeDraw ( Graphics *const  graphics)
virtual

Implements Widget.

Definition at line 438 of file staticbrowserbox.cpp.

References draw().

Referenced by setOpaque().

439 {
440  StaticBrowserBox::draw(graphics);
441 }
void draw(Graphics *const graphics)

◆ selectSelection()

void StaticBrowserBox::selectSelection ( )

Definition at line 776 of file staticbrowserbox.cpp.

References CAST_SIZE, LinkHandler::handleLink(), mLinkHandler, mLinks, and mSelectedLink.

Referenced by getPadding(), and PopupMenu::select().

777 {
778  if ((mLinkHandler == nullptr) ||
779  mSelectedLink < 0 ||
780  mSelectedLink >= static_cast<signed int>(mLinks.size()))
781  {
782  return;
783  }
784 
786  nullptr);
787 }
virtual void handleLink(const std::string &link, MouseEvent *event)=0
LinkHandler * mLinkHandler
#define CAST_SIZE
Definition: cast.h:33

◆ setEnableImages()

void StaticBrowserBox::setEnableImages ( const bool  n)
inline

Definition at line 127 of file staticbrowserbox.h.

References mEnableImages.

Referenced by DidYouKnowWindow::DidYouKnowWindow(), and HelpWindow::HelpWindow().

128  { mEnableImages = n; }

◆ setEnableKeys()

void StaticBrowserBox::setEnableKeys ( const bool  n)
inline

◆ setEnableTabs()

void StaticBrowserBox::setEnableTabs ( const bool  n)
inline

◆ setForegroundColorAll()

void StaticBrowserBox::setForegroundColorAll ( const Color color1,
const Color color2 
)

Definition at line 754 of file staticbrowserbox.cpp.

References Widget::mForegroundColor, and Widget2::mForegroundColor2.

Referenced by getPadding(), SpeechBubble::setText(), and SpeechBubble::SpeechBubble().

756 {
757  mForegroundColor = color1;
758  mForegroundColor2 = color2;
759 }
Color mForegroundColor
Definition: widget.h:1085
Color mForegroundColor2
Definition: widget2.h:112

◆ setLinkHandler()

void StaticBrowserBox::setLinkHandler ( LinkHandler linkHandler)

◆ setOpaque()

void StaticBrowserBox::setOpaque ( Opaque  opaque)
inline

◆ setProcessVars()

void StaticBrowserBox::setProcessVars ( const bool  n)
inline

◆ updateHeight()

void StaticBrowserBox::updateHeight ( )

Definition at line 443 of file staticbrowserbox.cpp.

References ColorName::BLACK, ColorName::BLUE, boldFont, ColorName::BROWN, CAST_S32, CAST_S8, CAST_SIZE, CAST_U32, ServerCommandType::font, FOR_EACH, ImageSet::get(), Widget::getFont(), Font::getHeight(), Image::getHeight(), Loader::getImage(), Widget2::getThemeCharColor(), Font::getWidth(), Image::getWidth(), ColorName::GRAY, ColorName::GREEN, Resource::incRef(), mColors, Widget::mDimension, mEmotes, mEnableImages, Widget::mForegroundColor, Widget2::mForegroundColor2, mHeight, mItemPadding, mLineParts, mLinks, mPadding, mSeparator, mTextRows, mUseEmotes, mUseLinksAndUserColors, mWidth, ColorName::ORANGE, ColorName::PINK, ColorName::PURPLE, ColorName::RED, Widget::setSize(), ImageSet::size(), ServerCommandType::size, anonymous_namespace{stringutils.cpp}::start, ServerCommandType::str, anonymous_namespace{libxml.cpp}::valid, Rect::width, x, BrowserLink::x1, BrowserLink::x2, y, BrowserLink::y1, BrowserLink::y2, and ColorName::YELLOW.

Referenced by Desktop::Desktop(), draw(), DidYouKnowWindow::loadData(), UpdaterWindow::loadFile(), HelpWindow::loadHelp(), HelpWindow::loadHelpSimple(), UpdaterWindow::loadNews(), UpdaterWindow::loadPatch(), WhoIsOnline::loadWebList(), UpdaterWindow::logic(), HelpWindow::search(), setOpaque(), SpeechBubble::setText(), PopupMenu::showPopup(), ServerInfoWindow::showServerInfo(), WhoIsOnline::updateWindow(), and Desktop::widgetResized().

444 {
445  unsigned int y = CAST_U32(mPadding);
446  int moreHeight = 0;
447  int link = 0;
448  bool bold = false;
449  const unsigned int wWidth = CAST_U32(mDimension.width - mPadding);
450  const Font *const font = getFont();
451  const int fontHeight = font->getHeight() + 2 * mItemPadding;
452  const int fontWidthMinus = font->getWidth("-");
453 
454  Color selColor[2] = {mForegroundColor, mForegroundColor2};
455  const Color textColor[2] = {mForegroundColor, mForegroundColor2};
456  mLineParts.clear();
457  uint32_t dataWidth = 0;
458 
459  if (mSeparator)
460  {
461  mSeparator = false;
462  mTextRows.pop_back();
463  }
464 
466  {
467  unsigned int x = CAST_U32(mPadding);
468  const std::string row = *(i);
469  int objects = 0;
470 
471  // Check for separator lines
472  if (row.find("---", 0) == 0)
473  {
474  const int dashWidth = fontWidthMinus;
475  for (x = CAST_U32(mPadding); x < wWidth; x ++)
476  {
477  mLineParts.push_back(LinePart(CAST_S32(x),
478  CAST_S32(y) + mItemPadding,
479  selColor[0], selColor[1], "-", false));
480  x += CAST_U32(CAST_S32(
481  dashWidth) - 2);
482  }
483 
484  y += CAST_U32(fontHeight);
485  continue;
486  }
487  else if (mEnableImages && row.find("~~~", 0) == 0)
488  {
489  std::string str = row.substr(3);
490  const size_t sz = str.size();
491  if (sz > 2 && str.substr(sz - 1) == "~")
492  str = str.substr(0, sz - 1);
493  Image *const img = Loader::getImage(str);
494  if (img != nullptr)
495  {
496  img->incRef();
497  mLineParts.push_back(LinePart(CAST_S32(x),
498  CAST_S32(y) + mItemPadding,
499  selColor[0], selColor[1], img));
500  y += CAST_U32(img->getHeight() + 2);
501  moreHeight += img->getHeight();
502  if (img->getWidth() + mPadding + 2 > CAST_S32(dataWidth))
503  dataWidth = img->getWidth() + 2 + mPadding;
504  }
505  continue;
506  }
507 
508  Color prevColor[2];
509  prevColor[0] = selColor[0];
510  prevColor[1] = selColor[1];
511  bold = false;
512 
513  for (size_t start = 0, end = std::string::npos;
514  start != std::string::npos;
515  start = end, end = std::string::npos)
516  {
517  size_t idx1 = end;
518  size_t idx2 = end;
519 
520  // "Tokenize" the string at control sequences
522  idx1 = row.find("##", start + 1);
523  if (start == 0 || mUseLinksAndUserColors)
524  {
525  // Check for color change in format "##x", x = [L,P,0..9]
526  if (row.find("##", start) == start && row.size() > start + 2)
527  {
528  const signed char c = row.at(start + 2);
529 
530  bool valid(false);
531  const Color col[2] =
532  {
535  c | 0x80), valid)
536  };
537 
538  if (c == '>')
539  {
540  selColor[0] = prevColor[0];
541  selColor[1] = prevColor[1];
542  }
543  else if (c == '<')
544  {
545  prevColor[0] = selColor[0];
546  prevColor[1] = selColor[1];
547  selColor[0] = col[0];
548  selColor[1] = col[1];
549  }
550  else if (c == 'B')
551  {
552  bold = true;
553  }
554  else if (c == 'b')
555  {
556  bold = false;
557  }
558  else if (valid)
559  {
560  selColor[0] = col[0];
561  selColor[1] = col[1];
562  }
563  else
564  {
565  switch (c)
566  {
567  case '0':
568  selColor[0] = mColors[0][ColorName::BLACK];
569  selColor[1] = mColors[1][ColorName::BLACK];
570  break;
571  case '1':
572  selColor[0] = mColors[0][ColorName::RED];
573  selColor[1] = mColors[1][ColorName::RED];
574  break;
575  case '2':
576  selColor[0] = mColors[0][ColorName::GREEN];
577  selColor[1] = mColors[1][ColorName::GREEN];
578  break;
579  case '3':
580  selColor[0] = mColors[0][ColorName::BLUE];
581  selColor[1] = mColors[1][ColorName::BLUE];
582  break;
583  case '4':
584  selColor[0] = mColors[0][ColorName::ORANGE];
585  selColor[1] = mColors[1][ColorName::ORANGE];
586  break;
587  case '5':
588  selColor[0] = mColors[0][ColorName::YELLOW];
589  selColor[1] = mColors[1][ColorName::YELLOW];
590  break;
591  case '6':
592  selColor[0] = mColors[0][ColorName::PINK];
593  selColor[1] = mColors[1][ColorName::PINK];
594  break;
595  case '7':
596  selColor[0] = mColors[0][ColorName::PURPLE];
597  selColor[1] = mColors[1][ColorName::PURPLE];
598  break;
599  case '8':
600  selColor[0] = mColors[0][ColorName::GRAY];
601  selColor[1] = mColors[1][ColorName::GRAY];
602  break;
603  case '9':
604  selColor[0] = mColors[0][ColorName::BROWN];
605  selColor[1] = mColors[1][ColorName::BROWN];
606  break;
607  default:
608  selColor[0] = textColor[0];
609  selColor[1] = textColor[1];
610  break;
611  }
612  }
613 
614  if (c == '<' && link < CAST_S32(mLinks.size()))
615  {
616  int size;
617  if (bold)
618  {
619  size = boldFont->getWidth(
620  mLinks[CAST_SIZE(link)].caption) + 1;
621  }
622  else
623  {
624  size = font->getWidth(
625  mLinks[CAST_SIZE(link)].caption) + 1;
626  }
627 
628  BrowserLink &linkRef = mLinks[CAST_SIZE(
629  link)];
630  linkRef.x1 = CAST_S32(x);
631  linkRef.y1 = CAST_S32(y);
632  linkRef.x2 = linkRef.x1 + size;
633  linkRef.y2 = CAST_S32(y) + fontHeight - 1;
634  link++;
635  }
636 
637  start += 3;
638  if (start == row.size())
639  break;
640  }
641  }
642  if (mUseEmotes)
643  idx2 = row.find("%%", start + 1);
644  if (idx1 < idx2)
645  end = idx1;
646  else
647  end = idx2;
648  if (mUseEmotes)
649  {
650  // check for emote icons
651  if (row.size() > start + 2 && row.substr(start, 2) == "%%")
652  {
653  if (objects < 5)
654  {
655  const int cid = row.at(start + 2) - '0';
656  if (cid >= 0)
657  {
658  if (mEmotes != nullptr)
659  {
660  const size_t sz = mEmotes->size();
661  if (CAST_SIZE(cid) < sz)
662  {
663  Image *const img = mEmotes->get(
664  CAST_SIZE(cid));
665  if (img != nullptr)
666  {
667  mLineParts.push_back(LinePart(
668  CAST_S32(x),
669  CAST_S32(y) + mItemPadding,
670  selColor[0], selColor[1], img));
671  x += 18;
672  }
673  }
674  }
675  }
676  objects ++;
677  }
678 
679  start += 3;
680  if (start == row.size())
681  {
682  if (x > dataWidth)
683  dataWidth = x;
684  break;
685  }
686  }
687  }
688  const size_t len = (end == std::string::npos) ? end : end - start;
689 
690  if (start >= row.length())
691  break;
692 
693  std::string part = row.substr(start, len);
694 
695  mLineParts.push_back(LinePart(CAST_S32(x),
696  CAST_S32(y) + mItemPadding,
697  selColor[0], selColor[1], part.c_str(), bold));
698 
699  int width = 0;
700  if (bold)
701  width = boldFont->getWidth(part);
702  else
703  width = font->getWidth(part);
704 
705  x += CAST_U32(width);
706  if (x > dataWidth)
707  dataWidth = x;
708  }
709  y += CAST_U32(fontHeight);
710  }
711  mWidth = dataWidth + mPadding;
712  mHeight = CAST_S32(mTextRows.size())
713  * fontHeight + moreHeight + 2 * mPadding;
714  setSize(mWidth,
715  mHeight);
716 }
void setSize(const int width, const int height)
Definition: widget.cpp:366
#define CAST_U32
Definition: cast.h:30
Font * getFont() const
Definition: widget.cpp:330
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
int width
Definition: rect.h:218
Font * boldFont
Definition: gui.cpp:111
Image * get(const size_type i) const
Definition: imageset.cpp:66
Definition: font.h:88
LinePartList mLineParts
Color mForegroundColor
Definition: widget.h:1085
const Color & getThemeCharColor(const signed char c, bool &valid) const A_INLINE
Definition: widget2.h:51
#define CAST_S32
Definition: cast.h:29
size_type size() const
Definition: imageset.h:72
Image * getImage(const std::string &idPath)
Definition: imageloader.cpp:85
#define CAST_S8
Definition: cast.h:25
static ImageSet * mEmotes
virtual void incRef()
Definition: resource.cpp:37
Color mForegroundColor2
Definition: widget2.h:112
int getWidth(const std::string &text) const
Definition: font.cpp:333
Definition: image.h:61
Definition: color.h:74
int getWidth() const A_INLINE
Definition: image.h:116
#define CAST_SIZE
Definition: cast.h:33
int getHeight() const
Definition: font.cpp:360
TextRows::const_iterator TextRowCIter
Rect mDimension
Definition: widget.h:1100
int getHeight() const A_INLINE
Definition: image.h:122
Color mColors[2][ColorName::COLORS_MAX]

◆ updateSize()

void StaticBrowserBox::updateSize ( )

Referenced by setOpaque().

Field Documentation

◆ mColors

Color StaticBrowserBox::mColors[2][ColorName::COLORS_MAX]
private

Definition at line 179 of file staticbrowserbox.h.

Referenced by updateHeight().

◆ mEmotes

ImageSet * StaticBrowserBox::mEmotes = 0
staticprivate

Definition at line 190 of file staticbrowserbox.h.

Referenced by StaticBrowserBox(), updateHeight(), and ~StaticBrowserBox().

◆ mEnableImages

bool StaticBrowserBox::mEnableImages
private

Definition at line 185 of file staticbrowserbox.h.

Referenced by addImage(), setEnableImages(), and updateHeight().

◆ mEnableKeys

bool StaticBrowserBox::mEnableKeys
private

Definition at line 186 of file staticbrowserbox.h.

Referenced by addRow(), and setEnableKeys().

◆ mEnableTabs

bool StaticBrowserBox::mEnableTabs
private

Definition at line 187 of file staticbrowserbox.h.

Referenced by addRow(), and setEnableTabs().

◆ mHeight

int StaticBrowserBox::mHeight
private

Definition at line 170 of file staticbrowserbox.h.

Referenced by updateHeight().

◆ mHighlightColor

Color StaticBrowserBox::mHighlightColor
private

Definition at line 177 of file staticbrowserbox.h.

Referenced by draw().

◆ mHighlightMode

unsigned int StaticBrowserBox::mHighlightMode
private

Definition at line 168 of file staticbrowserbox.h.

Referenced by draw(), and StaticBrowserBox().

◆ mHyperLinkColor

Color StaticBrowserBox::mHyperLinkColor
private

Definition at line 178 of file staticbrowserbox.h.

Referenced by draw().

◆ mInstances

int StaticBrowserBox::mInstances = 0
staticprivate

Definition at line 191 of file staticbrowserbox.h.

Referenced by StaticBrowserBox(), and ~StaticBrowserBox().

◆ mItemPadding

int StaticBrowserBox::mItemPadding
private

Definition at line 175 of file staticbrowserbox.h.

Referenced by StaticBrowserBox(), and updateHeight().

◆ mLineParts

LinePartList StaticBrowserBox::mLineParts
private

Definition at line 160 of file staticbrowserbox.h.

Referenced by draw(), getTextAtPos(), and updateHeight().

◆ mLinkHandler

LinkHandler* StaticBrowserBox::mLinkHandler
private

Definition at line 166 of file staticbrowserbox.h.

Referenced by mousePressed(), selectSelection(), and setLinkHandler().

◆ mLinks

Links StaticBrowserBox::mLinks
private

◆ mNewLinePadding

unsigned int StaticBrowserBox::mNewLinePadding
private

Definition at line 174 of file staticbrowserbox.h.

Referenced by StaticBrowserBox().

◆ mOpaque

Opaque StaticBrowserBox::mOpaque
private

Definition at line 181 of file staticbrowserbox.h.

Referenced by draw(), and setOpaque().

◆ mPadding

int StaticBrowserBox::mPadding
private

Definition at line 173 of file staticbrowserbox.h.

Referenced by addRow(), getPadding(), StaticBrowserBox(), and updateHeight().

◆ mProcessVars

bool StaticBrowserBox::mProcessVars
private

Definition at line 184 of file staticbrowserbox.h.

Referenced by addRow(), and setProcessVars().

◆ mSelectedLink

int StaticBrowserBox::mSelectedLink
private

◆ mSeparator

bool StaticBrowserBox::mSeparator
private

Definition at line 188 of file staticbrowserbox.h.

Referenced by addRow(), addSeparator(), and updateHeight().

◆ mSkin

Skin* StaticBrowserBox::mSkin
private

Definition at line 167 of file staticbrowserbox.h.

Referenced by StaticBrowserBox(), and ~StaticBrowserBox().

◆ mTextRowLinksCount

std::list<int> StaticBrowserBox::mTextRowLinksCount
private

Definition at line 155 of file staticbrowserbox.h.

Referenced by addImage(), addRow(), and clearRows().

◆ mTextRows

TextRows StaticBrowserBox::mTextRows
private

Definition at line 154 of file staticbrowserbox.h.

Referenced by addImage(), addRow(), clearRows(), getRows(), hasRows(), and updateHeight().

◆ mUseEmotes

bool StaticBrowserBox::mUseEmotes
private

Definition at line 183 of file staticbrowserbox.h.

Referenced by updateHeight().

◆ mUseLinksAndUserColors

bool StaticBrowserBox::mUseLinksAndUserColors
private

Definition at line 182 of file staticbrowserbox.h.

Referenced by addRow(), and updateHeight().

◆ mWidth

int StaticBrowserBox::mWidth
private

Definition at line 171 of file staticbrowserbox.h.

Referenced by draw(), and updateHeight().

◆ mYStart

int StaticBrowserBox::mYStart
private

Definition at line 172 of file staticbrowserbox.h.

Referenced by draw(), and getTextAtPos().


The documentation for this class was generated from the following files: