30 #include "render/graphics.h"
36 const std::string &skin,
37 const unsigned int rowHeight) :
38 ListBox(widget, listModel, skin),
39 mImagePadding(mSkin !=
nullptr ? mSkin->getOption(
"imagePadding") : 0),
40 mSpacing(mSkin !=
nullptr ? mSkin->getOption(
"spacing") : 0),
76 const int insideWidth = width - pad2;
77 for (
int f = 0; f < sz; f ++)
82 int strWidth = font->
getWidth(str) + 8;
88 STD_VECTOR<ExtendedListBoxItem> &list =
91 if (insideWidth < strWidth)
93 const size_t strSize = str.size();
94 size_t divPos = strSize / 2;
96 str[divPos - 1]) >= 0xc0)
100 for (
size_t d = divPos; d > 10; d --)
109 str.substr(0, divPos), useImage,
y));
110 str = str.substr(divPos);
124 for (
size_t f = 0; f < selSz; f ++)
127 const int y1 = item.
y;
139 width - pad2, maxY - minY + height));
142 for (
size_t f = 0; f < itemsSz; ++f)
147 const int row1 = item.
row;
149 if (image !=
nullptr)
153 item.
y + (height - image->getHeight()) / 2 +
mPadding);
158 for (
size_t f = 0; f < itemsSz; ++f)
161 const int row1 = item.
row;
162 const int y1 = item.
y;
164 if ((image ==
nullptr) || !item.
image)
180 for (
size_t f = 0; f < selSz; ++f)
183 const int row1 = item.
row;
184 const int y1 = item.
y;
186 if ((image ==
nullptr) || !item.
image)
202 for (
size_t f = 0; f < selSz; ++f)
207 const int row1 = item.
row;
209 if (image !=
nullptr)
213 item.
y + (height - image->getHeight()) / 2 +
mPadding);
241 for (
size_t f = 0; f < itemsSz; f ++)
245 if (y2 <= y && y2 + height >
y)
250 for (
size_t f = 0; f < selSz; f ++)
254 if (y2 <= y && y2 + height >
y)
std::vector< ExtendedListBoxItem > mListItems
void safeDraw(Graphics *const graphics)
void draw(Graphics *const graphics)
std::vector< ExtendedListBoxItem > mSelectedItems
int getSelectionByMouse(const int y) const
ExtendedListBox(const Widget2 *const widget, ListModel *const listModel, const std::string &skin, const unsigned int rowHeight)
virtual const Image * getImageAt(int i)=0
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)
Color mForegroundSelectedColor2
virtual void adjustSize()
virtual int getSelectionByMouse(const int y) const
Color mForegroundSelectedColor
virtual std::string getElementAt(int i)=0
virtual int getNumberOfElements()=0
#define BLOCK_START(name)