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