Harmonic Flow Framework (libhffwk)
Cross platform C++ 2D Game Engine Framework
DialogWidget.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 "DialogWidget.h"
22 #include "DialogListener.h"
23 #include "DialogButtonWidget.h"
24 #include "WidgetManager.h"
25 
26 #include "platform/Environment.h"
27 #include "platform/Graphics.h"
28 #include "platform/Image.h"
30 
31 using namespace HFCore;
32 
33 #include "debug/CrtDbgNew.h"
34 
39 
40 static int32_hf gDialogColors[][3] =
41 {
42  {255, 255, 255},
43  {255, 255, 0},
44  {255, 255, 255},
45  {255, 255, 255},
46  {255, 255, 255},
47 
48  {80, 80, 80},
49  {255, 255, 255}
50 };
51 
52 DialogWidget::DialogWidget(int32_hf id, DialogListener *dialogListener, Image *dialogImage,
53  bool isModal, const UString &dialogHeader, const UString &dialogLines,
54  const UString &dialogFooter, int32_hf buttonMode, Font *fontButton,
55  Image *buttonImage, Image *buttonImageOver, Image *buttonImageDown,
56  Image *buttonImageDisabled)
57 {
58  mId = id;
59  mDialogListener = dialogListener;
60  mDialogImage = dialogImage;
61  assert(mId > 0 && mDialogListener != NULL);
62 
63  mDeleteDialogImage = false;
64  mIsModal = isModal;
65 
66  mDialogHeader = dialogHeader;
67  mDialogLines = dialogLines;
68  mDialogFooter = dialogFooter;
69  mButtonMode = buttonMode;
70  mUsingCustomButtons = false;
72  {
73  mUsingCustomButtons = true;
74  }
75 
76  mFontButton = fontButton;
77 
78  mResult = 0x7FFFFFFF;
79 
80  mContentInsets = Insets(24, 24, 24, 24);
84  mSpaceAfterHeader = 10;
87 
89  {
90  // Create buttons and default to Yes No labels.
92  buttonImage, buttonImageOver, buttonImageDown,
93  buttonImageDisabled);
94 
96  buttonImage, buttonImageOver, buttonImageDown,
97  buttonImageDisabled);
98 
100  {
103  }
104  }
105  else if (mButtonMode == BUTTONS_FOOTER)
106  {
108  buttonImage, buttonImageOver, buttonImageDown,
109  buttonImageDisabled);
111  }
112  else
113  {
114  mYesOkButton = NULL;
116  mNumButtons = 0;
117  }
118 
119  mButtonWidth = buttonImage->getWidth();
120  mButtonHeight = buttonImage->getHeight();
121 
122  mHasTransparencies = true;
123  mHasAlpha = true;
124 
125  mFontHeader = NULL;
126  mFontLines = NULL;
127 
128  mDialogMovable = true;
129  mDragging = false;
130  mPriority = 1;
131 
132  setColors(gDialogColors, NUM_COLORS);
133 
134  mUsingAtlas = false;
135 }
136 
138  Image *dialogImage, bool isModal, int32_hf buttonMode)
139 {
140  mId = id;
141  mDialogListener = dialogListener;
142  mDialogImage = dialogImage;
143  assert(mId > 0 && mDialogListener != NULL);
144 
145  mDeleteDialogImage = false;
146  mIsModal = isModal;
147  mButtonMode = buttonMode;
148  mUsingCustomButtons = false;
150  {
151  mUsingCustomButtons = true;
152  }
153 
154  mYesOkButton = NULL;
156  mNumButtons = 0;
157 
158  mResult = 0x7FFFFFFF;
159 
160  mContentInsets = Insets(24, 24, 24, 24);
163  mLineSpacingOffset = 0;
164  mSpaceAfterHeader = 10;
165  mButtonSidePadding = 0;
166  mButtonHorzSpacing = 0;
167 
168  mHasTransparencies = true;
169  mHasAlpha = true;
170 
171  mFontHeader = NULL;
172  mFontLines = NULL;
173 
174  mDialogMovable = true;
175  mDragging = false;
176  mPriority = 1;
177 
178  setColors(gDialogColors, NUM_COLORS);
179 
180  mUsingAtlas = false;
181 }
182 
183 DialogWidget::DialogWidget(int32_hf id, DialogListener *dialogListener, Image *dialogImage,
184  bool isModal, const UString &dialogHeader, const UString &dialogLines,
185  const UString &dialogFooter, int32_hf buttonMode, Font *fontButton,
186  Image *atlasImage, const Rect &buttonRect,
187  const Rect &buttonOverRect, const Rect &buttonDownRect,
188  const Rect &buttonDisabledRect)
189 {
190  mId = id;
191  mDialogListener = dialogListener;
192  mDialogImage = dialogImage;
193  assert(mId > 0 && mDialogListener != NULL);
194 
195  mDeleteDialogImage = false;
196  mIsModal = isModal;
197 
198  mDialogHeader = dialogHeader;
199  mDialogLines = dialogLines;
200  mDialogFooter = dialogFooter;
201  mButtonMode = buttonMode;
202  mUsingCustomButtons = false;
204  {
205  mUsingCustomButtons = true;
206  }
207 
208  mFontButton = fontButton;
209 
210  mResult = 0x7FFFFFFF;
211 
212  mContentInsets = Insets(24, 24, 24, 24);
215  mLineSpacingOffset = 0;
216  mSpaceAfterHeader = 10;
217  mButtonSidePadding = 0;
218  mButtonHorzSpacing = 8;
219 
221  {
222  // Create buttons and default to Yes No labels.
224  atlasImage, buttonRect, buttonOverRect, buttonDownRect,
225  buttonDisabledRect);
226 
228  buttonRect, buttonOverRect, buttonDownRect, buttonDisabledRect);
229 
231  {
234  }
235  }
236  else if (mButtonMode == BUTTONS_FOOTER)
237  {
239  buttonRect, buttonOverRect, buttonDownRect, buttonDisabledRect);
241  }
242  else
243  {
244  mYesOkButton = NULL;
246  mNumButtons = 0;
247  }
248 
249  mButtonWidth = (int32_hf)buttonRect.getWidth();
250  mButtonHeight = (int32_hf)buttonRect.getHeight();
251 
252  mHasTransparencies = true;
253  mHasAlpha = true;
254 
255  mFontHeader = NULL;
256  mFontLines = NULL;
257 
258  mDialogMovable = true;
259  mDragging = false;
260  mPriority = 1;
261 
262  setColors(gDialogColors, NUM_COLORS);
263 
264  mUsingAtlas = false;
265 }
266 
268  const Rect &dialogRect,
269  bool isModal, const UString &dialogHeader, const UString &dialogLines,
270  const UString &dialogFooter, int32_hf buttonMode, Font *fontButton,
271  Image *atlasImage, const Rect &buttonRect, const
272  Rect &buttonOverRect, const Rect &buttonDownRect,
273  const Rect &buttonDisabledRect)
274 {
275  mId = id;
276  mDialogListener = dialogListener;
277  mAtlasImage = atlasImage;
278  mDialogRect = dialogRect;
279  assert(mId > 0 && mDialogListener != NULL);
280 
281  mDialogImage = NULL;
282  mDeleteDialogImage = false;
283  mIsModal = isModal;
284 
285  mDialogHeader = dialogHeader;
286  mDialogLines = dialogLines;
287  mDialogFooter = dialogFooter;
288  mButtonMode = buttonMode;
289  mUsingCustomButtons = false;
291  {
292  mUsingCustomButtons = true;
293  }
294 
295  mFontButton = fontButton;
296 
297  mResult = 0x7FFFFFFF;
298 
299  mContentInsets = Insets(24, 24, 24, 24);
302  mLineSpacingOffset = 0;
303  mSpaceAfterHeader = 10;
304  mButtonSidePadding = 0;
305  mButtonHorzSpacing = 8;
306 
308  {
309  // Create buttons and default to Yes No labels.
311  atlasImage, buttonRect, buttonOverRect, buttonDownRect,
312  buttonDisabledRect);
313 
315  atlasImage, buttonRect, buttonOverRect, buttonDownRect,
316  buttonDisabledRect);
317 
319  {
322  }
323  }
324  else if (mButtonMode == BUTTONS_FOOTER)
325  {
327  buttonRect, buttonOverRect, buttonDownRect,
328  buttonDisabledRect);
330  }
331  else
332  {
333  mYesOkButton = NULL;
335  mNumButtons = 0;
336  }
337 
338  mButtonWidth = (int32_hf)buttonRect.getWidth();
339  mButtonHeight = (int32_hf)buttonRect.getHeight();
340 
341  mHasTransparencies = true;
342  mHasAlpha = true;
343 
344  mFontHeader = NULL;
345  mFontLines = NULL;
346 
347  mDialogMovable = true;
348  mDragging = false;
349  mPriority = 1;
350 
351  setColors(gDialogColors, NUM_COLORS);
352 
353  mUsingAtlas = true;
354 }
355 
356 DialogWidget::DialogWidget(int32_hf id, DialogListener *dialogListener, Image *atlasImage,
357  const Rect &dialogRect, bool isModal, int32_hf buttonMode)
358 {
359  mId = id;
360  mDialogListener = dialogListener;
361  mAtlasImage = atlasImage;
362  mDialogRect = dialogRect;
363  assert(mId > 0 && mDialogListener != NULL);
364 
365  mDialogImage = NULL;
366  mDeleteDialogImage = false;
367  mIsModal = isModal;
368  mButtonMode = buttonMode;
369  mUsingCustomButtons = false;
371  {
372  mUsingCustomButtons = true;
373  }
374 
375  mYesOkButton = NULL;
377  mNumButtons = 0;
378 
379  mResult = 0x7FFFFFFF;
380 
381  mContentInsets = Insets(24, 24, 24, 24);
384  mLineSpacingOffset = 0;
385  mSpaceAfterHeader = 10;
386  mButtonSidePadding = 0;
387  mButtonHorzSpacing = 0;
388 
389  mHasTransparencies = true;
390  mHasAlpha = true;
391 
392  mFontHeader = NULL;
393  mFontLines = NULL;
394 
395  mDialogMovable = true;
396  mDragging = false;
397  mPriority = 1;
398 
399  setColors(gDialogColors, NUM_COLORS);
400 
401  mUsingAtlas = true;
402 }
403 
405 {
407  {
408  HFCORE_RESMGR->destroyResource(mDialogImage);
409  mDialogImage = NULL;
410  }
411 
414 }
415 
417 {
418  mFontButton = font;
419 }
420 
422 {
423  mFontHeader = font;
424 }
425 
427 {
428  mFontLines = font;
429 }
430 
431 void DialogWidget::setDeleteDialogImage(bool deleteDialogImage)
432 {
433  mDeleteDialogImage = deleteDialogImage;
434 }
435 
436 void DialogWidget::setColor(int32_hf idx, const Color &color)
437 {
438  Widget::setColor(idx, color);
439 
440  if (idx == COLOR_BUTTON_TEXT)
441  {
442  if (mYesOkButton != NULL)
443  {
445  }
446 
447  if (mNoCancelButton != NULL)
448  {
450  }
451  }
452  else if (idx == COLOR_BUTTON_TEXT_HILITE)
453  {
454  if (mYesOkButton != NULL)
455  {
457  }
458 
459  if (mNoCancelButton != NULL)
460  {
462  }
463  }
464 }
465 
467 {
470 
471  bool needSpace = false;
472  if (mDialogHeader.length() > 0 && mFontHeader != NULL)
473  {
474  height += mFontHeader->getHeight();
475  needSpace = true;
476  }
477 
478  if (mDialogLines.length() > 0 && mFontLines != NULL)
479  {
480  if (needSpace)
481  {
482  height += mSpaceAfterHeader;
483  }
484 
485  Graphics *g = HFCORE_ENV->getGraphics();
488 
489  height = getWordWrappedHeight(g, mFontLines, Rect(0, 0, (fp32_hf)w,
490  (fp32_hf)height), mDialogLines,
492 
493  needSpace = true;
494  }
495 
496  if ((mDialogFooter.length() != 0) && (mButtonMode != BUTTONS_FOOTER))
497  {
498  if (needSpace)
499  {
500  height += 8;
501  }
502 
503  height += mFontHeader->getLineSpacing();
504  needSpace = true;
505  }
506 
507  if (mYesOkButton != NULL)
508  {
509  if (needSpace)
510  {
511  height += 8;
512  }
513 
514  height += mButtonHeight + 8;
515  }
516 
517  return height;
518 }
519 
521 {
522  // draw actual dialog image
523  Rect boxRect(mBackgroundInsets.mLeft + mX, mBackgroundInsets.mTop + mY, 0, 0);
524  if (mUsingAtlas)
525  {
526  if (mAtlasImage != NULL && mDialogRect != Rect::ZERO())
527  {
528  fp32_hf x = boxRect.getX() + mWidth / 2;
529  fp32_hf y = boxRect.getY() + mHeight / 2;
530  mRenderHelper.drawImage(g, mAtlasImage, mDialogRect, x, y, 1.0f,
533  }
534  }
535  else
536  {
537  if (mDialogImage != NULL)
538  {
539  fp32_hf x = boxRect.getX() + mWidth / 2;
540  fp32_hf y = boxRect.getY() + mHeight / 2;
541  mRenderHelper.drawImage(g, mDialogImage, x, y, 1.0f, Graphics::DRAWMODE_NORMAL,
543  }
544  }
545 
546  // draw header
548  if (mDialogHeader.length() > 0 && mFontHeader != NULL)
549  {
550  drawHeader(g, curY);
551 
552  curY += mFontHeader->getHeight();
553  curY += mSpaceAfterHeader;
554  }
555 
556  // draw lines
557  if (mDialogLines.length() != 0 && mFontLines != NULL)
558  {
559  drawLines(g, curY);
560  }
561 
562  // draw footer
563  if ((mDialogFooter.length() != 0) && mFontHeader != NULL && (mButtonMode != BUTTONS_FOOTER))
564  {
565  curY += 8;
566  curY += mFontHeader->getLineSpacing();
567 
568  drawFooter(g, curY);
569  }
570 }
571 
572 void DialogWidget::drawHeader(Graphics *g, int32_hf y)
573 {
574  mRenderHelper.beginBatch(g, Graphics::BATCHMODE_STATIC);
575  mRenderHelper.drawCenteredString(g, mFontHeader, mColors[COLOR_HEADER], y,
577  mRenderHelper.endBatch(g, true);
578 }
579 
580 void DialogWidget::drawLines(Graphics *g, int32_hf y)
581 {
584 
586  (fp32_hf)y,
589  (fp32_hf)h);
590  int32_hf wrappedHeight = getWordWrappedHeight(g, mFontLines, rect, mDialogLines);
591  rect.setMaxY((fp32_hf)h - (fp32_hf)wrappedHeight + (fp32_hf)y);
592 
593  mRenderHelper.beginBatch(g, Graphics::BATCHMODE_STATIC);
594  mRenderHelper.drawWordWrappedString(g, mFontLines, mColors[COLOR_LINES], rect,
597  mRenderHelper.endBatch(g, true);
598 }
599 
600 void DialogWidget::drawFooter(Graphics *g, int32_hf y)
601 {
602  mRenderHelper.beginBatch(g, Graphics::BATCHMODE_STATIC);
603  mRenderHelper.drawCenteredString(g, mFontHeader, mColors[COLOR_FOOTER], y,
605  mRenderHelper.endBatch(g, true);
606 }
607 
609 {
610  Widget::update(dt);
611 }
612 
614 {
615  Widget::addedToManager(widgetManager);
616 
617  if (mYesOkButton != NULL)
618  {
619  widgetManager->addWidget(mYesOkButton);
620  }
621 
622  if (mNoCancelButton != NULL)
623  {
624  widgetManager->addWidget(mNoCancelButton);
625  }
626 }
627 
629 {
630  Widget::removedFromManager(widgetManager);
631 
632  if (mYesOkButton != NULL)
633  {
634  widgetManager->removeWidget(mYesOkButton);
635  }
636 
637  if (mNoCancelButton != NULL)
638  {
639  widgetManager->removeWidget(mNoCancelButton);
640  }
641 }
642 
644 {
646 
647  if (mYesOkButton != NULL)
648  {
650  }
651 
652  if (mNoCancelButton != NULL)
653  {
655  }
656 }
657 
659 {
660  Widget::resize(x, y, w, h);
661 
662  if ((mYesOkButton != NULL) && (mNoCancelButton != NULL))
663  {
666  mButtonHorzSpacing) / 2;
667 
668  int32_hf btnHeight = mButtonHeight;
669 
672  mBackgroundInsets.mBottom - btnHeight, btnWidth, btnHeight);
673 
675  btnWidth, btnHeight);
676  }
677  else if (mYesOkButton != NULL)
678  {
679  int32_hf x = (int32_hf)mX + (((int32_hf)mWidth - mButtonWidth) / 2);
680 
681  // Always center footer button.
684  mButtonWidth, mButtonHeight);
685  }
686 }
687 
689 {
690  return mIsModal;
691 }
692 
694 {
695  while ((mWidgetManager != NULL) && (mResult == 0x7FFFFFFF));
696 
697  if (autoKill)
698  {
700  }
701 
702  return mResult;
703 }
704 
706 {
707  if (touch.tapCount == 1 && mDialogMovable)
708  {
709  if (!mDragging && mDialogListener != NULL)
710  {
713  }
714  mDragging = true;
715  mDragPosX = (int32_hf)(touch.x - mX);
716  mDragPosY = (int32_hf)(touch.y - mY);
717  }
718  Widget::touchDown(touch);
719 }
720 
722 {
723  if (mDragging)
724  {
725  if (mDialogListener != NULL)
726  {
729  }
730  mDragging = false;
731  }
732  Widget::touchUp(touch);
733 }
734 
736 {
737  if (mDragging)
738  {
739  fp32_hf x = (touch.x - mX);
740  fp32_hf y = (touch.y - mY);
741  int32_hf screenWidth = HFCORE_ENV->getLogicalScreenWidth();
742  int32_hf screenHeight = HFCORE_ENV->getLogicalScreenHeight();
743 
744  fp32_hf newX = mX + x - mDragPosX;
745  fp32_hf newY = mY + y - mDragPosY;
746 
747  if (newX < -8)
748  {
749  newX = -8;
750  }
751  else if (newX + mWidth > screenWidth + 8)
752  {
753  newX = (fp32_hf)screenWidth - mWidth + 8;
754  }
755 
756  if (newY < -8)
757  {
758  newY = -8;
759  }
760  else if (newY + mHeight > screenHeight + 8)
761  {
762  newY = (fp32_hf)(screenHeight - mHeight + 8);
763  }
764 
765  mDragPosX = (int32_hf)(mX + x - newX);
766  mDragPosY = (int32_hf)(mY + y - newY);
767 
768  if (mDragPosX < 8)
769  {
770  mDragPosX = 8;
771  }
772  else if (mDragPosX > mWidth - 9)
773  {
774  mDragPosX = (int32_hf)mWidth - 9;
775  }
776 
777  if (mDragPosY < 8)
778  {
779  mDragPosY = 8;
780  }
781  else if (mDragPosY > mHeight - 9)
782  {
783  mDragPosY = (int32_hf)mHeight - 9;
784  }
785 
787  resize(newX, newY, (int32_hf)mWidth, (int32_hf)mHeight);
788  }
789 }
790 
792 {
793  if (mDragging)
794  {
795  fp32_hf x = (mouse.x - mX);
796  fp32_hf y = (mouse.y - mY);
797  int32_hf screenWidth = HFCORE_ENV->getLogicalScreenWidth();
798  int32_hf screenHeight = HFCORE_ENV->getLogicalScreenHeight();
799 
800  fp32_hf newX = (fp32_hf)(mX + x - mDragPosX);
801  fp32_hf newY = (fp32_hf)(mY + y - mDragPosY);
802 
803  if (newX < -8)
804  {
805  newX = -8;
806  }
807  else if (newX + mWidth > screenWidth + 8)
808  {
809  newX = (fp32_hf)(screenWidth - mWidth + 8);
810  }
811 
812  if (newY < -8)
813  {
814  newY = -8;
815  }
816  else if (newY + mHeight > screenHeight + 8)
817  {
818  newY = (fp32_hf)(screenHeight - mHeight + 8);
819  }
820 
821  mDragPosX = (int32_hf)(mX + x - newX);
822  mDragPosY = (int32_hf)(mY + y - newY);
823 
824  if (mDragPosX < 8)
825  {
826  mDragPosX = 8;
827  }
828  else if (mDragPosX > mWidth - 9)
829  {
830  mDragPosX = (int32_hf)mWidth - 9;
831  }
832 
833  if (mDragPosY < 8)
834  {
835  mDragPosY = 8;
836  }
837  else if (mDragPosY > mHeight - 9)
838  {
839  mDragPosY = (int32_hf)mHeight - 9;
840  }
841 
843  resize(newX, newY, (int32_hf)mWidth, (int32_hf)mHeight);
844  }
845 }
846 
848 {
849  if (mouse.clickCount == 1 && mDialogMovable)
850  {
851  if (!mDragging && mDialogListener != NULL)
852  {
855  }
856  mDragging = true;
857  mDragPosX = (int32_hf)(mouse.x - mX);
858  mDragPosY = (int32_hf)(mouse.y - mY);
859  }
861 }
862 
864 {
865  if (mDragging)
866  {
867  if (mDialogListener != NULL)
868  {
871  }
872  mDragging = false;
873  }
874  Widget::mouseButtonUp(mouse);
875 }
876 
878 {
879  if ((id == ID_YES) || (id == ID_NO) || mUsingCustomButtons)
880  {
883  }
884 }
885 
887 {
888  if ((id == ID_YES) || (id == ID_NO) || mUsingCustomButtons)
889  {
890  mResult = id;
892  }
893 }
894 
896 {
897 }
898 
900 {
901  if ((id == ID_YES) || (id == ID_NO) || mUsingCustomButtons)
902  {
903  mResult = id;
906  }
907 }
908 
910 {
911  if ((id == ID_YES) || (id == ID_NO) || mUsingCustomButtons)
912  {
913  mResult = id;
916  }
917 }
void endBatch(Graphics *g, bool render)
End current Batch.
int32_hf mSpaceAfterHeader
Holds space after header offset.
Definition: DialogWidget.h:496
virtual int32_hf waitForResult(bool autoKill=true)
Wait for result.
Rect drawCenteredString(Graphics *g, Font *font, Color color, int32_hf y, int32_hf widgetPosX, int32_hf widgetWidth, const UString &string, fp32_hf scale=1.0f)
Draw a centered string.
bool mIsModal
Flag indicating whether dialog is modal.
Definition: DialogWidget.h:526
int32_hf mLineSpacingOffset
Holds line spacing offset.
Definition: DialogWidget.h:471
Color for hilite label text.
Definition: ButtonWidget.h:135
Interface for all rendering related things.
int32_hf mPriority
Holds Widget priority (not used!).
Font * mFontLines
Holds pointer to Font to use for lines text.
Definition: DialogWidget.h:424
UString mDialogFooter
Holds dialog footer text.
Definition: DialogWidget.h:439
Insets mContentInsets
Holds content Insets.
Definition: DialogWidget.h:491
fp32_hf x
X coordinate, relative to window.
Definition: Touch.h:55
int32_hf mTop
Holds top inset.
Definition: Insets.h:68
virtual void dialogButtonMouseLeave(int32_hf dialogId, int32_hf buttonId)
Called automatically when a dialogButtonMouseLeave event occurs.
virtual void setBatchUIUpdateNeeded(bool update)
Set BatchUI update needed flag.
Definition: Widget.cpp:503
DialogListener * mDialogListener
Holds pointer to DialogListener class.
Definition: DialogWidget.h:373
virtual void dialogButtonMouseEnter(int32_hf dialogId, int32_hf buttonId)
Called automatically when a dialogButtonMouseEnter event occurs.
Rect mDialogRect
Holds dialog Rect.
Definition: DialogWidget.h:388
Image * mAtlasImage
Holds pointer to atlas Image.
Definition: DialogWidget.h:383
Interface for unicode string class UString.
Definition: UString.h:35
fp32_hf y
Y coordinate, relative to window.
Definition: Mouse.h:69
UString DIALOG_CANCEL_STRING
Holds string used for &#39;Cancel&#39; button. It&#39;s initially hardcoded to the string &#39;Cancel&#39;.
virtual int32_hf getLineSpacing()=0
Get Font line spacing.
DialogButtonWidget * mYesOkButton
Holds pointer to Yes/OK DialogButtonWidget.
Definition: DialogWidget.h:404
fp32_hf getWidth() const
Get Rect Width (or maxX).
Definition: Rect.h:168
int32_hf drawWordWrappedString(Graphics *g, Font *font, Color color, const Rect &rect, const UString &string, int32_hf lineSpacing=-1, int32_hf valign=TEXT_VALIGN_TOP, int32_hf halign=TEXT_HALIGN_LEFT, bool renderString=true, fp32_hf scale=1.0f)
Draw a word wrapped string within given rect Rect area and specified halign and valign horizontal and...
bool mUsingCustomButtons
Flag indicating if using custom buttons or not.
Definition: DialogWidget.h:399
#define HF_SAFE_DELETE(p)
Check if not NULL, delete and set to NULL.
Definition: HFDataTypes.h:49
virtual void dialogStartDrag(int32_hf dialogId)
Called automatically when a dialogStartDrag event occurs.
int int32_hf
A type definition for int.
Definition: HFDataTypes.h:349
Font * mFontHeader
Holds pointer to Font to use for header text.
Definition: DialogWidget.h:419
Two buttons: Yes and No.
Definition: DialogWidget.h:120
bool mHasTransparencies
Flag indicating if Widget has transparencies or not.
Definition: Widget.h:1075
UString DIALOG_YES_STRING
Holds string used for &#39;Yes&#39; button. It&#39;s initially hardcoded to the string &#39;Yes&#39;. ...
int32_hf mBottom
Holds bottom inset.
Definition: Insets.h:78
Insets mBackgroundInsets
Holds background Insets.
Definition: DialogWidget.h:486
static Rect ZERO()
Initialize Rect with 0 for all members.
Definition: Rect.h:141
virtual void touchUp(Touch::TouchInfo touch)
Called automatically when Touch up event occurs.
Definition: Widget.cpp:264
virtual void buttonDownTick(int32_hf id)
Called automatically when a buttonDownTick event occurs.
fp32_hf mX
Holds Widget X position.
Interface for UI DialogButtonWidget used in DialogWidget.
int32_hf mButtonSidePadding
Holds button side padding value.
Definition: DialogWidget.h:541
DialogButtonWidget * mNoCancelButton
Holds pointer to No/Cancel DialogButtonWidget.
Definition: DialogWidget.h:409
Interface for UI DialogButtonWidget used in DialogWidget.
int32_hf mLeft
Holds left inset.
Definition: Insets.h:63
fp32_hf x
X coordinate, relative to window.
Definition: Mouse.h:68
Interface for DialogWidget listener callback methods.
virtual void touchUp(Touch::TouchInfo touch)
Called automatically when Touch up event occurs.
int32_hf mDragPosX
Holds drag position X.
Definition: DialogWidget.h:511
int32_hf mDragPosY
Holds drag position Y.
Definition: DialogWidget.h:516
virtual void setColor(int32_hf idx, const Color &color)
Set Color for given idx and store in internal Widget::ColorVector.
Definition: Widget.cpp:123
virtual void touchMove(Touch::TouchInfo touch)
Called automatically when Touch move/drag event occurs.
A structure that contains Touch event information.
Definition: Touch.h:50
virtual void setHeaderFont(Font *font)
Set header Font to use.
fp32_hf width()
Get Widget width.
Definition: Widget.h:994
virtual void removedFromManager(WidgetManager *widgetManager)
Call removedFromManager() for all Widget&#39;s in internal list.
virtual void setLinesFont(Font *font)
Set lines Font to use.
fp32_hf getY() const
Get Rect Y (or minY).
Definition: Rect.h:159
virtual void addedToManager(WidgetManager *widgetManager)
Call addedToManager() for all Widget&#39;s in internal list.
Interface for Resource type Image.
#define HFCORE_RESMGR
Get HFCore::ResourceManager instance shortcut macro.
Definition: Environment.h:73
virtual int32_hf getHeight()=0
Get Font height.
#define NULL
Convenient define for 0.
Definition: HFDataTypes.h:42
int32_hf mButtonHorzSpacing
Holds button horizontal spacing value.
Definition: DialogWidget.h:536
virtual void setButtonFont(Font *font)
Set button Font to use.
Useful for static content.
Definition: Graphics.h:199
virtual Graphics::MinFilter getMinRenderFilter()
Get Graphics::MinFilter currently set.
Definition: Widget.cpp:488
Vertical text alignment TOP.
Definition: Widget.h:181
int32_hf mButtonMode
Holds button mode in use. Valid values are: DialogWidget::BUTTONS_NONE, DialogWidget::BUTTONS_YES_NO...
Definition: DialogWidget.h:452
virtual bool isModal()
Determine whether Dialog is modal.
int32_hf length() const
Get the length of the string.
Definition: UString.cpp:178
virtual void dialogButtonDown(int32_hf dialogId, int32_hf buttonId)
Called automatically when a dialogButtonDown event occurs.
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
virtual void removeWidget(Widget *widget)
Remove a Widget and call removedFromManager().
A structure that contains Mouse event information.
Definition: Mouse.h:63
virtual void orderInManagerChanged()
Method for controlling if order in manager has changed.
Definition: Widget.cpp:92
virtual void removedFromManager(WidgetManager *widgetManager)
Call removedFromManager() for all Widget&#39;s in internal list.
virtual void dialogButtonUp(int32_hf dialogId, int32_hf buttonId)
Called automatically when a dialogButtonUp event occurs.
Two buttons: OK and Cancel.
Definition: DialogWidget.h:121
virtual Graphics::MagFilter getMagRenderFilter()
Get Graphics::MagFilter currently set.
Definition: Widget.cpp:483
int32_hf mNumButtons
Holds number of buttons in use.
Definition: DialogWidget.h:429
int32_hf tapCount
Tap count.
Definition: Touch.h:60
WidgetManager manages Widget&#39;s and interacts with Game interface.
virtual void buttonMouseEnter(int32_hf id)
Called automatically when a buttonMouseEnter event occurs.
virtual void addWidget(Widget *widget)
Adds a new Widget and call addedToManager().
int32_hf mButtonHeight
Holds button height.
Definition: DialogWidget.h:481
fp32_hf y
Y coordinate, relative to window.
Definition: Touch.h:56
Color for normal label text.
Definition: ButtonWidget.h:134
Font * mFontButton
Holds pointer to Font to use for button text.
Definition: DialogWidget.h:414
virtual void setColor(int32_hf idx, const Color &color)
Set Color for given idx and store in internal Widget::ColorVector.
fp32_hf getX() const
Get Rect X (or minX).
Definition: Rect.h:150
virtual void mouseButtonDown(Mouse::MouseInfo mouse)
Called automatically when Mouse button down event occurs.
virtual void setLabel(UString &label)
Set label text.
bool killDialog(int32_hf dialogId, bool removeDialog, bool deleteDialog)
Kill DialogWidget with given dialogId.
virtual void addedToManager(WidgetManager *widgetManager)
Call addedToManager() for all Widget&#39;s in internal list.
virtual void mouseButtonUp(Mouse::MouseInfo mouse)
Called automatically when Mouse button up event occurs.
Definition: Widget.cpp:280
virtual void buttonUp(int32_hf id)
Called automatically when a buttonUp event occurs.
virtual void putInfront(Widget *widget, Widget *refWidget)
Put widget in front of refWidget.
virtual void touchDown(Touch::TouchInfo touch)
Called automatically when Touch down event occurs.
fp32_hf mY
Holds Widget Y position.
int32_hf mId
Holds Dialog ID.
Definition: DialogWidget.h:521
UString mDialogLines
Holds dialog lines text.
Definition: DialogWidget.h:444
UString DIALOG_NO_STRING
Holds string used for &#39;No&#39; button. It&#39;s initially hardcoded to the string &#39;No&#39;.
Interface for ResourceManager which handles all Resource loading etc.
Definition: Actor.h:34
virtual void orderInManagerChanged()
Method for controlling if order in manager has changed.
virtual int32_hf getPreferredHeight(int32_hf width)
Calculate the preferred height of the Dialog.
Interface for Resource type Image.
Definition: Image.h:63
Interface for DialogWidget listener callback methods.
Interface for Resource type Font.
Definition: Font.h:84
UString mDialogHeader
Holds dialog header text.
Definition: DialogWidget.h:434
Singleton interface for platform specific things.
Draw mode default / normal.
Definition: Graphics.h:143
virtual void update(fp32_hf dt)
Called by the framework once for every iteration of the game loop, immediately before rendering takes...
Definition: Widget.cpp:225
int32_hf mButtonWidth
Holds button width.
Definition: DialogWidget.h:476
int32_hf mTextVAlign
Holds text vertical alignment. Valid values are: Widget::TEXT_VALIGN_TOP, Widget::TEXT_VALIGN_CENTER...
Definition: DialogWidget.h:466
void drawImage(Graphics *g, Image *img, fp32_hf x, fp32_hf y, fp32_hf alpha=1.0f, Graphics::DrawMode drawMode=Graphics::DRAWMODE_NORMAL, Graphics::MagFilter magFilter=Graphics::MAGFILTER_LINEAR, Graphics::MinFilter minFilter=Graphics::MINFILTER_LINEAR)
Draw a Image.
Definition: RenderHelper.h:530
virtual void mouseMove(Mouse::MouseInfo mouse)
Called automatically when Mouse motion event occurs.
bool mHasAlpha
Flag indicating if Widget has Alpha or not.
virtual void update(fp32_hf dt)
Called by the framework once for every iteration of the game loop, immediately before rendering takes...
Specialized Boundary representing a Rect.
Definition: Rect.h:34
virtual void buttonDown(int32_hf id, int32_hf clickCount)
Called automatically when a buttonDown event occurs.
#define HFCORE_ENV
Get HFCore::Environment instance shortcut macro.
Definition: Environment.h:68
Interface for all rendering related things.
Definition: Graphics.h:120
virtual void mouseButtonDown(Mouse::MouseInfo mouse)
Called automatically when Mouse button down event occurs.
Definition: Widget.cpp:276
bool mDragging
Flag indicating whether dialog is dragging or not.
Definition: DialogWidget.h:506
WidgetManager manages Widget&#39;s and interacts with Game interface.
int32_hf mRight
Holds right inset.
Definition: Insets.h:73
void beginBatch(Graphics *g, Graphics::BatchMode mode, Rect clipRect=Rect::ZERO())
Begin Batch using specified Graphics::BatchMode and optional clipping Rect.
virtual void dialogStopDrag(int32_hf dialogId)
Called automatically when a dialogStopDrag event occurs.
virtual int32_hf getHeight()=0
Get the Image original height.
virtual void setColors(int32_hf colors[][3], int32_hf numColors)
Set RGB colors.
Definition: Widget.cpp:107
fp32_hf getHeight() const
Get Rect Height (or maxY).
Definition: Rect.h:177
virtual ~DialogWidget()
Destructor.
Interface for Widget Inset.
Definition: Insets.h:34
Image * mDialogImage
Holds pointer to dialog Image.
Definition: DialogWidget.h:378
int32_hf mTextHAlign
Holds text horizontal alignment. Valid values are: Widget::TEXT_HALIGN_LEFT, Widget::TEXT_HALIGN_CENT...
Definition: DialogWidget.h:459
virtual void resize(fp32_hf x, fp32_hf y, int32_hf w, int32_hf h)
Resize Widget.
ColorVector mColors
Vector holding Color&#39;s set by setColor() and setColors().
Definition: Widget.h:1081
virtual void draw(Graphics *g)
Called by the framework once for every iteration of the main loop.
Created in CustomDialog class.
Definition: DialogWidget.h:123
UString DIALOG_OK_STRING
Holds string used for &#39;OK&#39; button. It&#39;s initially hardcoded to the string &#39;OK&#39;.
bool mDeleteDialogImage
Flag indicating if dialog Image should be deleted or not.
Definition: DialogWidget.h:394
WidgetManager * mWidgetManager
Pointer to WidgetManager.
bool mDialogMovable
Flag indicating whether dialog is movable.
Definition: DialogWidget.h:501
fp32_hf height()
Get Widget height.
Definition: Widget.h:1001
int32_hf clickCount
Mouse click count.
Definition: Mouse.h:73
int32_hf mResult
Holds result value.
Definition: DialogWidget.h:531
virtual void setDeleteDialogImage(bool deleteDialogImage)
Set delete dialog Image flag.
virtual int32_hf getWidth()=0
Get the Image original width.
virtual int32_hf getWordWrappedHeight(Graphics *g, Font *font, const Rect &rect, const UString &line, int32_hf lineSpacing=-1)
Get word wrapped height for given text line.
Definition: Widget.cpp:391
fp32_hf mWidth
Holds Widget width.
Interface for UI DialogWidget.
virtual void touchDown(Touch::TouchInfo touch)
Called automatically when Touch down event occurs.
Definition: Widget.cpp:260
virtual void mouseButtonUp(Mouse::MouseInfo mouse)
Called automatically when Mouse button up event occurs.
float fp32_hf
A type definition for float.
Definition: HFDataTypes.h:359
virtual void buttonMouseLeave(int32_hf id)
Called automatically when a buttonMouseLeave event occurs.
DialogWidget(int32_hf id, DialogListener *dialogListener, Image *dialogImage, bool isModal, const UString &dialogHeader, const UString &dialogLines, const UString &dialogFooter, int32_hf buttonMode, Font *fontButton, Image *buttonImage=NULL, Image *buttonImageOver=NULL, Image *buttonImageDown=NULL, Image *buttonImageDisabled=NULL)
Constructor.
fp32_hf mHeight
Holds Widget height.
Horizontal text alignment CENTER.
Definition: Widget.h:172