aboutsummaryrefslogtreecommitdiff
path: root/src/dutil/inc/thmutil.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/dutil/inc/thmutil.h')
-rw-r--r--src/dutil/inc/thmutil.h711
1 files changed, 711 insertions, 0 deletions
diff --git a/src/dutil/inc/thmutil.h b/src/dutil/inc/thmutil.h
new file mode 100644
index 00000000..5b3d4667
--- /dev/null
+++ b/src/dutil/inc/thmutil.h
@@ -0,0 +1,711 @@
1#pragma once
2// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
3
4
5#ifdef __cplusplus
6extern "C" {
7#endif
8
9#define ReleaseTheme(p) if (p) { ThemeFree(p); p = NULL; }
10
11typedef HRESULT(CALLBACK *PFNTHM_EVALUATE_VARIABLE_CONDITION)(
12 __in_z LPCWSTR wzCondition,
13 __out BOOL* pf,
14 __in_opt LPVOID pvContext
15 );
16typedef HRESULT(CALLBACK *PFNTHM_FORMAT_VARIABLE_STRING)(
17 __in_z LPCWSTR wzFormat,
18 __inout LPWSTR* psczOut,
19 __in_opt LPVOID pvContext
20 );
21typedef HRESULT(CALLBACK *PFNTHM_GET_VARIABLE_NUMERIC)(
22 __in_z LPCWSTR wzVariable,
23 __out LONGLONG* pllValue,
24 __in_opt LPVOID pvContext
25 );
26typedef HRESULT(CALLBACK *PFNTHM_SET_VARIABLE_NUMERIC)(
27 __in_z LPCWSTR wzVariable,
28 __in LONGLONG llValue,
29 __in_opt LPVOID pvContext
30 );
31typedef HRESULT(CALLBACK *PFNTHM_GET_VARIABLE_STRING)(
32 __in_z LPCWSTR wzVariable,
33 __inout LPWSTR* psczValue,
34 __in_opt LPVOID pvContext
35 );
36typedef HRESULT(CALLBACK *PFNTHM_SET_VARIABLE_STRING)(
37 __in_z LPCWSTR wzVariable,
38 __in_z_opt LPCWSTR wzValue,
39 __in_opt LPVOID pvContext
40 );
41
42typedef enum THEME_ACTION_TYPE
43{
44 THEME_ACTION_TYPE_BROWSE_DIRECTORY,
45 THEME_ACTION_TYPE_CHANGE_PAGE,
46 THEME_ACTION_TYPE_CLOSE_WINDOW,
47} THEME_ACTION_TYPE;
48
49typedef enum THEME_CONTROL_DATA
50{
51 THEME_CONTROL_DATA_HOVER = 1,
52} THEME_CONTROL_DATA;
53
54typedef enum THEME_CONTROL_TYPE
55{
56 THEME_CONTROL_TYPE_UNKNOWN,
57 THEME_CONTROL_TYPE_BILLBOARD,
58 THEME_CONTROL_TYPE_BUTTON,
59 THEME_CONTROL_TYPE_CHECKBOX,
60 THEME_CONTROL_TYPE_COMBOBOX,
61 THEME_CONTROL_TYPE_COMMANDLINK,
62 THEME_CONTROL_TYPE_EDITBOX,
63 THEME_CONTROL_TYPE_HYPERLINK,
64 THEME_CONTROL_TYPE_HYPERTEXT,
65 THEME_CONTROL_TYPE_IMAGE,
66 THEME_CONTROL_TYPE_LABEL,
67 THEME_CONTROL_TYPE_PANEL,
68 THEME_CONTROL_TYPE_PROGRESSBAR,
69 THEME_CONTROL_TYPE_RADIOBUTTON,
70 THEME_CONTROL_TYPE_RICHEDIT,
71 THEME_CONTROL_TYPE_STATIC,
72 THEME_CONTROL_TYPE_LISTVIEW,
73 THEME_CONTROL_TYPE_TREEVIEW,
74 THEME_CONTROL_TYPE_TAB,
75} THEME_CONTROL_TYPE;
76
77typedef enum THEME_SHOW_PAGE_REASON
78{
79 THEME_SHOW_PAGE_REASON_DEFAULT,
80 THEME_SHOW_PAGE_REASON_CANCEL,
81 THEME_SHOW_PAGE_REASON_REFRESH,
82} THEME_SHOW_PAGE_REASON;
83
84
85struct THEME_COLUMN
86{
87 LPWSTR pszName;
88 UINT uStringId;
89 int nBaseWidth;
90 int nWidth;
91 BOOL fExpands;
92};
93
94
95struct THEME_TAB
96{
97 LPWSTR pszName;
98 UINT uStringId;
99};
100
101struct THEME_ACTION
102{
103 LPWSTR sczCondition;
104 THEME_ACTION_TYPE type;
105 union
106 {
107 struct
108 {
109 LPWSTR sczVariableName;
110 } BrowseDirectory;
111 struct
112 {
113 LPWSTR sczPageName;
114 BOOL fCancel;
115 } ChangePage;
116 };
117};
118
119struct THEME_CONDITIONAL_TEXT
120{
121 LPWSTR sczCondition;
122 LPWSTR sczText;
123};
124
125// THEME_ASSIGN_CONTROL_ID - Used to apply a specific id to a named control (usually
126// to set the WM_COMMAND).
127struct THEME_ASSIGN_CONTROL_ID
128{
129 WORD wId; // id to apply to control
130 LPCWSTR wzName; // name of control to match
131};
132
133const DWORD THEME_FIRST_ASSIGN_CONTROL_ID = 1024; // Recommended first control id to be assigned.
134
135struct THEME_CONTROL
136{
137 THEME_CONTROL_TYPE type;
138
139 WORD wId;
140 WORD wPageId;
141
142 LPWSTR sczName; // optional name for control, used to apply control id and link the control to a variable.
143 LPWSTR sczText;
144 LPWSTR sczTooltip;
145 LPWSTR sczNote; // optional text for command link
146 int nX;
147 int nY;
148 int nHeight;
149 int nWidth;
150 int nSourceX;
151 int nSourceY;
152 UINT uStringId;
153
154 LPWSTR sczEnableCondition;
155 LPWSTR sczVisibleCondition;
156 BOOL fDisableVariableFunctionality;
157
158 HBITMAP hImage;
159 HICON hIcon;
160
161 // Don't free these; it's just a handle to the central image lists stored in THEME. The handle is freed once, there.
162 HIMAGELIST rghImageList[4];
163
164 DWORD dwStyle;
165 DWORD dwExtendedStyle;
166 DWORD dwInternalStyle;
167
168 DWORD dwFontId;
169
170 // child controls
171 DWORD cControls;
172 THEME_CONTROL* rgControls;
173
174 // Used by billboard controls
175 WORD wBillboardInterval;
176 BOOL fBillboardLoops;
177
178 // Used by button and command link controls
179 THEME_ACTION* rgActions;
180 DWORD cActions;
181 THEME_ACTION* pDefaultAction;
182
183 // Used by hyperlink and owner-drawn button controls
184 DWORD dwFontHoverId;
185 DWORD dwFontSelectedId;
186
187 // Used by listview controls
188 THEME_COLUMN *ptcColumns;
189 DWORD cColumns;
190
191 // Used by radio button controls
192 BOOL fLastRadioButton;
193 LPWSTR sczValue;
194 LPWSTR sczVariable;
195
196 // Used by tab controls
197 THEME_TAB *pttTabs;
198 DWORD cTabs;
199
200 // Used by controls that have text
201 DWORD cConditionalText;
202 THEME_CONDITIONAL_TEXT* rgConditionalText;
203
204 // Used by command link controls
205 DWORD cConditionalNotes;
206 THEME_CONDITIONAL_TEXT* rgConditionalNotes;
207
208 // state variables that should be ignored
209 HWND hWnd;
210 DWORD dwData; // type specific data
211};
212
213
214struct THEME_IMAGELIST
215{
216 LPWSTR sczName;
217
218 HIMAGELIST hImageList;
219};
220
221struct THEME_SAVEDVARIABLE
222{
223 LPWSTR wzName;
224 LPWSTR sczValue;
225};
226
227struct THEME_PAGE
228{
229 WORD wId;
230 LPWSTR sczName;
231
232 DWORD cControlIndices;
233
234 DWORD cSavedVariables;
235 THEME_SAVEDVARIABLE* rgSavedVariables;
236};
237
238struct THEME_FONT
239{
240 HFONT hFont;
241 COLORREF crForeground;
242 HBRUSH hForeground;
243 COLORREF crBackground;
244 HBRUSH hBackground;
245};
246
247
248struct THEME
249{
250 WORD wId;
251
252 BOOL fAutoResize;
253
254 DWORD dwStyle;
255 DWORD dwFontId;
256 HANDLE hIcon;
257 LPWSTR sczCaption;
258 int nHeight;
259 int nMinimumHeight;
260 int nWidth;
261 int nMinimumWidth;
262 int nSourceX;
263 int nSourceY;
264 UINT uStringId;
265
266 HBITMAP hImage;
267
268 DWORD cFonts;
269 THEME_FONT* rgFonts;
270
271 DWORD cPages;
272 THEME_PAGE* rgPages;
273
274 DWORD cImageLists;
275 THEME_IMAGELIST* rgImageLists;
276
277 DWORD cControls;
278 THEME_CONTROL* rgControls;
279
280 // internal state variables -- do not use outside ThmUtil.cpp
281 HWND hwndParent; // parent for loaded controls
282 HWND hwndHover; // current hwnd hovered over
283 DWORD dwCurrentPageId;
284 HWND hwndTooltip;
285
286 // callback functions
287 PFNTHM_EVALUATE_VARIABLE_CONDITION pfnEvaluateCondition;
288 PFNTHM_FORMAT_VARIABLE_STRING pfnFormatString;
289 PFNTHM_GET_VARIABLE_NUMERIC pfnGetNumericVariable;
290 PFNTHM_SET_VARIABLE_NUMERIC pfnSetNumericVariable;
291 PFNTHM_GET_VARIABLE_STRING pfnGetStringVariable;
292 PFNTHM_SET_VARIABLE_STRING pfnSetStringVariable;
293
294 LPVOID pvVariableContext;
295};
296
297
298/********************************************************************
299 ThemeInitialize - initialized theme management.
300
301*******************************************************************/
302DAPI_(HRESULT) ThemeInitialize(
303 __in_opt HMODULE hModule
304 );
305
306/********************************************************************
307 ThemeUninitialize - uninitialize theme management.
308
309*******************************************************************/
310DAPI_(void) ThemeUninitialize();
311
312/********************************************************************
313 ThemeLoadFromFile - loads a theme from a loose file.
314
315 *******************************************************************/
316DAPI_(HRESULT) ThemeLoadFromFile(
317 __in_z LPCWSTR wzThemeFile,
318 __out THEME** ppTheme
319 );
320
321/********************************************************************
322 ThemeLoadFromResource - loads a theme from a module's data resource.
323
324 NOTE: The resource data must be UTF-8 encoded.
325*******************************************************************/
326DAPI_(HRESULT) ThemeLoadFromResource(
327 __in_opt HMODULE hModule,
328 __in_z LPCSTR szResource,
329 __out THEME** ppTheme
330 );
331
332/********************************************************************
333 ThemeFree - frees any memory associated with a theme.
334
335*******************************************************************/
336DAPI_(void) ThemeFree(
337 __in THEME* pTheme
338 );
339
340/********************************************************************
341ThemeRegisterVariableCallbacks - registers a context and callbacks
342 for working with variables.
343
344*******************************************************************/
345DAPI_(HRESULT) ThemeRegisterVariableCallbacks(
346 __in THEME* pTheme,
347 __in_opt PFNTHM_EVALUATE_VARIABLE_CONDITION pfnEvaluateCondition,
348 __in_opt PFNTHM_FORMAT_VARIABLE_STRING pfnFormatString,
349 __in_opt PFNTHM_GET_VARIABLE_NUMERIC pfnGetNumericVariable,
350 __in_opt PFNTHM_SET_VARIABLE_NUMERIC pfnSetNumericVariable,
351 __in_opt PFNTHM_GET_VARIABLE_STRING pfnGetStringVariable,
352 __in_opt PFNTHM_SET_VARIABLE_STRING pfnSetStringVariable,
353 __in_opt LPVOID pvContext
354 );
355
356/********************************************************************
357 ThemeLoadControls - creates the windows for all the theme controls.
358
359*******************************************************************/
360DAPI_(HRESULT) ThemeLoadControls(
361 __in THEME* pTheme,
362 __in HWND hwndParent,
363 __in_ecount_opt(cAssignControlIds) const THEME_ASSIGN_CONTROL_ID* rgAssignControlIds,
364 __in DWORD cAssignControlIds
365 );
366
367/********************************************************************
368 ThemeUnloadControls - resets all the theme control windows so the theme
369 controls can be reloaded.
370
371*******************************************************************/
372DAPI_(void) ThemeUnloadControls(
373 __in THEME* pTheme
374 );
375
376/********************************************************************
377 ThemeLocalize - Localizes all of the strings in the theme.
378
379*******************************************************************/
380DAPI_(HRESULT) ThemeLocalize(
381 __in THEME *pTheme,
382 __in const WIX_LOCALIZATION *pLocStringSet
383 );
384
385DAPI_(HRESULT) ThemeLoadStrings(
386 __in THEME* pTheme,
387 __in HMODULE hResModule
388 );
389
390/********************************************************************
391 ThemeLoadRichEditFromFile - Attach a richedit control to a RTF file.
392
393 *******************************************************************/
394DAPI_(HRESULT) ThemeLoadRichEditFromFile(
395 __in THEME* pTheme,
396 __in DWORD dwControl,
397 __in_z LPCWSTR wzFileName,
398 __in HMODULE hModule
399 );
400
401/********************************************************************
402 ThemeLoadRichEditFromResource - Attach a richedit control to resource data.
403
404 *******************************************************************/
405DAPI_(HRESULT) ThemeLoadRichEditFromResource(
406 __in THEME* pTheme,
407 __in DWORD dwControl,
408 __in_z LPCSTR szResourceName,
409 __in HMODULE hModule
410 );
411
412/********************************************************************
413 ThemeLoadRichEditFromResourceToHWnd - Attach a richedit control (by
414 HWND) to resource data.
415
416 *******************************************************************/
417DAPI_(HRESULT) ThemeLoadRichEditFromResourceToHWnd(
418 __in HWND hWnd,
419 __in_z LPCSTR szResourceName,
420 __in HMODULE hModule
421 );
422
423/********************************************************************
424 ThemeHandleKeyboardMessage - will translate the message using the active
425 accelerator table.
426
427*******************************************************************/
428DAPI_(BOOL) ThemeHandleKeyboardMessage(
429 __in_opt THEME* pTheme,
430 __in HWND hWnd,
431 __in MSG* pMsg
432 );
433
434/********************************************************************
435 ThemeDefWindowProc - replacement for DefWindowProc() when using theme.
436
437*******************************************************************/
438LRESULT CALLBACK ThemeDefWindowProc(
439 __in_opt THEME* pTheme,
440 __in HWND hWnd,
441 __in UINT uMsg,
442 __in WPARAM wParam,
443 __in LPARAM lParam
444 );
445
446/********************************************************************
447 ThemeGetPageIds - gets the page ids for the theme via page names.
448
449*******************************************************************/
450DAPI_(void) ThemeGetPageIds(
451 __in const THEME* pTheme,
452 __in_ecount(cGetPages) LPCWSTR* rgwzFindNames,
453 __inout_ecount(cGetPages) DWORD* rgdwPageIds,
454 __in DWORD cGetPages
455 );
456
457/********************************************************************
458 ThemeGetPage - gets a theme page by id.
459
460 *******************************************************************/
461DAPI_(THEME_PAGE*) ThemeGetPage(
462 __in const THEME* pTheme,
463 __in DWORD dwPage
464 );
465
466/********************************************************************
467 ThemeShowPage - shows or hides all of the controls in the page at one time.
468
469 *******************************************************************/
470DAPI_(HRESULT) ThemeShowPage(
471 __in THEME* pTheme,
472 __in DWORD dwPage,
473 __in int nCmdShow
474 );
475
476/********************************************************************
477ThemeShowPageEx - shows or hides all of the controls in the page at one time.
478 When using variables, TSPR_CANCEL reverts any changes made.
479 TSPR_REFRESH forces reevaluation of conditions.
480 It is expected that the current page is hidden before
481 showing a new page.
482
483*******************************************************************/
484DAPI_(HRESULT) ThemeShowPageEx(
485 __in THEME* pTheme,
486 __in DWORD dwPage,
487 __in int nCmdShow,
488 __in THEME_SHOW_PAGE_REASON reason
489 );
490
491
492/********************************************************************
493ThemeShowChild - shows a control's specified child control, hiding the rest.
494
495*******************************************************************/
496DAPI_(void) ThemeShowChild(
497 __in THEME* pTheme,
498 __in THEME_CONTROL* pParentControl,
499 __in DWORD dwIndex
500 );
501
502/********************************************************************
503 ThemeControlExists - check if a control with the specified id exists.
504
505 *******************************************************************/
506DAPI_(BOOL) ThemeControlExists(
507 __in const THEME* pTheme,
508 __in DWORD dwControl
509 );
510
511/********************************************************************
512 ThemeControlEnable - enables/disables a control.
513
514 *******************************************************************/
515DAPI_(void) ThemeControlEnable(
516 __in THEME* pTheme,
517 __in DWORD dwControl,
518 __in BOOL fEnable
519 );
520
521/********************************************************************
522 ThemeControlEnabled - returns whether a control is enabled/disabled.
523
524 *******************************************************************/
525DAPI_(BOOL) ThemeControlEnabled(
526 __in THEME* pTheme,
527 __in DWORD dwControl
528 );
529
530/********************************************************************
531 ThemeControlElevates - sets/removes the shield icon on a control.
532
533 *******************************************************************/
534DAPI_(void) ThemeControlElevates(
535 __in THEME* pTheme,
536 __in DWORD dwControl,
537 __in BOOL fElevates
538 );
539
540/********************************************************************
541 ThemeShowControl - shows/hides a control.
542
543 *******************************************************************/
544DAPI_(void) ThemeShowControl(
545 __in THEME* pTheme,
546 __in DWORD dwControl,
547 __in int nCmdShow
548 );
549
550/********************************************************************
551ThemeShowControlEx - shows/hides a control with support for
552conditional text and notes.
553
554*******************************************************************/
555DAPI_(void) ThemeShowControlEx(
556 __in THEME* pTheme,
557 __in DWORD dwControl,
558 __in int nCmdShow
559 );
560
561/********************************************************************
562 ThemeControlVisible - returns whether a control is visible.
563
564 *******************************************************************/
565DAPI_(BOOL) ThemeControlVisible(
566 __in THEME* pTheme,
567 __in DWORD dwControl
568 );
569
570DAPI_(BOOL) ThemePostControlMessage(
571 __in THEME* pTheme,
572 __in DWORD dwControl,
573 __in UINT Msg,
574 __in WPARAM wParam,
575 __in LPARAM lParam
576 );
577
578DAPI_(LRESULT) ThemeSendControlMessage(
579 __in const THEME* pTheme,
580 __in DWORD dwControl,
581 __in UINT Msg,
582 __in WPARAM wParam,
583 __in LPARAM lParam
584 );
585
586/********************************************************************
587 ThemeDrawBackground - draws the theme background.
588
589*******************************************************************/
590DAPI_(HRESULT) ThemeDrawBackground(
591 __in THEME* pTheme,
592 __in PAINTSTRUCT* pps
593 );
594
595/********************************************************************
596 ThemeDrawControl - draw an owner drawn control.
597
598*******************************************************************/
599DAPI_(HRESULT) ThemeDrawControl(
600 __in THEME* pTheme,
601 __in DRAWITEMSTRUCT* pdis
602 );
603
604/********************************************************************
605 ThemeHoverControl - mark a control as hover.
606
607*******************************************************************/
608DAPI_(BOOL) ThemeHoverControl(
609 __in THEME* pTheme,
610 __in HWND hwndParent,
611 __in HWND hwndControl
612 );
613
614/********************************************************************
615 ThemeIsControlChecked - gets whether a control is checked. Only
616 really useful for checkbox controls.
617
618*******************************************************************/
619DAPI_(BOOL) ThemeIsControlChecked(
620 __in THEME* pTheme,
621 __in DWORD dwControl
622 );
623
624/********************************************************************
625 ThemeSetControlColor - sets the color of text for a control.
626
627*******************************************************************/
628DAPI_(BOOL) ThemeSetControlColor(
629 __in THEME* pTheme,
630 __in HDC hdc,
631 __in HWND hWnd,
632 __out HBRUSH* phBackgroundBrush
633 );
634
635/********************************************************************
636 ThemeSetProgressControl - sets the current percentage complete in a
637 progress bar control.
638
639*******************************************************************/
640DAPI_(HRESULT) ThemeSetProgressControl(
641 __in THEME* pTheme,
642 __in DWORD dwControl,
643 __in DWORD dwProgressPercentage
644 );
645
646/********************************************************************
647 ThemeSetProgressControlColor - sets the current color of a
648 progress bar control.
649
650*******************************************************************/
651DAPI_(HRESULT) ThemeSetProgressControlColor(
652 __in THEME* pTheme,
653 __in DWORD dwControl,
654 __in DWORD dwColorIndex
655 );
656
657/********************************************************************
658 ThemeSetTextControl - sets the text of a control.
659
660*******************************************************************/
661DAPI_(HRESULT) ThemeSetTextControl(
662 __in const THEME* pTheme,
663 __in DWORD dwControl,
664 __in_z_opt LPCWSTR wzText
665 );
666
667/********************************************************************
668ThemeSetTextControl - sets the text of a control and optionally
669 invalidates the control.
670
671*******************************************************************/
672DAPI_(HRESULT) ThemeSetTextControlEx(
673 __in const THEME* pTheme,
674 __in DWORD dwControl,
675 __in BOOL fUpdate,
676 __in_z_opt LPCWSTR wzText
677 );
678
679/********************************************************************
680 ThemeGetTextControl - gets the text of a control.
681
682*******************************************************************/
683DAPI_(HRESULT) ThemeGetTextControl(
684 __in const THEME* pTheme,
685 __in DWORD dwControl,
686 __out_z LPWSTR* psczText
687 );
688
689/********************************************************************
690 ThemeUpdateCaption - updates the caption in the theme.
691
692*******************************************************************/
693DAPI_(HRESULT) ThemeUpdateCaption(
694 __in THEME* pTheme,
695 __in_z LPCWSTR wzCaption
696 );
697
698/********************************************************************
699 ThemeSetFocus - set the focus to the control supplied or the next
700 enabled control if it is disabled.
701
702*******************************************************************/
703DAPI_(void) ThemeSetFocus(
704 __in THEME* pTheme,
705 __in DWORD dwControl
706 );
707
708#ifdef __cplusplus
709}
710#endif
711