[UXTHEME] -Move the global variables for the scrollbars into the WND_CONTEXT. Hook...
[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 /* Scroll-bar hit testing */
122 enum SCROLL_HITTEST
123 {
124 SCROLL_NOWHERE, /* Outside the scroll bar */
125 SCROLL_TOP_ARROW, /* Top or left arrow */
126 SCROLL_TOP_RECT, /* Rectangle between the top arrow and the thumb */
127 SCROLL_THUMB, /* Thumb rectangle */
128 SCROLL_BOTTOM_RECT, /* Rectangle between the thumb and the bottom arrow */
129 SCROLL_BOTTOM_ARROW /* Bottom or right arrow */
130 };
131
132 /* The window context stores data for the window needed through the life of the window */
133 typedef struct _WND_CONTEXT
134 {
135 UINT lastHitTest;
136 BOOL HasAppDefinedRgn;
137 BOOL HasThemeRgn;
138 BOOL UpdatingRgn;
139 BOOL DirtyThemeRegion;
140
141 BOOL SCROLL_trackVertical;
142 enum SCROLL_HITTEST SCROLL_trackHitTest;
143 BOOL SCROLL_MovingThumb; /* Is the moving thumb being displayed? */
144 HWND SCROLL_TrackingWin;
145 INT SCROLL_TrackingBar;
146 INT SCROLL_TrackingPos;
147 INT SCROLL_TrackingVal;
148 } WND_CONTEXT, *PWND_CONTEXT;
149
150 /* The draw context stores data that are needed by the drawing operations in the non client area of the window */
151 typedef struct _DRAW_CONTEXT
152 {
153 HWND hWnd;
154 HDC hDC;
155 HTHEME theme;
156 HTHEME scrolltheme;
157 HTHEME hPrevTheme;
158 WINDOWINFO wi;
159 BOOL Active; /* wi.dwWindowStatus isn't correct for mdi child windows */
160 HRGN hRgn;
161 int CaptionHeight;
162
163 /* for double buffering */
164 HDC hDCScreen;
165 HBITMAP hbmpOld;
166 } DRAW_CONTEXT, *PDRAW_CONTEXT;
167
168 typedef enum
169 {
170 CLOSEBUTTON,
171 MAXBUTTON,
172 MINBUTTON,
173 HELPBUTTON
174 } CAPTIONBUTTON;
175
176 /*
177 The following values specify all possible button states
178 Note that not all of them are documented but it is easy to
179 find them by opening a theme file
180 */
181 typedef enum {
182 BUTTON_NORMAL = 1 ,
183 BUTTON_HOT ,
184 BUTTON_PRESSED ,
185 BUTTON_DISABLED ,
186 BUTTON_INACTIVE
187 } THEME_BUTTON_STATES;
188
189 #define HT_ISBUTTON(ht) ((ht) == HTMINBUTTON || (ht) == HTMAXBUTTON || (ht) == HTCLOSE || (ht) == HTHELP)
190
191 #define HASSIZEGRIP(Style, ExStyle, ParentStyle, WindowRect, ParentClientRect) \
192 ((!(Style & WS_CHILD) && (Style & WS_THICKFRAME) && !(Style & WS_MAXIMIZE)) || \
193 ((Style & WS_CHILD) && (ParentStyle & WS_THICKFRAME) && !(ParentStyle & WS_MAXIMIZE) && \
194 (WindowRect.right - WindowRect.left == ParentClientRect.right) && \
195 (WindowRect.bottom - WindowRect.top == ParentClientRect.bottom)))
196
197 #define HAS_MENU(hwnd,style) ((((style) & (WS_CHILD | WS_POPUP)) != WS_CHILD) && GetMenu(hwnd))
198
199 #define BUTTON_GAP_SIZE 2
200
201 #define MENU_BAR_ITEMS_SPACE (12)
202
203 #define SCROLL_TIMER 0 /* Scroll timer id */
204
205 /* Overlap between arrows and thumb */
206 #define SCROLL_ARROW_THUMB_OVERLAP 0
207
208 /* Delay (in ms) before first repetition when holding the button down */
209 #define SCROLL_FIRST_DELAY 200
210
211 /* Delay (in ms) between scroll repetitions */
212 #define SCROLL_REPEAT_DELAY 50
213
214 /* Minimum size of the thumb in pixels */
215 #define SCROLL_MIN_THUMB 6
216
217 /* Minimum size of the rectangle between the arrows */
218 #define SCROLL_MIN_RECT 4
219
220 LRESULT CALLBACK ThemeWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, WNDPROC DefWndProc);
221 void ThemeDrawScrollBar(PDRAW_CONTEXT pcontext, INT Bar, POINT* pt);
222 VOID NC_TrackScrollBar(HWND Wnd, WPARAM wParam, POINT Pt);
223 void ThemeInitDrawContext(PDRAW_CONTEXT pcontext, HWND hWnd, HRGN hRgn);
224 void ThemeCleanupDrawContext(PDRAW_CONTEXT pcontext);
225 PWND_CONTEXT ThemeGetWndContext(HWND hWnd);
226
227 extern HINSTANCE hDllInst;
228 extern ATOM atWindowTheme;
229 extern ATOM atWndContext;
230 extern BOOL gbThemeHooksActive;
231 extern PTHEME_FILE ActiveThemeFile;
232
233 void UXTHEME_InitSystem(HINSTANCE hInst);
234 void UXTHEME_LoadTheme(BOOL bLoad);
235 BOOL CALLBACK UXTHEME_broadcast_msg (HWND hWnd, LPARAM msg);
236
237 /* No alpha blending */
238 #define ALPHABLEND_NONE 0
239 /* "Cheap" binary alpha blending - but possibly faster */
240 #define ALPHABLEND_BINARY 1
241 /* Full alpha blending */
242 #define ALPHABLEND_FULL 2
243
244 #endif /* _UXTHEME_PCH_ */