[UXTHEME] -Implement the tab background texture. NOTE: A hack was used to go around...
[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 HRESULT UXTHEME_LoadImage(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, BOOL glyph,
89 HBITMAP *hBmp, RECT *bmpRect, BOOL* hasImageAlpha);
90
91 BOOL MSSTYLES_LookupProperty(LPCWSTR pszPropertyName, int *dwPrimitive, int *dwId);
92 BOOL MSSTYLES_LookupEnum(LPCWSTR pszValueName, int dwEnum, int *dwValue);
93 BOOL MSSTYLES_LookupPartState(LPCWSTR pszClass, LPCWSTR pszPart, LPCWSTR pszState, int *iPartId, int *iStateId);
94
95 HRESULT MSSTYLES_OpenThemeFile(LPCWSTR lpThemeFile, LPCWSTR pszColorName, LPCWSTR pszSizeName, PTHEME_FILE *tf);
96 HRESULT MSSTYLES_ReferenceTheme(PTHEME_FILE tf);
97 void MSSTYLES_CloseThemeFile(PTHEME_FILE tf);
98 void MSSTYLES_ParseThemeIni(PTHEME_FILE tf);
99 PTHEME_CLASS MSSTYLES_OpenThemeClass(PTHEME_FILE tf, LPCWSTR pszAppName, LPCWSTR pszClassList);
100 HRESULT MSSTYLES_CloseThemeClass(PTHEME_CLASS tc);
101 PUXINI_FILE MSSTYLES_GetThemeIni(PTHEME_FILE tf);
102 PTHEME_PARTSTATE MSSTYLES_FindPartState(PTHEME_CLASS tc, int iPartId, int iStateId, PTHEME_CLASS *tcNext);
103 PTHEME_PROPERTY MSSTYLES_FindProperty(PTHEME_CLASS tc, int iPartId, int iStateId, int iPropertyPrimitive, int iPropertyId);
104 PTHEME_PROPERTY MSSTYLES_FindMetric(PTHEME_FILE tf, int iPropertyPrimitive, int iPropertyId);
105 HBITMAP MSSTYLES_LoadBitmap(PTHEME_CLASS tc, LPCWSTR lpFilename, BOOL* hasAlpha);
106
107 HRESULT MSSTYLES_GetPropertyBool(PTHEME_PROPERTY tp, BOOL *pfVal);
108 HRESULT MSSTYLES_GetPropertyColor(PTHEME_PROPERTY tp, COLORREF *pColor);
109 HRESULT MSSTYLES_GetPropertyFont(PTHEME_PROPERTY tp, HDC hdc, LOGFONTW *pFont);
110 HRESULT MSSTYLES_GetPropertyInt(PTHEME_PROPERTY tp, int *piVal);
111 HRESULT MSSTYLES_GetPropertyIntList(PTHEME_PROPERTY tp, INTLIST *pIntList);
112 HRESULT MSSTYLES_GetPropertyPosition(PTHEME_PROPERTY tp, POINT *pPoint);
113 HRESULT MSSTYLES_GetPropertyString(PTHEME_PROPERTY tp, LPWSTR pszBuff, int cchMaxBuffChars);
114 HRESULT MSSTYLES_GetPropertyRect(PTHEME_PROPERTY tp, RECT *pRect);
115 HRESULT MSSTYLES_GetPropertyMargins(PTHEME_PROPERTY tp, RECT *prc, MARGINS *pMargins);
116
117 PUXINI_FILE UXINI_LoadINI(HMODULE hTheme, LPCWSTR lpName);
118 void UXINI_CloseINI(PUXINI_FILE uf);
119 LPCWSTR UXINI_GetNextSection(PUXINI_FILE uf, DWORD *dwLen);
120 BOOL UXINI_FindSection(PUXINI_FILE uf, LPCWSTR lpName);
121 LPCWSTR UXINI_GetNextValue(PUXINI_FILE uf, DWORD *dwNameLen, LPCWSTR *lpValue, DWORD *dwValueLen);
122 BOOL UXINI_FindValue(PUXINI_FILE uf, LPCWSTR lpName, LPCWSTR *lpValue, DWORD *dwValueLen);
123
124 /* Scroll-bar hit testing */
125 enum SCROLL_HITTEST
126 {
127 SCROLL_NOWHERE, /* Outside the scroll bar */
128 SCROLL_TOP_ARROW, /* Top or left arrow */
129 SCROLL_TOP_RECT, /* Rectangle between the top arrow and the thumb */
130 SCROLL_THUMB, /* Thumb rectangle */
131 SCROLL_BOTTOM_RECT, /* Rectangle between the thumb and the bottom arrow */
132 SCROLL_BOTTOM_ARROW /* Bottom or right arrow */
133 };
134
135 /* The window context stores data for the window needed through the life of the window */
136 typedef struct _WND_CONTEXT
137 {
138 UINT lastHitTest;
139 BOOL HasAppDefinedRgn;
140 BOOL HasThemeRgn;
141 BOOL UpdatingRgn;
142 BOOL DirtyThemeRegion;
143 HBRUSH hTabBackgroundBrush;
144 HBITMAP hTabBackgroundBmp;
145
146 BOOL SCROLL_trackVertical;
147 enum SCROLL_HITTEST SCROLL_trackHitTest;
148 BOOL SCROLL_MovingThumb; /* Is the moving thumb being displayed? */
149 HWND SCROLL_TrackingWin;
150 INT SCROLL_TrackingBar;
151 INT SCROLL_TrackingPos;
152 INT SCROLL_TrackingVal;
153 } WND_CONTEXT, *PWND_CONTEXT;
154
155 /* The draw context stores data that are needed by the drawing operations in the non client area of the window */
156 typedef struct _DRAW_CONTEXT
157 {
158 HWND hWnd;
159 HDC hDC;
160 HTHEME theme;
161 HTHEME scrolltheme;
162 HTHEME hPrevTheme;
163 WINDOWINFO wi;
164 BOOL Active; /* wi.dwWindowStatus isn't correct for mdi child windows */
165 HRGN hRgn;
166 int CaptionHeight;
167
168 /* for double buffering */
169 HDC hDCScreen;
170 HBITMAP hbmpOld;
171 } DRAW_CONTEXT, *PDRAW_CONTEXT;
172
173 typedef enum
174 {
175 CLOSEBUTTON,
176 MAXBUTTON,
177 MINBUTTON,
178 HELPBUTTON
179 } CAPTIONBUTTON;
180
181 /*
182 The following values specify all possible button states
183 Note that not all of them are documented but it is easy to
184 find them by opening a theme file
185 */
186 typedef enum {
187 BUTTON_NORMAL = 1 ,
188 BUTTON_HOT ,
189 BUTTON_PRESSED ,
190 BUTTON_DISABLED ,
191 BUTTON_INACTIVE
192 } THEME_BUTTON_STATES;
193
194 #define HT_ISBUTTON(ht) ((ht) == HTMINBUTTON || (ht) == HTMAXBUTTON || (ht) == HTCLOSE || (ht) == HTHELP)
195
196 #define HASSIZEGRIP(Style, ExStyle, ParentStyle, WindowRect, ParentClientRect) \
197 ((!(Style & WS_CHILD) && (Style & WS_THICKFRAME) && !(Style & WS_MAXIMIZE)) || \
198 ((Style & WS_CHILD) && (ParentStyle & WS_THICKFRAME) && !(ParentStyle & WS_MAXIMIZE) && \
199 (WindowRect.right - WindowRect.left == ParentClientRect.right) && \
200 (WindowRect.bottom - WindowRect.top == ParentClientRect.bottom)))
201
202 #define HAS_MENU(hwnd,style) ((((style) & (WS_CHILD | WS_POPUP)) != WS_CHILD) && GetMenu(hwnd))
203
204 #define BUTTON_GAP_SIZE 2
205
206 #define MENU_BAR_ITEMS_SPACE (12)
207
208 #define SCROLL_TIMER 0 /* Scroll timer id */
209
210 /* Overlap between arrows and thumb */
211 #define SCROLL_ARROW_THUMB_OVERLAP 0
212
213 /* Delay (in ms) before first repetition when holding the button down */
214 #define SCROLL_FIRST_DELAY 200
215
216 /* Delay (in ms) between scroll repetitions */
217 #define SCROLL_REPEAT_DELAY 50
218
219 /* Minimum size of the thumb in pixels */
220 #define SCROLL_MIN_THUMB 6
221
222 /* Minimum size of the rectangle between the arrows */
223 #define SCROLL_MIN_RECT 4
224
225 LRESULT CALLBACK ThemeWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, WNDPROC DefWndProc);
226 void ThemeDrawScrollBar(PDRAW_CONTEXT pcontext, INT Bar, POINT* pt);
227 VOID NC_TrackScrollBar(HWND Wnd, WPARAM wParam, POINT Pt);
228 void ThemeInitDrawContext(PDRAW_CONTEXT pcontext, HWND hWnd, HRGN hRgn);
229 void ThemeCleanupDrawContext(PDRAW_CONTEXT pcontext);
230 PWND_CONTEXT ThemeGetWndContext(HWND hWnd);
231
232 extern HINSTANCE hDllInst;
233 extern ATOM atWindowTheme;
234 extern ATOM atWndContext;
235 extern BOOL gbThemeHooksActive;
236 extern PTHEME_FILE ActiveThemeFile;
237
238 void UXTHEME_InitSystem(HINSTANCE hInst);
239 void UXTHEME_LoadTheme(BOOL bLoad);
240 BOOL CALLBACK UXTHEME_broadcast_msg (HWND hWnd, LPARAM msg);
241
242 /* No alpha blending */
243 #define ALPHABLEND_NONE 0
244 /* "Cheap" binary alpha blending - but possibly faster */
245 #define ALPHABLEND_BINARY 1
246 /* Full alpha blending */
247 #define ALPHABLEND_FULL 2
248
249 #endif /* _UXTHEME_PCH_ */