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.

166 lines
5.5 KiB

  1. //____________________________________________________________________________
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1998 - 1999
  5. //
  6. // File: tasksym.h
  7. //
  8. // Contents:
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 10/29/1998 DavidPe Adapted from BackOffice snapin
  15. //____________________________________________________________________________
  16. //
  17. #ifndef __TASKSYM_H__
  18. #define __TASKSYM_H__
  19. #include "tstring.h"
  20. #include "dlgs.h"
  21. #include "task.h" // for CSmartIcon
  22. extern const int NUM_SYMBOLS; // the total number of symbols available.
  23. class CConsoleTask;
  24. /*+-------------------------------------------------------------------------*
  25. * class CEOTSymbol
  26. *
  27. *
  28. * PURPOSE: encapsulates information about glyphs that are internal to MMC. These
  29. * have description text along with them.
  30. *+-------------------------------------------------------------------------*/
  31. class CEOTSymbol
  32. {
  33. public:
  34. CEOTSymbol(WORD iconResource, int value, int ID, int IDSecondary=0)
  35. {m_iconResource = iconResource; m_value = value; m_ID = ID; m_IDSecondary = IDSecondary;}
  36. ~CEOTSymbol();
  37. void Draw (HDC hdc, RECT *lpRect, bool bSmall = false) const ; // Draw into a DC.
  38. public:
  39. int GetID() const {return m_ID;}
  40. int GetIDSecondary() const {return m_IDSecondary;}
  41. int GetValue() const {return m_value;}
  42. bool operator == (const CEOTSymbol &rhs);
  43. static bool IsMatch(CStr &str1, CStr &str2);
  44. static int FindMatchingSymbol(LPCTSTR szDescription); // finds a symbol matching the given description.
  45. void SetIcon(const CSmartIcon & smartIconSmall, const CSmartIcon & smartIconLarge);
  46. CSmartIcon & GetSmallIcon() {return m_smartIconSmall;}
  47. CSmartIcon & GetLargeIcon() {return m_smartIconLarge;}
  48. private:
  49. WORD m_iconResource; // the resource id of the icon
  50. int m_value; // the number of the symbol
  51. int m_ID; // description text resource ID
  52. int m_IDSecondary; // secondary description\
  53. protected:
  54. mutable CSmartIcon m_smartIconSmall;
  55. mutable CSmartIcon m_smartIconLarge;
  56. };
  57. /*+-------------------------------------------------------------------------*
  58. * class CTaskSymbolDlg
  59. *
  60. *
  61. * PURPOSE:
  62. *
  63. *+-------------------------------------------------------------------------*/
  64. class CTaskSymbolDlg :
  65. public WTL::CPropertyPageImpl<CTaskSymbolDlg>
  66. {
  67. typedef WTL::CPropertyPageImpl<CTaskSymbolDlg> BC;
  68. public:
  69. CTaskSymbolDlg(CConsoleTask& rConsoleTask, bool bFindMatchingSymbol= false);
  70. ~CTaskSymbolDlg() { m_imageList.Destroy(); }
  71. enum { IDD = IDD_TASK_PROPS_SYMBOL_PAGE,
  72. IDD_WIZ = IDD_TASK_WIZARD_SYMBOL_PAGE};
  73. BEGIN_MSG_MAP(CTaskSymbolDlg)
  74. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
  75. MESSAGE_HANDLER(WM_CTLCOLORSTATIC, OnCtlColorStatic)
  76. CONTEXT_HELP_HANDLER()
  77. NOTIFY_HANDLER (IDC_GLYPH_LIST, NM_CUSTOMDRAW, OnCustomDraw)
  78. NOTIFY_HANDLER (IDC_GLYPH_LIST, LVN_ITEMCHANGED, OnSymbolChanged)
  79. COMMAND_ID_HANDLER(IDB_SELECT_TASK_ICON, OnSelectTaskIcon)
  80. COMMAND_HANDLER(IDC_CustomIconRadio, BN_CLICKED, OnIconSourceChanged)
  81. COMMAND_HANDLER(IDC_MMCIconsRadio, BN_CLICKED, OnIconSourceChanged)
  82. CHAIN_MSG_MAP(BC)
  83. REFLECT_NOTIFICATIONS()
  84. END_MSG_MAP()
  85. IMPLEMENT_CONTEXT_HELP(g_aHelpIDs_IDD_TASK_PROPS_SYMBOL_PAGE);
  86. //
  87. // message handlers
  88. //
  89. LRESULT OnInitDialog(UINT mMsg, WPARAM wParam, LPARAM lParam, BOOL& handled);
  90. LRESULT OnCtlColorStatic(UINT mMsg, WPARAM wParam, LPARAM lParam, BOOL& handled);
  91. LRESULT OnCustomDraw(int id, LPNMHDR pnmh, BOOL& bHandled );
  92. LRESULT OnSymbolChanged(int id, LPNMHDR pnmh, BOOL& bHandled );
  93. LRESULT OnSelectTaskIcon(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled );
  94. LRESULT OnIconSourceChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled );
  95. int OnWizardNext() {return OnOK() ? 0 : -1;}
  96. bool OnApply () {return OnOK();}
  97. BOOL OnOK();
  98. // implementation
  99. void DrawItem(NMCUSTOMDRAW *pnmcd);
  100. private:
  101. SC ScEnableControls (int id);
  102. protected:
  103. CConsoleTask& m_ConsoleTask; // get the name to match from here.
  104. WTL::CImageList m_imageList;
  105. WTL::CListViewCtrl m_listGlyphs; // the list control for the glyphs
  106. WTL::CStatic m_wndCustomIcon;
  107. CSmartIcon m_CustomIconSmall;
  108. CSmartIcon m_CustomIconLarge;
  109. bool m_bFindMatchingSymbol; // should we try to guess a symbol?
  110. bool m_bCustomIcon; // does this task use a custom icon?
  111. };
  112. class CTaskSymbolWizardPage: public CTaskSymbolDlg
  113. {
  114. typedef CTaskSymbolDlg BC;
  115. public:
  116. CTaskSymbolWizardPage(CConsoleTask& rConsoleTask): BC(rConsoleTask, true)
  117. {
  118. m_psp.pszTemplate = MAKEINTRESOURCE(BC::IDD_WIZ);
  119. /*
  120. * Wizard97-style pages have titles, subtitles and header bitmaps
  121. */
  122. VERIFY (m_strTitle. LoadString(GetStringModule(), IDS_TaskWiz_SymbolPageTitle));
  123. VERIFY (m_strSubtitle.LoadString(GetStringModule(), IDS_TaskWiz_SymbolPageSubtitle));
  124. m_psp.dwFlags |= PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  125. m_psp.pszHeaderTitle = m_strTitle.data();
  126. m_psp.pszHeaderSubTitle = m_strSubtitle.data();
  127. }
  128. BOOL OnSetActive()
  129. {
  130. // add the Finish button.
  131. WTL::CPropertySheetWindow(::GetParent(m_hWnd)).SetWizardButtons (PSWIZB_BACK | PSWIZB_NEXT);
  132. return TRUE;
  133. }
  134. private:
  135. tstring m_strTitle;
  136. tstring m_strSubtitle;
  137. };
  138. #endif // __TASKSYM_H__