Mercurial > projects > dwt-win
changeset 90:be0b130bb29a
activated loading of delayed libs
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Wed, 06 Feb 2008 22:49:46 +0100 |
parents | 8c6a38719fb8 |
children | b5c6e5033649 |
files | dwt/internal/gdip/Gdip.d dwt/internal/win32/OS.d |
diffstat | 2 files changed, 89 insertions(+), 50 deletions(-) [+] |
line wrap: on
line diff
--- a/dwt/internal/gdip/Gdip.d Wed Feb 06 21:59:14 2008 +0100 +++ b/dwt/internal/gdip/Gdip.d Wed Feb 06 22:49:46 2008 +0100 @@ -7,9 +7,9 @@ * * Contributors: * IBM Corporation - initial API and implementation - * D Port: + * Port to the D programming language: * John Reimer <terminal.node@gmail.com> - * Frank Benoit <keinfarbaton> + * Frank Benoit <benoit@tionex.de> *******************************************************************************/ module dwt.internal.gdip.Gdip; @@ -20,6 +20,7 @@ import dwt.internal.Platform; import dwt.internal.win32.WINTYPES; import dwt.internal.win32.WINAPI; +import dwt.internal.win32.OS; alias dwt.internal.gdip.native.GdiplusStartupInput GdiplusStartupInput; @@ -33,7 +34,11 @@ public class Gdip : Platform { - + static this(){ + if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (5, 1)) { + loadLib_Gdip(); + } + } /************************************************************************** **************************************************************************/
--- a/dwt/internal/win32/OS.d Wed Feb 06 21:59:14 2008 +0100 +++ b/dwt/internal/win32/OS.d Wed Feb 06 22:49:46 2008 +0100 @@ -63,6 +63,22 @@ struct Symbol { char[] name; void** symbol; + int major; + int minor; + } + static void loadLib( Symbol[] symbols, char[] libname ){ + if (auto lib = SharedLib.load(libname)) { + foreach( inout s; symbols ){ + if( OS.WIN32_VERSION >= OS.VERSION( s.major, s.minor )){ + *s.symbol = lib.getSymbol( s.name.ptr ); + if( s.symbol is null ){ + Trace.formatln( "{}: Symbol '{}' not found", libname, s.name ); + } + } + } + } else { + Trace.formatln( "Could not load the library {}", libname ); + } } public static HINSTANCE GetLibraryHandle(){ @@ -212,6 +228,23 @@ WIN32_MINOR = info.dwMinorVersion; WIN32_VERSION = VERSION (WIN32_MAJOR, WIN32_MINOR); + // when to load uxtheme + if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (5, 1)) { + loadLib( Symbols_UxTheme, `UxTheme.dll` ); + } + if (OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (5, 1)) { + loadLib( Symbols_CoreImm, `Coreimm.dll` ); + } + if (OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) { + loadLib( Symbols_User32, `User32.dll` ); + } + if (OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (5, 1)) { + loadLib( Symbols_Imm32, `Imm32.dll` ); + } + if (OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (5, 1)) { + loadLib( Symbols_Kernel32, `Kernel32.dll` ); + } + //PORTING_CHANGE: made by version //IsUnicode = !IsWin32s && !IsWin95; /* Load the manifest to force the XP Theme */ @@ -4181,28 +4214,30 @@ } // public static static Symbol[] Symbols_UxTheme = [ - { "IsAppThemed", cast(void**)& IsAppThemed }, - { "DrawThemeBackground", cast(void**)& DrawThemeBackground }, - { "DrawThemeEdge", cast(void**)& DrawThemeEdge }, - { "DrawThemeIcon", cast(void**)& DrawThemeIcon }, - { "DrawThemeParentBackground", cast(void**)& DrawThemeParentBackground }, - { "DrawThemeText", cast(void**)& DrawThemeText }, - { "OpenThemeData", cast(void**)& OpenThemeData }, - { "BufferedPaintInit", cast(void**)& BufferedPaintInit }, - { "CloseThemeData", cast(void**)& CloseThemeData }, - { "BufferedPaintUnInit", cast(void**)& BufferedPaintUnInit }, - { "BeginBufferedPaint", cast(void**)& BeginBufferedPaint }, - { "EndBufferedPaint", cast(void**)& EndBufferedPaint }, - { "GetThemeTextExtent", cast(void**)& GetThemeTextExtent }, - { "SetWindowTheme", cast(void**)& SetWindowTheme }, + { "IsAppThemed", cast(void**)& IsAppThemed, 5, 1 }, + { "DrawThemeBackground", cast(void**)& DrawThemeBackground, 5, 1 }, + { "DrawThemeEdge", cast(void**)& DrawThemeEdge, 5, 1 }, + { "DrawThemeIcon", cast(void**)& DrawThemeIcon, 5, 1 }, + { "DrawThemeParentBackground", cast(void**)& DrawThemeParentBackground, 5, 1 }, + { "DrawThemeText", cast(void**)& DrawThemeText, 5, 1 }, + { "OpenThemeData", cast(void**)& OpenThemeData, 5, 1 }, + { "CloseThemeData", cast(void**)& CloseThemeData, 5, 1 }, + { "GetThemeTextExtent", cast(void**)& GetThemeTextExtent, 5, 1 }, + { "SetWindowTheme", cast(void**)& SetWindowTheme, 5, 1 }, + { "BufferedPaintUnInit", cast(void**)& BufferedPaintUnInit, 6, 0 }, + { "BufferedPaintInit", cast(void**)& BufferedPaintInit, 6, 0 }, + { "BeginBufferedPaint", cast(void**)& BeginBufferedPaint, 6, 0 }, + { "EndBufferedPaint", cast(void**)& EndBufferedPaint, 6, 0 }, ]; static void loadLib_UxTheme(){ if (auto lib = SharedLib.load(`uxtheme.dll`)) { foreach( inout s; Symbols_UxTheme ){ - *s.symbol = lib.getSymbol( s.name.ptr ); - if( s.symbol is null ){ - Trace.formatln("UxTheme.dll: Symbol '{}' not found", s.name ); + if( OS.WIN32_VERSION >= OS.VERSION( s.major, s.minor )){ + *s.symbol = lib.getSymbol( s.name.ptr ); + if( s.symbol is null ){ + Trace.formatln("UxTheme.dll: Symbol '{}' not found", s.name ); + } } } } else { @@ -4306,48 +4341,47 @@ } // public static extern(Windows) static Symbol[] Symbols_CoreImm = [ - { "ImmAssociateContext", cast(void**)& ImmAssociateContext }, - { "ImmCreateContext", cast(void**)& ImmCreateContext }, - { "ImmDestroyContext", cast(void**)& ImmDestroyContext }, - { "ImmGetContext", cast(void**)& ImmGetContext }, - { "ImmGetConversionStatus", cast(void**)& ImmGetConversionStatus }, - { "ImmGetDefaultIMEWnd", cast(void**)& ImmGetDefaultIMEWnd }, - { "ImmGetOpenStatus", cast(void**)& ImmGetOpenStatus }, - { "ImmReleaseContext", cast(void**)& ImmReleaseContext }, - { "ImmSetCompositionFont", cast(void**)& ImmSetCompositionFont }, - { "ImmGetCompositionString", cast(void**)& ImmGetCompositionString }, - { "ImmGetCompositionFont", cast(void**)& ImmGetCompositionFont }, - { "ImmSetCompositionFont", cast(void**)& ImmSetCompositionFont }, - { "ImmGetCompositionString", cast(void**)& ImmGetCompositionString }, - { "ImmGetCompositionFont", cast(void**)& ImmGetCompositionFont }, - { "ImmSetCompositionWindow", cast(void**)& ImmSetCompositionWindow }, - { "ImmSetConversionStatus", cast(void**)& ImmSetConversionStatus }, - { "ImmSetOpenStatus", cast(void**)& ImmSetOpenStatus }, + { "ImmAssociateContext", cast(void**)& ImmAssociateContext, 5, 1 }, + { "ImmCreateContext", cast(void**)& ImmCreateContext, 5, 1 }, + { "ImmDestroyContext", cast(void**)& ImmDestroyContext, 5, 1 }, + { "ImmGetContext", cast(void**)& ImmGetContext, 5, 1 }, + { "ImmGetConversionStatus", cast(void**)& ImmGetConversionStatus, 5, 1 }, + { "ImmGetDefaultIMEWnd", cast(void**)& ImmGetDefaultIMEWnd, 5, 1 }, + { "ImmGetOpenStatus", cast(void**)& ImmGetOpenStatus, 5, 1 }, + { "ImmReleaseContext", cast(void**)& ImmReleaseContext, 5, 1 }, + { "ImmSetCompositionFont", cast(void**)& ImmSetCompositionFont, 5, 1 }, + { "ImmGetCompositionString", cast(void**)& ImmGetCompositionString, 5, 1 }, + { "ImmGetCompositionFont", cast(void**)& ImmGetCompositionFont, 5, 1 }, + { "ImmSetCompositionFont", cast(void**)& ImmSetCompositionFont, 5, 1 }, + { "ImmGetCompositionString", cast(void**)& ImmGetCompositionString, 5, 1 }, + { "ImmGetCompositionFont", cast(void**)& ImmGetCompositionFont, 5, 1 }, + { "ImmSetCompositionWindow", cast(void**)& ImmSetCompositionWindow, 5, 1 }, + { "ImmSetConversionStatus", cast(void**)& ImmSetConversionStatus, 5, 1 }, + { "ImmSetOpenStatus", cast(void**)& ImmSetOpenStatus, 5, 1 }, ]; -static void loadLib_CoreImm(){ - if (auto lib = SharedLib.load(`coreimm.dll`)) { - foreach( inout s; Symbols_CoreImm ){ - *s.symbol = lib.getSymbol( s.name.ptr ); - if( s.symbol is null ){ - Trace.formatln("CoreImm.dll: Symbol '{}' not found", s.name ); - } - } - } else { - Trace.formatln("Could not load the library coreimm.dll"); - } -} - // user32.dll vista public static extern(Windows) BOOL function() SetProcessDPIAware; +static Symbol[] Symbols_User32 = [ + { "SetProcessDPIAware", cast(void**)& SetProcessDPIAware, 6, 0 }, +]; + // Imm32.lib public static extern(Windows) BOOL function( DWORD idThread ) ImmDisableTextFrameService; +static Symbol[] Symbols_Imm32 = [ + { "ImmDisableTextFrameService", cast(void**)& ImmDisableTextFrameService, 5, 1 }, +]; // kernel32 winxp/vista public static extern(Windows) { HANDLE function( ACTCTX* pActCtx ) CreateActCtx; BOOL function( HACTCTX hActCtx, uint* lpCookie ) ActivateActCtx; } +static Symbol[] Symbols_Kernel32 = [ + { "CreateActCtx", cast(void**)& CreateActCtx, 5, 1 }, + { "ActivateActCtx", cast(void**)& ActivateActCtx, 5, 1 }, +]; + //------------------------------------------------------------------------ /** All Natives */ alias WINAPI.AbortDoc AbortDoc;