Leaked source code of windows server 2003
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.

202 lines
4.9 KiB

  1. // Copyright (c) 1997-1999 Microsoft Corporation
  2. //
  3. // wizard base class
  4. //
  5. // 12-15-97 sburns
  6. #ifndef WIZARD_HPP_INCLUDED
  7. #define WIZARD_HPP_INCLUDED
  8. // A Wizard manages the traversal of 1+ WizardPage instances.
  9. class Wizard
  10. {
  11. public:
  12. // These values allow evil hacks to access the buttons on the wizard
  13. // control with GetDlgItem. I discovered the control IDs by using spy++,
  14. // see also
  15. // Don't lecture me about sleazy comctl32 hacks, ok?
  16. enum ButtonIds
  17. {
  18. BACK_BTN_ID = 12323,
  19. NEXT_BTN_ID = 12324,
  20. FINISH_BTN_ID = 12325,
  21. HELP_BTN_ID = 9
  22. };
  23. Wizard(
  24. unsigned titleStringResID,
  25. unsigned banner16BitmapResID,
  26. unsigned banner256BitmapResID,
  27. unsigned watermark16BitmapResID,
  28. unsigned watermark1256BitmapResID);
  29. ~Wizard();
  30. // Adds the page to the wizard. Takes ownership of the instance, and
  31. // will delete it when the Wizard is deleted.
  32. void
  33. AddPage(WizardPage* page);
  34. // Invokes Create on all of the pages that have been added.
  35. // Calls Win32 ::PropertySheet to display and (modally) execute the
  36. // wizard. Returns same values as ::PropertySheet.
  37. //
  38. // parentWindow - in, optional, handle to parent window. Default is 0,
  39. // for which the current desktop window will be used.
  40. //
  41. // startPageIndex - in, optional, the index of the page to start the
  42. // wizard at. Default is 0, which is the first page that is added
  43. // using the AddPage method.
  44. //
  45. // sheetCallback - in, optional, pointer to a property sheet callback
  46. // function that will be called by ComCtl32 when the property sheet
  47. // is being created and destroyed.
  48. INT_PTR
  49. ModalExecute(
  50. HWND parentWindow = 0,
  51. UINT startPageIndex = 0,
  52. PFNPROPSHEETCALLBACK sheetCallback = 0);
  53. // Pushes the current page id on the backtracking stack, and causes the
  54. // given page to be transitioned to. Should be called in the OnSetActive or
  55. // OnWizNext method of a WizardPage instance (which is the default behavior
  56. // of the WizardPage base class).
  57. //
  58. // wizardPage - window handle of the current page (the page that is
  59. // handling OnSetActive or OnWizNext)
  60. //
  61. // pageResId - the resource ID of the next page to be shown.
  62. void
  63. SetNextPageID(HWND wizardPage, int pageResId);
  64. // Pops the last page id off the history stack, and sets that page to be
  65. // transitioned to. Should be called in the OnSetActive or OnWizBack
  66. // method of a WizardPage instance (which is the default behavior of the
  67. // WizardPage base class).
  68. //
  69. // wizardPage - window handle of the current page (the page that is
  70. // handling OnSetActive or OnWizBack)
  71. void
  72. Backtrack(HWND wizardPage);
  73. // Returns true if Backtrack was the last function called to cause a page
  74. // transition, false if not. By checking IsBacktracking in OnSetActive, a
  75. // WizardPage can determine if it was transitioned to by the user backing
  76. // up (IsBacktracking = true) or moving forward (IsBacktracking = false).
  77. bool
  78. IsBacktracking();
  79. private:
  80. // not implemented: copy not allowed
  81. Wizard(const Wizard&);
  82. const Wizard& operator=(const Wizard&);
  83. typedef
  84. std::list<WizardPage*, Burnslib::Heap::Allocator<WizardPage*> >
  85. PageList;
  86. typedef
  87. std::vector<unsigned, Burnslib::Heap::Allocator<unsigned> >
  88. UIntVector;
  89. // we derive a new stack class from std::stack to get at the protected
  90. // container member of that base class. We need to do this for our
  91. // loop collapsing logic.
  92. class PageIdStack : public std::stack<unsigned, UIntVector>
  93. {
  94. public:
  95. typedef std::stack<unsigned, UIntVector> base;
  96. PageIdStack() : base()
  97. {
  98. }
  99. void
  100. pop_and_remove_loops();
  101. void
  102. push(const value_type& x)
  103. {
  104. LOG(String::format(L"push %1!d!", x));
  105. base::push(x);
  106. // dump();
  107. }
  108. private:
  109. // void
  110. // dump()
  111. // {
  112. // LOG(String::format(L"%1!d!", size()));
  113. //
  114. // for (int i = 0; i < size(); ++i)
  115. // {
  116. // LOG(String::format(L"%1!d!", c[i]));
  117. // }
  118. //
  119. // // for(
  120. // // UIntVector::iterator i = c.begin();
  121. // // i != c.end();
  122. // // ++i)
  123. // // {
  124. // // LOG(String::format(L"%1!d!", *i));
  125. // // }
  126. // }
  127. };
  128. unsigned banner16ResId;
  129. unsigned banner256ResId;
  130. bool isBacktracking;
  131. PageIdStack pageIdHistory;
  132. PageList pages;
  133. unsigned titleResId;
  134. unsigned watermark16ResId;
  135. unsigned watermark256ResId;
  136. };
  137. #endif // WIZARD_HPP_INCLUDED