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