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.

dialog_box_base_class.cpp 3.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*****************************
  2. * dialog_box_base_class.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. #ifdef FTDI_DIALOG_BOX_BASE_CLASS
  24. using namespace FTDI;
  25. using namespace Theme;
  26. #define GRID_COLS 2
  27. #define GRID_ROWS 8
  28. template<typename T>
  29. void DialogBoxBaseClass::drawMessage(T message, const int16_t font) {
  30. CommandProcessor cmd;
  31. cmd.cmd(CMD_DLSTART)
  32. .cmd(CLEAR_COLOR_RGB(bg_color))
  33. .cmd(CLEAR(true,true,true))
  34. .cmd(COLOR_RGB(bg_text_enabled))
  35. .tag(0);
  36. draw_text_box(cmd, BTN_POS(1,1), BTN_SIZE(2,6), message, OPT_CENTER, font ? font : font_large);
  37. cmd.colors(normal_btn);
  38. }
  39. template void DialogBoxBaseClass::drawMessage(PGM_P const, const int16_t);
  40. void DialogBoxBaseClass::drawYesNoButtons(uint8_t default_btn) {
  41. CommandProcessor cmd;
  42. cmd.font(font_medium)
  43. .colors(default_btn == 1 ? action_btn : normal_btn).tag(1).button(BTN_POS(1,8), BTN_SIZE(1,1), GET_TEXT_F(MSG_YES))
  44. .colors(default_btn == 2 ? action_btn : normal_btn).tag(2).button(BTN_POS(2,8), BTN_SIZE(1,1), GET_TEXT_F(MSG_NO));
  45. }
  46. void DialogBoxBaseClass::drawOkayButton() {
  47. CommandProcessor cmd;
  48. cmd.font(font_medium)
  49. .tag(1).button(BTN_POS(1,8), BTN_SIZE(2,1), GET_TEXT_F(MSG_BUTTON_OKAY));
  50. }
  51. template<typename T>
  52. void DialogBoxBaseClass::drawButton(T label) {
  53. CommandProcessor cmd;
  54. cmd.font(font_medium)
  55. .tag(1).button(BTN_POS(1,8), BTN_SIZE(2,1), label);
  56. }
  57. template void DialogBoxBaseClass::drawButton(const char *);
  58. template void DialogBoxBaseClass::drawButton(FSTR_P);
  59. bool DialogBoxBaseClass::onTouchEnd(uint8_t tag) {
  60. switch (tag) {
  61. case 1: GOTO_PREVIOUS(); return true;
  62. case 2: GOTO_PREVIOUS(); return true;
  63. default: return false;
  64. }
  65. }
  66. void DialogBoxBaseClass::onIdle() {
  67. reset_menu_timeout();
  68. }
  69. #endif // FTDI_DIALOG_BOX_BASE_CLASS