35 #include "gui/widgets/browserbox.inc"
38 #include "render/graphics.h"
63 const std::string &skin) :
80 mHighlightColor(getThemeColor(
ThemeColorId::HIGHLIGHT, 255U)),
81 mHyperLinkColor(getThemeColor(
ThemeColorId::HYPERLINK, 255U)),
83 mUseLinksAndUserColors(true),
108 "graphics/sprites/chatemotes.png", 17, 18);
112 if (
mSkin !=
nullptr)
144 if (
theme !=
nullptr)
177 std::string tmp = row;
206 idx1 = tmp.find(
"@@");
207 while (idx1 != std::string::npos)
209 const size_t idx2 = tmp.find(
'|', idx1);
210 const size_t idx3 = tmp.find(
"@@", idx2);
212 if (idx2 == std::string::npos || idx3 == std::string::npos)
214 bLink.
link = tmp.substr(idx1 + 2, idx2 - (idx1 + 2));
215 bLink.
caption = tmp.substr(idx2 + 1, idx3 - (idx2 + 1));
226 newRow.append(tmp.substr(0, idx1));
228 std::string tmp2 = newRow;
229 idx1 = tmp2.find(
"##");
230 while (idx1 != std::string::npos)
233 idx1 = tmp2.find(
"##");
244 newRow.append(
"##<").append(bLink.
caption);
246 tmp.erase(0, idx3 + 2);
248 newRow.append(
"##>");
250 idx1 = tmp.find(
"@@");
277 std::string plain =
STD_MOVE(newRow);
281 const bool startBold = (plain.find(
"##B") == 0);
282 for (idx1 = plain.find(
"##");
283 idx1 != std::string::npos;
284 idx1 = plain.find(
"##"))
286 plain.erase(idx1, 3);
290 const int w = startBold ?
297 const char *
const text)
411 if (part.
mType == 0U)
430 else if (part.
mImage !=
nullptr)
453 const int fontWidthMinus = font->
getWidth(
"-");
458 uint32_t dataWidth = 0;
469 const std::string row = *(i);
473 if (row.find(
"---", 0) == 0)
475 const int dashWidth = fontWidthMinus;
480 selColor[0], selColor[1],
"-",
false));
490 std::string str = row.substr(3);
491 const size_t sz = str.size();
492 if (sz > 2 && str.substr(sz - 1) ==
"~")
493 str = str.substr(0, sz - 1);
500 selColor[0], selColor[1], img));
502 moreHeight += img->getHeight();
504 dataWidth = img->getWidth() + 2 +
mPadding;
510 prevColor[0] = selColor[0];
511 prevColor[1] = selColor[1];
514 for (
size_t start = 0, end = std::string::npos;
515 start != std::string::npos;
516 start = end, end = std::string::npos)
523 idx1 = row.find(
"##",
start + 1);
529 const signed char c = row.at(
start + 2);
541 selColor[0] = prevColor[0];
542 selColor[1] = prevColor[1];
546 prevColor[0] = selColor[0];
547 prevColor[1] = selColor[1];
548 selColor[0] = col[0];
549 selColor[1] = col[1];
561 selColor[0] = col[0];
562 selColor[1] = col[1];
609 selColor[0] = textColor[0];
610 selColor[1] = textColor[1];
639 if (
start == row.size())
644 idx2 = row.find(
"%%",
start + 1);
652 if (row.size() >
start + 2 && row.substr(
start, 2) ==
"%%")
656 const int cid = row.at(
start + 2) -
'0';
671 selColor[0], selColor[1], img));
681 if (
start == row.size())
689 const size_t len = (end == std::string::npos) ? end : end -
start;
691 if (
start >= row.length())
694 std::string part = row.substr(
start, len);
698 selColor[0], selColor[1], part.c_str(), bold));
714 * fontHeight + moreHeight + 2 *
mPadding;
726 if (
x < textX ||
y < textY)
727 return std::string();
748 str.append(part.
mText);
#define reportAlways(...)
int getWidth(const std::string &text) const
void drawString(Graphics *const graphics, Color col, const Color &col2, const std::string &text, const int x, const int y)
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
virtual void fillRectangle(const Rect &rectangle)=0
virtual void setColor(const Color &color)
virtual void drawLine(int x1, int y1, int x2, int y2)=0
ClipRect & getTopClip() const
void removeDragged(const Widget *const widget)
Image * get(const size_type i) const
virtual void handleLink(const std::string &link, MouseEvent *event)=0
const std::string getStr(const std::string &str)
int getOption(const std::string &name) const
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 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)
unsigned int mHighlightMode
LinkHandler * mLinkHandler
LinePartList::const_iterator LinePartCIter
void draw(Graphics *const graphics)
void mousePressed(MouseEvent &event)
bool mUseLinksAndUserColors
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 safeDraw(Graphics *const graphics)
void setLinkHandler(LinkHandler *linkHandler)
void unload(Skin *const skin)
static std::string getThemePath()
Skin * load(const std::string &filename, const std::string &filename2, const bool full, const std::string &defaultPath)
#define FOR_EACH(type, iter, array)
Image * getImage(const std::string &idPath)
ImageSet * getImageSet(const std::string &imagePath, const int w, const int h)
#define BLOCK_START(name)
std::string strprintf(const char *const format,...)
std::string encodeLinkText(std::string data)
static Color readColor(const std::string &description)