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.

505 lines
25 KiB

  1. //---------------------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //
  4. // File : uxthemep.h
  5. // Version: 1.0
  6. //---------------------------------------------------------------------------
  7. #ifndef _UXTHEMEP_H_
  8. #define _UXTHEMEP_H_
  9. //---------------------------------------------------------------------------
  10. #include <uxtheme.h>
  11. //---------------------------------------------------------------------------
  12. //---------------------------------------------------------------------------
  13. // The following routines are provided for use by Theme Selection UI.
  14. //---------------------------------------------------------------------------
  15. //---- bits returned by QueryThemeServices() ----
  16. #define QTS_AVAILABLE (1 << 0) // services are available
  17. #define QTS_RUNNING (1 << 1) // services are running
  18. //---------------------------------------------------------------------------
  19. // QueryThemeServices()
  20. // - returns flags about theme services (see above)
  21. //---------------------------------------------------------------------------
  22. THEMEAPI_(DWORD) QueryThemeServices();
  23. //---------------------------------------------------------------------------
  24. typedef HANDLE HTHEMEFILE; // handle to a loaded theme file
  25. //---------------------------------------------------------------------------
  26. // OpenThemeFile() - Load specified theme into memory (doesn't apply it)
  27. //
  28. // pszThemePath - full path of .msstyles file to load
  29. //
  30. // pszColorScheme - (optional) name of theme color scheme to load
  31. //
  32. // pszSize - (optional) name of theme size to load
  33. //
  34. // phThemeFile - if a theme is successfully opened, this handle
  35. // is set to a non-NULL value and holds a ref-count
  36. // on the theme to keep it in loaded in memory.
  37. //
  38. // fGlobalTheme - FALSE if it's a preview, TRUE if the theme is intended
  39. // to be made permanent for the user
  40. //---------------------------------------------------------------------------
  41. THEMEAPI OpenThemeFile(LPCWSTR pszThemePath, OPTIONAL LPCWSTR pszColorParam,
  42. OPTIONAL LPCWSTR pszSizeParam, OUT HTHEMEFILE *phThemeFile, BOOL fGlobalTheme);
  43. //---------------------------------------------------------------------------
  44. // CloseThemeFile() - decrements the ref-count for the theme identified
  45. // by the hThemeFile handle
  46. //
  47. // hThemeFile - open handle to the loaded theme file
  48. //---------------------------------------------------------------------------
  49. THEMEAPI CloseThemeFile(HTHEMEFILE hThemeFile);
  50. //---------------------------------------------------------------------------
  51. //--- WM_THEMECHANGED msg parameters (internal use only) ----
  52. //--- "wParam" is the "change number" ----
  53. //---- lParam bits ----
  54. #define WTC_THEMEACTIVE (1 << 0) // new theme is now active
  55. #define WTC_CUSTOMTHEME (1 << 1) // this msg for custom-themed apps
  56. //---------------------------------------------------------------------------
  57. //---- option flags for ApplyTheme() ----
  58. #define AT_LOAD_SYSMETRICS (1 << 0) // apply the theme's metrics w/theme
  59. // or default classic metrics when
  60. // turning themes off.
  61. #define AT_PROCESS (1 << 1) // apply to current process only
  62. #define AT_EXCLUDE (1 << 2) // all but the specified process/window
  63. #define AT_CACHETHEME (1 << 3) // cache this theme file, if applied
  64. #define AT_NOREGUPDATE (1 << 4) // don't update the CU registry for theme info
  65. #define AT_SYNC_LOADMETRICS (1 << 5) // load system metrics on calling thread
  66. //---- below flags currently not supported ----
  67. #define AT_DISABLE_FRAME_THEMING (1 << 10)
  68. #define AT_DISABLE_DIALOG_THEMING (1 << 11)
  69. //---------------------------------------------------------------------------
  70. // ApplyTheme() - Apply (or remove) a loaded theme file globally
  71. // or to specified apps/windows.
  72. //
  73. // Note that when a theme is applied globally
  74. // (hwndTarget is NULL), the theme services manager
  75. // will hold a refcount on the theme file. This
  76. // means that the caller can close his HTHEMEFILE
  77. // handle after the ApplyTheme() call.
  78. //
  79. // When the global theme is removed, the theme
  80. // services manager will drop is refcount.
  81. //
  82. // hThemeFile - (optional)handle to the loaded theme file.
  83. // if NULL then any theme on target app/windows
  84. // will be removed.
  85. //
  86. // dwApplyFlags - options for applying theme (see above)
  87. //
  88. // hwndTarget - (optional) only theme this window
  89. //---------------------------------------------------------------------------
  90. THEMEAPI ApplyTheme(OPTIONAL HTHEMEFILE hThemeFile, DWORD dwApplyFlags,
  91. OPTIONAL HWND hwndTarget);
  92. //---------------------------------------------------------------------------
  93. // RegisterDefaultTheme()
  94. // - registers the specified theme as the default
  95. // for all users on the system.
  96. //
  97. // pszThemeFileName - the name of the theme file (NULL = no theme)
  98. //
  99. // fOverride - if TRUE, will override current default theme
  100. //---------------------------------------------------------------------------
  101. THEMEAPI RegisterDefaultTheme(LPCWSTR pszFileName, BOOL fOverride);
  102. //---------------------------------------------------------------------------
  103. // THEMECALLBACK is a enum describing the type of callback being done
  104. //---------------------------------------------------------------------------
  105. typedef enum THEMECALLBACK
  106. {
  107. TCB_THEMENAME, // theme name enumeration
  108. TCB_COLORSCHEME, // color scheme enumeration
  109. TCB_SIZENAME, // size name enumeration
  110. TCB_SUBSTTABLE, // substitution table enumeration
  111. TCB_CDFILENAME, // classdata file name enumeration
  112. TCB_CDFILECOMBO, // classdata file color/size combinations
  113. TCB_FILENAME, // parsed a filename
  114. TCB_DOCPROPERTY, // parsed a standard doc property
  115. TCB_NEEDSUBST, // callback to get a substituted symbol
  116. TCB_MINCOLORDEPTH, // parsed the min color depth
  117. //---- localizable property callbacks ----
  118. TCB_FONT, // parsed a font string
  119. TCB_MIRRORIMAGE, // parsed the MirrorImage property
  120. TCB_LOCALIZABLE_RECT, // parsed a RECT property that needs to be localizable
  121. };
  122. //---------------------------------------------------------------------------
  123. typedef struct
  124. {
  125. WCHAR szName[MAX_PATH+1];
  126. WCHAR szDisplayName[MAX_PATH+1];
  127. WCHAR szToolTip[MAX_PATH+1];
  128. } THEMENAMEINFO;
  129. //---------------------------------------------------------------------------
  130. // THEMEENUMPROC() - callback used by the theme enum/parsing functions.
  131. // the return value is used to continue or abort
  132. // the enumeration.
  133. //
  134. // tcbType - callback type being made
  135. // pszName - simple name of the item being enumerated
  136. // pszName2 - varies by callback type
  137. // pszName3 - varies by callback type
  138. // iIndex - index number associated with some items
  139. // lParam - callback param supplied by caller
  140. //---------------------------------------------------------------------------
  141. typedef BOOL (CALLBACK* THEMEENUMPROC)(enum THEMECALLBACK tcbType,
  142. LPCWSTR pszName, OPTIONAL LPCWSTR pszName2,
  143. OPTIONAL LPCWSTR pszName3, OPTIONAL int iIndex, LPARAM lParam);
  144. //---------------------------------------------------------------------------
  145. // EnumThemes() - calls the callback function "lpEnumFunc" with each
  146. // theme. During the callback, the filename,
  147. // Display name, and tooltip string for each theme
  148. // are returned.
  149. //
  150. // pszThemeRoot - the theme root directory; each theme DLL found in
  151. // a separate subdir immediately under the theme root
  152. // dir is enumerated. The root name of the DLL must
  153. // match its containing subdir name
  154. //
  155. // lpEnumFunc - ptr to the caller's callback function which will
  156. // be called for each theme enumerated
  157. //
  158. // lParam - caller's callback parameter (will be passed to
  159. // lpEnumFunc())
  160. //---------------------------------------------------------------------------
  161. THEMEAPI EnumThemes(LPCWSTR pszThemeRoot, THEMEENUMPROC lpEnumFunc,
  162. LPARAM lParam);
  163. //---------------------------------------------------------------------------
  164. // EnumThemeSizes() - support direct enumeration of all available theme
  165. // sizes.
  166. //
  167. // pszThemeName - is the name of the theme file.
  168. // pszColorScheme - (optional) only sizes for this color are enum-ed
  169. // dwSizeIndex - 0-relative index of the size being queryed
  170. // ptn - ptr to struct to receive name strings
  171. //---------------------------------------------------------------------------
  172. THEMEAPI EnumThemeSizes(LPCWSTR pszThemeName,
  173. OPTIONAL LPCWSTR pszColorScheme, DWORD dwSizeIndex,
  174. OUT THEMENAMEINFO *ptn);
  175. //---------------------------------------------------------------------------
  176. // EnumThemeColors() - support direct enumeration of all available theme
  177. // color schemes.
  178. //
  179. // pszThemeName - name of the theme file.
  180. // pszSizeName - (optional) only colors for this size are enum-ed
  181. // dwColorIndex - 0-relative index of the color being queryed
  182. // ptn - ptr to struct to receive name strings
  183. //---------------------------------------------------------------------------
  184. THEMEAPI EnumThemeColors(LPCWSTR pszThemeName,
  185. OPTIONAL LPCWSTR pszSizeName, DWORD dwColorIndex,
  186. OUT THEMENAMEINFO *ptn);
  187. //---------------------------------------------------------------------------
  188. // GetThemeDefaults() - returns the default Color name and default Size
  189. // name for the specified theme file
  190. //
  191. // pszThemeName - name of the theme file
  192. //
  193. // pszDefaultColor - buffer to receive the default color name
  194. // (the canonical name, not the display version)
  195. // cchMaxColorChars - max chars that pszDefaultColor can contain
  196. //
  197. // pszDefaultSize - buffer to receive the default size name
  198. // (the canonical name, not the display version)
  199. // cchMaxSizeChars - max chars that pszDefaultSize can contain
  200. //---------------------------------------------------------------------------
  201. THEMEAPI GetThemeDefaults(LPCWSTR pszThemeName,
  202. OUT OPTIONAL LPWSTR pszDefaultColor, int cchMaxColorChars,
  203. OUT OPTIONAL LPWSTR pszDefaultSize, int cchMaxSizeChars);
  204. //---------------------------------------------------------------------------
  205. #define PTF_CONTAINER_PARSE 0x0001 // parse as a "themes.ini" file
  206. #define PTF_CLASSDATA_PARSE 0x0002 // parse as a "bigred.ini" classdata file
  207. #define PTF_CALLBACK_COLORSECTION 0x0004 // callback on all [colorscheme.xxx] sections
  208. #define PTF_CALLBACK_SIZESECTION 0x0008 // callback on all [size.xxx] sections
  209. #define PTF_CALLBACK_FILESECTION 0x0010 // callback on all [file.xxx] sections
  210. #define PTF_CALLBACK_FILENAMES 0x0020 // callback on all "filename=" properties
  211. #define PTF_CALLBACK_LOCALIZATIONS 0x0040 // callback on all localizable properties
  212. #define PTF_CALLBACK_DOCPROPERTIES 0x0080 // callback on all standard properties in [doc] section
  213. #define PTF_QUERY_DOCPROPERTY 0x0100 // query for value of specified property (internal)
  214. #define PTF_CALLBACK_SUBSTTABLE 0x0400 // callback on all [subst.xxx] sections
  215. #define PTF_CALLBACK_SUBSTSYMBOLS 0x0800 // callback on a substituted symbol (##)
  216. #define PTF_CALLBACK_MINCOLORDEPTH 0x1000 // callback on "MinColorDepth="
  217. //---------------------------------------------------------------------------
  218. // ParseThemeIniFile() - Parse the "themes.inc" file specified by
  219. // "pszFileName".
  220. // pzFileName - name of the theme.inc file to parse
  221. // dwParseFlags - flags that control parsing & callback options
  222. // pfnCallBack - ptr to caller-supplied callback function
  223. // lparam - caller's callback param
  224. //---------------------------------------------------------------------------
  225. THEMEAPI ParseThemeIniFile(LPCWSTR pszFileName, DWORD dwParseFlags,
  226. OPTIONAL THEMEENUMPROC pFnCallBack, OPTIONAL LPARAM lparam);
  227. //---------------------------------------------------------------------------
  228. #define THEME_PARSING_ERROR(hr) (SCODE_CODE(hr) == ERROR_UNKNOWN_PROPERTY)
  229. typedef struct _PARSE_ERROR_INFO
  230. {
  231. DWORD dwSize; // of this structure
  232. //---- last parse error info ----
  233. DWORD dwParseErrCode; // error code from last error
  234. WCHAR szMsg[2*MAX_PATH]; // value of first param for msg
  235. WCHAR szFileName[MAX_PATH]; // associated source filename
  236. WCHAR szSourceLine[MAX_PATH]; // source line
  237. int iLineNum; // source line number
  238. }
  239. PARSE_ERROR_INFO, *PPARSE_ERROR_INFO;
  240. //---------------------------------------------------------------------------
  241. // GetThemeParseErrorInfo()
  242. // - fill in the PARSE_ERROR_CONTEXT structure
  243. // with needed information about the last theme API
  244. // parse error.
  245. //
  246. // pInfo - ptr to the PARSE_ERROR_INFO to be filled
  247. //---------------------------------------------------------------------------
  248. THEMEAPI GetThemeParseErrorInfo(OUT PARSE_ERROR_INFO *pInfo);
  249. //---------------------------------------------------------------------------
  250. // resource base numbers for localizable string tables in a .msstyles file
  251. //---------------------------------------------------------------------------
  252. #define RES_BASENUM_COLORDISPLAYS 1000
  253. #define RES_BASENUM_COLORTOOLTIPS 2000
  254. #define RES_BASENUM_SIZEDISPLAYS 3000
  255. #define RES_BASENUM_SIZETOOLTIPS 4000
  256. #define RES_BASENUM_DOCPROPERTIES 5000 // in order shown in TmSchema.h
  257. #define RES_BASENUM_PROPVALUEPAIRS 6000 // property names & localizable values
  258. //---------------------------------------------------------------------------
  259. // DrawNCPreview() - Previews the theme for the NC area of a window
  260. //
  261. // hdc - HDC for preview to be draw into
  262. // prc - RECT for preview
  263. //
  264. //---------------------------------------------------------------------------
  265. #define NCPREV_INACTIVEWINDOW 0x00000001
  266. #define NCPREV_ACTIVEWINDOW 0x00000002
  267. #define NCPREV_MESSAGEBOX 0x00000004
  268. #define NCPREV_RTL 0x00000008
  269. THEMEAPI DrawNCPreview(HDC hdc, DWORD dwFlags, LPRECT prc, LPCWSTR pszVSPath,
  270. LPCWSTR pszVSColor, LPCWSTR pszVSSize, NONCLIENTMETRICS* pncm,
  271. COLORREF* prgb);
  272. //---------------------------------------------------------------------------
  273. // DumpLoadedThemeToTextFile()
  274. // - (for internal testing) dumps the contents of the
  275. // loaded theme file to the specified text file
  276. //
  277. // hThemeFile - the handle of the loaded theme file
  278. //
  279. // pszTextFile - path of the text file to create & write to
  280. //
  281. // fPacked - TRUE to dump packed objects; FALSE for normal
  282. // properties
  283. //
  284. // fFullInfo - includes sizes, offsets, paths, etc. Use FALSE
  285. // for info that will be DIFF-ed across builds/machines
  286. //---------------------------------------------------------------------------
  287. THEMEAPI DumpLoadedThemeToTextFile(HTHEMEFILE hThemeFile,
  288. LPCWSTR pszTextFile, BOOL fPacked, BOOL fFullInfo);
  289. #ifdef __cplusplus
  290. class CDrawBase; // forward
  291. class CTextDraw; // forward
  292. //---------------------------------------------------------------------------
  293. // CreateThemeDataFromObjects()
  294. // - creates a theme handle from a CBorderFill,
  295. // CImageFile, and/or CTextDraw object. At lease one
  296. // non-NULL ptr must be passed (either or both).
  297. //
  298. // pDrawObj - (optional) ptr to an object derived from CDrawBase
  299. // NOTE: if pDrawObj is a CImageFile ptr and its
  300. // "_pImageData" contains any alpha channel bitmaps,
  301. // the bits in those bitmaps will be "pre-multiplied"
  302. // for alpha blending.
  303. //
  304. // pTextObj - (optional) ptr to a CTextDraw object
  305. //
  306. // dwOtdFlags - theme override flags (see OpenThemeDataEx())
  307. //---------------------------------------------------------------------------
  308. THEMEAPI_(HTHEME) CreateThemeDataFromObjects(OPTIONAL CDrawBase *pDrawObj,
  309. OPTIONAL CTextDraw *pTextObj, DWORD dwOtdFlags);
  310. #endif
  311. //---------------------------------------------------------------------------
  312. // OpenThemeDataFromFile()
  313. // - Open the theme data for the specified loaded theme
  314. // file and semi-colon separated list of class names.
  315. // OpenThemeDataFromFile() will try each class name,
  316. // one at a time, and use the first matching theme info
  317. // found. If none match, "NULL" is returned.
  318. //
  319. // Note: normal controls should NOT use this API;
  320. // they should use "OpenThemeData()" (which uses the
  321. // current global or app theme).
  322. //
  323. // hLoadedThemeFile - handle to the loaded theme file.
  324. //
  325. // hwnd - (optional) hwnd to base the HTHEME on
  326. //
  327. // pszClassList - (optional) class name (or list of names) to match
  328. // to theme data section; if NULL, will get match
  329. // to [globals] section.
  330. //
  331. // fClient - TRUE if theming a client window with returned
  332. // HTHEME.
  333. //---------------------------------------------------------------------------
  334. THEMEAPI_(HTHEME) OpenThemeDataFromFile(HTHEMEFILE hLoadedThemeFile,
  335. OPTIONAL HWND hwnd, OPTIONAL LPCWSTR pszClassList, BOOL fClient);
  336. //---------------------------------------------------------------------------
  337. // OpenThemeFileFromData()
  338. // - Open the theme file corresponding to the HTHEME.
  339. //
  340. // hTheme - handle to the theme data from OpenThemeData().
  341. //
  342. // phThemeFile - ptr to return HTHEMEFILE to.
  343. //---------------------------------------------------------------------------
  344. THEMEAPI OpenThemeFileFromData(HTHEME hTheme, HTHEMEFILE *phThemeFile);
  345. //---------------------------------------------------------------------------
  346. // GetThemeSysSize96() - Get the value of the specified System size metric.
  347. // (original value authored for 96 dpi)
  348. //
  349. // hTheme - the theme data handle (required). Will return
  350. // size from [SysMetrics] section of theme.
  351. //
  352. // iSizeId - only the following sizes are supported:
  353. //
  354. // SM_CXBORDER (border width)
  355. // SM_CXVSCROLL (scrollbar width)
  356. // SM_CYHSCROLL (scrollbar height)
  357. // SM_CXSIZE (caption width)
  358. // SM_CYSIZE (caption height)
  359. // SM_CXSMSIZE (small caption width)
  360. // SM_CYSMSIZE (small caption height)
  361. // SM_CXMENUSIZE (menubar width)
  362. // SM_CYMENUSIZE (menubar height)
  363. //---------------------------------------------------------------------------
  364. THEMEAPI_(int) GetThemeSysSize96(HTHEME hTheme, int iSizeId);
  365. //---------------------------------------------------------------------------
  366. // GetThemeSysFont96() - Get the LOGFONT for the specified System font.
  367. // (original value authored for 96 dpi)
  368. //
  369. // hTheme - the theme data handle (required). Will return
  370. // size from [SysMetrics] section of theme.
  371. //
  372. // iFontId - the TMT_XXX font number (first font
  373. // is TMT_CAPTIONFONT)
  374. //
  375. // plf - ptr to LOGFONT to receive the font value.
  376. //---------------------------------------------------------------------------
  377. THEMEAPI GetThemeSysFont96(HTHEME hTheme, int iFontId, OUT LOGFONT *plf);
  378. //---------------------------------------------------------------------------
  379. // RefreshThemeForTS()
  380. // - turn themes on/off for current Terminal Server user
  381. //---------------------------------------------------------------------------
  382. THEMEAPI RefreshThemeForTS();
  383. //---------------------------------------------------------------------------
  384. //---- flag bits for OpenThemeDataEx() ----
  385. #define OTD_FORCE_RECT_SIZING 0x0001 // make all parts size to rect
  386. #define OTD_NONCLIENT 0x0002 // set if hTheme to be used for nonclient area
  387. //---------------------------------------------------------------------------
  388. // OpenThemeDataEx - Open the theme data for the specified HWND and
  389. // semi-colon separated list of class names.
  390. //
  391. // OpenThemeData() will try each class name, one at
  392. // a time, and use the first matching theme info
  393. // found. If a match is found, a theme handle
  394. // to the data is returned. If no match is found,
  395. // a "NULL" handle is returned.
  396. //
  397. // When the window is destroyed or a WM_THEMECHANGED
  398. // msg is received, "CloseThemeData()" should be
  399. // called to close the theme handle.
  400. //
  401. // hwnd - window handle of the control/window to be themed
  402. //
  403. // pszClassList - class name (or list of names) to match to theme data
  404. // section. if the list contains more than one name,
  405. // the names are tested one at a time for a match.
  406. // If a match is found, OpenThemeData() returns a
  407. // theme handle associated with the matching class.
  408. // This param is a list (instead of just a single
  409. // class name) to provide the class an opportunity
  410. // to get the "best" match between the class and
  411. // the current theme. For example, a button might
  412. // pass L"OkButton, Button" if its ID=ID_OK. If
  413. // the current theme has an entry for OkButton,
  414. // that will be used. Otherwise, we fall back on
  415. // the normal Button entry.
  416. //
  417. // dwFlags - allows certain overrides of std features
  418. // (see OTD_XXX defines above)
  419. //---------------------------------------------------------------------------
  420. THEMEAPI_(HTHEME) OpenThemeDataEx(HWND hwnd, LPCWSTR pszClassList, DWORD dwFlags);
  421. THEMEAPI CheckThemeSignature (LPCWSTR pszName);
  422. //---------------------------------------------------------------------------
  423. // ClassicGetSystemMetrics( int iMetric );
  424. //
  425. // ClassicSystemParametersInfoA( IN UINT uiAction, IN UINT uiParam,
  426. // IN OUT PVOID pvParam, IN UINT fWinIni);
  427. // ClassicSystemParametersInfoW( IN UINT uiAction, IN UINT uiParam,
  428. // IN OUT PVOID pvParam, IN UINT fWinIni);
  429. // ClassicAdjustWindowRectEx( IN LPRECT prcWnd, IN DWORD dwStyle, IN BOOL fMenu, IN DWORD dwExStyle );
  430. //
  431. // These exports correspond to their Win32 API counterparts and ensure that
  432. // the classic visual style metrics are retrieved. Theme hooks are shunted.
  433. //---------------------------------------------------------------------------
  434. THEMEAPI_(int) ClassicGetSystemMetrics( int iMetric );
  435. THEMEAPI_(BOOL) ClassicSystemParametersInfoA( UINT uiAction, UINT uiParam, IN OUT PVOID pvParam, UINT fWinIni);
  436. THEMEAPI_(BOOL) ClassicSystemParametersInfoW( UINT uiAction, UINT uiParam, IN OUT PVOID pvParam, UINT fWinIni);
  437. THEMEAPI_(BOOL) ClassicAdjustWindowRectEx( LPRECT prcWnd, DWORD dwStyle, BOOL fMenu, DWORD dwExStyle );
  438. #ifdef UNICODE
  439. #define ClassicSystemParametersInfo ClassicSystemParametersInfoW
  440. #else UNICODE
  441. #define ClassicSystemParametersInfo ClassicSystemParametersInfoA
  442. #endif UNICODE
  443. //---------------------------------------------------------------------------
  444. #define PACKTHEM_VERSION 3 // latest change: localizable properties
  445. //---------------------------------------------------------------------------
  446. #endif // _UXTHEMEP_H_
  447. //---------------------------------------------------------------------------