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