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.

212 lines
6.2 KiB

  1. /******************************************************************************
  2. Source File: Add Code Points.CPP
  3. This implements the CAddCodePoints class, which manages a dialog that allows
  4. the user to add additional code points to a glyph set.
  5. Copyright (c) 1997 by Microsoft Corporation. All rights Reserved.
  6. A Pretty Penny Enterprises Production
  7. Change History:
  8. 03-01-1997 Bob_Kjelgaard@Prodigy.Net Created it
  9. ******************************************************************************/
  10. #include "StdAfx.H"
  11. #include "MiniDev.H"
  12. #include "addcdpt.h"
  13. #include "codepage.h"
  14. #ifdef _DEBUG
  15. #define new DEBUG_NEW
  16. #undef THIS_FILE
  17. static char THIS_FILE[] = __FILE__;
  18. #endif
  19. static CCodePageInformation* pccpi = NULL ;
  20. /******************************************************************************
  21. CAddCodePoints::CAddCodePoints
  22. The class constructor primarily initializes the base class and reference
  23. members.
  24. ******************************************************************************/
  25. CAddCodePoints::CAddCodePoints(CWnd* pParent, CMapWordToDWord& cmw2d,
  26. CDWordArray& cda, CString csItemName)
  27. : CDialog(CAddCodePoints::IDD, pParent), m_cmw2dPoints(cmw2d),
  28. m_cdaPages(cda) {
  29. m_csItem = csItemName;
  30. // Allocate a CCodePageInformation class if needed.
  31. if (pccpi == NULL)
  32. pccpi = new CCodePageInformation ;
  33. for (int i= 0; i < m_cdaPages.GetSize(); i++)
  34. m_csaNames.Add(pccpi->Name(m_cdaPages[i]));
  35. m_pos = 0;
  36. m_uTimer = 0;
  37. //{{AFX_DATA_INIT(CAddCodePoints)
  38. //}}AFX_DATA_INIT
  39. }
  40. /******************************************************************************
  41. CAddCodePoints::DoDataExchange
  42. DDX override for the dialog- I'm not sure I need to keep this around.
  43. ******************************************************************************/
  44. void CAddCodePoints::DoDataExchange(CDataExchange* pDX) {
  45. CDialog::DoDataExchange(pDX);
  46. //{{AFX_DATA_MAP(CAddCodePoints)
  47. DDX_Control(pDX, IDC_Banner, m_cpcBanner);
  48. DDX_Control(pDX, IDC_GlyphList, m_clbList);
  49. //}}AFX_DATA_MAP
  50. }
  51. BEGIN_MESSAGE_MAP(CAddCodePoints, CDialog)
  52. //{{AFX_MSG_MAP(CAddCodePoints)
  53. ON_WM_TIMER()
  54. //}}AFX_MSG_MAP
  55. END_MESSAGE_MAP()
  56. /******************************************************************************
  57. CAddCodePoints::OnInitDialog
  58. This is the primary dialog intialization member. It uses the passed
  59. information to customize the title, then kicks off a timer so the UI appears
  60. while the list box is filled.
  61. ******************************************************************************/
  62. BOOL CAddCodePoints::OnInitDialog() {
  63. CDialog::OnInitDialog();
  64. GetWindowText(m_csHolder);
  65. SetWindowText(m_csHolder + m_csItem);
  66. m_uTimer = (unsigned)SetTimer(IDD, 10, NULL);
  67. if (!m_uTimer) { // No timer- fall back to filling the box slowly
  68. CWaitCursor cwc;
  69. OnTimer(m_uTimer);
  70. }
  71. return TRUE; // No need to change the default focus
  72. }
  73. /******************************************************************************
  74. CAddCodePoints::OnOK
  75. This is called when the OK button is pressed. We check the selection state
  76. of each item in the list. If it is not selected, we remove it from the map.
  77. Thus, we return a map with only the desired entries to the caller.
  78. ******************************************************************************/
  79. void CAddCodePoints::OnOK() {
  80. CWaitCursor cwc; // This could get slow
  81. for (unsigned u = 0; u < (unsigned) m_clbList.GetCount(); u++)
  82. if (!m_clbList.GetSel(u))
  83. m_cmw2dPoints.RemoveKey((WORD) m_clbList.GetItemData(u));
  84. CDialog::OnOK();
  85. }
  86. /******************************************************************************
  87. CAddCodePoints::OnInitDialog
  88. This is invoked after the timer expires. It uses the passed information to
  89. fill the code point list.
  90. ******************************************************************************/
  91. void CAddCodePoints::OnTimer(UINT nIDEvent) {
  92. if (nIDEvent != m_uTimer) {
  93. CDialog::OnTimer(nIDEvent);
  94. return;
  95. }
  96. WORD wKey;
  97. DWORD dwIndex;
  98. CString csWork;
  99. if (m_uTimer)
  100. ::KillTimer(m_hWnd, m_uTimer);
  101. if (!m_pos) {
  102. m_cpcBanner.SetRange(0, (int)m_cmw2dPoints.GetCount() - 1);
  103. m_cpcBanner.SetStep(1);
  104. m_cpcBanner.SetPos(0);
  105. csWork.LoadString(IDS_WaitToFill);
  106. CDC *pcdc = m_cpcBanner.GetDC();
  107. CRect crBanner;
  108. m_cpcBanner.GetClientRect(crBanner);
  109. pcdc -> SetBkMode(TRANSPARENT);
  110. pcdc -> DrawText(csWork, crBanner, DT_CENTER | DT_VCENTER);
  111. m_cpcBanner.ReleaseDC(pcdc);
  112. if (m_uTimer)
  113. m_clbList.EnableWindow(FALSE);
  114. else {
  115. m_clbList.LockWindowUpdate();
  116. m_clbList.ResetContent();
  117. }
  118. m_pos = m_cmw2dPoints.GetStartPosition();
  119. }
  120. // Put in just 100 items, unless the timer is off
  121. for (unsigned u = 0; m_pos && (!m_uTimer || u < 100); u++) {
  122. m_cmw2dPoints.GetNextAssoc(m_pos, wKey, dwIndex);
  123. csWork.Format(_TEXT("%4.4X: "), wKey);
  124. csWork += m_csaNames[dwIndex];
  125. int id = m_clbList.AddString(csWork);
  126. m_clbList.SetItemData(id, wKey);
  127. }
  128. if (!m_pos) {
  129. if (m_uTimer)
  130. m_clbList.EnableWindow(TRUE);
  131. else
  132. m_clbList.UnlockWindowUpdate();
  133. m_uTimer = 0;
  134. m_cpcBanner.SetPos(0);
  135. m_cpcBanner.ShowWindow(SW_HIDE);
  136. SetFocus();
  137. }
  138. if (m_uTimer) {
  139. m_cpcBanner.OffsetPos(u);
  140. csWork.LoadString(IDS_WaitToFill);
  141. CDC *pcdc = m_cpcBanner.GetDC();
  142. CRect crBanner;
  143. m_cpcBanner.GetClientRect(crBanner);
  144. pcdc -> SetBkMode(TRANSPARENT);
  145. pcdc -> DrawText(csWork, crBanner, DT_CENTER | DT_VCENTER);
  146. m_cpcBanner.ReleaseDC(pcdc);
  147. m_uTimer = (unsigned)SetTimer(IDD, 10, NULL);
  148. if (!m_uTimer) {
  149. CWaitCursor cwc; // Might be a while...
  150. m_clbList.EnableWindow(TRUE);
  151. m_clbList.LockWindowUpdate();
  152. OnTimer(m_uTimer);
  153. }
  154. }
  155. }
  156.