Source code of Windows XP (NT5)
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.

203 lines
5.0 KiB

  1. // Copyright (c) 1997-2000 Microsoft Corporation
  2. #include "pch.hxx" // pch
  3. #pragma hdrstop
  4. #include "resource.h"
  5. #include "pgWelcom.h"
  6. #include "select.h"
  7. extern HPALETTE g_hpal3D;
  8. UINT IDMapT[3][2] = { 0, IDC_TEXT1,
  9. 1, IDC_TEXT2,
  10. 2, IDC_TEXT3
  11. };
  12. // a-anilk; Re-write to use owner drawn controls: 05/08/99
  13. CWelcomePg::CWelcomePg(
  14. LPPROPSHEETPAGE ppsp
  15. ) : WizardPage(ppsp, IDS_TEXTSIZETITLE, IDS_TEXTSIZESUBTITLE)
  16. {
  17. m_dwPageId = IDD_WIZWELCOME;
  18. ppsp->pszTemplate = MAKEINTRESOURCE(m_dwPageId);
  19. m_nCurrentHilight = 0;
  20. m_nCurValueIndex = 0;
  21. }
  22. CWelcomePg::~CWelcomePg(
  23. VOID
  24. )
  25. {
  26. }
  27. LRESULT
  28. CWelcomePg::OnCommand(
  29. HWND hwnd,
  30. WPARAM wParam,
  31. LPARAM lParam
  32. )
  33. {
  34. LRESULT lResult = 1;
  35. return lResult;
  36. }
  37. LRESULT CWelcomePg::OnInitDialog(HWND hwnd, WPARAM wParam, LPARAM lParam)
  38. {
  39. SetFocus(GetDlgItem(hwnd, IDC_TEXT1));
  40. LoadString(g_hInstDll, IDS_WELCOMETEXT1, m_szWelcomeText[0], ARRAYSIZE(m_szWelcomeText[0]));
  41. LoadString(g_hInstDll, IDS_WELCOMETEXT2, m_szWelcomeText[1], ARRAYSIZE(m_szWelcomeText[1]));
  42. LoadString(g_hInstDll, IDS_WELCOMETEXT3, m_szWelcomeText[2], ARRAYSIZE(m_szWelcomeText[2]));
  43. LoadString(g_hInstDll, IDS_WELCOMETEXT4, m_szWelcomeText[3], ARRAYSIZE(m_szWelcomeText[3]));
  44. LoadArrayFromStringTable(IDS_LKPREV_WELCOME_MINTEXTSIZES, m_rgnValues, &m_nCountValues);
  45. return 1;
  46. }
  47. void CWelcomePg::InvalidateRects(int PrevHilight)
  48. {
  49. InvalidateRect(GetDlgItem(m_hwnd, IDMapT[PrevHilight][1]), NULL, TRUE);
  50. }
  51. // These is to set the Focus and sync the painting
  52. LRESULT CWelcomePg::OnPSN_SetActive(HWND hwnd, INT idCtl, LPPSHNOTIFY pnmh)
  53. {
  54. syncInit = FALSE;
  55. uIDEvent = SetTimer(hwnd, NULL, 100, NULL);
  56. m_nCurrentHilight = m_nCurValueIndex = 0;
  57. // Localization taken care... 9,11,15 in JPN
  58. if ( g_Options.m_nMinimalFontSize <=9 )
  59. m_nCurrentHilight = 0;
  60. else if (g_Options.m_nMinimalFontSize <=12 )
  61. m_nCurrentHilight = 1;
  62. else if (g_Options.m_nMinimalFontSize <=16 )
  63. m_nCurrentHilight = 2;
  64. m_nCurValueIndex = m_nCurrentHilight;
  65. return 0;
  66. }
  67. LRESULT CWelcomePg::OnTimer( HWND hwnd, WPARAM wParam, LPARAM lParam )
  68. {
  69. KillTimer(hwnd, uIDEvent);
  70. syncInit = TRUE;
  71. return 1;
  72. }
  73. // Sets the focus to the current item in OnInitDialog.
  74. void CWelcomePg::SetFocussedItem(int m_nCurrentHilight)
  75. {
  76. SetFocus(GetDlgItem(m_hwnd, IDMapT[m_nCurrentHilight][1]));
  77. }
  78. LRESULT CWelcomePg::OnDrawItem(HWND hwnd, WPARAM wParam, LPARAM lParam)
  79. {
  80. UINT idCtrl = (UINT) wParam;
  81. LPDRAWITEMSTRUCT lpDrawItemStruct = (LPDRAWITEMSTRUCT) lParam;
  82. int index;
  83. if ( !syncInit)
  84. SetFocussedItem(m_nCurrentHilight);
  85. switch(idCtrl)
  86. {
  87. case IDC_TEXT1:
  88. index = 0;
  89. break;
  90. case IDC_TEXT2:
  91. index = 1;
  92. break;
  93. case IDC_TEXT3:
  94. index = 2;
  95. break;
  96. default:
  97. _ASSERTE(FALSE);
  98. return 1; // Prefix #113778 (this should never happen; only three controls on dialog)
  99. break;
  100. }
  101. // For each button, Check the state, And if the button is selected,
  102. // means that it has current focus, So Re-paint the previously hilighted and
  103. // the current selected buttons....
  104. // Make sure we ignore the initial events so that we minimize the flicker...
  105. if ( (lpDrawItemStruct->itemState & ODS_FOCUS) && (m_nCurrentHilight != index))
  106. {
  107. if ( syncInit )
  108. {
  109. // Erase the previous one...
  110. InvalidateRects(m_nCurrentHilight);
  111. Sleep(100);
  112. m_nCurrentHilight= m_nCurValueIndex = index;
  113. }
  114. }
  115. Draw( lpDrawItemStruct, index );
  116. return 1;
  117. }
  118. void CWelcomePg::Draw(LPDRAWITEMSTRUCT ldi, int i)
  119. {
  120. int nOldBkMode = SetBkMode(ldi->hDC, TRANSPARENT);
  121. HDC hdc = ldi->hDC;
  122. RECT rcOriginal = ldi->rcItem;
  123. HFONT hFontOld = (HFONT)SelectObject(hdc, g_Options.GetClosestMSSansSerif(m_rgnValues[i], (m_nCurrentHilight == i)));
  124. TextOut(hdc, rcOriginal.left + 10 , rcOriginal.top + 10 - i, m_szWelcomeText[i], lstrlen(m_szWelcomeText[i]));
  125. SelectObject(hdc, hFontOld);
  126. SetBkMode(ldi->hDC, nOldBkMode);
  127. //If current hi-lighted item, Then draw the bounding rectangle.
  128. if ( m_nCurrentHilight == i)
  129. {
  130. DrawHilight(m_hwnd, ldi);
  131. }
  132. }
  133. LRESULT
  134. CWelcomePg::OnPSN_WizNext(
  135. HWND hwnd,
  136. INT idCtl,
  137. LPPSHNOTIFY pnmh
  138. )
  139. {
  140. // Tell the second page that we've done something
  141. g_Options.m_bWelcomePageTouched = TRUE;
  142. // In addition to knowing the actual font size we need to know if it's normal,
  143. // large or extra large so we can update display CPL on what's happened.
  144. g_Options.m_nMinimalFontSize = m_rgnValues[m_nCurValueIndex];
  145. g_Options.m_schemePreview.m_nSelectedSize = m_nCurValueIndex;
  146. return WizardPage::OnPSN_WizNext(hwnd, idCtl, pnmh);
  147. #if 0
  148. // We are going to allow people to 'back' to this page
  149. // As a HACK, we want this page to come out only once.
  150. // If we try to remove ourselves, and the call the
  151. // default OnPSN_WizNext(), we'll get an assert when
  152. // that function tries to find the 'next' page. Instead
  153. // we manually do the things from OnPSN_WizNext()
  154. // Remove ourself from the wizard after we select a size.
  155. DWORD dwTemp = IDD_WIZWELCOME;
  156. sm_WizPageOrder.RemovePages(&dwTemp, 1);
  157. SetWindowLong(hwnd, DWL_MSGRESULT, IDD_WIZWELCOME2);
  158. return TRUE;
  159. #endif
  160. }