@@ -34,7 +34,7 @@ namespace OpenXcom
3434 * @param x X position in pixels.
3535 * @param y Y position in pixels.
3636 */
37- TextList::TextList (int width, int height, int x, int y) : InteractiveSurface(width, height, x, y), _texts(), _columns(), _big(0 ), _small(0 ), _scroll(0 ), _visibleRows(0 ), _color(0 ), _align(ALIGN_LEFT ), _dot(false ), _selectable(false ), _selRow(0 ), _bg(0 ), _selector(0 ), _margin(0 )
37+ TextList::TextList (int width, int height, int x, int y) : InteractiveSurface(width, height, x, y), _texts(), _columns(), _big(0 ), _small(0 ), _scroll(0 ), _visibleRows(0 ), _color(0 ), _align(ALIGN_LEFT ), _dot(false ), _selectable(false ), _selRow(0 ), _bg(0 ), _selector(0 ), _margin(0 ), _arrow1(), _arrow2(), _arrowPos(- 1 )
3838{
3939 _up = new ArrowButton (ARROW_BIG_UP , 13 , 14 , getX () + getWidth () + 4 , getY () + 1 );
4040 _up->setVisible (false );
@@ -49,11 +49,21 @@ TextList::TextList(int width, int height, int x, int y) : InteractiveSurface(wid
4949 */
5050TextList::~TextList ()
5151{
52- for (std::vector< std::vector<Text*> >::iterator u = _texts.begin (); u < _texts.end (); u++) {
53- for (std::vector<Text*>::iterator v = (*u).begin (); v < (*u).end (); v++) {
54- delete (*v);
52+ for (std::vector< std::vector<Text*> >::iterator u = _texts.begin (); u < _texts.end (); u++)
53+ {
54+ for (std::vector<Text*>::iterator v = (*u).begin (); v < (*u).end (); v++)
55+ {
56+ delete *v;
5557 }
5658 }
59+ for (std::vector<ArrowButton*>::iterator i = _arrow1.begin (); i < _arrow1.end (); i++)
60+ {
61+ delete *i;
62+ }
63+ for (std::vector<ArrowButton*>::iterator i = _arrow2.begin (); i < _arrow2.end (); i++)
64+ {
65+ delete *i;
66+ }
5767 delete _selector;
5868 delete _up;
5969 delete _down;
@@ -99,9 +109,13 @@ void TextList::addRow(int cols, ...)
99109 for (std::wstring::iterator c = buf.begin (); c < buf.end (); c++)
100110 {
101111 if (*c == ' ' )
112+ {
102113 w += _small->getWidth () / 2 ;
114+ }
103115 else
116+ {
104117 w += _small->getChar (*c)->getCrop ()->w + _small->getSpacing ();
118+ }
105119 }
106120 while (w < _columns[i])
107121 {
@@ -118,10 +132,21 @@ void TextList::addRow(int cols, ...)
118132 rowX += _columns[i];
119133 }
120134 _texts.push_back (temp);
121- draw ();
122135
123- va_end (args);
136+ if (_arrowPos != -1 )
137+ {
138+ ArrowButton *a1 = new ArrowButton (ARROW_SMALL_UP , 11 , 8 , _arrowPos, getY ());
139+ a1->setPalette (this ->getPalette ());
140+ a1->setColor (_up->getColor ());
141+ _arrow1.push_back (a1);
142+ ArrowButton *a2 = new ArrowButton (ARROW_SMALL_DOWN , 11 , 8 , _arrowPos + 13 , getY ());
143+ a2->setPalette (this ->getPalette ());
144+ a2->setColor (_up->getColor ());
145+ _arrow2.push_back (a2);
146+ }
124147
148+ draw ();
149+ va_end (args);
125150 updateArrows ();
126151}
127152
@@ -162,8 +187,18 @@ void TextList::setPalette(SDL_Color *colors, int firstcolor, int ncolors)
162187 (*v)->setPalette (colors, firstcolor, ncolors);
163188 }
164189 }
190+ for (std::vector<ArrowButton*>::iterator i = _arrow1.begin (); i < _arrow1.end (); i++)
191+ {
192+ (*i)->setPalette (colors, firstcolor, ncolors);
193+ }
194+ for (std::vector<ArrowButton*>::iterator i = _arrow2.begin (); i < _arrow2.end (); i++)
195+ {
196+ (*i)->setPalette (colors, firstcolor, ncolors);
197+ }
165198 if (_selector != 0 )
199+ {
166200 _selector->setPalette (colors, firstcolor, ncolors);
201+ }
167202 _up->setPalette (colors, firstcolor, ncolors);
168203 _down->setPalette (colors, firstcolor, ncolors);
169204}
@@ -185,7 +220,9 @@ void TextList::setFonts(Font *big, Font *small)
185220 _selector->setVisible (false );
186221
187222 for (int y = 0 ; y < getHeight (); y += _small->getHeight () + _small->getSpacing ())
223+ {
188224 _visibleRows++;
225+ }
189226}
190227
191228/* *
@@ -275,6 +312,16 @@ void TextList::setArrowColor(Uint8 color)
275312 _down->setColor (color);
276313}
277314
315+ /* *
316+ * Sets the position of the column of arrow buttons
317+ * in the text list.
318+ * @param pos X in pixels (-1 to disable).
319+ */
320+ void TextList::setArrowColumn (int pos)
321+ {
322+ _arrowPos = pos;
323+ }
324+
278325/* *
279326 * Removes all the rows currently stored in the list.
280327 */
@@ -342,6 +389,10 @@ void TextList::draw()
342389 (*j)->setY ((i - _scroll) * (_small->getHeight () + _small->getSpacing ()));
343390 (*j)->blit (this );
344391 }
392+ _arrow1[i]->setY ((i - _scroll) * (_small->getHeight () + _small->getSpacing ()));
393+ _arrow1[i]->blit (this );
394+ _arrow2[i]->setY ((i - _scroll) * (_small->getHeight () + _small->getSpacing ()));
395+ _arrow2[i]->blit (this );
345396 }
346397}
347398
0 commit comments