reactos/dll/win32/uxtheme/uxthemep.h

272 lines
8.6 KiB
C
Raw Normal View History

#ifndef _UXTHEME_PCH_
#define _UXTHEME_PCH_
#include <stdarg.h>
#define WIN32_NO_STATUS
#define _INC_WINDOWS
#define COM_NO_WINDOWS_H
#include <windef.h>
#include <winbase.h>
#include <wingdi.h>
#include <winuser.h>
#include <winnls.h>
#include <windowsx.h>
#include <undocuser.h>
#include <undocgdi.h>
#include <uxtheme.h>
#include <uxundoc.h>
#include <vfwmsgs.h>
#include <tmschema.h>
#define NTOS_MODE_USER
#include <ndk/ntndk.h>
#include <ndk/rtltypes.h>
#include <wine/debug.h>
WINE_DEFAULT_DEBUG_CHANNEL(uxtheme);
#define TMT_ENUM 200
#define MAX_THEME_APP_NAME 60
#define MAX_THEME_CLASS_NAME 60
#define MAX_THEME_VALUE_NAME 60
typedef struct _THEME_PROPERTY {
int iPrimitiveType;
int iPropertyId;
PROPERTYORIGIN origin;
LPCWSTR lpValue;
DWORD dwValueLen;
struct _THEME_PROPERTY *next;
} THEME_PROPERTY, *PTHEME_PROPERTY;
typedef struct _THEME_PARTSTATE {
int iPartId;
int iStateId;
PTHEME_PROPERTY properties;
struct _THEME_PARTSTATE *next;
} THEME_PARTSTATE, *PTHEME_PARTSTATE;
Sync to Wine-20050725: Thomas Weidenmueller <wine-patches@reactsoft.com> - IsThemeDialogTextureEnabled should have one parameter to match the prototype in the official headers. Mike McCormack <mike@codeweavers.com> - gcc 4.0 -Wpointer-sign fixes (Reg* functions). Stefan Huehner <stefan@huehner.org> - Make some function static. - Fix -Wmissing-declarations warnings. Frank Richter <frank.richter@gmail.com> - Enable/disable "flat menus" based on the setting from the active theme. - Have the theme INI file parsed upon theme activation and not just when the first theme data is requested; that way, the themed system colors are set correctly from the start, and not just after some theme data was requested. - GetThemeBackgroundContentRect() does not use the content margins alone, it also falls back to the border size or sizing margins, and if it can't find any possible margins at all, it returns the original rectangle. - Make dialog theme texture setting non-global (ie a per-window setting). - Better viewport origin in DrawThemeParentBackground(). - OpenThemeData() now always sets the window theme to the handle returned (even if that is NULL) - previously, it could happen that when no theme was active or the theme data could not be opened that the window theme remained became then-dangling (and hence subsequent calls to GetWindowTheme() would return that bogus theme). - Correct border rectangle drawing. - Don't crash if NULL is passed as the class list to OpenThemeData(). - UXTHEME_LoadImage(): Set default image count to 1 to avoid division by zero in case image count property is not given. Properly support 0 state IDs. - Every window needs to receive WM_THEMECHANGED (esp. controls), so also send it to child windows. - Changed the default transparent color in case none was explicitly specified from the upper left pixel color to magenta. Empirically gives better results. - Write WCHAR strings to registry with correct size. - Opening some theme class data now also increases the reference count of the theme file, so as long as theme class data is still opened somewhere, the theme file won't get freed. Otherwise, it could happen that invalid class data was used, which could lead to problems. svn path=/trunk/; revision=17342
2005-08-12 18:22:47 +00:00
struct _THEME_FILE;
typedef struct _THEME_CLASS {
HMODULE hTheme;
Sync to Wine-20050725: Thomas Weidenmueller <wine-patches@reactsoft.com> - IsThemeDialogTextureEnabled should have one parameter to match the prototype in the official headers. Mike McCormack <mike@codeweavers.com> - gcc 4.0 -Wpointer-sign fixes (Reg* functions). Stefan Huehner <stefan@huehner.org> - Make some function static. - Fix -Wmissing-declarations warnings. Frank Richter <frank.richter@gmail.com> - Enable/disable "flat menus" based on the setting from the active theme. - Have the theme INI file parsed upon theme activation and not just when the first theme data is requested; that way, the themed system colors are set correctly from the start, and not just after some theme data was requested. - GetThemeBackgroundContentRect() does not use the content margins alone, it also falls back to the border size or sizing margins, and if it can't find any possible margins at all, it returns the original rectangle. - Make dialog theme texture setting non-global (ie a per-window setting). - Better viewport origin in DrawThemeParentBackground(). - OpenThemeData() now always sets the window theme to the handle returned (even if that is NULL) - previously, it could happen that when no theme was active or the theme data could not be opened that the window theme remained became then-dangling (and hence subsequent calls to GetWindowTheme() would return that bogus theme). - Correct border rectangle drawing. - Don't crash if NULL is passed as the class list to OpenThemeData(). - UXTHEME_LoadImage(): Set default image count to 1 to avoid division by zero in case image count property is not given. Properly support 0 state IDs. - Every window needs to receive WM_THEMECHANGED (esp. controls), so also send it to child windows. - Changed the default transparent color in case none was explicitly specified from the upper left pixel color to magenta. Empirically gives better results. - Write WCHAR strings to registry with correct size. - Opening some theme class data now also increases the reference count of the theme file, so as long as theme class data is still opened somewhere, the theme file won't get freed. Otherwise, it could happen that invalid class data was used, which could lead to problems. svn path=/trunk/; revision=17342
2005-08-12 18:22:47 +00:00
struct _THEME_FILE* tf;
WCHAR szAppName[MAX_THEME_APP_NAME];
WCHAR szClassName[MAX_THEME_CLASS_NAME];
PTHEME_PARTSTATE partstate;
struct _THEME_CLASS *overrides;
struct _THEME_CLASS *next;
} THEME_CLASS, *PTHEME_CLASS;
Sync to Wine-20050830: Kevin Koltzau <kevin@plop.org> - Fix 'cast to pointer from integer of different size' warnings in 64bit. Frank Richter <frank.richter@gmail.com> - Add support for the BT_NONE background type. - Better computations to have uniformly sized parts scaled in both directions. - Implement GetThemeBackgroundExtent(). - Implement DrawThemeEdge(). - Implement support for the ST_TILE background stretching mode. - Implementation for GetThemePartSize() (not entirely equivalent to native uxtheme, but sensibly useable). - Enhance uxtheme to store the themed system metrics in the registry and also backup the old metrics. That way, themed system colors are set even uxtheme was not loaded and initialized yet, and when a theme is deactivated, the colors prior to the activation are restored as well. - Also, not having to set the system colors in uxtheme startup works around weird problems where SetSystemColors() ended up being called from inside window creation and this seemingly led to some creation message being sent twice. - Make GetThemeMargins() return default values (0 margin) if the function does not succeed. - More elaborate IsThemeBackgroundPartiallyTransparent() implementation; also returns TRUE for theme parts with 32bpp images. - Since theme images are reused now it's not really a good idea to delete them in drawing functions. - Pass around what kind of transparency an image actually needs. Use alpha-blending for 32bpp images. - Set some default values for truesize sizing that seem closer to Windows. - If a MINSIZEn property is not present, fall back to actual size of nth image to determine whether it is suitable. - EnumThemeColors() and EnumThemeSizes() actually do not return a single string with the color/size name, but rather a struct containing three strings - name, display name and tooltip. - The default image layout is HORIZONTAL, not VERTICAL. - Take a common computation out of two if-branches in UXTHEME_LoadImage(). - Compare result of RegQueryValueExW() with ERROR_SUCCESS. - Another fix to use magenta as the default transparent color. - Implement "manual" image sharing(as opposed to using LoadImage() with LR_SHARED) by keeping the loaded images in a list. This is needed for proper alpha support later on since once-per-image preparations will be needed then. - Add support for horizontal & vertical alignment when doing truesize sizing. - Whatever TrueSizeStretchMark is for - it's not what Wine uxtheme used it for. Native uxtheme always stretches "truesize" parts when the destination is smaller than the part image size, but TrueSizeStretchMark doesn't seem to have an influence. svn path=/trunk/; revision=17719
2005-09-07 16:22:51 +00:00
typedef struct _THEME_IMAGE {
WCHAR name[MAX_PATH];
HBITMAP image;
BOOL hasAlpha;
struct _THEME_IMAGE *next;
} THEME_IMAGE, *PTHEME_IMAGE;
typedef struct _THEME_FILE {
DWORD dwRefCount;
HMODULE hTheme;
WCHAR szThemeFile[MAX_PATH];
LPWSTR pszAvailColors;
LPWSTR pszAvailSizes;
LPWSTR pszSelectedColor;
LPWSTR pszSelectedSize;
PTHEME_CLASS classes;
PTHEME_PROPERTY metrics;
Sync to Wine-20050830: Kevin Koltzau <kevin@plop.org> - Fix 'cast to pointer from integer of different size' warnings in 64bit. Frank Richter <frank.richter@gmail.com> - Add support for the BT_NONE background type. - Better computations to have uniformly sized parts scaled in both directions. - Implement GetThemeBackgroundExtent(). - Implement DrawThemeEdge(). - Implement support for the ST_TILE background stretching mode. - Implementation for GetThemePartSize() (not entirely equivalent to native uxtheme, but sensibly useable). - Enhance uxtheme to store the themed system metrics in the registry and also backup the old metrics. That way, themed system colors are set even uxtheme was not loaded and initialized yet, and when a theme is deactivated, the colors prior to the activation are restored as well. - Also, not having to set the system colors in uxtheme startup works around weird problems where SetSystemColors() ended up being called from inside window creation and this seemingly led to some creation message being sent twice. - Make GetThemeMargins() return default values (0 margin) if the function does not succeed. - More elaborate IsThemeBackgroundPartiallyTransparent() implementation; also returns TRUE for theme parts with 32bpp images. - Since theme images are reused now it's not really a good idea to delete them in drawing functions. - Pass around what kind of transparency an image actually needs. Use alpha-blending for 32bpp images. - Set some default values for truesize sizing that seem closer to Windows. - If a MINSIZEn property is not present, fall back to actual size of nth image to determine whether it is suitable. - EnumThemeColors() and EnumThemeSizes() actually do not return a single string with the color/size name, but rather a struct containing three strings - name, display name and tooltip. - The default image layout is HORIZONTAL, not VERTICAL. - Take a common computation out of two if-branches in UXTHEME_LoadImage(). - Compare result of RegQueryValueExW() with ERROR_SUCCESS. - Another fix to use magenta as the default transparent color. - Implement "manual" image sharing(as opposed to using LoadImage() with LR_SHARED) by keeping the loaded images in a list. This is needed for proper alpha support later on since once-per-image preparations will be needed then. - Add support for horizontal & vertical alignment when doing truesize sizing. - Whatever TrueSizeStretchMark is for - it's not what Wine uxtheme used it for. Native uxtheme always stretches "truesize" parts when the destination is smaller than the part image size, but TrueSizeStretchMark doesn't seem to have an influence. svn path=/trunk/; revision=17719
2005-09-07 16:22:51 +00:00
PTHEME_IMAGE images;
} THEME_FILE, *PTHEME_FILE;
typedef struct _UXINI_FILE *PUXINI_FILE;
typedef struct _UXTHEME_HANDLE
{
RTL_HANDLE_TABLE_ENTRY Handle;
PTHEME_CLASS pClass;
} UXTHEME_HANDLE, *PUXTHEME_HANDLE;
PTHEME_CLASS ValidateHandle(HTHEME hTheme);
HRESULT UXTHEME_LoadImage(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, BOOL glyph,
HBITMAP *hBmp, RECT *bmpRect, BOOL* hasImageAlpha);
BOOL MSSTYLES_LookupProperty(LPCWSTR pszPropertyName, int *dwPrimitive, int *dwId);
BOOL MSSTYLES_LookupEnum(LPCWSTR pszValueName, int dwEnum, int *dwValue);
BOOL MSSTYLES_LookupPartState(LPCWSTR pszClass, LPCWSTR pszPart, LPCWSTR pszState, int *iPartId, int *iStateId);
HRESULT MSSTYLES_OpenThemeFile(LPCWSTR lpThemeFile, LPCWSTR pszColorName, LPCWSTR pszSizeName, PTHEME_FILE *tf);
HRESULT MSSTYLES_ReferenceTheme(PTHEME_FILE tf);
void MSSTYLES_CloseThemeFile(PTHEME_FILE tf);
void MSSTYLES_ParseThemeIni(PTHEME_FILE tf);
PTHEME_CLASS MSSTYLES_OpenThemeClass(PTHEME_FILE tf, LPCWSTR pszAppName, LPCWSTR pszClassList);
HRESULT MSSTYLES_CloseThemeClass(PTHEME_CLASS tc);
PUXINI_FILE MSSTYLES_GetThemeIni(PTHEME_FILE tf);
PTHEME_PARTSTATE MSSTYLES_FindPartState(PTHEME_CLASS tc, int iPartId, int iStateId, PTHEME_CLASS *tcNext);
PTHEME_PROPERTY MSSTYLES_FindProperty(PTHEME_CLASS tc, int iPartId, int iStateId, int iPropertyPrimitive, int iPropertyId);
PTHEME_PROPERTY MSSTYLES_FindMetric(PTHEME_FILE tf, int iPropertyPrimitive, int iPropertyId);
Sync to Wine-20050830: Kevin Koltzau <kevin@plop.org> - Fix 'cast to pointer from integer of different size' warnings in 64bit. Frank Richter <frank.richter@gmail.com> - Add support for the BT_NONE background type. - Better computations to have uniformly sized parts scaled in both directions. - Implement GetThemeBackgroundExtent(). - Implement DrawThemeEdge(). - Implement support for the ST_TILE background stretching mode. - Implementation for GetThemePartSize() (not entirely equivalent to native uxtheme, but sensibly useable). - Enhance uxtheme to store the themed system metrics in the registry and also backup the old metrics. That way, themed system colors are set even uxtheme was not loaded and initialized yet, and when a theme is deactivated, the colors prior to the activation are restored as well. - Also, not having to set the system colors in uxtheme startup works around weird problems where SetSystemColors() ended up being called from inside window creation and this seemingly led to some creation message being sent twice. - Make GetThemeMargins() return default values (0 margin) if the function does not succeed. - More elaborate IsThemeBackgroundPartiallyTransparent() implementation; also returns TRUE for theme parts with 32bpp images. - Since theme images are reused now it's not really a good idea to delete them in drawing functions. - Pass around what kind of transparency an image actually needs. Use alpha-blending for 32bpp images. - Set some default values for truesize sizing that seem closer to Windows. - If a MINSIZEn property is not present, fall back to actual size of nth image to determine whether it is suitable. - EnumThemeColors() and EnumThemeSizes() actually do not return a single string with the color/size name, but rather a struct containing three strings - name, display name and tooltip. - The default image layout is HORIZONTAL, not VERTICAL. - Take a common computation out of two if-branches in UXTHEME_LoadImage(). - Compare result of RegQueryValueExW() with ERROR_SUCCESS. - Another fix to use magenta as the default transparent color. - Implement "manual" image sharing(as opposed to using LoadImage() with LR_SHARED) by keeping the loaded images in a list. This is needed for proper alpha support later on since once-per-image preparations will be needed then. - Add support for horizontal & vertical alignment when doing truesize sizing. - Whatever TrueSizeStretchMark is for - it's not what Wine uxtheme used it for. Native uxtheme always stretches "truesize" parts when the destination is smaller than the part image size, but TrueSizeStretchMark doesn't seem to have an influence. svn path=/trunk/; revision=17719
2005-09-07 16:22:51 +00:00
HBITMAP MSSTYLES_LoadBitmap(PTHEME_CLASS tc, LPCWSTR lpFilename, BOOL* hasAlpha);
HRESULT MSSTYLES_GetPropertyBool(PTHEME_PROPERTY tp, BOOL *pfVal);
HRESULT MSSTYLES_GetPropertyColor(PTHEME_PROPERTY tp, COLORREF *pColor);
HRESULT MSSTYLES_GetPropertyFont(PTHEME_PROPERTY tp, HDC hdc, LOGFONTW *pFont);
HRESULT MSSTYLES_GetPropertyInt(PTHEME_PROPERTY tp, int *piVal);
HRESULT MSSTYLES_GetPropertyIntList(PTHEME_PROPERTY tp, INTLIST *pIntList);
HRESULT MSSTYLES_GetPropertyPosition(PTHEME_PROPERTY tp, POINT *pPoint);
HRESULT MSSTYLES_GetPropertyString(PTHEME_PROPERTY tp, LPWSTR pszBuff, int cchMaxBuffChars);
HRESULT MSSTYLES_GetPropertyRect(PTHEME_PROPERTY tp, RECT *pRect);
HRESULT MSSTYLES_GetPropertyMargins(PTHEME_PROPERTY tp, RECT *prc, MARGINS *pMargins);
PUXINI_FILE UXINI_LoadINI(HMODULE hTheme, LPCWSTR lpName);
void UXINI_CloseINI(PUXINI_FILE uf);
LPCWSTR UXINI_GetNextSection(PUXINI_FILE uf, DWORD *dwLen);
BOOL UXINI_FindSection(PUXINI_FILE uf, LPCWSTR lpName);
LPCWSTR UXINI_GetNextValue(PUXINI_FILE uf, DWORD *dwNameLen, LPCWSTR *lpValue, DWORD *dwValueLen);
BOOL UXINI_FindValue(PUXINI_FILE uf, LPCWSTR lpName, LPCWSTR *lpValue, DWORD *dwValueLen);
/* Scroll-bar hit testing */
enum SCROLL_HITTEST
{
SCROLL_NOWHERE, /* Outside the scroll bar */
SCROLL_TOP_ARROW, /* Top or left arrow */
SCROLL_TOP_RECT, /* Rectangle between the top arrow and the thumb */
SCROLL_THUMB, /* Thumb rectangle */
SCROLL_BOTTOM_RECT, /* Rectangle between the thumb and the bottom arrow */
SCROLL_BOTTOM_ARROW /* Bottom or right arrow */
};
/* The window context stores data for the window needed through the life of the window */
typedef struct _WND_DATA
{
HTHEME hthemeWindow;
HTHEME hthemeScrollbar;
RECT rcCaptionButtons[4];
UINT lastHitTest;
BOOL HasAppDefinedRgn;
BOOL HasThemeRgn;
BOOL UpdatingRgn;
BOOL DirtyThemeRegion;
HBRUSH hTabBackgroundBrush;
HBITMAP hTabBackgroundBmp;
BOOL SCROLL_trackVertical;
enum SCROLL_HITTEST SCROLL_trackHitTest;
BOOL SCROLL_MovingThumb; /* Is the moving thumb being displayed? */
HWND SCROLL_TrackingWin;
INT SCROLL_TrackingBar;
INT SCROLL_TrackingPos;
INT SCROLL_TrackingVal;
} WND_DATA, *PWND_DATA;
/* The draw context stores data that are needed by the drawing operations in the non client area of the window */
typedef struct _DRAW_CONTEXT
{
HWND hWnd;
HDC hDC;
HTHEME theme;
HTHEME scrolltheme;
HTHEME hPrevTheme;
WINDOWINFO wi;
BOOL Active; /* wi.dwWindowStatus isn't correct for mdi child windows */
HRGN hRgn;
int CaptionHeight;
/* for double buffering */
HDC hDCScreen;
HBITMAP hbmpOld;
} DRAW_CONTEXT, *PDRAW_CONTEXT;
typedef enum
{
CLOSEBUTTON,
MAXBUTTON,
MINBUTTON,
HELPBUTTON
} CAPTIONBUTTON;
/*
The following values specify all possible button states
Note that not all of them are documented but it is easy to
find them by opening a theme file
*/
typedef enum {
BUTTON_NORMAL = 1 ,
BUTTON_HOT ,
BUTTON_PRESSED ,
BUTTON_DISABLED ,
BUTTON_INACTIVE ,
BUTTON_INACTIVE_HOT ,
BUTTON_INACTIVE_PRESSED ,
BUTTON_INACTIVE_DISABLED
} THEME_BUTTON_STATES;
#define HT_ISBUTTON(ht) ((ht) == HTMINBUTTON || (ht) == HTMAXBUTTON || (ht) == HTCLOSE || (ht) == HTHELP)
#define HASSIZEGRIP(Style, ExStyle, ParentStyle, WindowRect, ParentClientRect) \
((!(Style & WS_CHILD) && (Style & WS_THICKFRAME) && !(Style & WS_MAXIMIZE)) || \
((Style & WS_CHILD) && (ParentStyle & WS_THICKFRAME) && !(ParentStyle & WS_MAXIMIZE) && \
(WindowRect.right - WindowRect.left == ParentClientRect.right) && \
(WindowRect.bottom - WindowRect.top == ParentClientRect.bottom)))
#define HAS_MENU(hwnd,style) ((((style) & (WS_CHILD | WS_POPUP)) != WS_CHILD) && GetMenu(hwnd))
#define BUTTON_GAP_SIZE 2
#define MENU_BAR_ITEMS_SPACE (12)
#define SCROLL_TIMER 0 /* Scroll timer id */
/* Overlap between arrows and thumb */
#define SCROLL_ARROW_THUMB_OVERLAP 0
/* Delay (in ms) before first repetition when holding the button down */
#define SCROLL_FIRST_DELAY 200
/* Delay (in ms) between scroll repetitions */
#define SCROLL_REPEAT_DELAY 50
/* Minimum size of the thumb in pixels */
#define SCROLL_MIN_THUMB 6
/* Minimum size of the rectangle between the arrows */
#define SCROLL_MIN_RECT 4
LRESULT CALLBACK ThemeWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, WNDPROC DefWndProc);
void ThemeCalculateCaptionButtonsPos(HWND hWnd, HTHEME htheme);
void ThemeDrawScrollBar(PDRAW_CONTEXT pcontext, INT Bar, POINT* pt);
VOID NC_TrackScrollBar(HWND Wnd, WPARAM wParam, POINT Pt);
void ThemeInitDrawContext(PDRAW_CONTEXT pcontext, HWND hWnd, HRGN hRgn);
void ThemeCleanupDrawContext(PDRAW_CONTEXT pcontext);
PWND_DATA ThemeGetWndData(HWND hWnd);
HTHEME GetNCCaptionTheme(HWND hWnd, DWORD style);
HTHEME GetNCScrollbarTheme(HWND hWnd, DWORD style);
extern HINSTANCE hDllInst;
extern ATOM atWindowTheme;
extern ATOM atWndContext;
extern BOOL g_bThemeHooksActive;
void UXTHEME_InitSystem(HINSTANCE hInst);
void UXTHEME_LoadTheme(BOOL bLoad);
BOOL CALLBACK UXTHEME_broadcast_theme_changed (HWND hWnd, LPARAM enable);
/* No alpha blending */
#define ALPHABLEND_NONE 0
/* "Cheap" binary alpha blending - but possibly faster */
#define ALPHABLEND_BINARY 1
/* Full alpha blending */
#define ALPHABLEND_FULL 2
#endif /* _UXTHEME_PCH_ */