My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

alert_dialog_box.cpp 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /************************
  2. * alert_dialog_box.cpp *
  3. ************************/
  4. /****************************************************************************
  5. * Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
  6. * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
  7. * *
  8. * This program is free software: you can redistribute it and/or modify *
  9. * it under the terms of the GNU General Public License as published by *
  10. * the Free Software Foundation, either version 3 of the License, or *
  11. * (at your option) any later version. *
  12. * *
  13. * This program is distributed in the hope that it will be useful, *
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  16. * GNU General Public License for more details. *
  17. * *
  18. * To view a copy of the GNU General Public License, go to the following *
  19. * location: <https://www.gnu.org/licenses/>. *
  20. ****************************************************************************/
  21. #include "../config.h"
  22. #include "../screens.h"
  23. #include "../screen_data.h"
  24. #ifdef FTDI_ALERT_DIALOG_BOX
  25. constexpr static AlertDialogBoxData &mydata = screen_data.AlertDialogBox;
  26. using namespace FTDI;
  27. using namespace Theme;
  28. void AlertDialogBox::onEntry() {
  29. BaseScreen::onEntry();
  30. sound.play(mydata.isError ? sad_trombone : twinkle, PLAY_ASYNCHRONOUS);
  31. }
  32. void AlertDialogBox::onRedraw(draw_mode_t what) {
  33. if (what & FOREGROUND) {
  34. drawOkayButton();
  35. }
  36. }
  37. template<typename T>
  38. void AlertDialogBox::show(T message) {
  39. drawMessage(message);
  40. storeBackground();
  41. mydata.isError = false;
  42. GOTO_SCREEN(AlertDialogBox);
  43. }
  44. template<typename T>
  45. void AlertDialogBox::showError(T message) {
  46. drawMessage(message);
  47. storeBackground();
  48. mydata.isError = true;
  49. GOTO_SCREEN(AlertDialogBox);
  50. }
  51. void AlertDialogBox::hide() {
  52. if (AT_SCREEN(AlertDialogBox))
  53. GOTO_PREVIOUS();
  54. }
  55. template void AlertDialogBox::show(const char *);
  56. template void AlertDialogBox::show(FSTR_P);
  57. template void AlertDialogBox::showError(const char *);
  58. template void AlertDialogBox::showError(FSTR_P);
  59. #endif // FTDI_ALERT_DIALOG_BOX