home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / appwiz / customwz / chooser.cpp next >
C/C++ Source or Header  |  1998-03-05  |  3KB  |  94 lines

  1. // chooser.cpp : implementation of the CDialogChooser class
  2. //
  3. // Copyright (c) 1985-1998, Microsoft Corporation. All rights reserved.
  4. //
  5.  
  6. #include "stdafx.h"
  7. #include "customwz.h"
  8. #include "sampleaw.h"
  9. #include "chooser.h"
  10. #include "typedlg.h"
  11. #include "zapdlg.h"
  12. #include "seqdlg.h"
  13.  
  14. #ifdef _PSEUDO_DEBUG
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18.  
  19. // On construction, create instances of each step we can pop up.
  20. CDialogChooser::CDialogChooser()
  21. {
  22.     m_pDlgs[0] = NULL;
  23.  
  24.     m_pDlgs[DLG_CUSTOMTYPE] = new CCustomTypeDlg;
  25.     m_pDlgs[DLG_ZAP] = new CZapDlg;
  26.     m_pDlgs[DLG_SEQUENCE] = new CSequenceDlg;
  27.  
  28.     m_nCurrDlg = 0;     // We start with the New Project dialog
  29.     m_nCustomType = CUSTOMTYPE_ZAP; // Default custom appwiz type is base
  30. }
  31.  
  32. // On deconstruction, destroy instances of each step.
  33. CDialogChooser::~CDialogChooser()
  34. {
  35.     for (int i=1; i <= NUM_DLGS; i++)
  36.     {
  37.         ASSERT(m_pDlgs[i] != NULL);
  38.         delete m_pDlgs[i];
  39.     }
  40. }
  41.  
  42. void CDialogChooser::UpdateTitleIfNecessary()
  43. {
  44.     static CString strPreviousRoot;
  45.     CString strCurrentRoot;
  46.     sampleaw.m_Dictionary.Lookup(_T("Root"), strCurrentRoot);
  47.     if (strCurrentRoot != strPreviousRoot)
  48.     {
  49.         // The project name has changed, so update the
  50.         //  default value of the custom AppWizard's title
  51.         ((CCustomTypeDlg*) m_pDlgs[DLG_CUSTOMTYPE])->UpdateTitle(strCurrentRoot);
  52.         strPreviousRoot = strCurrentRoot;
  53.     }
  54. }
  55.  
  56. // On Next, use the custom AppWizard type we're generating to determine what
  57. //  dialog to pop up.
  58. CAppWizStepDlg* CDialogChooser::Next(CAppWizStepDlg* pDlg)
  59. {
  60.     ASSERT(pDlg == m_pDlgs[m_nCurrDlg]);
  61.     ASSERT(0 == m_nCurrDlg || m_nCurrDlg == DLG_CUSTOMTYPE);
  62.  
  63.     if (pDlg == NULL)   // i.e., if the New Project Dialog is present,
  64.     {
  65.         m_nCurrDlg = DLG_CUSTOMTYPE;    // Then pop up our first step
  66.         UpdateTitleIfNecessary();   // and update title's default
  67.     }
  68.     else if (m_nCustomType == CUSTOMTYPE_ZAP)
  69.     {
  70.         m_nCurrDlg = DLG_ZAP;       // Pop up the zap step
  71.     }
  72.     else    // m_nCustomType == CUSTOMTYPE_SEQUENCE
  73.     {
  74.         m_nCurrDlg = DLG_SEQUENCE;  // Pop up the appwiz sequence step
  75.     }
  76.  
  77.     return m_pDlgs[m_nCurrDlg];
  78. }
  79.  
  80. // On Back, determine whether we should go back to the New Project
  81. //  dialog, or back to step 1.
  82. CAppWizStepDlg* CDialogChooser::Back(CAppWizStepDlg* pDlg)
  83. {
  84.     ASSERT(pDlg == m_pDlgs[m_nCurrDlg]);
  85.     ASSERT(0 < m_nCurrDlg && m_nCurrDlg <= NUM_DLGS);
  86.  
  87.     if (m_nCurrDlg == DLG_CUSTOMTYPE)
  88.         m_nCurrDlg = 0; // If we're on step 1, go to New Project dialog
  89.     else
  90.         m_nCurrDlg = DLG_CUSTOMTYPE;    // Otherwise, go to step 1
  91.  
  92.     return m_pDlgs[m_nCurrDlg];
  93. }
  94.