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.

263 lines
6.9 KiB

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