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