| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- // DummyDriverConfig.cpp: implementation of the CDummyRoboDriverConfig class.
- //
- //////////////////////////////////////////////////////////////////////
- #include <stdio.h>
- #include "DummyDriverConfig.h"
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CDummyRoboDriverConfig::CDummyRoboDriverConfig(IUserDialogFactory *pDialogFactory)
- : m_pDialogFactory(pDialogFactory)
- {
- m_pDialog = NULL;
- m_pParallelize = NULL;
- /** Install the watchdog to recieve any dialog changes on user interaction. */
- if(m_pDialogFactory != NULL)
- m_pDialogFactory->InstallWatchdog(this);
- }
- CDummyRoboDriverConfig::~CDummyRoboDriverConfig()
- {
- }
-
- void CDummyRoboDriverConfig::ValueChanged(const char *szName)
- {
- #define VCON(name,call) if (!strcmp(name,szName)) call();
- VCON(ABSTRACTUSERDIALOG_CANCEL, OnQuit);
- VCON("OK", OnOk);
- VCON(CONFIG_PRINTBEFOREBURN, OnPrintOrderChanged);
- #undef VCON
- /* Variable changes are notified by calling this method */
- }
- void CDummyRoboDriverConfig::Exec()
- {
- if(m_pDialogFactory != NULL)
- {
- const char *szDriverName = m_pDialogFactory->GetOEMName(DUMMYDRIVER_ID);
- const char *szTitleTemplate = "%s Driver Configuration";
- char *szWindowTitle = NULL;
-
- if((szDriverName != NULL) && (szTitleTemplate != NULL))
- {
- szWindowTitle = new char[strlen(szDriverName) + strlen(szTitleTemplate) + 1];
- if(szWindowTitle != NULL)
- sprintf(szWindowTitle, szTitleTemplate, szDriverName);
- }
- /** At first create our configuration dialog window with the driver name in title. */
- m_pDialog = m_pDialogFactory->CreateUserDialog(szWindowTitle);
- if(szWindowTitle != NULL)
- delete [] szWindowTitle, szWindowTitle = NULL;
- if(m_pDialog != NULL)
- {
- /** Create our two check boxes. */
- CreateDialogContent();
- /** Create the defaul 'OK' and 'Cancel' button */
- IUserDialogContainer *pButtons = m_pDialog->CreateHBox(DE_OPTION_ALIGN_RIGHT);
- if(pButtons != NULL)
- {
- pButtons->CreatePushButton(100, 0, DE_OPTION_ALIGN_CENTER, "OK", "OK");
- pButtons->CreatePushButton(100, 0, DE_OPTION_ALIGN_CENTER, ABSTRACTUSERDIALOG_CANCEL, "Cancel");
- }
- m_pDialog->Exec();
- delete m_pDialog; m_pDialog=NULL;
- };
- };
- }
- void CDummyRoboDriverConfig::OnPrintOrderChanged()
- {
- if((m_pParallelize != NULL) && (m_pDialogFactory != NULL))
- {
- BOOL bCanParallelize =!m_pDialogFactory->GetConfigurationValueBOOL(CONFIG_PRINTBEFOREBURN, DEFAULTCONFIG_PRINTBEFOREBURN);
- if(bCanParallelize)
- m_pParallelize->SetSensitive(TRUE);
- else
- {
- m_pDialogFactory->SetConfigurationValueBOOL(CONFIG_PARALLELIZE, FALSE);
- m_pParallelize->SetSensitive(FALSE);
- }
- }
- }
- void CDummyRoboDriverConfig::OnQuit()
- {
- if(m_pDialog != NULL)
- m_pDialog->Quit();
- }
- void CDummyRoboDriverConfig::OnOk()
- {
- if(m_pDialog != NULL)
- m_pDialog->Quit();
- }
- void CDummyRoboDriverConfig::CreateDialogContent()
- {
- m_pDialog->CreateCheckBox(DE_OPTION_ALIGN_LEFT, CONFIG_PRINTBEFOREBURN, "Print before burning", DEFAULTCONFIG_PRINTBEFOREBURN);
- m_pParallelize = m_pDialog->CreateCheckBox(DE_OPTION_ALIGN_LEFT, CONFIG_PARALLELIZE, "Parallelize burning and printing", DEFAULTCONFIG_PARALLELIZE);
- OnPrintOrderChanged();
- }
|