1 #ifndef _UXTHEME_PCH_
2 #define _UXTHEME_PCH_
3
4 #include <stdarg.h>
5
6 #include "resource.h"
7
8 #define WIN32_NO_STATUS
9 #define _INC_WINDOWS
10 #define COM_NO_WINDOWS_H
11
12 #include <windef.h>
13 #include <winbase.h>
14 #include <wingdi.h>
15 #include <winuser.h>
16 #include <winnls.h>
17 #include <windowsx.h>
18 #include <undocuser.h>
19 #include <undocgdi.h>
20 #include <uxtheme.h>
21 #include <uxundoc.h>
22 #include <vfwmsgs.h>
23 #include <tmschema.h>
24
25 #define NTOS_MODE_USER
26 #include <ndk/ntndk.h>
27 #include <ndk/rtltypes.h>
28
29 #include <wine/debug.h>
30 WINE_DEFAULT_DEBUG_CHANNEL(uxtheme);
31
32 #define TMT_ENUM 200
33
34 #define MAX_THEME_APP_NAME 60
35 #define MAX_THEME_CLASS_NAME 60
36 #define MAX_THEME_VALUE_NAME 60
37
38 typedef struct _THEME_PROPERTY {
39 int iPrimitiveType;
40 int iPropertyId;
41 PROPERTYORIGIN origin;
42
43 LPCWSTR lpValue;
44 DWORD dwValueLen;
45
46 struct _THEME_PROPERTY *next;
47 } THEME_PROPERTY, *PTHEME_PROPERTY;
48
49 typedef struct _THEME_PARTSTATE {
50 int iPartId;
51 int iStateId;
52 PTHEME_PROPERTY properties;
53
54 struct _THEME_PARTSTATE *next;
55 } THEME_PARTSTATE, *PTHEME_PARTSTATE;
56
57 struct _THEME_FILE;
58
59 typedef struct _THEME_CLASS {
60 HMODULE hTheme;
61 struct _THEME_FILE* tf;
62 WCHAR szAppName[MAX_THEME_APP_NAME];
63 WCHAR szClassName[MAX_THEME_CLASS_NAME];
64 PTHEME_PARTSTATE partstate;
65 struct _THEME_CLASS *overrides;
66
67 struct _THEME_CLASS *next;
68 } THEME_CLASS, *PTHEME_CLASS;
69
70 typedef struct _THEME_IMAGE {
71 WCHAR name[MAX_PATH];
72 HBITMAP image;
73 BOOL hasAlpha;
74
75 struct _THEME_IMAGE *next;
76 } THEME_IMAGE, *PTHEME_IMAGE;
77
78 typedef struct _THEME_FILE {
79 DWORD dwRefCount;
80 HMODULE hTheme;
81 WCHAR szThemeFile[MAX_PATH];
82 LPWSTR pszAvailColors;
83 LPWSTR pszAvailSizes;
84
85 LPWSTR pszSelectedColor;
86 LPWSTR pszSelectedSize;
87
88 PTHEME_CLASS classes;
89 PTHEME_PROPERTY metrics;
90 PTHEME_IMAGE images;
91 } THEME_FILE, *PTHEME_FILE;
92
93 typedef struct tagTMERRINFO
94 {
95 UINT nID;
96 WCHAR szParam1[MAX_PATH];
97 WCHAR szParam2[MAX_PATH];
98 WCHAR szFile[MAX_PATH];
99 WCHAR szLine[MAX_PATH];
100 INT nLineNo;
101 } TMERRINFO, *PTMERRINFO;
102
103 typedef struct _UXINI_FILE *PUXINI_FILE;
104
105 typedef struct _UXTHEME_HANDLE
106 {
107 RTL_HANDLE_TABLE_ENTRY Handle;
108 PTHEME_CLASS pClass;
109 } UXTHEME_HANDLE, *PUXTHEME_HANDLE;
110
111 PTHEME_CLASS ValidateHandle(HTHEME hTheme);
112
113 HRESULT UXTHEME_LoadImage(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, BOOL glyph,
114 HBITMAP *hBmp, RECT *bmpRect, BOOL* hasImageAlpha);
115
116 BOOL MSSTYLES_LookupProperty(LPCWSTR pszPropertyName, int *dwPrimitive, int *dwId);
117 BOOL MSSTYLES_LookupEnum(LPCWSTR pszValueName, int dwEnum, int *dwValue);
118 BOOL MSSTYLES_LookupPartState(LPCWSTR pszClass, LPCWSTR pszPart, LPCWSTR pszState, int *iPartId, int *iStateId);
119
120 HRESULT MSSTYLES_OpenThemeFile(LPCWSTR lpThemeFile, LPCWSTR pszColorName, LPCWSTR pszSizeName, PTHEME_FILE *tf);
121 HRESULT MSSTYLES_ReferenceTheme(PTHEME_FILE tf);
122 void MSSTYLES_CloseThemeFile(PTHEME_FILE tf);
123 void MSSTYLES_ParseThemeIni(PTHEME_FILE tf);
124 PTHEME_CLASS MSSTYLES_OpenThemeClass(PTHEME_FILE tf, LPCWSTR pszAppName, LPCWSTR pszClassList);
125 HRESULT MSSTYLES_CloseThemeClass(PTHEME_CLASS tc);
126 PUXINI_FILE MSSTYLES_GetThemeIni(PTHEME_FILE tf);
127 PTHEME_PARTSTATE MSSTYLES_FindPartState(PTHEME_CLASS tc, int iPartId, int iStateId, PTHEME_CLASS *tcNext);
128 PTHEME_PROPERTY MSSTYLES_FindProperty(PTHEME_CLASS tc, int iPartId, int iStateId, int iPropertyPrimitive, int iPropertyId);
129 PTHEME_PROPERTY MSSTYLES_FindMetric(PTHEME_FILE tf, int iPropertyPrimitive, int iPropertyId);
130 #ifdef ENABLE_PNG_SUPPORT
131 EXTERN_C
132 BOOL
133 MSSTYLES_TryLoadPng(
134 _In_ HINSTANCE hTheme,
135 _In_ LPCWSTR szFile,
136 _In_ LPCWSTR type,
137 _Out_ HBITMAP *phBitmap);
138 EXTERN_C
139 BOOL
140 prepare_png_alpha(
141 _In_ HBITMAP png,
142 _Out_ BOOL* hasAlpha);
143 #endif /* ENABLE_PNG_SUPPORT */
144 HBITMAP MSSTYLES_LoadBitmap(PTHEME_CLASS tc, LPCWSTR lpFilename, BOOL* hasAlpha);
145
146 HRESULT MSSTYLES_GetPropertyBool(PTHEME_PROPERTY tp, BOOL *pfVal);
147 HRESULT MSSTYLES_GetPropertyColor(PTHEME_PROPERTY tp, COLORREF *pColor);
148 HRESULT MSSTYLES_GetPropertyFont(PTHEME_PROPERTY tp, HDC hdc, LOGFONTW *pFont);
149 HRESULT MSSTYLES_GetPropertyInt(PTHEME_PROPERTY tp, int *piVal);
150 HRESULT MSSTYLES_GetPropertyIntList(PTHEME_PROPERTY tp, INTLIST *pIntList);
151 HRESULT MSSTYLES_GetPropertyPosition(PTHEME_PROPERTY tp, POINT *pPoint);
152 HRESULT MSSTYLES_GetPropertyString(PTHEME_PROPERTY tp, LPWSTR pszBuff, int cchMaxBuffChars);
153 HRESULT MSSTYLES_GetPropertyRect(PTHEME_PROPERTY tp, RECT *pRect);
154 HRESULT MSSTYLES_GetPropertyMargins(PTHEME_PROPERTY tp, RECT *prc, MARGINS *pMargins);
155
156 PUXINI_FILE UXINI_LoadINI(HMODULE hTheme, LPCWSTR lpName);
157 void UXINI_CloseINI(PUXINI_FILE uf);
158 LPCWSTR UXINI_GetNextSection(PUXINI_FILE uf, DWORD *dwLen);
159 BOOL UXINI_FindSection(PUXINI_FILE uf, LPCWSTR lpName);
160 LPCWSTR UXINI_GetNextValue(PUXINI_FILE uf, DWORD *dwNameLen, LPCWSTR *lpValue, DWORD *dwValueLen);
161 BOOL UXINI_FindValue(PUXINI_FILE uf, LPCWSTR lpName, LPCWSTR *lpValue, DWORD *dwValueLen);
162
163 /* Scroll-bar hit testing */
164 enum SCROLL_HITTEST
165 {
166 SCROLL_NOWHERE, /* Outside the scroll bar */
167 SCROLL_TOP_ARROW, /* Top or left arrow */
168 SCROLL_TOP_RECT, /* Rectangle between the top arrow and the thumb */
169 SCROLL_THUMB, /* Thumb rectangle */
170 SCROLL_BOTTOM_RECT, /* Rectangle between the thumb and the bottom arrow */
171 SCROLL_BOTTOM_ARROW /* Bottom or right arrow */
172 };
173
174 /* The window context stores data for the window needed through the life of the window */
175 typedef struct _WND_DATA
176 {
177 HTHEME hthemeWindow;
178 HTHEME hthemeScrollbar;
179
180 RECT rcCaptionButtons[4];
181 UINT lastHitTest;
182 BOOL HasAppDefinedRgn;
183 BOOL HasThemeRgn;
184 BOOL UpdatingRgn;
185 BOOL DirtyThemeRegion;
186 HBRUSH hTabBackgroundBrush;
187 HBITMAP hTabBackgroundBmp;
188
189 BOOL SCROLL_trackVertical;
190 enum SCROLL_HITTEST SCROLL_trackHitTest;
191 BOOL SCROLL_MovingThumb; /* Is the moving thumb being displayed? */
192 HWND SCROLL_TrackingWin;
193 INT SCROLL_TrackingBar;
194 INT SCROLL_TrackingPos;
195 INT SCROLL_TrackingVal;
196 } WND_DATA, *PWND_DATA;
197
198 /* The draw context stores data that are needed by the drawing operations in the non client area of the window */
199 typedef struct _DRAW_CONTEXT
200 {
201 HWND hWnd;
202 HDC hDC;
203 HTHEME theme;
204 HTHEME scrolltheme;
205 HTHEME hPrevTheme;
206 WINDOWINFO wi;
207 BOOL Active; /* wi.dwWindowStatus isn't correct for mdi child windows */
208 HRGN hRgn;
209 int CaptionHeight;
210
211 /* for double buffering */
212 HDC hDCScreen;
213 HBITMAP hbmpOld;
214 } DRAW_CONTEXT, *PDRAW_CONTEXT;
215
216 typedef enum
217 {
218 CLOSEBUTTON,
219 MAXBUTTON,
220 MINBUTTON,
221 HELPBUTTON
222 } CAPTIONBUTTON;
223
224 /*
225 The following values specify all possible button states
226 Note that not all of them are documented but it is easy to
227 find them by opening a theme file
228 */
229 typedef enum {
230 BUTTON_NORMAL = 1 ,
231 BUTTON_HOT ,
232 BUTTON_PRESSED ,
233 BUTTON_DISABLED ,
234 BUTTON_INACTIVE ,
235 BUTTON_INACTIVE_HOT ,
236 BUTTON_INACTIVE_PRESSED ,
237 BUTTON_INACTIVE_DISABLED
238 } THEME_BUTTON_STATES;
239
240 #define HT_ISBUTTON(ht) ((ht) == HTMINBUTTON || (ht) == HTMAXBUTTON || (ht) == HTCLOSE || (ht) == HTHELP)
241
242 #define HASSIZEGRIP(Style, ExStyle, ParentStyle, WindowRect, ParentClientRect) \
243 ((!(Style & WS_CHILD) && (Style & WS_THICKFRAME) && !(Style & WS_MAXIMIZE)) || \
244 ((Style & WS_CHILD) && (ParentStyle & WS_THICKFRAME) && !(ParentStyle & WS_MAXIMIZE) && \
245 (WindowRect.right - WindowRect.left == ParentClientRect.right) && \
246 (WindowRect.bottom - WindowRect.top == ParentClientRect.bottom)))
247
248 #define HAS_MENU(hwnd,style) ((((style) & (WS_CHILD | WS_POPUP)) != WS_CHILD) && GetMenu(hwnd))
249
250 #define BUTTON_GAP_SIZE 2
251
252 #define MENU_BAR_ITEMS_SPACE (12)
253
254 #define SCROLL_TIMER 0 /* Scroll timer id */
255
256 /* Overlap between arrows and thumb */
257 #define SCROLL_ARROW_THUMB_OVERLAP 0
258
259 /* Delay (in ms) before first repetition when holding the button down */
260 #define SCROLL_FIRST_DELAY 200
261
262 /* Delay (in ms) between scroll repetitions */
263 #define SCROLL_REPEAT_DELAY 50
264
265 /* Minimum size of the thumb in pixels */
266 #define SCROLL_MIN_THUMB 6
267
268 /* Minimum size of the rectangle between the arrows */
269 #define SCROLL_MIN_RECT 4
270
271 LRESULT CALLBACK ThemeWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, WNDPROC DefWndProc);
272 void ThemeCalculateCaptionButtonsPos(HWND hWnd, HTHEME htheme);
273 LONG SCROLL_getObjectId(INT nBar);
274 void ThemeDrawScrollBarEx(PDRAW_CONTEXT pcontext, INT nBar, PSCROLLBARINFO psbi, POINT* pt);
275 void ThemeDrawScrollBar(PDRAW_CONTEXT pcontext, INT Bar, POINT* pt);
276 VOID NC_TrackScrollBar(HWND Wnd, WPARAM wParam, POINT Pt);
277 void ThemeInitDrawContext(PDRAW_CONTEXT pcontext, HWND hWnd, HRGN hRgn);
278 void ThemeCleanupDrawContext(PDRAW_CONTEXT pcontext);
279 PWND_DATA ThemeGetWndData(HWND hWnd);
280 HTHEME GetNCCaptionTheme(HWND hWnd, DWORD style);
281 HTHEME GetNCScrollbarTheme(HWND hWnd, DWORD style);
282
283 extern HINSTANCE hDllInst;
284 extern ATOM atWindowTheme;
285 extern ATOM atWndContext;
286 extern BOOL g_bThemeHooksActive;
287
288 void UXTHEME_InitSystem(HINSTANCE hInst);
289 void UXTHEME_UnInitSystem(HINSTANCE hInst);
290 void UXTHEME_LoadTheme(BOOL bLoad);
291 BOOL CALLBACK UXTHEME_broadcast_theme_changed (HWND hWnd, LPARAM enable);
292
293 /* No alpha blending */
294 #define ALPHABLEND_NONE 0
295 /* "Cheap" binary alpha blending - but possibly faster */
296 #define ALPHABLEND_BINARY 1
297 /* Full alpha blending */
298 #define ALPHABLEND_FULL 2
299
300 extern DWORD gdwErrorInfoTlsIndex;
301
302 VOID UXTHEME_DeleteParseErrorInfo(VOID);
303
304 static inline
305 HRESULT
UXTHEME_MakeError(_In_ LONG error)306 UXTHEME_MakeError(_In_ LONG error)
307 {
308 if (error < 0)
309 return (HRESULT)error;
310 return HRESULT_FROM_WIN32(error);
311 }
312
313 static inline
314 HRESULT
UXTHEME_MakeLastError(VOID)315 UXTHEME_MakeLastError(VOID)
316 {
317 return UXTHEME_MakeError(GetLastError());
318 }
319
320 HRESULT
321 UXTHEME_MakeParseError(
322 _In_ UINT nID,
323 _In_ LPCWSTR pszParam1,
324 _In_ LPCWSTR pszParam2,
325 _In_ LPCWSTR pszFile,
326 _In_ LPCWSTR pszLine,
327 _In_ INT nLineNo);
328
329 #endif /* _UXTHEME_PCH_ */
330