Harmonic Flow Framework (libhffwk)
Cross platform C++ 2D Game Engine Framework
ListWidget.cpp
1 /*
2  Harmonic Flow Framework
3  Copyright (C) 2011-2018 Andreas Widen <andreas@harmonicflow.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 #include "ListWidget.h"
22 #include "WidgetManager.h"
23 #include "ScrollbarWidget.h"
24 #include "ListListener.h"
25 
26 #include "platform/Environment.h"
27 #include "font/Font.h"
28 
29 #include <assert.h>
30 
31 using namespace HFCore;
32 
33 #include "debug/CrtDbgNew.h"
34 
35 static int32_hf gInitialListWidgetColors[][3] =
36 {
37  {255, 255, 255},
38  {255, 255, 255},
39  {0, 0, 0},
40  {0, 192, 0},
41  {0, 0, 128},
42  {255, 255, 255}
43 };
44 
46 {
47  assert(font != NULL);
48  assert(listListener != NULL);
49 
51  mHiliteIdx = -1;
52  mSelectIdx = -1;
53 
54  if (font != NULL)
55  {
56  mItemHeight = font->getHeight();
57  }
58  else
59  {
60  mItemHeight = -1;
61  }
62 
63  setColors(gInitialListWidgetColors, 6);
64 
65  mId = id;
66  mFont = font;
67  mListListener = listListener;
68  mParent = NULL;
69  mChild = NULL;
70  mScrollbar = NULL;
71  mPosition = 0;
72  mPageSize = 0;
73  mSortFromChild = false;
74  mDrawOutline = true;
76  mDrawSelectWhenHilited = false;
77  mDoFingerWhenHilited = true;
78 }
79 
81 {
82 }
83 
84 void ListWidget::setHilite(int32_hf hiliteIdx, bool notifyListener)
85 {
86  int32_hf oldIdx = mHiliteIdx;
87  mHiliteIdx = hiliteIdx;
88 
89  if (oldIdx != mHiliteIdx && notifyListener && mListListener != NULL)
90  {
92  }
93 }
94 
96 {
97  Widget::removedFromManager(widgetManager);
98 
99  if (mListListener)
100  {
102  }
103 }
104 
106 {
107  std::wstring string = mLines[idx];
108 
109  while (string.length() < (uint32_hf) mMaxNumericPlaces)
110  {
111  string = L"0" + string;
112  }
113 
114  if (mSortFromChild)
115  {
116  return mChild->getSortKey(idx) + string;
117  }
118  else
119  {
120  if (mChild == NULL)
121  {
122  return string;
123  }
124  else
125  {
126  return string + mChild->getSortKey(idx);
127  }
128  }
129 
130  return L"";
131 }
132 
133 void ListWidget::sort(bool ascending)
134 {
135  int32_hf count = mLines.size();
136  int32_hf *map = new int32_hf[count];
137  std::wstring *keys = new std::wstring[count];
138 
139  int32_hf i;
140  for (i = 0; i < count; i++)
141  {
142  map[i] = i;
143  keys[i] = getSortKey(i);
144  }
145 
146  for (i = 1; i < count; i++)
147  for (int32_hf j = 0; j < count - i; j++)
148  {
149  int32_hf comp = keys[j].compare(keys[j + 1]);
150  if ((ascending && (comp > 0)) || (!ascending && (comp < 0)))
151  {
152  int32_hf swapInt = map[j];
153  map[j] = map[j + 1];
154  map[j + 1] = swapInt;
155 
156  std::wstring swapKey = keys[j];
157  keys[j] = keys[j + 1];
158  keys[j + 1] = swapKey;
159  }
160  }
161 
162  ListWidget *listWidget = this;
163  while (listWidget->mParent != NULL)
164  {
165  listWidget = listWidget->mParent;
166  }
167 
168  while (listWidget != NULL)
169  {
170  StringUtil::WStringVector newLines;
171  ColorVector newLineColors;
172 
173  for (int32_hf i = 0; i < count; i++)
174  {
175  newLines.push_back(listWidget->mLines[map[i]]);
176  newLineColors.push_back(listWidget->mLineColors[map[i]]);
177  }
178 
179  listWidget->mLines = newLines;
180  listWidget->mLineColors = newLineColors;
181 
182  listWidget = listWidget->mChild;
183  }
184 
185  HF_SAFE_DELETE_ARR(map);
186  HF_SAFE_DELETE_ARR(keys);
187 }
188 
190 {
191  int32_hf size = mLines.size();
192  if (size > 0 && idx >= 0 && idx < size)
193  {
194  return mLines[idx];
195  }
196 
197  return L"";
198 }
199 
201 {
202  Widget::resize(x, y, w, h);
203 
204  fp32_hf pageSize = 1;
205  int32_hf itemHeight = (mItemHeight != -1) ? mItemHeight : mFont->getHeight();
206 
207  if (mHeight > itemHeight + 8)
208  {
209  pageSize = (mHeight - 8.0f) / (fp32_hf)itemHeight;
210  }
211 
212  mPageSize = pageSize;
213 
214  if (mScrollbar != NULL)
215  {
216  mScrollbar->setPageSize(pageSize);
217  }
218 }
219 
220 int32_hf ListWidget::addLine(const std::wstring &line, bool alphabetical)
221 {
222  int32_hf idx = -1;
223  bool inserted = false;
224 
225  if (alphabetical)
226  {
227  for (int32_hf i = 0; i < (int32_hf) mLines.size(); i++)
228  {
229  if (wcscmp(line.c_str(), mLines[i].c_str()) < 0)
230  {
231  idx = i;
232 
233  ListWidget *listWidget = this;
234 
235  while (listWidget->mParent != NULL)
236  {
237  listWidget = listWidget->mParent;
238  }
239 
240  while (listWidget != NULL)
241  {
242  if (listWidget == this)
243  {
244  listWidget->mLines.insert(listWidget->mLines.begin() + i, line);
245  }
246  else
247  {
248  listWidget->mLines.insert(listWidget->mLines.begin() + i, L"-");
249  }
250 
251  listWidget->mLineColors.insert(listWidget->mLineColors.begin() + i,
253 
254  listWidget = listWidget->mChild;
255  }
256 
257  inserted = true;
258  break;
259  }
260  }
261  }
262 
263  if (!inserted)
264  {
265  idx = mLines.size();
266 
267  ListWidget *listWidget = this;
268 
269  while (listWidget->mParent != NULL)
270  {
271  listWidget = listWidget->mParent;
272  }
273 
274  while (listWidget != NULL)
275  {
276  if (listWidget == this)
277  {
278  listWidget->mLines.push_back(line);
279  }
280  else
281  {
282  listWidget->mLines.push_back(L"-");
283  }
284 
285  listWidget->mLineColors.push_back(mColors[COLOR_TEXT]);
286 
287  listWidget = listWidget->mChild;
288  }
289  }
290 
291  if (mScrollbar != NULL)
292  {
294  }
295 
296  return idx;
297 }
298 
299 void ListWidget::setLine(int32_hf idx, const std::wstring &line)
300 {
301  int32_hf size = mLines.size();
302  if (size > 0 && idx >= 0 && idx < size)
303  {
304  mLines[idx] = line;
305  }
306 }
307 
309 {
310  return mLines.size();
311 }
312 
313 int32_hf ListWidget::getLineIdx(const std::wstring &line)
314 {
315  for (int32_hf i = 0; i < (int32_hf)mLines.size(); i++)
316  {
317  if (wcscmp(mLines[i].c_str(), line.c_str()) == 0)
318  {
319  return i;
320  }
321  }
322 
323  return -1;
324 }
325 
327 {
328  ListWidget *listWidget = this;
329 
330  while (listWidget->mParent != NULL)
331  {
332  listWidget = listWidget->mParent;
333  }
334 
335  while (listWidget != NULL)
336  {
337  listWidget->mSelectIdx = selectIdx;
338  listWidget = listWidget->mChild;
339  }
340 }
341 
342 void ListWidget::setColor(const std::wstring &line, const Color &color)
343 {
344  int32_hf idx = getLineIdx(line);
345  setLineColor(idx, color);
346 }
347 
348 void ListWidget::setColor(int32_hf idx, const Color &color)
349 {
350  Widget::setColor(idx, color);
351 }
352 
353 void ListWidget::setLineColor(int32_hf idx, const Color &color)
354 {
355  if ((idx >= 0) && (idx < (int32_hf)mLines.size()))
356  {
357  ListWidget *listWidget = this;
358 
359  while (listWidget->mParent != NULL)
360  {
361  listWidget = listWidget->mParent;
362  }
363 
364  while (listWidget != NULL)
365  {
366  listWidget->mLineColors[idx] = color;
367 
368  listWidget = listWidget->mChild;
369  }
370  }
371 }
372 
374 {
375  if (idx != -1)
376  {
377  ListWidget *listWidget = this;
378 
379  while (listWidget->mParent != NULL)
380  {
381  listWidget = listWidget->mParent;
382  }
383 
384  while (listWidget != NULL)
385  {
386  listWidget->mLines.erase(listWidget->mLines.begin() + idx);
387  listWidget->mLineColors.erase(listWidget->mLineColors.begin() + idx);
388 
389  listWidget = listWidget->mChild;
390  }
391  }
392 
393  if (mScrollbar != NULL)
394  {
396  }
397 }
398 
400 {
401  ListWidget *listWidget = this;
402 
403  while (listWidget->mParent != NULL)
404  {
405  listWidget = listWidget->mParent;
406  }
407 
408  while (listWidget != NULL)
409  {
410  listWidget->mLines.clear();
411  listWidget->mLineColors.clear();
412  listWidget->mSelectIdx = -1;
413  listWidget->mHiliteIdx = -1;
414 
415  listWidget = listWidget->mChild;
416  }
417 
418  if (mScrollbar != NULL)
419  {
421  }
422 }
423 
425 {
426  int32_hf maxWidth = 0;
427 
428  for (int32_hf i = 0; i < (int32_hf)mLines.size(); i++)
429  {
430  maxWidth = hf_max(maxWidth, mFont->getStringWidth(mLines[i].c_str()));
431  }
432 
433  return maxWidth + 16;
434 }
435 
437 {
438  int32_hf itemHeight = (mItemHeight != -1) ? mItemHeight : mFont->getHeight();
439 
440  return itemHeight * mLines.size() + 8;
441 }
442 
444 {
446 
447  if (mChild != NULL && HFCORE_WIDMGR != NULL)
448  {
449  HFCORE_WIDMGR->putInfront(mChild, this);
450  }
451 
452  if (mScrollbar != NULL && HFCORE_WIDMGR != NULL)
453  {
454  HFCORE_WIDMGR->putInfront(mScrollbar, this);
455  }
456 }
457 
459 {
460  if (mDrawOutline)
461  {
462  mRenderHelper.drawRect(g, mX, mY, mWidth, mHeight, mColors[COLOR_OUTLINE]);
463  }
464 
465  mRenderHelper.drawRect(g, mX + 1, mY + 1, mWidth - 2, mHeight - 2, mColors[COLOR_BKG]);
466 
467  mClipRect.set(mX + 4, mY + 4, mWidth - 8, mHeight - 8);
468 
469  drawAllLines(g);
470 }
471 
472 void ListWidget::drawAllLines(Graphics *g)
473 {
474  int32_hf firstLine = (int32_hf) mPosition;
475  int32_hf lastLine = hf_min((int32_hf) mLines.size() - 1,
477 
478  int32_hf itemHeight, itemOffset;
479  if (mItemHeight != -1)
480  {
481  itemHeight = mItemHeight;
482  itemOffset = (itemHeight - mFont->getHeight()) / 2;
483  }
484  else
485  {
486  itemHeight = mFont->getHeight();
487  itemOffset = 0;
488  }
489 
490  Color color;
491  for (int32_hf i = firstLine; i <= lastLine; i++)
492  {
493  int32_hf drawY = 4 + (int32_hf)((i - mPosition) * itemHeight);
494 
495  if (i == mSelectIdx || (i == mHiliteIdx && mDrawSelectWhenHilited))
496  {
497  mRenderHelper.enableClipRect(g, mClipRect);
498  mRenderHelper.drawRect(g, mX, (fp32_hf)(drawY + mY), mWidth,
499  (fp32_hf)itemHeight, mColors[COLOR_SELECT]);
500  mRenderHelper.disableClipRect(g);
501  }
502 
503  if (i == mHiliteIdx)
504  {
505  color = mColors[COLOR_HILITE];
506  }
507  else if ((i == mSelectIdx) && (mColors.size() > COLOR_SELECT_TEXT))
508  {
509  color = mColors[COLOR_SELECT_TEXT];
510  }
511  else
512  {
513  color = mColors[COLOR_TEXT];
514  }
515 
516  std::wstring line = mLines[i];
517  int32_hf fontX;
518  switch (mJustify)
519  {
520  case JUSTIFY_LEFT:
521  fontX = 4 + (int32_hf)mX;
522  break;
523  case JUSTIFY_CENTER:
524  fontX = ((int32_hf)mWidth - mFont->getStringWidth(line.c_str())) / 2 + (int32_hf)mX;
525  break;
526  default:
527  fontX = (int32_hf)mWidth - mFont->getStringWidth(line.c_str()) - 4 + (int32_hf)mX;
528  break;
529  }
530 
531  mRenderHelper.beginBatch(g, Graphics::BATCHMODE_STATIC, mClipRect);
532  drawLine(g, (fp32_hf)fontX, (fp32_hf)(drawY +
533  (mFont->getHeight() / 2) - 4 + itemOffset + mY), line, color);
534  mRenderHelper.endBatch(g, true);
535  }
536 }
537 
538 void ListWidget::drawLine(Graphics *g, fp32_hf x, fp32_hf y,
539  std::wstring &line, Color color)
540 {
541  mRenderHelper.drawString(g, mFont, color,
542  line.c_str(), (int32_hf)x, (int32_hf)y);
543 }
544 
546 {
547  if (mChild != NULL)
548  {
549  mChild->scrollPosition(id, position);
550  }
551 
552  mPosition = position;
554 }
555 
557 {
558  if (kb.key == Keyboard::KEY_ESCAPE)
559  {
561  // inform listeners that ESC is pressed.
563  }
564 }
565 
567 {
568  int32_hf itemHeight = (mItemHeight != -1) ? mItemHeight : mFont->getHeight();
569 
570  int32_hf newHilite = (int32_hf)(((touch.y - mY - 4) /
571  (fp32_hf) itemHeight) + mPosition);
572 
573  if ((newHilite < 0) || (newHilite >= (int32_hf) mLines.size()))
574  {
575  newHilite = -1;
576  }
577 
578  if (newHilite != mHiliteIdx)
579  {
580  ListWidget *listWidget = this;
581 
582  while (listWidget->mParent != NULL)
583  {
584  listWidget = listWidget->mParent;
585  }
586 
587  while (listWidget != NULL)
588  {
590  listWidget->setHilite(newHilite, true);
591  listWidget = listWidget->mChild;
592  }
593  }
594 
595  if ((mHiliteIdx != -1) && (mListListener != NULL))
596  {
599  }
600 }
601 
603 {
604 }
605 
607 {
608  int32_hf itemHeight = (mItemHeight != -1) ? mItemHeight : mFont->getHeight();
609 
610  int32_hf newHilite = (int32_hf)(((mouse.y - mY - 4) /
611  (fp32_hf) itemHeight) + mPosition);
612 
613  if ((newHilite < 0) || (newHilite >= (int32_hf) mLines.size()))
614  {
615  newHilite = -1;
616  }
617 
618  if (newHilite != mHiliteIdx)
619  {
620  ListWidget *listWidget = this;
621 
622  while (listWidget->mParent != NULL)
623  {
624  listWidget = listWidget->mParent;
625  }
626 
627  while (listWidget != NULL)
628  {
630  listWidget->setHilite(newHilite, true);
631  listWidget = listWidget->mChild;
632  }
633  }
634 }
635 
637 {
638  if (mScrollbar != NULL)
639  {
640  int32_hf scrollAmount = 5;
641  if (mouse.wheelDelta > 0)
642  {
644  mScrollbar->setValue(mScrollbar->mValue - scrollAmount);
645  }
646  else if (mouse.wheelDelta < 0)
647  {
649  mScrollbar->setValue(mScrollbar->mValue + scrollAmount);
650  }
651  }
652 }
653 
655 {
656  if ((mHiliteIdx != -1) && (mListListener != NULL))
657  {
660  }
661 }
662 
664 {
665  ListWidget *listWidget = this;
666 
667  while (listWidget->mParent != NULL)
668  {
669  listWidget = listWidget->mParent;
670  }
671 
672  while (listWidget != NULL)
673  {
674  listWidget->setHilite(-1, true);
675  listWidget = listWidget->mChild;
676  }
678 }
unsigned int uint32_hf
A type definition for unsigned int.
Definition: HFDataTypes.h:354
void endBatch(Graphics *g, bool render)
End current Batch.
virtual int32_hf getStringWidth(const UString &str, fp32_hf scale=1.0f)=0
Get the width of str.
virtual void resize(fp32_hf x, fp32_hf y, int32_hf w, int32_hf h)
Resize Widget.
Definition: ListWidget.cpp:200
Interface for Resource type Font.
ScrollbarWidget * mScrollbar
Holds pointer to ScrollbarWidget.
Definition: ListWidget.h:325
fp32_hf drawString(Graphics *g, Font *font, Color color, const UString &string, int32_hf x, int32_hf y, fp32_hf scale=1.0f)
Draw a string.
ListWidget * mParent
Holds pointer to parent ListWidget.
Definition: ListWidget.h:374
virtual int32_hf getLineIdx(const std::wstring &line)
Get line index for line.
Definition: ListWidget.cpp:313
virtual void listWidgetEscapeKeyPressed()
Called automatically when ESCAPE key is pressed within ListWidget.
Definition: ListListener.h:97
virtual void setBatchUIUpdateNeeded(bool update)
Set BatchUI update needed flag.
Definition: Widget.cpp:503
void disableClipRect(Graphics *g)
Disable clip Rect.
fp32_hf y
Y coordinate, relative to window.
Definition: Mouse.h:69
virtual std::wstring getStringAt(int32_hf idx)
Get string at idx.
Definition: ListWidget.cpp:189
fp64_hf mPageSize
Holds list page size.
Definition: ListWidget.h:354
virtual void listClosed(int32_hf id)
Called automatically when list is closed.
Definition: ListListener.h:82
int int32_hf
A type definition for int.
Definition: HFDataTypes.h:349
bool mDrawSelectWhenHilited
Flag indicating whether to draw select when hilited or not.
Definition: ListWidget.h:405
fp64_hf mPosition
Holds list position.
Definition: ListWidget.h:349
virtual void setColor(const std::wstring &line, const Color &color)
Set Color for line.
Definition: ListWidget.cpp:342
virtual void keyDown(Keyboard::KeyboardInfo kb)
Called automatically when Keyboard keyDown event occurs.
Definition: ListWidget.cpp:556
Interface for UI ListWidget.
Definition: ListWidget.h:131
void drawRect(Graphics *g, fp32_hf x0, fp32_hf y0, fp32_hf w, fp32_hf h, Color color, Graphics::DrawMode drawMode=Graphics::DRAWMODE_NORMAL)
Draw a Rect.
Font * mFont
Holds pointer to Font.
Definition: ListWidget.h:320
virtual void setPageSize(fp32_hf newPageSize)
Set page size.
virtual void listClicked(int32_hf id, int32_hf idx, int32_hf clickCount)
Called automatically when list is clicked on.
Definition: ListListener.h:75
fp32_hf mX
Holds Widget X position.
int32_hf wheelDelta
Mouse wheel delta value (scroll forward = -120, scroll backward = 120)
Definition: Mouse.h:74
Interface for ListWidget listener callback methods.
Definition: ListListener.h:65
virtual void touchMove(Touch::TouchInfo touch)
Called automatically when Touch move/drag event occurs.
Definition: ListWidget.cpp:602
std::vector< Color > ColorVector
typedef for Vector holding Color.
Definition: Widget.h:227
ListWidget * mChild
Holds pointer to child ListWidget.
Definition: ListWidget.h:379
Interface for UI ScrollbarWidget.
#define HF_SAFE_DELETE_ARR(p)
Check if not NULL, delete array and set to NULL.
Definition: HFDataTypes.h:56
virtual void setColor(int32_hf idx, const Color &color)
Set Color for given idx and store in internal Widget::ColorVector.
Definition: Widget.cpp:123
A structure that contains Touch event information.
Definition: Touch.h:50
virtual void listHiliteChanged(int32_hf id, int32_hf oldIdx, int32_hf newIdx)
Called automatically when list hilite changes.
Definition: ListListener.h:91
virtual void removedFromManager(WidgetManager *widgetManager)
Call removedFromManager() for all Widget&#39;s in internal list.
virtual void scrollPosition(int32_hf id, fp32_hf position)
Set scroll position.
Definition: ListWidget.cpp:545
virtual void draw(Graphics *g)
Called by the framework once for every iteration of the main loop.
Definition: ListWidget.cpp:458
Interface for ListWidget listener callback methods.
virtual int32_hf getHeight()=0
Get Font height.
#define NULL
Convenient define for 0.
Definition: HFDataTypes.h:42
virtual void touchDown(Touch::TouchInfo touch)
Called automatically when Touch down event occurs.
Definition: ListWidget.cpp:566
Useful for static content.
Definition: Graphics.h:199
virtual std::wstring getSortKey(int32_hf idx)
Get sort key for idx.
Definition: ListWidget.cpp:105
virtual void mouseWheel(Mouse::MouseInfo mouse)
Called automatically when Mouse wheel event occurs.
Definition: ListWidget.cpp:636
virtual void setValue(fp32_hf newValue)
Set value.
virtual int32_hf getOptimalHeight()
Get optimal list height.
Definition: ListWidget.cpp:436
virtual void resize(fp32_hf x, fp32_hf y, int32_hf w, int32_hf h)
Resize Widget.
Definition: Widget.cpp:181
Interface for RGBA Color.
Definition: Color.h:51
A structure that contains Mouse event information.
Definition: Mouse.h:63
int32_hf mSelectIdx
Holds list select index.
Definition: ListWidget.h:364
virtual void orderInManagerChanged()
Method for controlling if order in manager has changed.
Definition: Widget.cpp:92
#define HFCORE_WIDMGR
Get HFCore::WidgetManager instance shortcut macro.
Definition: Environment.h:78
Interface for UI ListWidget.
int32_hf mJustify
Holds list justify. Valid values are: ListWidget::JUSTIFY_LEFT, ListWidget::JUSTIFY_CENTER, ListWidget::JUSTIFY_RIGHT.
Definition: ListWidget.h:332
A structure that contains Keyboard event information.
Definition: Keyboard.h:103
int32_hf tapCount
Tap count.
Definition: Touch.h:60
WidgetManager manages Widget&#39;s and interacts with Game interface.
Key key
Key enum value if any.
Definition: Keyboard.h:109
fp32_hf y
Y coordinate, relative to window.
Definition: Touch.h:56
virtual void setLineColor(int32_hf idx, const Color &color)
Set line Color for idx.
Definition: ListWidget.cpp:353
virtual void setSelect(int32_hf selectIdx)
Set select for line with selectIdx.
Definition: ListWidget.cpp:326
#define hf_min(a, b)
Returns the smallest of a and b.
Definition: HFDataTypes.h:123
void enableClipRect(Graphics *g, Rect clipRect)
Enable clip Rect.
int32_hf mMaxNumericPlaces
Holds max numeric places.
Definition: ListWidget.h:394
virtual void mouseLeave(Mouse::MouseInfo mouse)
Called automatically when Mouse leave event occurs.
Definition: ListWidget.cpp:663
virtual int32_hf getLineCount()
Get line count.
Definition: ListWidget.cpp:308
virtual void sort(bool ascending)
Sort list ascending or descending.
Definition: ListWidget.cpp:133
ListWidget(int32_hf id, Font *font, ListListener *listListener)
Constructor.
Definition: ListWidget.cpp:45
virtual void removeAll()
Remove all lines.
Definition: ListWidget.cpp:399
Color for selected text.
Definition: ListWidget.h:154
fp32_hf mY
Holds Widget Y position.
virtual void setLine(int32_hf idx, const std::wstring &line)
Set line at idx.
Definition: ListWidget.cpp:299
fp32_hf mValue
Holds scrollbar value.
Color for selection.
Definition: ListWidget.h:153
virtual void orderInManagerChanged()
Method for controlling if order in manager has changed.
Definition: ListWidget.cpp:443
Definition: Actor.h:34
int32_hf mHiliteIdx
Holds list hilite index.
Definition: ListWidget.h:359
Interface for Resource type Font.
Definition: Font.h:84
int32_hf mId
Holds ListWidget ID.
Definition: ListWidget.h:315
Singleton interface for platform specific things.
int32_hf mItemHeight
Holds item height.
Definition: ListWidget.h:399
virtual void removeLine(int32_hf idx)
Remove line at idx.
Definition: ListWidget.cpp:373
StringUtil::WStringVector mLines
Holds StringUtil::WStringVector containing all list lines.
Definition: ListWidget.h:338
virtual void setMaxValue(fp32_hf newMaxValue)
Set max value.
virtual int32_hf getOptimalWidth()
Get optimal list width.
Definition: ListWidget.cpp:424
virtual void mouseMove(Mouse::MouseInfo mouse)
Called automatically when Mouse motion event occurs.
Definition: ListWidget.cpp:606
Interface for all rendering related things.
Definition: Graphics.h:120
WidgetManager manages Widget&#39;s and interacts with Game interface.
void beginBatch(Graphics *g, Graphics::BatchMode mode, Rect clipRect=Rect::ZERO())
Begin Batch using specified Graphics::BatchMode and optional clipping Rect.
virtual void setColors(int32_hf colors[][3], int32_hf numColors)
Set RGB colors.
Definition: Widget.cpp:107
bool mSortFromChild
Flag indicating whether to sort from child or not.
Definition: ListWidget.h:384
ListListener * mListListener
Holds pointer to ListListener class.
Definition: ListWidget.h:369
bool mDoFingerWhenHilited
Flag indicating whether to show finger when hilited or not.
Definition: ListWidget.h:411
ColorVector mColors
Vector holding Color&#39;s set by setColor() and setColors().
Definition: Widget.h:1081
bool mDrawOutline
Flag indicating whether to draw outline or not.
Definition: ListWidget.h:389
void setHilite(int32_hf hiliteIdx, bool notifyListener=false)
Set hilite.
Definition: ListWidget.cpp:84
ColorVector mLineColors
Holds Widget::ColorVector containing all the line Color&#39;s.
Definition: ListWidget.h:344
Color for background.
Definition: ListWidget.h:149
#define hf_max(a, b)
Returns the largest of a and b.
Definition: HFDataTypes.h:116
virtual void removedFromManager(WidgetManager *widgetManager)
Call removedFromManager() for all Widget&#39;s in internal list.
Definition: ListWidget.cpp:95
void set(fp32_hf x, fp32_hf y, fp32_hf width, fp32_hf height, bool isCentered=false)
Initializes the Rect.
Definition: Rect.cpp:36
int32_hf clickCount
Mouse click count.
Definition: Mouse.h:73
std::vector< std::wstring > WStringVector
typedef for Vector holding std::wstring.
Definition: StringUtil.h:63
virtual void mouseButtonDown(Mouse::MouseInfo mouse)
Called automatically when Mouse button down event occurs.
Definition: ListWidget.cpp:654
virtual int32_hf addLine(const std::wstring &line, bool alphabetical)
Add new line to list.
Definition: ListWidget.cpp:220
fp32_hf mWidth
Holds Widget width.
virtual ~ListWidget()
Destructor.
Definition: ListWidget.cpp:80
float fp32_hf
A type definition for float.
Definition: HFDataTypes.h:359
fp32_hf mHeight
Holds Widget height.