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