DummyDriverConfig.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. // DummyDriverConfig.cpp: implementation of the CDummyRoboDriverConfig class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include <stdio.h>
  5. #include "DummyDriverConfig.h"
  6. //////////////////////////////////////////////////////////////////////
  7. // Construction/Destruction
  8. //////////////////////////////////////////////////////////////////////
  9. CDummyRoboDriverConfig::CDummyRoboDriverConfig(IUserDialogFactory *pDialogFactory)
  10. : m_pDialogFactory(pDialogFactory)
  11. {
  12. m_pDialog = NULL;
  13. m_pParallelize = NULL;
  14. /** Install the watchdog to recieve any dialog changes on user interaction. */
  15. if(m_pDialogFactory != NULL)
  16. m_pDialogFactory->InstallWatchdog(this);
  17. }
  18. CDummyRoboDriverConfig::~CDummyRoboDriverConfig()
  19. {
  20. }
  21. void CDummyRoboDriverConfig::ValueChanged(const char *szName)
  22. {
  23. #define VCON(name,call) if (!strcmp(name,szName)) call();
  24. VCON(ABSTRACTUSERDIALOG_CANCEL, OnQuit);
  25. VCON("OK", OnOk);
  26. VCON(CONFIG_PRINTBEFOREBURN, OnPrintOrderChanged);
  27. #undef VCON
  28. /* Variable changes are notified by calling this method */
  29. }
  30. void CDummyRoboDriverConfig::Exec()
  31. {
  32. if(m_pDialogFactory != NULL)
  33. {
  34. const char *szDriverName = m_pDialogFactory->GetOEMName(DUMMYDRIVER_ID);
  35. const char *szTitleTemplate = "%s Driver Configuration";
  36. char *szWindowTitle = NULL;
  37. if((szDriverName != NULL) && (szTitleTemplate != NULL))
  38. {
  39. szWindowTitle = new char[strlen(szDriverName) + strlen(szTitleTemplate) + 1];
  40. if(szWindowTitle != NULL)
  41. sprintf(szWindowTitle, szTitleTemplate, szDriverName);
  42. }
  43. /** At first create our configuration dialog window with the driver name in title. */
  44. m_pDialog = m_pDialogFactory->CreateUserDialog(szWindowTitle);
  45. if(szWindowTitle != NULL)
  46. delete [] szWindowTitle, szWindowTitle = NULL;
  47. if(m_pDialog != NULL)
  48. {
  49. /** Create our two check boxes. */
  50. CreateDialogContent();
  51. /** Create the defaul 'OK' and 'Cancel' button */
  52. IUserDialogContainer *pButtons = m_pDialog->CreateHBox(DE_OPTION_ALIGN_RIGHT);
  53. if(pButtons != NULL)
  54. {
  55. pButtons->CreatePushButton(100, 0, DE_OPTION_ALIGN_CENTER, "OK", "OK");
  56. pButtons->CreatePushButton(100, 0, DE_OPTION_ALIGN_CENTER, ABSTRACTUSERDIALOG_CANCEL, "Cancel");
  57. }
  58. m_pDialog->Exec();
  59. delete m_pDialog; m_pDialog=NULL;
  60. };
  61. };
  62. }
  63. void CDummyRoboDriverConfig::OnPrintOrderChanged()
  64. {
  65. if((m_pParallelize != NULL) && (m_pDialogFactory != NULL))
  66. {
  67. BOOL bCanParallelize =!m_pDialogFactory->GetConfigurationValueBOOL(CONFIG_PRINTBEFOREBURN, DEFAULTCONFIG_PRINTBEFOREBURN);
  68. if(bCanParallelize)
  69. m_pParallelize->SetSensitive(TRUE);
  70. else
  71. {
  72. m_pDialogFactory->SetConfigurationValueBOOL(CONFIG_PARALLELIZE, FALSE);
  73. m_pParallelize->SetSensitive(FALSE);
  74. }
  75. }
  76. }
  77. void CDummyRoboDriverConfig::OnQuit()
  78. {
  79. if(m_pDialog != NULL)
  80. m_pDialog->Quit();
  81. }
  82. void CDummyRoboDriverConfig::OnOk()
  83. {
  84. if(m_pDialog != NULL)
  85. m_pDialog->Quit();
  86. }
  87. void CDummyRoboDriverConfig::CreateDialogContent()
  88. {
  89. m_pDialog->CreateCheckBox(DE_OPTION_ALIGN_LEFT, CONFIG_PRINTBEFOREBURN, "Print before burning", DEFAULTCONFIG_PRINTBEFOREBURN);
  90. m_pParallelize = m_pDialog->CreateCheckBox(DE_OPTION_ALIGN_LEFT, CONFIG_PARALLELIZE, "Parallelize burning and printing", DEFAULTCONFIG_PARALLELIZE);
  91. OnPrintOrderChanged();
  92. }