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 <undocgdi.h> 18 #include <uxtheme.h> 19 #include <uxundoc.h> 20 #include <vfwmsgs.h> 21 #include <tmschema.h> 22 23 #define NTOS_MODE_USER 24 #include <ndk/ntndk.h> 25 #include <ndk/rtltypes.h> 26 27 #include <wine/debug.h> 28 WINE_DEFAULT_DEBUG_CHANNEL(uxtheme); 29 30 #define TMT_ENUM 200 31 32 #define MAX_THEME_APP_NAME 60 33 #define MAX_THEME_CLASS_NAME 60 34 #define MAX_THEME_VALUE_NAME 60 35 36 typedef struct _THEME_PROPERTY { 37 int iPrimitiveType; 38 int iPropertyId; 39 PROPERTYORIGIN origin; 40 41 LPCWSTR lpValue; 42 DWORD dwValueLen; 43 44 struct _THEME_PROPERTY *next; 45 } THEME_PROPERTY, *PTHEME_PROPERTY; 46 47 typedef struct _THEME_PARTSTATE { 48 int iPartId; 49 int iStateId; 50 PTHEME_PROPERTY properties; 51 52 struct _THEME_PARTSTATE *next; 53 } THEME_PARTSTATE, *PTHEME_PARTSTATE; 54 55 struct _THEME_FILE; 56 57 typedef struct _THEME_CLASS { 58 HMODULE hTheme; 59 struct _THEME_FILE* tf; 60 WCHAR szAppName[MAX_THEME_APP_NAME]; 61 WCHAR szClassName[MAX_THEME_CLASS_NAME]; 62 PTHEME_PARTSTATE partstate; 63 struct _THEME_CLASS *overrides; 64 65 struct _THEME_CLASS *next; 66 } THEME_CLASS, *PTHEME_CLASS; 67 68 typedef struct _THEME_IMAGE { 69 WCHAR name[MAX_PATH]; 70 HBITMAP image; 71 BOOL hasAlpha; 72 73 struct _THEME_IMAGE *next; 74 } THEME_IMAGE, *PTHEME_IMAGE; 75 76 typedef struct _THEME_FILE { 77 DWORD dwRefCount; 78 HMODULE hTheme; 79 WCHAR szThemeFile[MAX_PATH]; 80 LPWSTR pszAvailColors; 81 LPWSTR pszAvailSizes; 82 83 LPWSTR pszSelectedColor; 84 LPWSTR pszSelectedSize; 85 86 PTHEME_CLASS classes; 87 PTHEME_PROPERTY metrics; 88 PTHEME_IMAGE images; 89 } THEME_FILE, *PTHEME_FILE; 90 91 typedef struct _UXINI_FILE *PUXINI_FILE; 92 93 typedef struct _UXTHEME_HANDLE 94 { 95 RTL_HANDLE_TABLE_ENTRY Handle; 96 PTHEME_CLASS pClass; 97 } UXTHEME_HANDLE, *PUXTHEME_HANDLE; 98 99 PTHEME_CLASS ValidateHandle(HTHEME hTheme); 100 101 HRESULT UXTHEME_LoadImage(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, BOOL glyph, 102 HBITMAP *hBmp, RECT *bmpRect, BOOL* hasImageAlpha); 103 104 BOOL MSSTYLES_LookupProperty(LPCWSTR pszPropertyName, int *dwPrimitive, int *dwId); 105 BOOL MSSTYLES_LookupEnum(LPCWSTR pszValueName, int dwEnum, int *dwValue); 106 BOOL MSSTYLES_LookupPartState(LPCWSTR pszClass, LPCWSTR pszPart, LPCWSTR pszState, int *iPartId, int *iStateId); 107 108 HRESULT MSSTYLES_OpenThemeFile(LPCWSTR lpThemeFile, LPCWSTR pszColorName, LPCWSTR pszSizeName, PTHEME_FILE *tf); 109 HRESULT MSSTYLES_ReferenceTheme(PTHEME_FILE tf); 110 void MSSTYLES_CloseThemeFile(PTHEME_FILE tf); 111 void MSSTYLES_ParseThemeIni(PTHEME_FILE tf); 112 PTHEME_CLASS MSSTYLES_OpenThemeClass(PTHEME_FILE tf, LPCWSTR pszAppName, LPCWSTR pszClassList); 113 HRESULT MSSTYLES_CloseThemeClass(PTHEME_CLASS tc); 114 PUXINI_FILE MSSTYLES_GetThemeIni(PTHEME_FILE tf); 115 PTHEME_PARTSTATE MSSTYLES_FindPartState(PTHEME_CLASS tc, int iPartId, int iStateId, PTHEME_CLASS *tcNext); 116 PTHEME_PROPERTY MSSTYLES_FindProperty(PTHEME_CLASS tc, int iPartId, int iStateId, int iPropertyPrimitive, int iPropertyId); 117 PTHEME_PROPERTY MSSTYLES_FindMetric(PTHEME_FILE tf, int iPropertyPrimitive, int iPropertyId); 118 #ifdef ENABLE_PNG_SUPPORT 119 EXTERN_C 120 BOOL 121 MSSTYLES_TryLoadPng( 122 _In_ HINSTANCE hTheme, 123 _In_ LPCWSTR szFile, 124 _In_ LPCWSTR type, 125 _Out_ HBITMAP *phBitmap); 126 EXTERN_C 127 BOOL 128 prepare_png_alpha( 129 _In_ HBITMAP png, 130 _Out_ BOOL* hasAlpha); 131 #endif /* ENABLE_PNG_SUPPORT */ 132 HBITMAP MSSTYLES_LoadBitmap(PTHEME_CLASS tc, LPCWSTR lpFilename, BOOL* hasAlpha); 133 134 HRESULT MSSTYLES_GetPropertyBool(PTHEME_PROPERTY tp, BOOL *pfVal); 135 HRESULT MSSTYLES_GetPropertyColor(PTHEME_PROPERTY tp, COLORREF *pColor); 136 HRESULT MSSTYLES_GetPropertyFont(PTHEME_PROPERTY tp, HDC hdc, LOGFONTW *pFont); 137 HRESULT MSSTYLES_GetPropertyInt(PTHEME_PROPERTY tp, int *piVal); 138 HRESULT MSSTYLES_GetPropertyIntList(PTHEME_PROPERTY tp, INTLIST *pIntList); 139 HRESULT MSSTYLES_GetPropertyPosition(PTHEME_PROPERTY tp, POINT *pPoint); 140 HRESULT MSSTYLES_GetPropertyString(PTHEME_PROPERTY tp, LPWSTR pszBuff, int cchMaxBuffChars); 141 HRESULT MSSTYLES_GetPropertyRect(PTHEME_PROPERTY tp, RECT *pRect); 142 HRESULT MSSTYLES_GetPropertyMargins(PTHEME_PROPERTY tp, RECT *prc, MARGINS *pMargins); 143 144 PUXINI_FILE UXINI_LoadINI(HMODULE hTheme, LPCWSTR lpName); 145 void UXINI_CloseINI(PUXINI_FILE uf); 146 LPCWSTR UXINI_GetNextSection(PUXINI_FILE uf, DWORD *dwLen); 147 BOOL UXINI_FindSection(PUXINI_FILE uf, LPCWSTR lpName); 148 LPCWSTR UXINI_GetNextValue(PUXINI_FILE uf, DWORD *dwNameLen, LPCWSTR *lpValue, DWORD *dwValueLen); 149 BOOL UXINI_FindValue(PUXINI_FILE uf, LPCWSTR lpName, LPCWSTR *lpValue, DWORD *dwValueLen); 150 151 /* Scroll-bar hit testing */ 152 enum SCROLL_HITTEST 153 { 154 SCROLL_NOWHERE, /* Outside the scroll bar */ 155 SCROLL_TOP_ARROW, /* Top or left arrow */ 156 SCROLL_TOP_RECT, /* Rectangle between the top arrow and the thumb */ 157 SCROLL_THUMB, /* Thumb rectangle */ 158 SCROLL_BOTTOM_RECT, /* Rectangle between the thumb and the bottom arrow */ 159 SCROLL_BOTTOM_ARROW /* Bottom or right arrow */ 160 }; 161 162 /* The window context stores data for the window needed through the life of the window */ 163 typedef struct _WND_DATA 164 { 165 HTHEME hthemeWindow; 166 HTHEME hthemeScrollbar; 167 168 RECT rcCaptionButtons[4]; 169 UINT lastHitTest; 170 BOOL HasAppDefinedRgn; 171 BOOL HasThemeRgn; 172 BOOL UpdatingRgn; 173 BOOL DirtyThemeRegion; 174 HBRUSH hTabBackgroundBrush; 175 HBITMAP hTabBackgroundBmp; 176 177 BOOL SCROLL_trackVertical; 178 enum SCROLL_HITTEST SCROLL_trackHitTest; 179 BOOL SCROLL_MovingThumb; /* Is the moving thumb being displayed? */ 180 HWND SCROLL_TrackingWin; 181 INT SCROLL_TrackingBar; 182 INT SCROLL_TrackingPos; 183 INT SCROLL_TrackingVal; 184 } WND_DATA, *PWND_DATA; 185 186 /* The draw context stores data that are needed by the drawing operations in the non client area of the window */ 187 typedef struct _DRAW_CONTEXT 188 { 189 HWND hWnd; 190 HDC hDC; 191 HTHEME theme; 192 HTHEME scrolltheme; 193 HTHEME hPrevTheme; 194 WINDOWINFO wi; 195 BOOL Active; /* wi.dwWindowStatus isn't correct for mdi child windows */ 196 HRGN hRgn; 197 int CaptionHeight; 198 199 /* for double buffering */ 200 HDC hDCScreen; 201 HBITMAP hbmpOld; 202 } DRAW_CONTEXT, *PDRAW_CONTEXT; 203 204 typedef enum 205 { 206 CLOSEBUTTON, 207 MAXBUTTON, 208 MINBUTTON, 209 HELPBUTTON 210 } CAPTIONBUTTON; 211 212 /* 213 The following values specify all possible button states 214 Note that not all of them are documented but it is easy to 215 find them by opening a theme file 216 */ 217 typedef enum { 218 BUTTON_NORMAL = 1 , 219 BUTTON_HOT , 220 BUTTON_PRESSED , 221 BUTTON_DISABLED , 222 BUTTON_INACTIVE , 223 BUTTON_INACTIVE_HOT , 224 BUTTON_INACTIVE_PRESSED , 225 BUTTON_INACTIVE_DISABLED 226 } THEME_BUTTON_STATES; 227 228 #define HT_ISBUTTON(ht) ((ht) == HTMINBUTTON || (ht) == HTMAXBUTTON || (ht) == HTCLOSE || (ht) == HTHELP) 229 230 #define HASSIZEGRIP(Style, ExStyle, ParentStyle, WindowRect, ParentClientRect) \ 231 ((!(Style & WS_CHILD) && (Style & WS_THICKFRAME) && !(Style & WS_MAXIMIZE)) || \ 232 ((Style & WS_CHILD) && (ParentStyle & WS_THICKFRAME) && !(ParentStyle & WS_MAXIMIZE) && \ 233 (WindowRect.right - WindowRect.left == ParentClientRect.right) && \ 234 (WindowRect.bottom - WindowRect.top == ParentClientRect.bottom))) 235 236 #define HAS_MENU(hwnd,style) ((((style) & (WS_CHILD | WS_POPUP)) != WS_CHILD) && GetMenu(hwnd)) 237 238 #define BUTTON_GAP_SIZE 2 239 240 #define MENU_BAR_ITEMS_SPACE (12) 241 242 #define SCROLL_TIMER 0 /* Scroll timer id */ 243 244 /* Overlap between arrows and thumb */ 245 #define SCROLL_ARROW_THUMB_OVERLAP 0 246 247 /* Delay (in ms) before first repetition when holding the button down */ 248 #define SCROLL_FIRST_DELAY 200 249 250 /* Delay (in ms) between scroll repetitions */ 251 #define SCROLL_REPEAT_DELAY 50 252 253 /* Minimum size of the thumb in pixels */ 254 #define SCROLL_MIN_THUMB 6 255 256 /* Minimum size of the rectangle between the arrows */ 257 #define SCROLL_MIN_RECT 4 258 259 LRESULT CALLBACK ThemeWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, WNDPROC DefWndProc); 260 void ThemeCalculateCaptionButtonsPos(HWND hWnd, HTHEME htheme); 261 void ThemeDrawScrollBar(PDRAW_CONTEXT pcontext, INT Bar, POINT* pt); 262 VOID NC_TrackScrollBar(HWND Wnd, WPARAM wParam, POINT Pt); 263 void ThemeInitDrawContext(PDRAW_CONTEXT pcontext, HWND hWnd, HRGN hRgn); 264 void ThemeCleanupDrawContext(PDRAW_CONTEXT pcontext); 265 PWND_DATA ThemeGetWndData(HWND hWnd); 266 HTHEME GetNCCaptionTheme(HWND hWnd, DWORD style); 267 HTHEME GetNCScrollbarTheme(HWND hWnd, DWORD style); 268 269 extern HINSTANCE hDllInst; 270 extern ATOM atWindowTheme; 271 extern ATOM atWndContext; 272 extern BOOL g_bThemeHooksActive; 273 274 void UXTHEME_InitSystem(HINSTANCE hInst); 275 void UXTHEME_LoadTheme(BOOL bLoad); 276 BOOL CALLBACK UXTHEME_broadcast_theme_changed (HWND hWnd, LPARAM enable); 277 278 /* No alpha blending */ 279 #define ALPHABLEND_NONE 0 280 /* "Cheap" binary alpha blending - but possibly faster */ 281 #define ALPHABLEND_BINARY 1 282 /* Full alpha blending */ 283 #define ALPHABLEND_FULL 2 284 285 #endif /* _UXTHEME_PCH_ */ 286