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.

261 lines
7.1 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. // File: uiopthelp.h
  4. // Copyright (C) 1994-1997 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // Class used to represent a single 'option'.
  8. //
  9. // Owner: MHotchin
  10. //
  11. //-----------------------------------------------------------------------------
  12. #pragma once
  13. //
  14. // Base structure
  15. //
  16. struct UI_OPTS_BASE
  17. {
  18. TCHAR* pszName; // internal name of the option
  19. UINT nDisplayName; // string id of the display name
  20. UINT nDisplayHelp; // string id of the help string
  21. PFNOnValidateUIOption pfnVal; // function to call during validation.
  22. // This may be null
  23. WORD wStorageTypes; // storage type of option
  24. CLocUIOptionDef::ControlType wReadOnly; // ReadOnly value
  25. CLocUIOptionDef::ControlType wVisible; // Visible value
  26. };
  27. // Structures of option data
  28. //
  29. // BOOL options
  30. //
  31. struct UI_OPTS_BOOL
  32. {
  33. UI_OPTS_BASE base; // base class data
  34. BOOL bDefValue; // default value of the option
  35. CLocUIOption::EditorType et; // type of BOOL option
  36. };
  37. //
  38. // PICK options
  39. //
  40. struct UI_OPTS_PICK
  41. {
  42. UI_OPTS_BASE base; // base class data
  43. DWORD dwDefValue; // default value of the option
  44. BOOL bAdd; // allow additions to the list
  45. UINT nListEntries; // list of entries to pick from
  46. // Each entry is separated by \n
  47. // The last entry does not have a \n
  48. };
  49. const TCHAR UI_PICK_TERMINATOR = _T('\n');
  50. //
  51. // DWORD options
  52. struct UI_OPTS_DWORD
  53. {
  54. UI_OPTS_BASE base; // base class data
  55. DWORD dwDefValue; // default value of the option
  56. CLocUIOption::EditorType et; // type of DWORD option
  57. };
  58. //
  59. // String options
  60. //
  61. struct UI_OPTS_STR
  62. {
  63. UI_OPTS_BASE base; // base class data
  64. UINT nDefValue; // string table entry for default value
  65. CLocUIOption::EditorType et;
  66. };
  67. //
  68. // String list options
  69. //
  70. struct UI_OPTS_STRLIST
  71. {
  72. UI_OPTS_BASE base; // base class data
  73. UINT nDefList; // Each entry is separated by \n
  74. // The last entry does not have a \n
  75. };
  76. //
  77. // File Name options
  78. //
  79. struct UI_OPTS_FILENAME
  80. {
  81. UI_OPTS_BASE base; // base class data
  82. UINT nExtensions; // The default extensions to the UI
  83. UINT nDefValue; // string table entry for default value
  84. };
  85. //
  86. // Helper class definition
  87. //
  88. #pragma warning(disable: 4275) // non dll-interface class 'foo' used
  89. // as base for dll-interface class 'bar'
  90. class LTAPIENTRY CLocUIOptionImpHelper : public CObject
  91. {
  92. public:
  93. CLocUIOptionImpHelper(HINSTANCE hInst);
  94. void GetOptions(CLocUIOptionSet *pOptionSet, UINT nDesc, UINT nHelp);
  95. void SetBools(const UI_OPTS_BOOL* pBools, int nCntBools);
  96. void SetPicks(const UI_OPTS_PICK* pPicks, int nCntPicks);
  97. void SetDwords(const UI_OPTS_DWORD* pDwords, int nCntDwords);
  98. void SetStrs(const UI_OPTS_STR* pStrs, int nCntStrs);
  99. void SetStrLists(const UI_OPTS_STRLIST* pStrLists, int nCntStrLists);
  100. void SetFNames(const UI_OPTS_FILENAME* pFNames, int nCntFNames);
  101. void AssertValid(void) const;
  102. protected:
  103. HINSTANCE m_hInst;
  104. const UI_OPTS_BOOL* m_pBools;
  105. int m_nCntBools;
  106. const UI_OPTS_PICK* m_pPicks;
  107. int m_nCntPicks;
  108. const UI_OPTS_DWORD* m_pDwords;
  109. int m_nCntDwords;
  110. const UI_OPTS_STR* m_pStrs;
  111. int m_nCntStrs;
  112. const UI_OPTS_STRLIST* m_pStrLists;
  113. int m_nCntStrLists;
  114. const UI_OPTS_FILENAME* m_pFNames;
  115. int m_nCntFNames;
  116. void GetBoolOptions(CLocUIOptionSet* pOptionSet);
  117. void GetPicksOptions(CLocUIOptionSet* pOptionSet);
  118. void GetDwordsOptions(CLocUIOptionSet* pOptionSet);
  119. void GetStrsOptions(CLocUIOptionSet* pOptionSet);
  120. void GetStrListsOptions(CLocUIOptionSet* pOptionSet);
  121. void GetFNamesOptions(CLocUIOptionSet* pOptionSet);
  122. void GetListFromId(UINT nId, CPasStringList& pasList);
  123. void GetStringFromId(UINT nId, CPascalString& pas);
  124. };
  125. #pragma warning(default : 4275)
  126. //
  127. // Helper macros for building data structures
  128. //
  129. // The _EXT versions of the macros allow setting the less common
  130. // attributes (readonly and visible)
  131. //
  132. // BOOL
  133. #define BEGIN_LOC_UI_OPTIONS_BOOL(var) \
  134. const UI_OPTS_BOOL var[] = \
  135. {
  136. #define LOC_UI_OPTIONS_BOOL_ENTRY(name, def, et, id, idHelp, pfnval, st) \
  137. { {name, id, idHelp, pfnval, st, CLocUIOptionDef::ctDefault, CLocUIOptionDef::ctDefault}, def, et}
  138. #define LOC_UI_OPTIONS_BOOL_ENTRY_EXT(name, def, et, id, idHelp, pfnval, st, ro, visible) \
  139. { {name, id, idHelp, pfnval, st, ro, visible}, def, et}
  140. #define END_LOC_UI_OPTIONS_BOOL() \
  141. }
  142. // Pick
  143. #define BEGIN_LOC_UI_OPTIONS_PICK(var) \
  144. const UI_OPTS_PICK var[] = \
  145. {
  146. #define LOC_UI_OPTIONS_PICK_ENTRY(name, def, add, list, id, idHelp, pfnval, st) \
  147. { {name, id, idHelp, pfnval, st, CLocUIOptionDef::ctDefault, CLocUIOptionDef::ctDefault}, def, add, list}
  148. #define LOC_UI_OPTIONS_PICK_ENTRY_EXT(name, def, add, list, id, idHelp, pfnval, st, ro, visible) \
  149. { {name, id, idHelp, pfnval, st, ro, visible}, def, add, list}
  150. #define END_LOC_UI_OPTIONS_PICK() \
  151. }
  152. // DWORD
  153. #define BEGIN_LOC_UI_OPTIONS_DWORD(var) \
  154. const UI_OPTS_DWORD var[] = \
  155. {
  156. #define LOC_UI_OPTIONS_DWORD_ENTRY(name, def, et, id, idHelp, pfnval, st) \
  157. { {name, id, idHelp, pfnval, st, CLocUIOptionDef::ctDefault, CLocUIOptionDef::ctDefault},def, et}
  158. #define LOC_UI_OPTIONS_DWORD_ENTRY_EXT(name, def, et, id, idHelp, pfnval, st, ro, visible) \
  159. { {name, id, idHelp, pfnval, st, ro, visible},def, et}
  160. #define END_LOC_UI_OPTIONS_DWORD() \
  161. }
  162. // String
  163. #define BEGIN_LOC_UI_OPTIONS_STR(var) \
  164. const UI_OPTS_STR var[] = \
  165. {
  166. #define LOC_UI_OPTIONS_STR_ENTRY(name, def, et, id, idHelp, pfnval, st) \
  167. { {name, id, idHelp, pfnval, st, CLocUIOptionDef::ctDefault, CLocUIOptionDef::ctDefault}, def, et}
  168. #define LOC_UI_OPTIONS_STR_ENTRY_EXT(name, def, et, id, idHelp, pfnval, st, ro, visible) \
  169. { {name, id, idHelp, pfnval, st, ro, visible}, def, et}
  170. #define END_LOC_UI_OPTIONS_STR() \
  171. }
  172. // String List
  173. #define BEGIN_LOC_UI_OPTIONS_STRLIST(var) \
  174. const UI_OPTS_STRLIST var[] = \
  175. {
  176. #define LOC_UI_OPTIONS_STRLIST_ENTRY(name, def, id, idHelp, pfnval, st) \
  177. { {name, id, idHelp, pfnval, st, CLocUIOptionDef::ctDefault, CLocUIOptionDef::ctDefault}, def}
  178. #define LOC_UI_OPTIONS_STRLIST_ENTRY_EXT(name, def, id, idHelp, pfnval, st, ro, visible) \
  179. { {name, id, idHelp, pfnval, st, ro, visible}, def}
  180. #define END_LOC_UI_OPTIONS_STRLIST() \
  181. }
  182. // File Names
  183. #define BEGIN_LOC_UI_OPTIONS_FILENAME(var) \
  184. const UI_OPTS_FILENAME var[] = \
  185. {
  186. #define LOC_UI_OPTIONS_FILENAME_ENTRY(name, def, id, idHelp, idExt, pfnval, st) \
  187. { {name, id, idHelp, pfnval, st, CLocUIOptionDef::ctDefault, CLocUIOptionDef::ctDefault}, idExt, def}
  188. #define LOC_UI_OPTIONS_FILENAME_ENTRY_EXT(name, def, id, idHelp, idExt, pfnval, st, ro, visible) \
  189. { {name, id, idHelp, pfnval, st, ro, visible}, idExt, def}
  190. #define END_LOC_UI_OPTIONS_FILENAME() \
  191. }