From cda5a1a107b6185ec2c49950ab7397a5b521c098 Mon Sep 17 00:00:00 2001 From: "KJK::Hyperion" Date: Fri, 24 Oct 2003 21:29:48 +0000 Subject: [PATCH] Minimal UxTheme skeleton (includes Borland C++ Builder project for my own sanity) svn path=/trunk/; revision=6424 --- reactos/lib/uxtheme/.cvsignore | 13 ++ reactos/lib/uxtheme/include/nostyle/button.h | 12 ++ reactos/lib/uxtheme/makefile | 29 +++ reactos/lib/uxtheme/nostyle/.cvsignore | 5 + reactos/lib/uxtheme/nostyle/button.c | 193 +++++++++++++++++ reactos/lib/uxtheme/uxtheme.bpr | 124 +++++++++++ reactos/lib/uxtheme/uxtheme.def | 97 +++++++++ reactos/lib/uxtheme/uxtheme.rc | 51 +++++ reactos/lib/uxtheme/uxthemedll.c | 205 +++++++++++++++++++ reactos/lib/uxtheme/uxthemedll.h | 50 +++++ 10 files changed, 779 insertions(+) create mode 100644 reactos/lib/uxtheme/.cvsignore create mode 100644 reactos/lib/uxtheme/include/nostyle/button.h create mode 100644 reactos/lib/uxtheme/makefile create mode 100644 reactos/lib/uxtheme/nostyle/.cvsignore create mode 100644 reactos/lib/uxtheme/nostyle/button.c create mode 100644 reactos/lib/uxtheme/uxtheme.bpr create mode 100644 reactos/lib/uxtheme/uxtheme.def create mode 100644 reactos/lib/uxtheme/uxtheme.rc create mode 100644 reactos/lib/uxtheme/uxthemedll.c create mode 100644 reactos/lib/uxtheme/uxthemedll.h diff --git a/reactos/lib/uxtheme/.cvsignore b/reactos/lib/uxtheme/.cvsignore new file mode 100644 index 00000000000..91b16a2de8a --- /dev/null +++ b/reactos/lib/uxtheme/.cvsignore @@ -0,0 +1,13 @@ +*.coff +*.dll +*.d +*.a +*.o +*.sym +*.map +*.tmp +*.~* +*.il? +*.res +*.tds +*.lib diff --git a/reactos/lib/uxtheme/include/nostyle/button.h b/reactos/lib/uxtheme/include/nostyle/button.h new file mode 100644 index 00000000000..01bc619d292 --- /dev/null +++ b/reactos/lib/uxtheme/include/nostyle/button.h @@ -0,0 +1,12 @@ +#ifndef UXTHEME_BUTTON_H__ +#define UXTHEME_BUTTON_H__ + +#include "uxthemedll.h" + +extern const UXTHEME_VTABLE Button_Vt; + + + +#endif + +/* EOF */ diff --git a/reactos/lib/uxtheme/makefile b/reactos/lib/uxtheme/makefile new file mode 100644 index 00000000000..367a948f13c --- /dev/null +++ b/reactos/lib/uxtheme/makefile @@ -0,0 +1,29 @@ +# $Id: makefile,v 1.1 2003/10/24 21:29:48 hyperion Exp $ + +PATH_TO_TOP = ../.. + +TARGET_TYPE = dynlink + +TARGET_NAME = uxtheme + +TARGET_SDKLIBS = kernel32.a user32.a gdi32.a + +TARGET_CFLAGS = -Wall -Werror -D_DISABLE_TIDENTS + +TARGET_LFLAGS = -nostartfiles -nostdlib + +TARGET_BASE = 0x5B180000 + +TARGET_OBJECTS = \ + uxthemedll.o \ + button.o + +DEP_OBJECTS = $(TARGET_OBJECTS) + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +include $(TOOLS_PATH)/depend.mk + +# EOF diff --git a/reactos/lib/uxtheme/nostyle/.cvsignore b/reactos/lib/uxtheme/nostyle/.cvsignore new file mode 100644 index 00000000000..58e74345fea --- /dev/null +++ b/reactos/lib/uxtheme/nostyle/.cvsignore @@ -0,0 +1,5 @@ +*.d +*.a +*.o +*.sym +*.obj diff --git a/reactos/lib/uxtheme/nostyle/button.c b/reactos/lib/uxtheme/nostyle/button.c new file mode 100644 index 00000000000..ef42c891249 --- /dev/null +++ b/reactos/lib/uxtheme/nostyle/button.c @@ -0,0 +1,193 @@ +#include "uxthemedll.h" +#include "nostyle/button.h" + +/* Functions */ +STDAPI Button_DrawBackground +( + struct UXTHEME_DATA_ * pData, + HDC hdc, + int iPartId, + int iStateId, + const RECT * pRect, + const RECT * pClipRect +); + +STDAPI_(BOOL) Button_IsPartDefined +( + struct UXTHEME_DATA_ * pData, + int iPartId, + int iStateId +); + +const UXTHEME_VTABLE Button_Vt = +{ + Button_DrawBackground +}; + +/* BP_PUSHBUTTON */ +static const UINT Button_PushButton_State[] = +{ + DFCS_BUTTONPUSH, /* PBS_NORMAL */ + DFCS_BUTTONPUSH | DFCS_HOT, /* PBS_HOT */ + DFCS_BUTTONPUSH | DFCS_PUSHED, /* PBS_PRESSED */ + DFCS_BUTTONPUSH | DFCS_INACTIVE /* PBS_DISABLED */ + /* TODO */ /* PBS_DEFAULTED */ +}; + +/* BP_RADIOBUTTON */ /* FIXME: not sure about DrawFrameControl with radios */ +static const UINT Button_RadioButton_State[] = +{ + DFCS_BUTTONRADIO, /* RBS_UNCHECKEDNORMAL */ + DFCS_BUTTONRADIO | DFCS_HOT, /* RBS_UNCHECKEDHOT */ + DFCS_BUTTONRADIO | DFCS_PUSHED, /* RBS_UNCHECKEDPRESSED */ + DFCS_BUTTONRADIO | DFCS_INACTIVE, /* RBS_UNCHECKEDDISABLED */ + DFCS_BUTTONRADIO | DFCS_CHECKED, /* RBS_CHECKEDNORMAL */ + DFCS_BUTTONRADIO | DFCS_CHECKED | DFCS_HOT, /* RBS_CHECKEDHOT */ + DFCS_BUTTONRADIO | DFCS_CHECKED | DFCS_PUSHED, /* RBS_CHECKEDPRESSED */ + DFCS_BUTTONRADIO | DFCS_CHECKED | DFCS_INACTIVE /* RBS_CHECKEDDISABLED */ +}; + +/* BP_CHECKBOX */ /* FIXME: not sure about DrawFrameControl with checkboxes */ +static const UINT Button_CheckBox_State[] = +{ + DFCS_BUTTONCHECK, /* CBS_UNCHECKEDNORMAL */ + DFCS_BUTTONCHECK | DFCS_HOT, /* CBS_UNCHECKEDHOT */ + DFCS_BUTTONCHECK | DFCS_PUSHED, /* CBS_UNCHECKEDPRESSED */ + DFCS_BUTTONCHECK | DFCS_INACTIVE, /* CBS_UNCHECKEDDISABLED */ + DFCS_BUTTONCHECK | DFCS_CHECKED, /* CBS_CHECKEDNORMAL */ + DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_HOT, /* CBS_CHECKEDHOT */ + DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_PUSHED, /* CBS_CHECKEDPRESSED */ + DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_INACTIVE /* CBS_CHECKEDDISABLED */ + /* TODO */ /* CBS_MIXEDNORMAL */ + /* TODO */ /* CBS_MIXEDHOT */ + /* TODO */ /* CBS_MIXEDPRESSED */ + /* TODO */ /* CBS_MIXEDDISABLED */ +}; + +static UINT const * Button_Part_State[] = +{ + Button_PushButton_State, + Button_RadioButton_State, + Button_CheckBox_State + /* TODO: group box */ +}; + +STDAPI Button_DrawBackground +( + struct UXTHEME_DATA_ * pData, + HDC hdc, + int iPartId, + int iStateId, + const RECT * pRect, + const RECT * pClipRect +) +{ + UINT uState = 0; + HRGN hrgnSave; + HRESULT hres; + + if(!Button_IsPartDefined(pData, iPartId, iStateId)) return E_FAIL; + + uState = Button_Part_State[iPartId - 1][iStateId - 1]; + + if(pClipRect && FAILED(hres = UxTheme_ClipDc(hdc, pClipRect, &hrgnSave))) + return hres; + + if(!DrawFrameControl(hdc, (LPRECT)pRect, DFC_BUTTON, uState)) + hres = HRESULT_FROM_WIN32(GetLastError()); + + if(pClipRect) UxTheme_UnclipDc(hdc, hrgnSave); + + return hres; +} + +STDAPI_(BOOL) Button_IsPartDefined +( + struct UXTHEME_DATA_ * pData, + int iPartId, + int iStateId +) +{ + switch(iPartId) + { + case BP_PUSHBUTTON: + switch(iStateId) + { + case PBS_NORMAL: + case PBS_HOT: + case PBS_PRESSED: + case PBS_DISABLED: + case PBS_DEFAULTED: + break; + + default: + return FALSE; + } + + break; + + case BP_RADIOBUTTON: + switch(iStateId) + { + case RBS_UNCHECKEDNORMAL: + case RBS_UNCHECKEDHOT: + case RBS_UNCHECKEDPRESSED: + case RBS_UNCHECKEDDISABLED: + case RBS_CHECKEDNORMAL: + case RBS_CHECKEDHOT: + case RBS_CHECKEDPRESSED: + case RBS_CHECKEDDISABLED: + break; + + default: + return FALSE; + } + + break; + + case BP_CHECKBOX: + switch(iStateId) + { + case CBS_UNCHECKEDNORMAL: + case CBS_UNCHECKEDHOT: + case CBS_UNCHECKEDPRESSED: + case CBS_UNCHECKEDDISABLED: + case CBS_CHECKEDNORMAL: + case CBS_CHECKEDHOT: + case CBS_CHECKEDPRESSED: + case CBS_CHECKEDDISABLED: + case CBS_MIXEDNORMAL: + case CBS_MIXEDHOT: + case CBS_MIXEDPRESSED: + case CBS_MIXEDDISABLED: + break; + + default: + return FALSE; + } + + break; + + case BP_GROUPBOX: + switch(iStateId) + { + case GBS_NORMAL: + case GBS_DISABLED: + break; + + default: + return FALSE; + } + + break; + + case BP_USERBUTTON: + default: + return FALSE; + } + + return TRUE; +} + +/* EOF */ + diff --git a/reactos/lib/uxtheme/uxtheme.bpr b/reactos/lib/uxtheme/uxtheme.bpr new file mode 100644 index 00000000000..bd03c8c923f --- /dev/null +++ b/reactos/lib/uxtheme/uxtheme.bpr @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1040 +CodePage=1252 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +Launcher= +UseLauncher=0 +DebugCWD= +HostApplication=.\CustomControlSample.exe +RemoteHost= +RemotePath= +RemoteLauncher= +RemoteCWD= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + +[Language] +ActiveLang= +ProjectLang= +RootDir= + +[Linker] +LibPrefix= +LibSuffix= +LibVersion= + + \ No newline at end of file diff --git a/reactos/lib/uxtheme/uxtheme.def b/reactos/lib/uxtheme/uxtheme.def new file mode 100644 index 00000000000..e11cb1537cc --- /dev/null +++ b/reactos/lib/uxtheme/uxtheme.def @@ -0,0 +1,97 @@ +LIBRARY UXTHEME.DLL + +EXPORTS +; @0 +; @1 +; @2 +; @3 +; @4 +CloseThemeData @5 +DrawThemeBackground @6 +; @7 +; @8 +; @9 +; @10 +; @11 +;DrawThemeEdge @12 +; @13 +; @14 +; @15 +; @16 +; @17 +; @18 +; @19 +; @20 +; @21 +; @22 +; @23 +; @24 +; @25 +; @26 +; @27 +; @28 +; @29 +; @30 +; @31 +; @32 +; @33 +; @34 +; @35 +; @36 +;DrawThemeIcon @37 +DrawThemeParentBackground @38 +;DrawThemeText @39 +;EnableThemeDialogTexture @40 +;EnableTheming @41 +;GetCurrentThemeName @42 +; @43 +; @44 +; @45 +; @46 +; @47 +; @48 +;GetThemeAppProperties @49 +;GetThemeBackgroundContentRect @50 +;GetThemeBackgroundExtent @51 +;GetThemeBackgroundRegion @52 +;GetThemeBool @53 +;GetThemeColor @54 +;GetThemeDocumentationProperty @55 +;GetThemeEnumValue @56 +;GetThemeFilename @57 +;GetThemeFont @58 +;GetThemeInt @59 +; @60 +; @61 +; @62 +; @63 +;GetThemeIntList @64 +;GetThemeMargins @65 +;GetThemeMetric @66 +;GetThemePartSize @67 +;GetThemePosition @68 +;GetThemePropertyOrigin @69 +;GetThemeRect @70 +;GetThemeString @71 +;GetThemeSysBool @72 +;GetThemeSysColor @73 +;GetThemeSysColorBrush @74 +;GetThemeSysFont @75 +;GetThemeSysInt @76 +;GetThemeSysSize @77 +;GetThemeSysString @78 +;GetThemeTextExtent @79 +;GetThemeTextMetrics @80 +;GetWindowTheme @81 +;HitTestThemeBackground @82 +;IsAppThemed @83 +;IsThemeActive @84 +IsThemeBackgroundPartiallyTransparent @85 +;IsThemeDialogTextureEnabled @86 +;IsThemePartDefined @87 +OpenThemeData @88 +;SetThemeAppProperties @89 +;SetWindowTheme @90 + +; EOF + diff --git a/reactos/lib/uxtheme/uxtheme.rc b/reactos/lib/uxtheme/uxtheme.rc new file mode 100644 index 00000000000..cfe2bbfbc89 --- /dev/null +++ b/reactos/lib/uxtheme/uxtheme.rc @@ -0,0 +1,51 @@ +#include +#include + +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +VS_VERSION_INFO VERSIONINFO + FILEVERSION \ + RES_UINT_FV_MAJOR, \ + RES_UINT_FV_MINOR, \ + RES_UINT_FV_REVISION, \ + RES_UINT_FV_BUILD + + PRODUCTVERSION \ + RES_UINT_PV_MAJOR, \ + RES_UINT_PV_MINOR, \ + RES_UINT_PV_REVISION, \ + RES_UINT_PV_BUILD + + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L + +BEGIN + BLOCK "StringFileInfo" + { + BLOCK "040904b0" + { + VALUE "CompanyName", RES_STR_COMPANY_NAME + VALUE "FileDescription", "ReactOS UxTheme\0" + VALUE "FileVersion", RES_STR_FILE_VERSION + VALUE "InternalName", "uxtheme\0" + VALUE "LegalCopyright", RES_STR_LEGAL_COPYRIGHT + VALUE "OriginalFilename", "uxtheme.dll\0" + VALUE "ProductName", RES_STR_PRODUCT_NAME + VALUE "ProductVersion", RES_STR_PRODUCT_VERSION + } + } + + BLOCK "VarFileInfo" + { + VALUE "Translation", 0x409, 1200 + } +END + +/* EOF */ diff --git a/reactos/lib/uxtheme/uxthemedll.c b/reactos/lib/uxtheme/uxthemedll.c new file mode 100644 index 00000000000..c267dfc2f4c --- /dev/null +++ b/reactos/lib/uxtheme/uxthemedll.c @@ -0,0 +1,205 @@ +#include "uxthemedll.h" +#include "nostyle/button.h" + +#include + +#define HTHEME_TO_UXTHEME_(H__) ((PUXTHEME_DATA)(H__)) + +STDAPI UxTheme_ClipDc(HDC hdc, const RECT * pClipRect, HRGN * phrgnSave) +{ + *phrgnSave = CreateRectRgn(0, 0, 0, 0); + + switch(GetClipRgn(hdc, *phrgnSave)) + { + /* no user-defined clipping region */ + case 0: + { + HRGN hrgnClip; + + /* no region to restore */ + DeleteObject(*phrgnSave); + *phrgnSave = NULL; + + /* create the clipping rectangle */ + if((hrgnClip = CreateRectRgnIndirect(pClipRect)) != NULL) + { + /* select the clipping rectangle */ + if(SelectClipRgn(hdc, hrgnClip) != ERROR) + { + /* success */ + DeleteObject(hrgnClip); + return S_OK; + } + + /* failure */ + DeleteObject(hrgnClip); + } + + break; + } + + /* user-defined clipping region */ + case 1: + { + HRGN hrgnClip; + + /* create the clipping rectangle */ + if((hrgnClip = CreateRectRgnIndirect(pClipRect)) != NULL) + { + /* select the clipping rectangle */ + if(ExtSelectClipRgn(hdc, hrgnClip, RGN_AND) != ERROR) + { + /* success */ + DeleteObject(hrgnClip); + return S_OK; + } + + /* failure */ + DeleteObject(hrgnClip); + } + + break; + } + + /* error */ + case -1: + { + /* no region to restore */ + DeleteObject(*phrgnSave); + *phrgnSave = NULL; + + break; + } + } + + /* failure */ + return HRESULT_FROM_WIN32(GetLastError()); +} + +STDAPI UxTheme_UnclipDc(HDC hdc, HRGN hrgnSave) +{ + HRESULT hres; + + if(hrgnSave == NULL) return S_FALSE; + + if(SelectClipRgn(hdc, hrgnSave) != ERROR) hres = S_OK; + else hres = HRESULT_FROM_WIN32(GetLastError()); + + DeleteObject(hrgnSave); + return hres; +} + +THEMEAPI DrawThemeBackground +( + HTHEME hTheme, + HDC hdc, + int iPartId, + int iStateId, + const RECT * pRect, + const RECT * pClipRect +) +{ + PUXTHEME_DATA pUxTheme = HTHEME_TO_UXTHEME_(hTheme); + + return pUxTheme->pvt->p_DrawBackground + ( + pUxTheme, + hdc, + iPartId, + iStateId, + pRect, + pClipRect + ); +} + +THEMEAPI DrawThemeEdge +( + HTHEME hTheme, + HDC hdc, + int iPartId, + int iStateId, + const RECT * pDestRect, + UINT uEdge, + UINT uFlags, + RECT * pContentRect +) +{ + return E_FAIL; +} + +THEMEAPI DrawThemeIcon +( + HTHEME hTheme, + HDC hdc, + int iPartId, + int iStateId, + const RECT * pRect, + HIMAGELIST himl, + int iImageIndex +) +{ + return E_FAIL; +} + +THEMEAPI DrawThemeParentBackground +( + HWND hwnd, + HDC hdc, + RECT * prc +) +{ + return E_FAIL; +} + +THEMEAPI_(BOOL) IsThemeBackgroundPartiallyTransparent +( + HTHEME hTheme, + int iPartId, + int iStateId +) +{ + return FALSE; +} + +THEMEAPI_(HTHEME) OpenThemeData +( + HWND hwnd, + LPCWSTR pszClassList +) +{ + PUXTHEME_DATA pUxTheme; + PCUXTHEME_VTABLE pvt; + + if(_wcsicmp(pszClassList, L"Button") == 0) pvt = &Button_Vt; + else return NULL; + + pUxTheme = (PUXTHEME_DATA)malloc(sizeof(*pUxTheme)); + + if(pUxTheme == NULL) return NULL; + + pUxTheme->pvt = pvt; + + return (HTHEME)pUxTheme; +} + +THEMEAPI CloseThemeData +( + HTHEME hTheme +) +{ + return E_FAIL; +} + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fwdreason, LPVOID lpvReserved) +{ + (void)lpvReserved; + + if(fwdreason == DLL_PROCESS_ATTACH) + DisableThreadLibraryCalls(hinstDLL); + + return TRUE; +} + +/* EOF */ + + diff --git a/reactos/lib/uxtheme/uxthemedll.h b/reactos/lib/uxtheme/uxthemedll.h new file mode 100644 index 00000000000..771bca0d245 --- /dev/null +++ b/reactos/lib/uxtheme/uxthemedll.h @@ -0,0 +1,50 @@ +#ifndef UXTHEMEDLL_H_INCLUDED__ +#define UXTHEMEDLL_H_INCLUDED__ + +#include + +#define _UXTHEME_ +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +struct UXTHEME_DATA_; +struct UXTHEME_VTABLE_; + +struct UXTHEME_VTABLE_ +{ + HRESULT STDAPICALLTYPE (* p_DrawBackground) + ( + struct UXTHEME_DATA_ * pData, + HDC hdc, + int iPartId, + int iStateId, + const RECT * pRect, + const RECT * pClipRect + ); +}; + +typedef struct UXTHEME_VTABLE_ UXTHEME_VTABLE, * PUXTHEME_VTABLE; +typedef const struct UXTHEME_VTABLE_ * PCUXTHEME_VTABLE; + +typedef struct UXTHEME_DATA_ +{ + PCUXTHEME_VTABLE pvt; + PVOID pData; +} +UXTHEME_DATA, * PUXTHEME_DATA; + +STDAPI UxTheme_ClipDc(HDC hdc, const RECT * pClipRect, HRGN * phrgnSave); +STDAPI UxTheme_UnclipDc(HDC hdc, HRGN hrgnSave); + +#ifdef __cplusplus +} +#endif + +#endif + +/* EOF */