summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsje <sje@4f64403b-2f21-0410-a795-97e2b3489a10>2006-11-01 14:34:02 +0000
committersje <sje@4f64403b-2f21-0410-a795-97e2b3489a10>2006-11-01 14:34:02 +0000
commitc9afe68aa201d99fd8651a35e45064b57e4d2699 (patch)
tree7d44aa04d970e15da1b6a56974182155cef17654
parent31d3a6408d045eadaff094d4c11bf017817743d7 (diff)
git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@5 4f64403b-2f21-0410-a795-97e2b3489a10
-rw-r--r--font_service/FontService.cpp95
-rw-r--r--font_service/FontService.dsp160
-rw-r--r--font_service/FontService.dsw29
-rw-r--r--font_service/FontService.h18
-rw-r--r--font_service/FontService.mdsp104
-rw-r--r--font_service/FontService.plg68
-rw-r--r--font_service/FontService.sln20
-rw-r--r--font_service/FontService.vcproj377
-rw-r--r--font_service/Makefile197
-rw-r--r--font_service/Makefile.nodeflib197
-rw-r--r--font_service/collection.h545
-rw-r--r--font_service/common.h68
-rw-r--r--font_service/docs/m_fontservice.h148
-rw-r--r--font_service/docs/m_fontservicew.h152
-rw-r--r--font_service/forkthread.cpp93
-rw-r--r--font_service/forkthread.h63
-rw-r--r--font_service/m_fontservice.h148
-rw-r--r--font_service/m_fontservicew.h152
-rw-r--r--font_service/module_fonts.cpp239
-rw-r--r--font_service/module_fonts.h8
-rw-r--r--font_service/options.cpp689
-rw-r--r--font_service/options.h3
-rw-r--r--font_service/resource.h50
-rw-r--r--font_service/resource.rc133
-rw-r--r--font_service/services.cpp358
-rw-r--r--font_service/services.h46
26 files changed, 4160 insertions, 0 deletions
diff --git a/font_service/FontService.cpp b/font_service/FontService.cpp
new file mode 100644
index 0000000..e03e804
--- /dev/null
+++ b/font_service/FontService.cpp
@@ -0,0 +1,95 @@
+// Copyright Scott Ellis (mail@scottellis.com.au) 2005
+// This software is licenced under the GPL (General Public Licence)
+// available at http://www.gnu.org/copyleft/gpl.html
+
+#include "common.h"
+#include "FontService.h"
+#include "m_fontservice.h"
+
+#include "module_fonts.h"
+
+PLUGININFO pluginInfo={
+ sizeof(PLUGININFO),
+ "FontService",
+ PLUGIN_MAKE_VERSION(0, 1, 4, 3),
+ "Provides a UI for font settings, and services to plugins for font control.",
+ "S. Ellis",
+ "mail@scottellis.com.au",
+ "© 2005 S. Ellis",
+ "www.scottellis.com.au",
+ 0,
+ 0
+};
+
+HINSTANCE hInstance;
+PLUGINLINK *pluginLink;
+struct MM_INTERFACE memoryManagerInterface;
+
+HANDLE hFontReloadEvent, hColourReloadEvent;
+
+extern "C" FONTSERVICE_API PLUGININFO* MirandaPluginInfo(DWORD mirandaVersion)
+{
+ return &pluginInfo;
+}
+
+extern "C" BOOL APIENTRY DllMain( HANDLE hModule,
+ DWORD ul_reason_for_call,
+ LPVOID lpReserved
+ )
+{
+ hInstance = (HINSTANCE)hModule;
+ DisableThreadLibraryCalls(hInstance);
+ return TRUE;
+}
+
+
+int ModulesLoaded(WPARAM wParam, LPARAM lParam) {
+ if(!GetModuleHandle(L"CLIST_MODERN"))
+ RegisterCListFonts();
+
+ if(GetModuleHandle(L"SRMM"))
+ RegisterSRMMFonts();
+ if(GetModuleHandle(L"CHAT"))
+ RegisterChatFonts();
+
+ return 0;
+}
+
+extern "C" FONTSERVICE_API int Load(PLUGINLINK *link)
+{
+ pluginLink=link;
+ memset(&memoryManagerInterface, 0, sizeof(memoryManagerInterface));
+ memoryManagerInterface.cbSize = sizeof(memoryManagerInterface);
+ CallService(MS_SYSTEM_GET_MMI, 0, (LPARAM) & memoryManagerInterface);
+
+ HookEvent(ME_OPT_INITIALISE, OptInit);
+
+ CreateServiceFunction(MS_FONT_REGISTER, RegisterFont);
+ CreateServiceFunction(MS_FONT_GET, GetFont);
+
+ CreateServiceFunction(MS_COLOUR_REGISTER, RegisterColour);
+ CreateServiceFunction(MS_COLOUR_GET, GetColour);
+
+ CreateServiceFunction(MS_FONT_REGISTERW, RegisterFontW);
+ CreateServiceFunction(MS_FONT_GETW, GetFontW);
+
+ CreateServiceFunction(MS_COLOUR_REGISTERW, RegisterColourW);
+ CreateServiceFunction(MS_COLOUR_GETW, GetColourW);
+
+ hFontReloadEvent = CreateHookableEvent(ME_FONT_RELOAD);
+ hColourReloadEvent = CreateHookableEvent(ME_COLOUR_RELOAD);
+
+ if(ServiceExists(MS_LANGPACK_GETCODEPAGE))
+ code_page = CallService(MS_LANGPACK_GETCODEPAGE, 0, 0);
+
+ // do last for silly dyna plugin
+ HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
+ return 0;
+}
+
+extern "C" FONTSERVICE_API int Unload(PLUGINLINK *link)
+{
+ DestroyHookableEvent(hFontReloadEvent);
+ DestroyHookableEvent(hColourReloadEvent);
+ return 0;
+}
diff --git a/font_service/FontService.dsp b/font_service/FontService.dsp
new file mode 100644
index 0000000..77c33dd
--- /dev/null
+++ b/font_service/FontService.dsp
@@ -0,0 +1,160 @@
+# Microsoft Developer Studio Project File - Name="FontService" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=FontService - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "FontService.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "FontService.mak" CFG="FontService - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "FontService - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "FontService - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "FontService - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FONTSERVICE_EXPORTS" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FONTSERVICE_EXPORTS" /Yu"stdafx.h" /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0xc09 /d "NDEBUG"
+# ADD RSC /l 0xc09 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 comctl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"../../bin/release/plugins/FontService.dll"
+
+!ELSEIF "$(CFG)" == "FontService - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FONTSERVICE_EXPORTS" /Yu"stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FONTSERVICE_EXPORTS" /Yu"stdafx.h" /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0xc09 /d "_DEBUG"
+# ADD RSC /l 0xc09 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 comctl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x22030000" /dll /debug /machine:I386 /out:"../../bin/debug/plugins/FontService.dll" /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "FontService - Win32 Release"
+# Name "FontService - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\FontService.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\module_fonts.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\options.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\services.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.cpp
+# ADD CPP /Yc"stdafx.h"
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\FontService.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\m_fontservice.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\module_fonts.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\options.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\services.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# Begin Source File
+
+SOURCE=.\resource.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\resource.rc
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\ReadMe.txt
+# End Source File
+# End Target
+# End Project
diff --git a/font_service/FontService.dsw b/font_service/FontService.dsw
new file mode 100644
index 0000000..194876e
--- /dev/null
+++ b/font_service/FontService.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "FontService"=".\FontService.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/font_service/FontService.h b/font_service/FontService.h
new file mode 100644
index 0000000..b88b40a
--- /dev/null
+++ b/font_service/FontService.h
@@ -0,0 +1,18 @@
+// Copyright Scott Ellis (mail@scottellis.com.au) 2005
+// This software is licenced under the GPL (General Public Licence)
+// available at http://www.gnu.org/copyleft/gpl.html
+
+// The following ifdef block is the standard way of creating macros which make exporting
+// from a DLL simpler. All files within this DLL are compiled with the FONTSERVICE_EXPORTS
+// symbol defined on the command line. this symbol should not be defined on any project
+// that uses this DLL. This way any other project whose source files include this file see
+// FONTSERVICE_API functions as being imported from a DLL, wheras this DLL sees symbols
+// defined with this macro as being exported.
+#ifdef FONTSERVICE_EXPORTS
+#define FONTSERVICE_API __declspec(dllexport)
+#else
+#define FONTSERVICE_API __declspec(dllimport)
+#endif
+
+#include "services.h"
+#include "options.h"
diff --git a/font_service/FontService.mdsp b/font_service/FontService.mdsp
new file mode 100644
index 0000000..5a746f6
--- /dev/null
+++ b/font_service/FontService.mdsp
@@ -0,0 +1,104 @@
+[Project]
+name=FontService
+type=2
+defaultConfig=1
+
+
+[Debug]
+// compiler
+workingDirectory=
+arguments=
+intermediateFilesDirectory=Debug
+outputFilesDirectory=Debug
+compilerPreprocessor=UNICODE,_UNICODE,FONTSERVICE_EXPORTS,MICROSOFT_LAYER_FOR_UNICODE=1
+extraCompilerOptions=
+compilerIncludeDirectory=..\..\include
+noWarning=0
+defaultWarning=0
+allWarning=1
+extraWarning=0
+isoWarning=0
+warningsAsErrors=0
+debugType=1
+debugLevel=2
+exceptionEnabled=1
+runtimeTypeEnabled=1
+optimizeLevel=0
+
+// linker
+libraryPath=
+outputFilename=Debug\FontService.dll
+libraries=unicows,gdi32
+extraLinkerOptions=
+ignoreStartupFile=0
+ignoreDefaultLibs=0
+stripExecutableFile=0
+
+// archive
+extraArchiveOptions=
+
+//resource
+resourcePreprocessor=
+resourceIncludeDirectory=
+extraResourceOptions=
+
+[Release]
+// compiler
+workingDirectory=
+arguments=
+intermediateFilesDirectory=Release
+outputFilesDirectory=Release
+compilerPreprocessor=UNICODE,_UNICODE,FONTSERVICE_EXPORTS,MICROSOFT_LAYER_FOR_UNICODE=1
+extraCompilerOptions=
+compilerIncludeDirectory=..\..\include
+noWarning=0
+defaultWarning=0
+allWarning=1
+extraWarning=0
+isoWarning=0
+warningAsErrors=0
+debugType=0
+debugLevel=1
+exceptionEnabled=1
+runtimeTypeEnabled=1
+optimizeLevel=2
+
+// linker
+libraryPath=
+outputFilename=Release\FontService.dll
+libraries=unicows, gdi32
+extraLinkerOptions=
+ignoreStartupFile=0
+ignoreDefaultLibs=0
+stripExecutableFile=1
+
+// archive
+extraArchiveOptions=
+
+//resource
+resourcePreprocessor=
+resourceIncludeDirectory=
+extraResourceOptions=
+
+[Source]
+1=FontService.cpp
+2=module_fonts.cpp
+3=options.cpp
+4=services.cpp
+[Header]
+1=FontService.h
+2=common.h
+3=m_fontservice.h
+4=m_fontservicew.h
+5=module_fonts.h
+6=options.h
+7=resource.h
+8=services.h
+[Resource]
+1=resource.rc
+[Other]
+[History]
+collection.h,3038
+FontService.h,682
+options.cpp,986
+FontService.cpp,353
diff --git a/font_service/FontService.plg b/font_service/FontService.plg
new file mode 100644
index 0000000..38f6869
--- /dev/null
+++ b/font_service/FontService.plg
@@ -0,0 +1,68 @@
+<html>
+<body>
+<pre>
+<h1>Build Log</h1>
+<h3>
+--------------------Configuration: FontService - Win32 Release--------------------
+</h3>
+<h3>Command Lines</h3>
+Creating temporary file "C:\DOCUME~1\sje\LOCALS~1\Temp\RSP95.tmp" with contents
+[
+/nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FONTSERVICE_EXPORTS" /Fp"Release/FontService.pch" /Yu"stdafx.h" /Fo"Release/" /Fd"Release/" /FD /c
+"C:\Documents and Settings\sje\My Documents\MyProjects\miranda\plugins\FontService\FontService.cpp"
+]
+Creating command line "cl.exe @C:\DOCUME~1\sje\LOCALS~1\Temp\RSP95.tmp"
+Creating temporary file "C:\DOCUME~1\sje\LOCALS~1\Temp\RSP96.tmp" with contents
+[
+comctl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /pdb:"Release/FontService.pdb" /machine:I386 /out:"../../bin/release/plugins/FontService.dll" /implib:"Release/FontService.lib"
+".\Release\FontService.obj"
+".\Release\module_fonts.obj"
+".\Release\options.obj"
+".\Release\services.obj"
+".\Release\StdAfx.obj"
+".\Release\resource.res"
+]
+Creating command line "link.exe @C:\DOCUME~1\sje\LOCALS~1\Temp\RSP96.tmp"
+<h3>Output Window</h3>
+Compiling...
+FontService.cpp
+Linking...
+ Creating library Release/FontService.lib and object Release/FontService.exp
+
+
+
+<h3>Results</h3>
+FontService.dll - 0 error(s), 0 warning(s)
+<h3>
+--------------------Configuration: FontService - Win32 Debug--------------------
+</h3>
+<h3>Command Lines</h3>
+Creating temporary file "C:\DOCUME~1\sje\LOCALS~1\Temp\RSP9A.tmp" with contents
+[
+/nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FONTSERVICE_EXPORTS" /Fp"Debug/FontService.pch" /Yu"stdafx.h" /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
+"C:\Documents and Settings\sje\My Documents\MyProjects\miranda\plugins\FontService\FontService.cpp"
+]
+Creating command line "cl.exe @C:\DOCUME~1\sje\LOCALS~1\Temp\RSP9A.tmp"
+Creating temporary file "C:\DOCUME~1\sje\LOCALS~1\Temp\RSP9B.tmp" with contents
+[
+comctl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x22030000" /dll /incremental:yes /pdb:"Debug/FontService.pdb" /debug /machine:I386 /out:"../../bin/debug/plugins/FontService.dll" /implib:"Debug/FontService.lib" /pdbtype:sept
+".\Debug\FontService.obj"
+".\Debug\module_fonts.obj"
+".\Debug\options.obj"
+".\Debug\services.obj"
+".\Debug\StdAfx.obj"
+".\Debug\resource.res"
+]
+Creating command line "link.exe @C:\DOCUME~1\sje\LOCALS~1\Temp\RSP9B.tmp"
+<h3>Output Window</h3>
+Compiling...
+FontService.cpp
+Linking...
+
+
+
+<h3>Results</h3>
+FontService.dll - 0 error(s), 0 warning(s)
+</pre>
+</body>
+</html>
diff --git a/font_service/FontService.sln b/font_service/FontService.sln
new file mode 100644
index 0000000..e0da11e
--- /dev/null
+++ b/font_service/FontService.sln
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FontService", "FontService.vcproj", "{0807190B-C904-4889-8CAE-D42508748947}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {0807190B-C904-4889-8CAE-D42508748947}.Debug|Win32.ActiveCfg = Debug|Win32
+ {0807190B-C904-4889-8CAE-D42508748947}.Debug|Win32.Build.0 = Debug|Win32
+ {0807190B-C904-4889-8CAE-D42508748947}.Release|Win32.ActiveCfg = Release|Win32
+ {0807190B-C904-4889-8CAE-D42508748947}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/font_service/FontService.vcproj b/font_service/FontService.vcproj
new file mode 100644
index 0000000..f61ac1a
--- /dev/null
+++ b/font_service/FontService.vcproj
@@ -0,0 +1,377 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="FontService"
+ ProjectGUID="{0807190B-C904-4889-8CAE-D42508748947}"
+ RootNamespace="FontService"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".\Release"
+ IntermediateDirectory=".\Release"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="true"
+ SuppressStartupBanner="true"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Release/FontService.tlb"
+ HeaderFileName=""
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ InlineFunctionExpansion="1"
+ AdditionalIncludeDirectories="../../include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;FONTSERVICE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;MICROSOFT_LAYER_FOR_UNICODE=1"
+ StringPooling="true"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="common.h"
+ AssemblerListingLocation=".\Release/"
+ ObjectFile=".\Release/"
+ ProgramDataBaseFileName=".\Release/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="3081"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="unicows.lib comctl32.lib"
+ OutputFile="../../bin/release/plugins/FontService.dll"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ GenerateManifest="false"
+ IgnoreDefaultLibraryNames="Kernel32.lib Advapi32.lib User32.lib Gdi32.lib Shell32.lib Comdlg32.lib Version.lib Mpr.lib Rasapi32.lib Winmm.lib Winspool.lib Vfw32.lib Secur32.lib Oleacc.lib Oledlg.lib Sensapi.lib"
+ ProgramDatabaseFile=".\Release/FontService.pdb"
+ ImportLibrary="$(IntDir)/$(TargetName).lib"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ SuppressStartupBanner="true"
+ OutputFile=".\Release/FontService.bsc"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="_DEBUG"
+ MkTypLibCompatible="true"
+ SuppressStartupBanner="true"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Debug/FontService.tlb"
+ HeaderFileName=""
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../include"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FONTSERVICE_EXPORTS;_CRT_SECURE_NO_DEPRECATE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="common.h"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="3081"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="comctl32.lib odbc32.lib odbccp32.lib unicows.lib"
+ OutputFile="../../bin/debug/plugins/FontService.dll"
+ LinkIncremental="2"
+ SuppressStartupBanner="true"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile=".\Debug/FontService.pdb"
+ BaseAddress="0x22030000"
+ ImportLibrary="$(IntDir)/$(TargetName).lib"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ SuppressStartupBanner="true"
+ OutputFile=".\Debug/FontService.bsc"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+ >
+ <File
+ RelativePath="FontService.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="module_fonts.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="options.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="services.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl"
+ >
+ <File
+ RelativePath=".\collection.h"
+ >
+ </File>
+ <File
+ RelativePath=".\common.h"
+ >
+ </File>
+ <File
+ RelativePath="FontService.h"
+ >
+ </File>
+ <File
+ RelativePath="m_fontservice.h"
+ >
+ </File>
+ <File
+ RelativePath=".\m_fontservicew.h"
+ >
+ </File>
+ <File
+ RelativePath="module_fonts.h"
+ >
+ </File>
+ <File
+ RelativePath="options.h"
+ >
+ </File>
+ <File
+ RelativePath="services.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+ >
+ <File
+ RelativePath="resource.h"
+ >
+ </File>
+ <File
+ RelativePath="resource.rc"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <File
+ RelativePath="ReadMe.txt"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/font_service/Makefile b/font_service/Makefile
new file mode 100644
index 0000000..53b136d
--- /dev/null
+++ b/font_service/Makefile
@@ -0,0 +1,197 @@
+#################################################################
+## This Makefile Exported by MinGW Developer Studio
+## Copyright (c) 2002-2004 by Parinya Thipchart
+#################################################################
+
+ifneq (,$(findstring Release, $(CFG)))
+ override CFG = Release
+else
+ override CFG = Debug
+endif
+
+PROJECT = FontService
+CC = "C:\msys\bin\g++.exe"
+
+WINDRES = "$(COMPILER_BIN)windres.exe"
+ifeq ($(CFG),Debug)
+ OBJ_DIR = Debug
+ OUTPUT_DIR = Debug
+ TARGET = FontService.dll
+ C_INCLUDE_DIRS = -I"../../../../../../../msys/include" -I"../../../../../../../msys/local/include" -I"../../../../../../../msys/local/include" -I"../../../../../../../msys/local/include"
+ C_PREPROC = -DUNICODE -D_UNICODE -DFONTSERVICE_EXPORTS -DMICROSOFT_LAYER_FOR_UNICODE=1
+ CFLAGS = -pipe -Wall -g2 -O0 -frtti -fexceptions
+ RC_INCLUDE_DIRS =
+ RC_PREPROC =
+ RCFLAGS =
+ LIB_DIRS = -L"../../../../../../../msys/lib" -L"../../../../../../../msys/local/lib" -L"../../../../../../../msys/local/lib"
+ LIBS = -lunicows -lgdi32
+ LDFLAGS = -pipe -shared -Wl,--output-def,"$(OBJ_DIR)\FontService.def",--out-implib,"$(OBJ_DIR)\libFontService.dll.a"
+endif
+
+ifeq ($(CFG),Release)
+ OBJ_DIR = Release
+ OUTPUT_DIR = Release
+ TARGET = FontService.dll
+ C_INCLUDE_DIRS = -I"../../../../../../../msys/include" -I"../../../../../../../msys/local/include" -I"../../../../../../../msys/local/include" -I"../../../../../../../msys/local/include"
+ C_PREPROC = -DUNICODE -D_UNICODE -DFONTSERVICE_EXPORTS -DMICROSOFT_LAYER_FOR_UNICODE=1
+ CFLAGS = -pipe -Wall -g0 -O2 -frtti -fexceptions
+ RC_INCLUDE_DIRS =
+ RC_PREPROC =
+ RCFLAGS =
+ LIB_DIRS = -L"../../../../../../../msys/lib" -L"../../../../../../../msys/local/lib" -L"../../../../../../../msys/local/lib"
+ LIBS = -lunicows -lgdi32
+ LDFLAGS = -pipe -shared -Wl,--output-def,"$(OBJ_DIR)\FontService.def",--out-implib,"$(OBJ_DIR)\libFontService.dll.a" -s
+endif
+
+ifeq ($(OS),Windows_NT)
+ NULL =
+else
+ NULL = nul
+endif
+
+SRC_OBJS = \
+ $(OBJ_DIR)/FontService.o \
+ $(OBJ_DIR)/StdAfx.o \
+ $(OBJ_DIR)/module_fonts.o \
+ $(OBJ_DIR)/options.o \
+ $(OBJ_DIR)/services.o
+
+RSRC_OBJS = \
+ $(OBJ_DIR)/resource.res
+
+define build_target
+@echo Linking...
+@$(CC) -o "$(OUTPUT_DIR)\$(TARGET)" $(SRC_OBJS) $(RSRC_OBJS) $(LIB_DIRS) $(LIBS) $(LDFLAGS)
+endef
+
+define compile_resource
+@echo Compiling $<
+@$(WINDRES) $(RCFLAGS) $(RC_PREPROC) $(RC_INCLUDE_DIRS) -O COFF -i "$<" -o "$@"
+endef
+
+define compile_source
+@echo Compiling $<
+@$(CC) $(CFLAGS) $(C_PREPROC) $(C_INCLUDE_DIRS) -c "$<" -o "$@"
+endef
+
+.PHONY: print_header directories
+
+$(TARGET): print_header directories $(RSRC_OBJS) $(SRC_OBJS)
+ $(build_target)
+
+.PHONY: clean cleanall
+
+cleanall:
+ @echo Deleting intermediate files for 'FontService - $(CFG)'
+ -@del $(OBJ_DIR)\*.o
+ -@del $(OBJ_DIR)\*.res
+ -@del "$(OUTPUT_DIR)\$(TARGET)"
+ -@del "$(OBJ_DIR)\$(PROJECT).def"
+ -@del "$(OBJ_DIR)\lib$(PROJECT).dll.a"
+ -@rmdir "$(OUTPUT_DIR)"
+
+clean:
+ @echo Deleting intermediate files for 'FontService - $(CFG)'
+ -@del $(OBJ_DIR)\*.o
+ -@del $(OBJ_DIR)\*.res
+
+print_header:
+ @echo ----------Configuration: FontService - $(CFG)----------
+
+directories:
+ -@if not exist "$(OUTPUT_DIR)\$(NULL)" mkdir "$(OUTPUT_DIR)"
+ -@if not exist "$(OBJ_DIR)\$(NULL)" mkdir "$(OBJ_DIR)"
+
+$(OBJ_DIR)/resource.res: resource.rc \
+resource.h
+ $(compile_resource)
+
+$(OBJ_DIR)/FontService.o: FontService.cpp \
+StdAfx.h \
+resource.h \
+../../include/win2k.h \
+../../include/newpluginapi.h \
+../../include/m_langpack.h \
+../../include/m_database.h \
+../../include/m_system.h \
+../../include/m_options.h \
+../../include/m_utils.h \
+../../include/m_clui.h \
+../../include/m_clc.h \
+../chat/m_chat.h \
+FontService.h \
+services.h \
+m_fontservice.h \
+m_fontservicew.h \
+options.h \
+module_fonts.h
+ $(compile_source)
+
+$(OBJ_DIR)/StdAfx.o: StdAfx.cpp \
+StdAfx.h \
+resource.h \
+../../include/win2k.h \
+../../include/newpluginapi.h \
+../../include/m_langpack.h \
+../../include/m_database.h \
+../../include/m_system.h \
+../../include/m_options.h \
+../../include/m_utils.h \
+../../include/m_clui.h \
+../../include/m_clc.h \
+../chat/m_chat.h
+ $(compile_source)
+
+$(OBJ_DIR)/module_fonts.o: module_fonts.cpp \
+StdAfx.h \
+resource.h \
+../../include/win2k.h \
+../../include/newpluginapi.h \
+../../include/m_langpack.h \
+../../include/m_database.h \
+../../include/m_system.h \
+../../include/m_options.h \
+../../include/m_utils.h \
+../../include/m_clui.h \
+../../include/m_clc.h \
+../chat/m_chat.h \
+module_fonts.h \
+m_fontservice.h
+ $(compile_source)
+
+$(OBJ_DIR)/options.o: options.cpp \
+StdAfx.h \
+resource.h \
+../../include/win2k.h \
+../../include/newpluginapi.h \
+../../include/m_langpack.h \
+../../include/m_database.h \
+../../include/m_system.h \
+../../include/m_options.h \
+../../include/m_utils.h \
+../../include/m_clui.h \
+../../include/m_clc.h \
+../chat/m_chat.h \
+services.h \
+m_fontservice.h \
+m_fontservicew.h
+ $(compile_source)
+
+$(OBJ_DIR)/services.o: services.cpp \
+StdAfx.h \
+resource.h \
+../../include/win2k.h \
+../../include/newpluginapi.h \
+../../include/m_langpack.h \
+../../include/m_database.h \
+../../include/m_system.h \
+../../include/m_options.h \
+../../include/m_utils.h \
+../../include/m_clui.h \
+../../include/m_clc.h \
+../chat/m_chat.h \
+services.h \
+m_fontservice.h \
+m_fontservicew.h
+ $(compile_source)
+
diff --git a/font_service/Makefile.nodeflib b/font_service/Makefile.nodeflib
new file mode 100644
index 0000000..209bd5a
--- /dev/null
+++ b/font_service/Makefile.nodeflib
@@ -0,0 +1,197 @@
+#################################################################
+## This Makefile Exported by MinGW Developer Studio
+## Copyright (c) 2002-2004 by Parinya Thipchart
+#################################################################
+
+ifneq (,$(findstring Release, $(CFG)))
+ override CFG = Release
+else
+ override CFG = Debug
+endif
+
+PROJECT = FontService
+CC = "C:\msys\bin\g++.exe"
+
+WINDRES = "$(COMPILER_BIN)windres.exe"
+ifeq ($(CFG),Debug)
+ OBJ_DIR = Debug
+ OUTPUT_DIR = Debug
+ TARGET = FontService.dll
+ C_INCLUDE_DIRS = -I"../../../../../../../msys/include" -I"../../../../../../../msys/local/include" -I"../../../../../../../msys/local/include" -I"../../../../../../../msys/local/include"
+ C_PREPROC = -DUNICODE -D_UNICODE -DFONTSERVICE_EXPORTS -DMICROSOFT_LAYER_FOR_UNICODE=1
+ CFLAGS = -pipe -Wall -g2 -O0 -frtti -fexceptions
+ RC_INCLUDE_DIRS =
+ RC_PREPROC =
+ RCFLAGS =
+ LIB_DIRS = -L"../../../../../../../msys/lib" -L"../../../../../../../msys/local/lib" -L"../../../../../../../msys/local/lib"
+ LIBS = -lunicows -lgdi32
+ LDFLAGS = -pipe -shared -Wl,--output-def,"$(OBJ_DIR)\FontService.def",--out-implib,"$(OBJ_DIR)\libFontService.dll.a"
+endif
+
+ifeq ($(CFG),Release)
+ OBJ_DIR = Release
+ OUTPUT_DIR = Release
+ TARGET = FontService.dll
+ C_INCLUDE_DIRS = -I"../../../../../../../msys/include" -I"../../../../../../../msys/local/include" -I"../../../../../../../msys/local/include" -I"../../../../../../../msys/local/include"
+ C_PREPROC = -DUNICODE -D_UNICODE -DFONTSERVICE_EXPORTS -DMICROSOFT_LAYER_FOR_UNICODE=1
+ CFLAGS = -pipe -Wall -g0 -O2 -frtti -fexceptions
+ RC_INCLUDE_DIRS =
+ RC_PREPROC =
+ RCFLAGS =
+ LIB_DIRS = -L"../../../../../../../msys/lib" -L"../../../../../../../msys/local/lib" -L"../../../../../../../msys/local/lib"
+ LIBS = -lunicows -lgdi32
+ LDFLAGS = -pipe -shared -Wl,--output-def,"$(OBJ_DIR)\FontService.def",--out-implib,"$(OBJ_DIR)\libFontService.dll.a" -nodefaultlibs -s -L"../../../../../../../msys/lib" -L"../../../../../../../msys/local/lib"
+endif
+
+ifeq ($(OS),Windows_NT)
+ NULL =
+else
+ NULL = nul
+endif
+
+SRC_OBJS = \
+ $(OBJ_DIR)/FontService.o \
+ $(OBJ_DIR)/StdAfx.o \
+ $(OBJ_DIR)/module_fonts.o \
+ $(OBJ_DIR)/options.o \
+ $(OBJ_DIR)/services.o
+
+RSRC_OBJS = \
+ $(OBJ_DIR)/resource.res
+
+define build_target
+@echo Linking...
+@$(CC) -o "$(OUTPUT_DIR)\$(TARGET)" $(SRC_OBJS) $(RSRC_OBJS) $(LIB_DIRS) $(LIBS) $(LDFLAGS)
+endef
+
+define compile_resource
+@echo Compiling $<
+@$(WINDRES) $(RCFLAGS) $(RC_PREPROC) $(RC_INCLUDE_DIRS) -O COFF -i "$<" -o "$@"
+endef
+
+define compile_source
+@echo Compiling $<
+@$(CC) $(CFLAGS) $(C_PREPROC) $(C_INCLUDE_DIRS) -c "$<" -o "$@"
+endef
+
+.PHONY: print_header directories
+
+$(TARGET): print_header directories $(RSRC_OBJS) $(SRC_OBJS)
+ $(build_target)
+
+.PHONY: clean cleanall
+
+cleanall:
+ @echo Deleting intermediate files for 'FontService - $(CFG)'
+ -@del $(OBJ_DIR)\*.o
+ -@del $(OBJ_DIR)\*.res
+ -@del "$(OUTPUT_DIR)\$(TARGET)"
+ -@del "$(OBJ_DIR)\$(PROJECT).def"
+ -@del "$(OBJ_DIR)\lib$(PROJECT).dll.a"
+ -@rmdir "$(OUTPUT_DIR)"
+
+clean:
+ @echo Deleting intermediate files for 'FontService - $(CFG)'
+ -@del $(OBJ_DIR)\*.o
+ -@del $(OBJ_DIR)\*.res
+
+print_header:
+ @echo ----------Configuration: FontService - $(CFG)----------
+
+directories:
+ -@if not exist "$(OUTPUT_DIR)\$(NULL)" mkdir "$(OUTPUT_DIR)"
+ -@if not exist "$(OBJ_DIR)\$(NULL)" mkdir "$(OBJ_DIR)"
+
+$(OBJ_DIR)/resource.res: resource.rc \
+resource.h
+ $(compile_resource)
+
+$(OBJ_DIR)/FontService.o: FontService.cpp \
+StdAfx.h \
+resource.h \
+../../include/win2k.h \
+../../include/newpluginapi.h \
+../../include/m_langpack.h \
+../../include/m_database.h \
+../../include/m_system.h \
+../../include/m_options.h \
+../../include/m_utils.h \
+../../include/m_clui.h \
+../../include/m_clc.h \
+../chat/m_chat.h \
+FontService.h \
+services.h \
+m_fontservice.h \
+m_fontservicew.h \
+options.h \
+module_fonts.h
+ $(compile_source)
+
+$(OBJ_DIR)/StdAfx.o: StdAfx.cpp \
+StdAfx.h \
+resource.h \
+../../include/win2k.h \
+../../include/newpluginapi.h \
+../../include/m_langpack.h \
+../../include/m_database.h \
+../../include/m_system.h \
+../../include/m_options.h \
+../../include/m_utils.h \
+../../include/m_clui.h \
+../../include/m_clc.h \
+../chat/m_chat.h
+ $(compile_source)
+
+$(OBJ_DIR)/module_fonts.o: module_fonts.cpp \
+StdAfx.h \
+resource.h \
+../../include/win2k.h \
+../../include/newpluginapi.h \
+../../include/m_langpack.h \
+../../include/m_database.h \
+../../include/m_system.h \
+../../include/m_options.h \
+../../include/m_utils.h \
+../../include/m_clui.h \
+../../include/m_clc.h \
+../chat/m_chat.h \
+module_fonts.h \
+m_fontservice.h
+ $(compile_source)
+
+$(OBJ_DIR)/options.o: options.cpp \
+StdAfx.h \
+resource.h \
+../../include/win2k.h \
+../../include/newpluginapi.h \
+../../include/m_langpack.h \
+../../include/m_database.h \
+../../include/m_system.h \
+../../include/m_options.h \
+../../include/m_utils.h \
+../../include/m_clui.h \
+../../include/m_clc.h \
+../chat/m_chat.h \
+services.h \
+m_fontservice.h \
+m_fontservicew.h
+ $(compile_source)
+
+$(OBJ_DIR)/services.o: services.cpp \
+StdAfx.h \
+resource.h \
+../../include/win2k.h \
+../../include/newpluginapi.h \
+../../include/m_langpack.h \
+../../include/m_database.h \
+../../include/m_system.h \
+../../include/m_options.h \
+../../include/m_utils.h \
+../../include/m_clui.h \
+../../include/m_clc.h \
+../chat/m_chat.h \
+services.h \
+m_fontservice.h \
+m_fontservicew.h
+ $(compile_source)
+
diff --git a/font_service/collection.h b/font_service/collection.h
new file mode 100644
index 0000000..d65a024
--- /dev/null
+++ b/font_service/collection.h
@@ -0,0 +1,545 @@
+template<class T> class Collection {
+protected:
+ unsigned long count;
+public:
+ Collection(): count(0) {}
+
+ virtual void clear() = 0;
+ virtual void add(T &val) = 0;
+ virtual const bool remove(T &val) = 0;
+
+ const unsigned long size() const {return count;}
+};
+
+template<class T> class Node {
+public:
+ T val;
+
+ Node(T &v): val(v) {}
+ virtual ~Node() {}
+};
+
+template<class T> class ListNode: public Node<T> {
+public:
+ ListNode<T> *next, *prev;
+
+ ListNode(T &v): Node<T>(v), next(0), prev(0) {}
+ virtual ~ListNode() {
+ if(next) next->prev = prev;
+ if(prev) prev->next = next;
+ }
+};
+
+template<class T> class LinkedList: public Collection<T> {
+protected:
+ ListNode<T> *head, *tail;
+
+public:
+ class Iterator {
+ friend class LinkedList<T>;
+ protected:
+ ListNode<T> *n;
+ Iterator(ListNode<T> *start): n(start) {}
+ public:
+ Iterator(const Iterator &other): n(other.n) {}
+
+ virtual T &val() {return n->val;}
+ virtual void next() {if(n) n = n->next;}
+ virtual void prev() {if(n) n = n->prev;}
+ virtual const bool has_val() {return (n ? true : false); }
+ };
+
+ LinkedList(): Collection<T>(), head(0), tail(0) {};
+ LinkedList(const LinkedList<T> &other): Collection<T>(), head(0), tail(0) {
+ for(Iterator i = other.start(); i.has_val(); i.next())
+ add(i.val());
+ }
+ virtual ~LinkedList() {clear();}
+
+ LinkedList<T> &operator=(const LinkedList<T> &other) {
+ clear();
+ for(Iterator i = other.start(); i.has_val(); i.next())
+ add(i.val());
+ return *this;
+ }
+
+ virtual void clear() {
+ ListNode<T> *n;
+ while(head) {
+ n = head;
+ head = head->next;
+ delete n;
+ }
+ tail = 0;
+ Collection<T>::count = 0;
+ }
+
+ virtual Iterator start() const {return Iterator(head);}
+
+ virtual void add_front(T &val) {
+ ListNode<T> *n = new ListNode<T>(val);
+ n->next = head;
+ if(head) head->prev = n;
+ head = n;
+ if(!tail) tail = n;
+ Collection<T>::count++;
+ }
+
+ virtual void add(T &val) {
+ ListNode<T> *n = new ListNode<T>(val);
+ n->prev = tail;
+ if(tail) tail->next = n;
+ tail = n;
+ if(!head) head = n;
+ Collection<T>::count++;
+ }
+
+ virtual const bool remove(T &val) {
+ ListNode<T> *n = head;
+ while(n) {
+ if(n->val == val) {
+ if(n == head) head = head->next;
+ if(n == tail) tail = tail->prev;
+
+ delete n;
+ Collection<T>::count--;
+ return true;
+ } else
+ n = n->next;
+ }
+
+ return false;
+ }
+
+ // queue/stack functions
+ // stack - use push/pop
+ // queue - use push_back/pop
+ virtual void push(T &val) {
+ add_front(val);
+ }
+
+ virtual void push(T val) {
+ add_front(val);
+ }
+
+ virtual void push_back(T &val) {
+ add(val);
+ }
+
+ virtual const bool pop(T &val) {
+ if(!head) return false;
+
+ ListNode<T> *n = head;
+ if(head) {
+ head = head->next;
+ if(n == tail) tail = 0;
+ val = n->val;
+ delete n;
+ Collection<T>::count--;
+ return true;
+ } else
+ return false;
+ }
+};
+
+template<class T> class DynamicArray: public Collection<T> {
+protected:
+ T *ar;
+
+ unsigned long initial, limit, increment;
+
+public:
+ class Iterator {
+ friend class DynamicArray<T>;
+ protected:
+ T *ar;
+ unsigned long count;
+ unsigned long pos;
+ Iterator(T *a, const int c, unsigned long p): ar(a), count(c), pos(p) {}
+ public:
+ Iterator(const Iterator &other): ar(other.ar), count(other.count), pos(other.pos) {}
+
+ virtual T &val() {return ar[pos];}
+ virtual void next() {pos++;}
+ virtual void prev() {pos--;}
+ virtual const bool has_val() {return pos < count; }
+ };
+
+ DynamicArray(unsigned long init = 0, unsigned long inc = 1): Collection<T>(), ar(0), initial(init), limit(init), increment(inc) {
+ if(limit) ar = (T *)malloc(limit * sizeof(T));
+ }
+ virtual ~DynamicArray() {free(ar);}
+
+ virtual void clear() {
+ Collection<T>::count = 0;
+ limit = initial;
+ if(limit) ar = (T *)realloc(ar, limit * sizeof(T));
+ else free(ar);
+ }
+
+ virtual Iterator start() {return Iterator(ar, Collection<T>::count, 0);}
+
+ virtual void add(T &val) {
+ if(Collection<T>::count == limit) {
+ limit += increment;
+ ar = (T *)realloc(ar, limit * sizeof(T));
+ ar[Collection<T>::count++] = val;
+ } else
+ ar[Collection<T>::count++] = val;
+ }
+
+ virtual const bool remove(T &val) {
+ for(unsigned long i = 0; i < Collection<T>::count; i++) {
+ if(ar[i] == val) {
+ memmove(ar + i, ar + i + 1, (Collection<T>::count - i) * sizeof(T));
+ Collection<T>::count--;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ virtual const bool remove(const unsigned long index) {
+ if(index >= Collection<T>::count) return false;
+
+ memmove(ar + index, ar + index + 1, (Collection<T>::count - index) * sizeof(T));
+ Collection<T>::count--;
+ return true;
+ }
+
+ virtual const bool insert(T &val, const unsigned long index) {
+ if(index > Collection<T>::count) return false;
+
+ if(Collection<T>::count == limit) {
+ limit += increment;
+ ar = (T *)realloc(ar, limit * sizeof(T));
+ }
+
+ if(index < Collection<T>::count)
+ memmove(ar + index + 1, ar + index, (Collection<T>::count - index) * sizeof(T));
+
+ ar[index] = val;
+ Collection<T>::count++;
+ return true;
+ }
+
+ virtual T &operator[](const int index) {
+ return ar[index];
+ }
+
+ const bool index_of(const T &val, unsigned long &index) {
+ for(int i = 0; i < Collection<T>::count; i++) {
+ if(ar[index] == val) {
+ index = i;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ // stack functions
+ virtual const bool pop(T &val) {
+ if(Collection<T>::count) {
+ val = ar[Collection<T>::count -1];
+ remove(Collection<T>::count -1);
+ return true;
+ }
+ return false;
+ }
+
+ virtual void push(T &val) {
+ add(val);
+ }
+};
+
+template<class T> class SortedDynamicArray: public DynamicArray<T> {
+public:
+ SortedDynamicArray(unsigned long init = 0, unsigned long inc = 1): DynamicArray<T>(init, inc) {}
+ virtual ~SortedDynamicArray() {}
+
+ const bool get_index(T &val, unsigned long &index) {
+ unsigned long low = 0;
+ unsigned long high = Collection<T>::count-1;
+
+ while( high < Collection<T>::count && low <= high )
+ {
+ unsigned long i = ( low+high )/2;
+ if ( DynamicArray<T>::ar[i] == val )
+ { index = i;
+ return true;
+ } else if (DynamicArray<T>::ar[i] < val)
+ low = i+1;
+ else
+ high = i-1;
+ }
+
+ index = low;
+ return false;
+ }
+
+ virtual void add(T &val) {
+ unsigned long index;
+ get_index(val, index);
+ insert(val, index);
+ }
+};
+
+template<class T> class TreeNode: public Node<T> {
+public:
+ TreeNode<T> *parent, *left, *right;
+
+ TreeNode(T &v, TreeNode<T> *par): Node<T>(v), parent(par), left(0), right(0) {}
+ virtual ~TreeNode() {
+ if(parent) {
+ if(parent->left == this) parent->left = 0;
+ else parent->right = 0;
+ }
+ }
+};
+
+template<class T> class BinaryTree: public Collection<T> {
+protected:
+
+ TreeNode<T> *root;
+
+ TreeNode<T> *delete_node(TreeNode<T> *n) {
+ if(n->left && n->right) {
+ //if(rand() & 1) { // ?
+ TreeNode<T> *minmax = n->left;
+ while(minmax->right) minmax = minmax->right;
+ //} else {
+ // Node *minmax = current->right;
+ // while(minmax->left) minmax = minmax->left;
+ //}
+ n->val = minmax->val;
+ delete_node(minmax);
+ Collection<T>::count--;
+ return n;
+ } else if(n->right) {
+ if(n->parent) {
+ if(n->parent->left = n) n->parent->left = n->right;
+ else n->parent->right = n->right;
+ } else
+ root = n->right;
+ n->right->parent = n->parent;
+ } else if(n->left) {
+ if(n->parent) {
+ if(n->parent->left = n) n->parent->left = n->left;
+ else n->parent->right = n->left;
+ } else
+ root = n->left;
+ n->left->parent = n->parent;
+ } else {
+ if(n == root) root = 0;
+ }
+ delete n;
+ Collection<T>::count--;
+ return 0;
+ }
+
+ void insert_node(TreeNode<T> *n) {
+ TreeNode<T> *current = root, *parent = 0;
+ while(current) {
+ parent = current;
+ if(n->val < current->val)
+ current = current->left;
+ else
+ current = current->right;
+ }
+
+ if(parent) {
+ if(n->val < parent->val) {
+ parent->left = n;
+ n->parent = parent;
+ } else {
+ parent->right = n;
+ n->parent = parent;
+ }
+ } else
+ root = n;
+
+ }
+
+public:
+ class Iterator {
+ friend class BinaryTree<T>;
+ protected:
+
+ class EvalNode {
+ public:
+ bool evaluate;
+ TreeNode<T> *node;
+
+ EvalNode(): evaluate(false), node(0) {}
+ EvalNode(const bool eval, TreeNode<T> *n): evaluate(eval), node(n) {}
+ const bool operator==(const EvalNode &other) const {return node == other.node;}
+ EvalNode &operator=(const EvalNode &other) {evaluate = other.evaluate; node = other.node; return *this;}
+
+ };
+
+ TreeNode<T> *n;
+ LinkedList<EvalNode> stack;
+
+
+ Iterator(TreeNode<T> *start): n(0) {
+ if(start) {
+ stack.push(EvalNode(true, start));
+ next();
+ }
+ }
+
+ public:
+ Iterator(const Iterator &other):n(other.n), stack(other.stack) {}
+ virtual ~Iterator() {}
+
+ virtual T &val() {return n->val;}
+ virtual void next() {
+ EvalNode en;
+ bool popped = false;
+ while((popped = stack.pop(en)) && en.evaluate) {
+ if(en.node->right) stack.push(EvalNode(true, en.node->right));
+ stack.push(EvalNode(false, en.node));
+ if(en.node->left) stack.push(EvalNode(true, en.node->left));
+ }
+
+ n = (popped ? en.node : 0);
+ }
+ virtual const bool has_val() {return (n ? true : false);}
+ };
+
+ BinaryTree(): Collection<T>(), root(0) {};
+ BinaryTree(BinaryTree<T> &other): Collection<T>(), root(0) {
+ for(Iterator i = other.start(); i.has_val(); i.next())
+ add(i.val());
+ }
+ virtual ~BinaryTree() {clear();}
+
+ BinaryTree &operator=(BinaryTree<T> &other) {
+ clear();
+ for(Iterator i = other.start(); i.has_val(); i.next())
+ add(i.val());
+ return *this;
+ }
+
+ virtual void clear() {
+ TreeNode<T> *current = root, *parent = 0;
+ while(current) {
+ if(current->left) current = current->left;
+ else if(current->right) current = current->right;
+ else {
+ parent = current->parent;
+ delete current;
+ current = parent;
+ }
+ }
+
+ root = 0;
+ Collection<T>::count = 0;
+ }
+
+ void add(T &val) {
+ TreeNode<T> *n = new TreeNode<T>(val, 0);
+ insert_node(n);
+ Collection<T>::count++;
+ }
+
+ const bool remove(T &val) {
+ TreeNode<T> *current = root;
+ while(current) {
+ if(current->val == val)
+ break;
+ else if(val < current->val)
+ current = current->left;
+ else
+ current = current->right;
+ }
+
+ if(current) {
+ delete_node(current);
+ return true;
+ }
+
+ return false;
+ }
+
+ Iterator start() {return Iterator(root);}
+};
+
+template<class A, class B> class Pair {
+public:
+ A first;
+ B second;
+
+ Pair(const A &f): first(f) {}
+ Pair(const A &f, const B &s): first(f), second(s) {}
+ Pair(Pair<A,B> &other): first(other.first), second(other.second) {}
+ virtual ~Pair() {}
+
+ const bool operator<(const Pair<A,B> &other) const {return first < other.first;}
+ const bool operator==(const Pair<A,B> &other) const {return first == other.first;}
+ Pair<A,B> &operator=(const Pair<A,B> &other) {first = other.first; second = other.second; return *this;}
+};
+
+template<class A, class B> class Map: public BinaryTree< Pair< A, B > > {
+protected:
+
+ TreeNode<Pair< A, B > > *find(A &val) {
+ TreeNode<Pair< A, B > > *n = BinaryTree< Pair< A, B > >::root;
+ while(n) {
+ if(n->val.first == val)
+ return n;
+ else if(val < n->val.first)
+ n = n->left;
+ else
+ n = n->right;
+
+ }
+ return 0;
+ }
+public:
+ Map(): BinaryTree< Pair<A,B> >() {}
+ virtual ~Map() {}
+
+ void put(A &key, B &value) {
+ add(Pair<A,B>(key, value));
+ }
+
+ const bool get(A &key, B &val) const {
+ const TreeNode<Pair< A, B > > *n = find(key);
+ if(n) {
+ val = n->val.second;
+ return true;
+ } else
+ return false;
+ }
+
+ B &operator[](A &key) {
+ TreeNode<Pair< A, B > > *n = find(key);
+ if(n)
+ return n->val.second;
+ else {
+ Pair< A, B > p(key);
+ TreeNode<Pair< A, B > > *n = new TreeNode<Pair< A, B > >(p, 0);
+ insert_node(n);
+ Collection< Pair< A, B > >::count++;
+ return n->val.second;
+ }
+ }
+
+ const bool exists(A &key) const {
+ const TreeNode<Pair< A, B > > *n = find(key);
+ if(n) {
+ return true;
+ } else
+ return false;
+ }
+
+ const bool remove(A &key) {
+ TreeNode<Pair< A, B > > *n = find(key);
+ if(n) {
+ delete_node(n);
+ return true;
+ } else
+ return false;
+ }
+};
diff --git a/font_service/common.h b/font_service/common.h
new file mode 100644
index 0000000..ecc26bc
--- /dev/null
+++ b/font_service/common.h
@@ -0,0 +1,68 @@
+// Copyright Scott Ellis (mail@scottellis.com.au) 2005
+// This software is licenced under the GPL (General Public Licence)
+// available at http://www.gnu.org/copyleft/gpl.html
+
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#if !defined(AFX_STDAFX_H__3357FB97_A3B3_44D0_8D35_6F9F5CF8F494__INCLUDED_)
+#define AFX_STDAFX_H__3357FB97_A3B3_44D0_8D35_6F9F5CF8F494__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+
+// Insert your headers here
+//#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+
+#include <tchar.h>
+#define _WIN32_WINNT 0x0501
+#include <windows.h>
+#include <commctrl.h>
+#include <stdio.h>
+#include <time.h>
+#include <stddef.h>
+#include <process.h>
+#include "resource.h"
+#include <win2k.h>
+#include <richedit.h>
+#include <richole.h>
+
+#include <newpluginapi.h>
+#include <m_langpack.h>
+#include <m_database.h>
+#include <m_system.h>
+#include <m_options.h>
+#include <m_utils.h>
+
+#include <m_clui.h>
+#include <m_clc.h>
+
+#include <m_chat.h>
+
+extern HINSTANCE hInstance;
+
+extern HANDLE hFontReloadEvent, hColourReloadEvent;
+
+extern struct MM_INTERFACE memoryManagerInterface;
+
+#define mir_alloc(n) memoryManagerInterface.mmi_malloc(n)
+#define mir_free(ptr) memoryManagerInterface.mmi_free(ptr)
+#define mir_realloc(ptr,size) memoryManagerInterface.mmi_realloc(ptr,size)
+
+__inline char * mir_strdup(const char * src)
+{
+ char * p = 0;
+ if ( src == NULL ) return NULL;
+ p=(char *)mir_alloc( strlen(src)+1 );
+ strcpy(p, src);
+ return p;
+}
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STDAFX_H__3357FB97_A3B3_44D0_8D35_6F9F5CF8F494__INCLUDED_)
diff --git a/font_service/docs/m_fontservice.h b/font_service/docs/m_fontservice.h
new file mode 100644
index 0000000..08e4dec
--- /dev/null
+++ b/font_service/docs/m_fontservice.h
@@ -0,0 +1,148 @@
+// Copyright Scott Ellis (mail@scottellis.com.au) 2005
+// This software is licenced under the GPL (General Public Licence)
+// available at http://www.gnu.org/copyleft/gpl.html
+
+#ifndef _FONT_SERVICE_API_INC
+#define _FONT_SERVICE_API_INC
+
+// style flags
+#define DBFONTF_BOLD 1
+#define DBFONTF_ITALIC 2
+#define DBFONTF_UNDERLINE 4
+#define DBFONTF_STRIKEOUT 8
+
+// flags for compatibility
+#define FIDF_APPENDNAME 1 // append 'Name' to the setting used to store font face (as CLC settings require)
+#define FIDF_NOAS 2 // disable the <prefix>As setting to prevent 'same as' behaviour
+#define FIDF_SAVEACTUALHEIGHT 4 // write the actual height of a test string to the db
+#define FIDF_SAVEPOINTSIZE 8 // write the font point size to the db
+
+// additional flags
+#define FIDF_DEFAULTVALID 32 // the default font settings are valid - else, just use generic default
+#define FIDF_NEEDRESTART 64 // setting changes will not take effect until miranda is restarted
+#define FIDF_ALLOWREREGISTER 128 // allow plugins to register this font again (i.e. override already registered settings such as flags)
+#define FIDF_ALLOWEFFECTS 256 // allow setting of font effects (i.e. underline and strikeout)
+
+// settings to be used for the value of 'deffontsettings' in the FontID structure below - i.e. defaults
+typedef struct FontSettings_tag
+{
+ COLORREF colour;
+ char size;
+ BYTE style; // see the DBFONTF_* flags above
+ BYTE charset;
+ char szFace[LF_FACESIZE];
+} FontSettings;
+
+// a font identifier structure - used for registering a font, and getting one out again
+typedef struct FontID_tag {
+ int cbSize;
+ char group[64]; // group the font belongs to - this is the 'Font Group' list in the options page
+ char name[64]; // this is the name of the font setting - e.g. 'contacts' in the 'contact list' group
+ char dbSettingsGroup[32]; // the 'module' in the database where the font data is stored
+ char prefix[32]; // this is prepended to the settings used to store this font's data in the db
+ DWORD flags; // bitwise OR of the FIDF_* flags above
+ FontSettings deffontsettings; // defaults, valid if flags & FIDF_DEFAULTVALID
+ int order; // controls the order in the font group in which the fonts are listed in the UI (if order fields are equal,
+ // they will be ordered alphabetically by name)
+} FontID;
+
+typedef struct ColourID_tag {
+ int cbSize;
+ char group[64];
+ char name[64];
+ char dbSettingsGroup[32];
+ char setting[32];
+ DWORD flags; // not used
+ COLORREF defcolour; // default value
+ int order;
+} ColourID;
+
+// register a font
+// wparam = (FontID *)&font_id
+// lparam = 0
+#define MS_FONT_REGISTER "Font/Register"
+
+// get a font
+// will fill the logfont structure passed in with the user's choices, or the default if it was set and the user has not chosen a font yet,
+// or the global default font settings otherwise (i.e. no user choice and default set, or font not registered)
+// global default font is gotten using SPI_GETICONTITLELOGFONT, color COLOR_WINDOWTEXT, size 8.
+// wparam = (FontID *)&font_id (only name and group matter)
+// lParam = (LOGFONT *)&logfont
+// returns the font's colour
+#define MS_FONT_GET "Font/Get"
+
+// fired when a user modifies font settings, so reload your fonts
+// wparam = lparam = 0
+#define ME_FONT_RELOAD "Font/Reload"
+
+// register a colour (this should be used for everything except actual text colour for registered fonts)
+// [note - a colour with name 'Background' [translated!] has special meaning and will be used as the background colour of
+// the font list box in the options, for the given group]
+// wparam = (ColourID *)&colour_id
+// lparam = 0
+#define MS_COLOUR_REGISTER "Colour/Register"
+
+// get a colour
+// wparam = (ColourID *)&colour_id (only name and group matter)
+// rerturns the colour (as COLORREF), or -1 if not found
+#define MS_COLOUR_GET "Colour/Get"
+
+// fired when a user modifies font settings, so reget your fonts and colours
+// wparam = lparam = 0
+#define ME_COLOUR_RELOAD "Colour/Reload"
+
+
+
+//////////////////// Example ///////////////
+#ifdef I_AM_A_CONSTANT_THAT_IS_NEVER_DEFINED_BUT_ALLOWS_THE_CODE_BELOW_NOT_TO_BE_COMMENTED
+
+
+// In the modules loaded event handler, register your fonts
+int testOnModulesLoaded(WPARAM wParam, LPARAM lParam) {
+ FontID fid = {0};
+ fid.cbSize = sizeof(fid);
+ strncpy(fid.name, "Test Font", 64);
+ strncpy(fid.group, "My Group", 64);
+ strncpy(fid.dbSettingsGroup, "MyPlugin", 32);
+ strncpy(fid.prefix, "testFont", 32);
+ fid.order = 0;
+
+ // you could register the font at this point - getting it will get either the global default or what the user has set it
+ // to - but we'll set a default font:
+
+ fid.flags = FIDF_DEFAULTVALID;
+
+ fid.deffontsettings.charset = DEFAULT_CHARSET;
+ fid.deffontsettings.colour = RGB(255, 0, 0);
+ fid.deffontsettings.size = 8;
+ fid.deffontsettings.style = DBFONTF_BOLD;
+ strncpy(fid.deffontsettings.szFace, "Arial", LF_FACESIZE);
+
+ CallService(MS_FONT_REGISTER, (WPARAM)&fid, 0);
+
+ // if you add more fonts, and leave the 'order' field at 0, they will be ordered alphabetically
+
+ // .....
+
+ return 0;
+}
+
+// Later, when you need the LOGFONT structure for drawing with a font, do this
+void InSomeCodeSomewhere() {
+ //.....
+ LOGFONT lf;
+ COLORREF col;
+ FontID fid;
+ strncpy(fid.name, "Test Font", 64);
+ strncpy(fid.group, "My Group", 64);
+
+ col = (COLORREF)CallService(MS_FONT_GET, (WPARAM)&fid, (LPARAM)&lf);
+
+ // then procede to use the font
+ //....
+}
+
+#endif // example code
+
+#endif // _FONT_SERVICE_API_INC
+
diff --git a/font_service/docs/m_fontservicew.h b/font_service/docs/m_fontservicew.h
new file mode 100644
index 0000000..6d96aff
--- /dev/null
+++ b/font_service/docs/m_fontservicew.h
@@ -0,0 +1,152 @@
+// Copyright Scott Ellis (mail@scottellis.com.au) 2005
+// This software is licenced under the GPL (General Public Licence)
+// available at http://www.gnu.org/copyleft/gpl.html
+
+#ifndef _FONT_SERVICEW_API_INC
+#define _FONT_SERVICEW_API_INC
+
+// style flags
+#define DBFONTF_BOLD 1
+#define DBFONTF_ITALIC 2
+#define DBFONTF_UNDERLINE 4
+#define DBFONTF_STRIKEOUT 8
+
+// flags for compatibility
+#define FIDF_APPENDNAME 1 // append 'Name' to the setting used to store font face (as CLC settings require)
+#define FIDF_NOAS 2 // disable the <prefix>As setting to prevent 'same as' behaviour
+#define FIDF_SAVEACTUALHEIGHT 4 // write the actual height of a test string to the db
+#define FIDF_SAVEPOINTSIZE 8 // write the font point size to the db
+
+// additional flags
+#define FIDF_DEFAULTVALID 32 // the default font settings are valid - else, just use generic default
+#define FIDF_NEEDRESTART 64 // setting changes will not take effect until miranda is restarted
+#define FIDF_ALLOWREREGISTER 128 // allow plugins to register this font again (i.e. override already registered settings such as flags)
+#define FIDF_ALLOWEFFECTS 256 // allow setting of font effects (i.e. underline and strikeout)
+
+// settings to be used for the value of 'deffontsettings' in the FontID structure below - i.e. defaults
+typedef struct FontSettingsW_tag
+{
+ COLORREF colour;
+ char size;
+ BYTE style; // see the DBFONTF_* flags above
+ BYTE charset;
+ wchar_t szFace[LF_FACESIZE];
+} FontSettingsW;
+
+// a font identifier structure - used for registering a font, and getting one out again
+typedef struct FontIDW_tag {
+ int cbSize;
+ wchar_t group[64]; // group the font belongs to - this is the 'Font Group' list in the options page
+ wchar_t name[64]; // this is the name of the font setting - e.g. 'contacts' in the 'contact list' group
+ char dbSettingsGroup[32]; // the 'module' in the database where the font data is stored
+ char prefix[32]; // this is prepended to the settings used to store this font's data in the db
+ DWORD flags; // bitwise OR of the FIDF_* flags above
+ FontSettingsW deffontsettings; // defaults, valid if flags & FIDF_DEFAULTVALID
+ int order; // controls the order in the font group in which the fonts are listed in the UI (if order fields are equal,
+ // they will be ordered alphabetically by name)
+} FontIDW;
+
+typedef struct ColourIDW_tag {
+ int cbSize;
+ wchar_t group[64];
+ wchar_t name[64];
+ char dbSettingsGroup[32];
+ char setting[32];
+ DWORD flags; // not used
+ COLORREF defcolour; // default value
+ int order;
+} ColourIDW;
+
+// register a font
+// wparam = (FontID *)&font_id
+// lparam = 0
+#define MS_FONT_REGISTERW "Font/RegisterW"
+
+// get a font
+// will fill the logfont structure passed in with the user's choices, or the default if it was set and the user has not chosen a font yet,
+// or the global default font settings otherwise (i.e. no user choice and default set, or font not registered)
+// global default font is gotten using SPI_GETICONTITLELOGFONT, color COLOR_WINDOWTEXT, size 8.
+// wparam = (FontID *)&font_id (only name and group matter)
+// lParam = (LOGFONT *)&logfont
+// returns the font's colour
+#define MS_FONT_GETW "Font/GetW"
+
+// fired when a user modifies font settings, so reload your fonts
+// wparam = lparam = 0
+#ifndef ME_FONT_RELOAD
+#define ME_FONT_RELOAD "Font/Reload"
+#endif
+
+// register a colour (this should be used for everything except actual text colour for registered fonts)
+// [note - a colour with name 'Background' [translated!] has special meaning and will be used as the background colour of
+// the font list box in the options, for the given group]
+// wparam = (ColourID *)&colour_id
+// lparam = 0
+#define MS_COLOUR_REGISTERW "Colour/RegisterW"
+
+// get a colour
+// wparam = (ColourID *)&colour_id (only name and group matter)
+// rerturns the colour (as COLORREF), or -1 if not found
+#define MS_COLOUR_GETW "Colour/GetW"
+
+// fired when a user modifies font settings, so reget your fonts and colours
+// wparam = lparam = 0
+#ifndef ME_COLOUR_RELOAD
+#define ME_COLOUR_RELOAD "Colour/Reload"
+#endif
+
+
+
+//////////////////// Example ///////////////
+#ifdef I_AM_A_CONSTANT_THAT_IS_NEVER_DEFINED_BUT_ALLOWS_THE_CODE_BELOW_NOT_TO_BE_COMMENTED
+
+
+// In the modules loaded event handler, register your fonts
+int testOnModulesLoaded(WPARAM wParam, LPARAM lParam) {
+ FontID fid = {0};
+ fid.cbSize = sizeof(fid);
+ strncpy(fid.name, "Test Font", 64);
+ strncpy(fid.group, "My Group", 64);
+ strncpy(fid.dbSettingsGroup, "MyPlugin", 32);
+ strncpy(fid.prefix, "testFont", 32);
+ fid.order = 0;
+
+ // you could register the font at this point - getting it will get either the global default or what the user has set it
+ // to - but we'll set a default font:
+
+ fid.flags = FIDF_DEFAULTVALID;
+
+ fid.deffontsettings.charset = DEFAULT_CHARSET;
+ fid.deffontsettings.colour = RGB(255, 0, 0);
+ fid.deffontsettings.size = 8;
+ fid.deffontsettings.style = DBFONTF_BOLD;
+ strncpy(fid.deffontsettings.szFace, "Arial", LF_FACESIZE);
+
+ CallService(MS_FONT_REGISTER, (WPARAM)&fid, 0);
+
+ // if you add more fonts, and leave the 'order' field at 0, they will be ordered alphabetically
+
+ // .....
+
+ return 0;
+}
+
+// Later, when you need the LOGFONT structure for drawing with a font, do this
+void InSomeCodeSomewhere() {
+ //.....
+ LOGFONT lf;
+ COLORREF col;
+ FontID fid;
+ strncpy(fid.name, "Test Font", 64);
+ strncpy(fid.group, "My Group", 64);
+
+ col = (COLORREF)CallService(MS_FONT_GET, (WPARAM)&fid, (LPARAM)&lf);
+
+ // then procede to use the font
+ //....
+}
+
+#endif // example code
+
+#endif // _FONT_SERVICE_API_INC
+
diff --git a/font_service/forkthread.cpp b/font_service/forkthread.cpp
new file mode 100644
index 0000000..9968c15
--- /dev/null
+++ b/font_service/forkthread.cpp
@@ -0,0 +1,93 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2003 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+#include "stdafx.h"
+
+struct FORK_ARG
+{
+ HANDLE hEvent;
+ void (__cdecl * threadcode) (void *);
+ unsigned (__stdcall * threadcodeex) (void *);
+ void *arg;
+};
+
+void __cdecl forkthread_r(void *fa)
+{
+ void (*callercode) (void *) = ((struct FORK_ARG *)fa)->threadcode;
+ void *arg = ((struct FORK_ARG *)fa)->arg;
+ CallService(MS_SYSTEM_THREAD_PUSH, 0, 0);
+ SetEvent(((struct FORK_ARG *)fa)->hEvent);
+ __try {
+ callercode(arg);
+ }
+ __finally {
+ CallService(MS_SYSTEM_THREAD_POP, 0, 0);
+ }
+ return;
+}
+
+unsigned long forkthread(void (__cdecl * threadcode) (void *), unsigned long stacksize, void *arg)
+{
+ unsigned long rc;
+ struct FORK_ARG fa;
+ fa.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ fa.threadcode = threadcode;
+ fa.arg = arg;
+ rc = _beginthread(forkthread_r, stacksize, &fa);
+ if ((unsigned long) -1L != rc) {
+ WaitForSingleObject(fa.hEvent, INFINITE);
+ } //if
+ CloseHandle(fa.hEvent);
+ return rc;
+}
+
+unsigned int __stdcall forkthreadex_r(void *fa)
+{
+ unsigned (__stdcall * threadcode) (void *) = ((struct FORK_ARG *)fa)->threadcodeex;
+ void *arg = ((struct FORK_ARG *)fa)->arg;
+ unsigned long rc;
+
+ CallService(MS_SYSTEM_THREAD_PUSH, 0, 0);
+ SetEvent(((struct FORK_ARG *)fa)->hEvent);
+ __try {
+ rc = threadcode(arg);
+ }
+ __finally {
+ CallService(MS_SYSTEM_THREAD_POP, 0, 0);
+ }
+ return rc;
+}
+
+unsigned long forkthreadex(void *sec, unsigned stacksize, unsigned (__stdcall * threadcode) (void *), void *arg, unsigned cf, unsigned *thraddr)
+{
+ unsigned long rc;
+ struct FORK_ARG fa;
+ fa.threadcodeex = threadcode;
+ fa.arg = arg;
+ fa.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ rc = _beginthreadex(sec, stacksize, forkthreadex_r, &fa, 0, thraddr);
+ if (rc) {
+ WaitForSingleObject(fa.hEvent, INFINITE);
+ }
+ CloseHandle(fa.hEvent);
+ return rc;
+}
diff --git a/font_service/forkthread.h b/font_service/forkthread.h
new file mode 100644
index 0000000..82907a3
--- /dev/null
+++ b/font_service/forkthread.h
@@ -0,0 +1,63 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2003 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+/*
+
+Purpose:
+
+ A safe version of _beginthread()
+
+Description:
+
+ A new thread is created and the source thread is paused until
+ internal code to call MS_SYSTEM_THREAD_PUSH is made in the context
+ if the new thread.
+
+ The source thread is then released and then the user supplied
+ code is called, when that function returns -- MS_SYSTEM_THREAD_POP
+ is called and then the thread returns.
+
+ This insures that Miranda will not exit whilst new threads
+ are trying to be born; and the unwind wait stack will unsure
+ that Miranda will wait for all created threads to return as well.
+
+Cavets:
+
+ The function must be reimplemented across MT plugins, since thread
+ creation depends on CRT which can not be shared.
+
+*/
+unsigned long forkthread (
+ void (__cdecl *threadcode)(void*),
+ unsigned long stacksize,
+ void *arg
+);
+
+unsigned long forkthreadex(
+ void *sec,
+ unsigned stacksize,
+ unsigned (__stdcall *threadcode)(void*),
+ void *arg,
+ unsigned cf,
+ unsigned *thraddr
+); \ No newline at end of file
diff --git a/font_service/m_fontservice.h b/font_service/m_fontservice.h
new file mode 100644
index 0000000..08e4dec
--- /dev/null
+++ b/font_service/m_fontservice.h
@@ -0,0 +1,148 @@
+// Copyright Scott Ellis (mail@scottellis.com.au) 2005
+// This software is licenced under the GPL (General Public Licence)
+// available at http://www.gnu.org/copyleft/gpl.html
+
+#ifndef _FONT_SERVICE_API_INC
+#define _FONT_SERVICE_API_INC
+
+// style flags
+#define DBFONTF_BOLD 1
+#define DBFONTF_ITALIC 2
+#define DBFONTF_UNDERLINE 4
+#define DBFONTF_STRIKEOUT 8
+
+// flags for compatibility
+#define FIDF_APPENDNAME 1 // append 'Name' to the setting used to store font face (as CLC settings require)
+#define FIDF_NOAS 2 // disable the <prefix>As setting to prevent 'same as' behaviour
+#define FIDF_SAVEACTUALHEIGHT 4 // write the actual height of a test string to the db
+#define FIDF_SAVEPOINTSIZE 8 // write the font point size to the db
+
+// additional flags
+#define FIDF_DEFAULTVALID 32 // the default font settings are valid - else, just use generic default
+#define FIDF_NEEDRESTART 64 // setting changes will not take effect until miranda is restarted
+#define FIDF_ALLOWREREGISTER 128 // allow plugins to register this font again (i.e. override already registered settings such as flags)
+#define FIDF_ALLOWEFFECTS 256 // allow setting of font effects (i.e. underline and strikeout)
+
+// settings to be used for the value of 'deffontsettings' in the FontID structure below - i.e. defaults
+typedef struct FontSettings_tag
+{
+ COLORREF colour;
+ char size;
+ BYTE style; // see the DBFONTF_* flags above
+ BYTE charset;
+ char szFace[LF_FACESIZE];
+} FontSettings;
+
+// a font identifier structure - used for registering a font, and getting one out again
+typedef struct FontID_tag {
+ int cbSize;
+ char group[64]; // group the font belongs to - this is the 'Font Group' list in the options page
+ char name[64]; // this is the name of the font setting - e.g. 'contacts' in the 'contact list' group
+ char dbSettingsGroup[32]; // the 'module' in the database where the font data is stored
+ char prefix[32]; // this is prepended to the settings used to store this font's data in the db
+ DWORD flags; // bitwise OR of the FIDF_* flags above
+ FontSettings deffontsettings; // defaults, valid if flags & FIDF_DEFAULTVALID
+ int order; // controls the order in the font group in which the fonts are listed in the UI (if order fields are equal,
+ // they will be ordered alphabetically by name)
+} FontID;
+
+typedef struct ColourID_tag {
+ int cbSize;
+ char group[64];
+ char name[64];
+ char dbSettingsGroup[32];
+ char setting[32];
+ DWORD flags; // not used
+ COLORREF defcolour; // default value
+ int order;
+} ColourID;
+
+// register a font
+// wparam = (FontID *)&font_id
+// lparam = 0
+#define MS_FONT_REGISTER "Font/Register"
+
+// get a font
+// will fill the logfont structure passed in with the user's choices, or the default if it was set and the user has not chosen a font yet,
+// or the global default font settings otherwise (i.e. no user choice and default set, or font not registered)
+// global default font is gotten using SPI_GETICONTITLELOGFONT, color COLOR_WINDOWTEXT, size 8.
+// wparam = (FontID *)&font_id (only name and group matter)
+// lParam = (LOGFONT *)&logfont
+// returns the font's colour
+#define MS_FONT_GET "Font/Get"
+
+// fired when a user modifies font settings, so reload your fonts
+// wparam = lparam = 0
+#define ME_FONT_RELOAD "Font/Reload"
+
+// register a colour (this should be used for everything except actual text colour for registered fonts)
+// [note - a colour with name 'Background' [translated!] has special meaning and will be used as the background colour of
+// the font list box in the options, for the given group]
+// wparam = (ColourID *)&colour_id
+// lparam = 0
+#define MS_COLOUR_REGISTER "Colour/Register"
+
+// get a colour
+// wparam = (ColourID *)&colour_id (only name and group matter)
+// rerturns the colour (as COLORREF), or -1 if not found
+#define MS_COLOUR_GET "Colour/Get"
+
+// fired when a user modifies font settings, so reget your fonts and colours
+// wparam = lparam = 0
+#define ME_COLOUR_RELOAD "Colour/Reload"
+
+
+
+//////////////////// Example ///////////////
+#ifdef I_AM_A_CONSTANT_THAT_IS_NEVER_DEFINED_BUT_ALLOWS_THE_CODE_BELOW_NOT_TO_BE_COMMENTED
+
+
+// In the modules loaded event handler, register your fonts
+int testOnModulesLoaded(WPARAM wParam, LPARAM lParam) {
+ FontID fid = {0};
+ fid.cbSize = sizeof(fid);
+ strncpy(fid.name, "Test Font", 64);
+ strncpy(fid.group, "My Group", 64);
+ strncpy(fid.dbSettingsGroup, "MyPlugin", 32);
+ strncpy(fid.prefix, "testFont", 32);
+ fid.order = 0;
+
+ // you could register the font at this point - getting it will get either the global default or what the user has set it
+ // to - but we'll set a default font:
+
+ fid.flags = FIDF_DEFAULTVALID;
+
+ fid.deffontsettings.charset = DEFAULT_CHARSET;
+ fid.deffontsettings.colour = RGB(255, 0, 0);
+ fid.deffontsettings.size = 8;
+ fid.deffontsettings.style = DBFONTF_BOLD;
+ strncpy(fid.deffontsettings.szFace, "Arial", LF_FACESIZE);
+
+ CallService(MS_FONT_REGISTER, (WPARAM)&fid, 0);
+
+ // if you add more fonts, and leave the 'order' field at 0, they will be ordered alphabetically
+
+ // .....
+
+ return 0;
+}
+
+// Later, when you need the LOGFONT structure for drawing with a font, do this
+void InSomeCodeSomewhere() {
+ //.....
+ LOGFONT lf;
+ COLORREF col;
+ FontID fid;
+ strncpy(fid.name, "Test Font", 64);
+ strncpy(fid.group, "My Group", 64);
+
+ col = (COLORREF)CallService(MS_FONT_GET, (WPARAM)&fid, (LPARAM)&lf);
+
+ // then procede to use the font
+ //....
+}
+
+#endif // example code
+
+#endif // _FONT_SERVICE_API_INC
+
diff --git a/font_service/m_fontservicew.h b/font_service/m_fontservicew.h
new file mode 100644
index 0000000..6d96aff
--- /dev/null
+++ b/font_service/m_fontservicew.h
@@ -0,0 +1,152 @@
+// Copyright Scott Ellis (mail@scottellis.com.au) 2005
+// This software is licenced under the GPL (General Public Licence)
+// available at http://www.gnu.org/copyleft/gpl.html
+
+#ifndef _FONT_SERVICEW_API_INC
+#define _FONT_SERVICEW_API_INC
+
+// style flags
+#define DBFONTF_BOLD 1
+#define DBFONTF_ITALIC 2
+#define DBFONTF_UNDERLINE 4
+#define DBFONTF_STRIKEOUT 8
+
+// flags for compatibility
+#define FIDF_APPENDNAME 1 // append 'Name' to the setting used to store font face (as CLC settings require)
+#define FIDF_NOAS 2 // disable the <prefix>As setting to prevent 'same as' behaviour
+#define FIDF_SAVEACTUALHEIGHT 4 // write the actual height of a test string to the db
+#define FIDF_SAVEPOINTSIZE 8 // write the font point size to the db
+
+// additional flags
+#define FIDF_DEFAULTVALID 32 // the default font settings are valid - else, just use generic default
+#define FIDF_NEEDRESTART 64 // setting changes will not take effect until miranda is restarted
+#define FIDF_ALLOWREREGISTER 128 // allow plugins to register this font again (i.e. override already registered settings such as flags)
+#define FIDF_ALLOWEFFECTS 256 // allow setting of font effects (i.e. underline and strikeout)
+
+// settings to be used for the value of 'deffontsettings' in the FontID structure below - i.e. defaults
+typedef struct FontSettingsW_tag
+{
+ COLORREF colour;
+ char size;
+ BYTE style; // see the DBFONTF_* flags above
+ BYTE charset;
+ wchar_t szFace[LF_FACESIZE];
+} FontSettingsW;
+
+// a font identifier structure - used for registering a font, and getting one out again
+typedef struct FontIDW_tag {
+ int cbSize;
+ wchar_t group[64]; // group the font belongs to - this is the 'Font Group' list in the options page
+ wchar_t name[64]; // this is the name of the font setting - e.g. 'contacts' in the 'contact list' group
+ char dbSettingsGroup[32]; // the 'module' in the database where the font data is stored
+ char prefix[32]; // this is prepended to the settings used to store this font's data in the db
+ DWORD flags; // bitwise OR of the FIDF_* flags above
+ FontSettingsW deffontsettings; // defaults, valid if flags & FIDF_DEFAULTVALID
+ int order; // controls the order in the font group in which the fonts are listed in the UI (if order fields are equal,
+ // they will be ordered alphabetically by name)
+} FontIDW;
+
+typedef struct ColourIDW_tag {
+ int cbSize;
+ wchar_t group[64];
+ wchar_t name[64];
+ char dbSettingsGroup[32];
+ char setting[32];
+ DWORD flags; // not used
+ COLORREF defcolour; // default value
+ int order;
+} ColourIDW;
+
+// register a font
+// wparam = (FontID *)&font_id
+// lparam = 0
+#define MS_FONT_REGISTERW "Font/RegisterW"
+
+// get a font
+// will fill the logfont structure passed in with the user's choices, or the default if it was set and the user has not chosen a font yet,
+// or the global default font settings otherwise (i.e. no user choice and default set, or font not registered)
+// global default font is gotten using SPI_GETICONTITLELOGFONT, color COLOR_WINDOWTEXT, size 8.
+// wparam = (FontID *)&font_id (only name and group matter)
+// lParam = (LOGFONT *)&logfont
+// returns the font's colour
+#define MS_FONT_GETW "Font/GetW"
+
+// fired when a user modifies font settings, so reload your fonts
+// wparam = lparam = 0
+#ifndef ME_FONT_RELOAD
+#define ME_FONT_RELOAD "Font/Reload"
+#endif
+
+// register a colour (this should be used for everything except actual text colour for registered fonts)
+// [note - a colour with name 'Background' [translated!] has special meaning and will be used as the background colour of
+// the font list box in the options, for the given group]
+// wparam = (ColourID *)&colour_id
+// lparam = 0
+#define MS_COLOUR_REGISTERW "Colour/RegisterW"
+
+// get a colour
+// wparam = (ColourID *)&colour_id (only name and group matter)
+// rerturns the colour (as COLORREF), or -1 if not found
+#define MS_COLOUR_GETW "Colour/GetW"
+
+// fired when a user modifies font settings, so reget your fonts and colours
+// wparam = lparam = 0
+#ifndef ME_COLOUR_RELOAD
+#define ME_COLOUR_RELOAD "Colour/Reload"
+#endif
+
+
+
+//////////////////// Example ///////////////
+#ifdef I_AM_A_CONSTANT_THAT_IS_NEVER_DEFINED_BUT_ALLOWS_THE_CODE_BELOW_NOT_TO_BE_COMMENTED
+
+
+// In the modules loaded event handler, register your fonts
+int testOnModulesLoaded(WPARAM wParam, LPARAM lParam) {
+ FontID fid = {0};
+ fid.cbSize = sizeof(fid);
+ strncpy(fid.name, "Test Font", 64);
+ strncpy(fid.group, "My Group", 64);
+ strncpy(fid.dbSettingsGroup, "MyPlugin", 32);
+ strncpy(fid.prefix, "testFont", 32);
+ fid.order = 0;
+
+ // you could register the font at this point - getting it will get either the global default or what the user has set it
+ // to - but we'll set a default font:
+
+ fid.flags = FIDF_DEFAULTVALID;
+
+ fid.deffontsettings.charset = DEFAULT_CHARSET;
+ fid.deffontsettings.colour = RGB(255, 0, 0);
+ fid.deffontsettings.size = 8;
+ fid.deffontsettings.style = DBFONTF_BOLD;
+ strncpy(fid.deffontsettings.szFace, "Arial", LF_FACESIZE);
+
+ CallService(MS_FONT_REGISTER, (WPARAM)&fid, 0);
+
+ // if you add more fonts, and leave the 'order' field at 0, they will be ordered alphabetically
+
+ // .....
+
+ return 0;
+}
+
+// Later, when you need the LOGFONT structure for drawing with a font, do this
+void InSomeCodeSomewhere() {
+ //.....
+ LOGFONT lf;
+ COLORREF col;
+ FontID fid;
+ strncpy(fid.name, "Test Font", 64);
+ strncpy(fid.group, "My Group", 64);
+
+ col = (COLORREF)CallService(MS_FONT_GET, (WPARAM)&fid, (LPARAM)&lf);
+
+ // then procede to use the font
+ //....
+}
+
+#endif // example code
+
+#endif // _FONT_SERVICE_API_INC
+
diff --git a/font_service/module_fonts.cpp b/font_service/module_fonts.cpp
new file mode 100644
index 0000000..ff84740
--- /dev/null
+++ b/font_service/module_fonts.cpp
@@ -0,0 +1,239 @@
+#include "common.h"
+#include "module_fonts.h"
+#include "m_fontservice.h"
+
+#define CLIST_FONTID_CONTACTS 0
+#define CLIST_FONTID_INVIS 1
+#define CLIST_FONTID_OFFLINE 2
+#define CLIST_FONTID_NOTONLIST 3
+#define CLIST_FONTID_GROUPS 4
+#define CLIST_FONTID_GROUPCOUNTS 5
+#define CLIST_FONTID_DIVIDERS 6
+#define CLIST_FONTID_OFFINVIS 7
+#define CLIST_FONTID_MAX 7
+
+// from CList
+static const char *szClistFontIdDescr[CLIST_FONTID_MAX + 1] =
+ { "Standard contacts", "Online contacts to whom you have a different visibility", "Offline contacts", "Contacts which are 'not on list'",
+"Groups", "Group member counts", "Dividers", "Offline contacts to whom you have a different visibility" };
+
+static int fontListOrder[CLIST_FONTID_MAX + 1] =
+ { CLIST_FONTID_CONTACTS, CLIST_FONTID_INVIS, CLIST_FONTID_OFFLINE, CLIST_FONTID_OFFINVIS,
+ CLIST_FONTID_NOTONLIST, CLIST_FONTID_GROUPS, CLIST_FONTID_GROUPCOUNTS, CLIST_FONTID_DIVIDERS };
+
+
+// from SRMM
+struct SRMMFontOptionsList
+{
+ char *szDescr;
+ COLORREF defColour;
+ char *szDefFace;
+ BYTE defCharset, defStyle;
+ char defSize;
+ COLORREF colour;
+ char szFace[LF_FACESIZE];
+ BYTE charset, style;
+ char size;
+}
+static fontOptionsList[] = {
+ {"Outgoing messages", RGB(106, 106, 106), "Arial", DEFAULT_CHARSET, 0, -12},
+ {"Incoming messages", RGB(0, 0, 0), "Arial", DEFAULT_CHARSET, 0, -12},
+ {"Outgoing name", RGB(89, 89, 89), "Arial", DEFAULT_CHARSET, DBFONTF_BOLD, -12},
+ {"Outgoing time", RGB(0, 0, 0), "Terminal", DEFAULT_CHARSET, DBFONTF_BOLD, -9},
+ {"Outgoing colon", RGB(89, 89, 89), "Arial", DEFAULT_CHARSET, 0, -11},
+ {"Incoming name", RGB(215, 0, 0), "Arial", DEFAULT_CHARSET, DBFONTF_BOLD, -12},
+ {"Incoming time", RGB(0, 0, 0), "Terminal", DEFAULT_CHARSET, DBFONTF_BOLD, -9},
+ {"Incoming colon", RGB(215, 0, 0), "Arial", DEFAULT_CHARSET, 0, -11},
+ {"Message area", RGB(0, 0, 0), "Arial", DEFAULT_CHARSET, 0, -12},
+ {"Notices", RGB(90, 90, 160), "Arial", DEFAULT_CHARSET, 0, -12},
+};
+const int msgDlgFontCount = sizeof(fontOptionsList) / sizeof(fontOptionsList[0]);
+
+struct ChatFontOptionsList
+{
+ char *szDescr;
+ COLORREF defColour;
+ char *szDefFace;
+ BYTE defCharset, defStyle;
+ char defSize;
+ COLORREF colour;
+ char szFace[LF_FACESIZE];
+ BYTE charset, style;
+ char size;
+}
+
+//remeber to put these in the Translate( ) template file too
+static chatFontOptionsList[] = {
+ {"Timestamp", RGB(50, 50, 240), "Terminal", DEFAULT_CHARSET, 0, -8},
+ {"Others nicknames", RGB(0, 0, 0), "Courier New", DEFAULT_CHARSET, DBFONTF_BOLD, -13},
+ {"Your nickname", RGB(0, 0, 0), "Courier New", DEFAULT_CHARSET, DBFONTF_BOLD, -13},
+ {"User has joined", RGB(90, 160, 90), "Courier New", DEFAULT_CHARSET, 0, -13},
+ {"User has left", RGB(160, 160, 90), "Courier New", DEFAULT_CHARSET, 0, -13},
+ {"User has disconnected", RGB(160, 90, 90), "Courier New", DEFAULT_CHARSET, 0, -13},
+ {"User kicked ...", RGB(100, 100, 100), "Courier New", DEFAULT_CHARSET, 0, -13},
+ {"User is now known as ...", RGB(90, 90, 160), "Courier New", DEFAULT_CHARSET, 0, -13},
+ {"Notice from user", RGB(160, 130, 60), "Courier New", DEFAULT_CHARSET, 0, -13},
+ {"Incoming message", RGB(90, 90, 90), "Courier New", DEFAULT_CHARSET, 0, -13},
+ {"Outgoing message", RGB(90, 90, 90), "Courier New", DEFAULT_CHARSET, 0, -13},
+ {"The topic is ...", RGB(70, 70, 160), "Courier New", DEFAULT_CHARSET, 0, -13},
+ {"Information messages", RGB(130, 130, 195), "Courier New", DEFAULT_CHARSET, 0, -13},
+ {"User enables status for ...", RGB(70, 150, 70), "Courier New", DEFAULT_CHARSET, 0, -13},
+ {"User disables status for ...", RGB(150, 70, 70), "Courier New", DEFAULT_CHARSET, 0, -13},
+ {"Action message", RGB(160, 90, 160), "Courier New", DEFAULT_CHARSET, 0, -13},
+ {"Highlighted message", RGB(180, 150, 80), "Courier New", DEFAULT_CHARSET, 0, -13},
+ {"Message typing area", RGB(0, 0, 40), "MS Shell Dlg", DEFAULT_CHARSET, 0, -13},
+ {"User list members", RGB(40,40, 90), "MS Shell Dlg", DEFAULT_CHARSET, 0, -11},
+ {"User list statuses", RGB(0, 0, 0), "MS Shell Dlg", DEFAULT_CHARSET, DBFONTF_BOLD, -11},
+};
+const int chatMsgDlgFontCount = sizeof(chatFontOptionsList) / sizeof(chatFontOptionsList[0]);
+
+#define CLCDEFAULT_BKCOLOUR GetSysColor(COLOR_3DFACE)
+#define CLCDEFAULT_SELTEXTCOLOUR GetSysColor(COLOR_HIGHLIGHTTEXT)
+#define CLCDEFAULT_HOTTEXTCOLOUR (IsWinVer98Plus()?RGB(0,0,255):GetSysColor(COLOR_HOTLIGHT))
+#define CLCDEFAULT_QUICKSEARCHCOLOUR RGB(255,255,0)
+
+void RegisterCListFonts() {
+ FontID fontid = {0};
+ char idstr[10];
+
+ fontid.cbSize = sizeof(FontID);
+ fontid.flags = FIDF_ALLOWREREGISTER | FIDF_APPENDNAME | FIDF_NOAS | FIDF_SAVEPOINTSIZE | FIDF_ALLOWEFFECTS;
+
+ for (int i = 0; i <= CLIST_FONTID_MAX; i++) {
+ strncpy(fontid.dbSettingsGroup, "CLC", sizeof(fontid.dbSettingsGroup));
+ strncpy(fontid.group, Translate("Contact List"), sizeof(fontid.group));
+ strncpy(fontid.name, Translate(szClistFontIdDescr[fontListOrder[i]]), sizeof(fontid.name));
+ sprintf(idstr, "Font%d", fontListOrder[i]);
+ strncpy(fontid.prefix, idstr, sizeof(fontid.prefix));
+ fontid.order = fontListOrder[i];
+
+ CallService(MS_FONT_REGISTER, (WPARAM)&fontid, 0);
+ }
+
+
+ // and colours
+ ColourID colourid;
+ colourid.cbSize = sizeof(ColourID);
+ strncpy(colourid.dbSettingsGroup, "CLC", sizeof(colourid.dbSettingsGroup));
+
+ strncpy(colourid.setting, "BkColour", sizeof(colourid.setting));
+ strncpy(colourid.name, Translate("Background"), sizeof(colourid.name));
+ colourid.order = 0;
+ strncpy(colourid.group, Translate("Contact List"), sizeof(colourid.group));
+ colourid.defcolour = CLCDEFAULT_BKCOLOUR;
+ CallService(MS_COLOUR_REGISTER, (WPARAM)&colourid, 0);
+
+ strncpy(colourid.setting, "SelTextColour", sizeof(colourid.setting));
+ strncpy(colourid.name, Translate("Selected Text"), sizeof(colourid.name));
+ colourid.order = 1;
+ strncpy(colourid.group, Translate("Contact List"), sizeof(colourid.group));
+ colourid.defcolour = CLCDEFAULT_SELTEXTCOLOUR;
+ CallService(MS_COLOUR_REGISTER, (WPARAM)&colourid, 0);
+
+ strncpy(colourid.setting, "HotTextColour", sizeof(colourid.setting));
+ strncpy(colourid.name, Translate("Hottrack Text"), sizeof(colourid.name));
+ colourid.order = 1;
+ strncpy(colourid.group, Translate("Contact List"), sizeof(colourid.group));
+ colourid.defcolour = CLCDEFAULT_HOTTEXTCOLOUR;
+ CallService(MS_COLOUR_REGISTER, (WPARAM)&colourid, 0);
+
+ strncpy(colourid.setting, "QuickSearchColour", sizeof(colourid.setting));
+ strncpy(colourid.name, Translate("Quicksearch Text"), sizeof(colourid.name));
+ colourid.order = 1;
+ strncpy(colourid.group, Translate("Contact List"), sizeof(colourid.group));
+ colourid.defcolour = CLCDEFAULT_QUICKSEARCHCOLOUR;
+ CallService(MS_COLOUR_REGISTER, (WPARAM)&colourid, 0);
+}
+
+void RegisterSRMMFonts() {
+ FontID fontid = {0};
+ char idstr[10];
+
+ fontid.cbSize = sizeof(FontID);
+ fontid.flags = FIDF_ALLOWREREGISTER | FIDF_DEFAULTVALID;
+ int index = 0;
+ for(int i = 0; i < msgDlgFontCount; i++, index++) {
+ strncpy(fontid.dbSettingsGroup, "SRMM", sizeof(fontid.dbSettingsGroup));
+ strncpy(fontid.group, Translate("Message Log"), sizeof(fontid.group));
+ strncpy(fontid.name, Translate(fontOptionsList[i].szDescr), sizeof(fontid.name));
+ sprintf(idstr, "SRMFont%d", index);
+ strncpy(fontid.prefix, idstr, sizeof(fontid.prefix));
+ fontid.order = index;
+
+ fontid.deffontsettings.charset = fontOptionsList[i].defCharset;
+ fontid.deffontsettings.colour = fontOptionsList[i].defColour;
+ fontid.deffontsettings.size = fontOptionsList[i].defSize;
+ fontid.deffontsettings.style = fontOptionsList[i].defStyle;
+ strncpy(fontid.deffontsettings.szFace, fontOptionsList[i].szDefFace, sizeof(fontid.deffontsettings.szFace));
+
+ CallService(MS_FONT_REGISTER, (WPARAM)&fontid, 0);
+ }
+
+ ColourID colourid;
+ colourid.cbSize = sizeof(ColourID);
+ strncpy(colourid.dbSettingsGroup, "SRMM", sizeof(colourid.dbSettingsGroup));
+ strncpy(colourid.setting, "BkgColour", sizeof(colourid.setting));
+ strncpy(colourid.name, Translate("Background"), sizeof(colourid.name));
+ colourid.order = 0;
+ strncpy(colourid.group, Translate("Message Log"), sizeof(colourid.group));
+
+ CallService(MS_COLOUR_REGISTER, (WPARAM)&colourid, 0);
+}
+
+void RegisterChatFonts() {
+
+ FontID fontid = {0};
+ char idstr[10];
+
+ fontid.cbSize = sizeof(FontID);
+ fontid.flags = FIDF_ALLOWREREGISTER | FIDF_DEFAULTVALID | FIDF_NEEDRESTART;
+ int index = 0;
+ for(int i = 0; i < chatMsgDlgFontCount; i++, index++) {
+ strncpy(fontid.dbSettingsGroup, "ChatFonts", sizeof(fontid.dbSettingsGroup));
+ strncpy(fontid.group, Translate("Chat Module"), sizeof(fontid.group));
+ strncpy(fontid.name, Translate(chatFontOptionsList[i].szDescr), sizeof(fontid.name));
+ sprintf(idstr, "Font%d", index);
+ strncpy(fontid.prefix, idstr, sizeof(fontid.prefix));
+ fontid.order = index;
+
+ fontid.deffontsettings.charset = chatFontOptionsList[i].defCharset;
+ fontid.deffontsettings.colour = chatFontOptionsList[i].defColour;
+ fontid.deffontsettings.size = chatFontOptionsList[i].defSize;
+ fontid.deffontsettings.style = chatFontOptionsList[i].defStyle;
+ strncpy(fontid.deffontsettings.szFace, chatFontOptionsList[i].szDefFace, sizeof(fontid.deffontsettings.szFace));
+
+ CallService(MS_FONT_REGISTER, (WPARAM)&fontid, 0);
+ }
+
+ ColourID colourid;
+ colourid.cbSize = sizeof(ColourID);
+ strncpy(colourid.dbSettingsGroup, "Chat", sizeof(colourid.dbSettingsGroup));
+
+ strncpy(colourid.setting, "ColorLogBG", sizeof(colourid.setting));
+ strncpy(colourid.name, Translate("Background"), sizeof(colourid.name));
+ colourid.order = 0;
+ strncpy(colourid.group, Translate("Chat Module"), sizeof(colourid.group));
+ colourid.defcolour = GetSysColor(COLOR_WINDOW);
+ CallService(MS_COLOUR_REGISTER, (WPARAM)&colourid, 0);
+
+ strncpy(colourid.setting, "ColorMessageBG", sizeof(colourid.setting));
+ strncpy(colourid.name, Translate("Message Background"), sizeof(colourid.name));
+ colourid.order = 0;
+ strncpy(colourid.group, Translate("Chat Module"), sizeof(colourid.group));
+ colourid.defcolour = GetSysColor(COLOR_WINDOW);
+ CallService(MS_COLOUR_REGISTER, (WPARAM)&colourid, 0);
+
+ strncpy(colourid.setting, "ColorNicklistBG", sizeof(colourid.setting));
+ strncpy(colourid.name, Translate("Userlist Background"), sizeof(colourid.name));
+ colourid.order = 0;
+ strncpy(colourid.group, Translate("Chat Module"), sizeof(colourid.group));
+ colourid.defcolour = GetSysColor(COLOR_WINDOW);
+ CallService(MS_COLOUR_REGISTER, (WPARAM)&colourid, 0);
+
+ strncpy(colourid.setting, "ColorNicklistLines", sizeof(colourid.setting));
+ strncpy(colourid.name, Translate("Userlist Lines"), sizeof(colourid.name));
+ colourid.order = 0;
+ strncpy(colourid.group, Translate("Chat Module"), sizeof(colourid.group));
+ colourid.defcolour = GetSysColor(COLOR_INACTIVEBORDER);
+ CallService(MS_COLOUR_REGISTER, (WPARAM)&colourid, 0);
+}
diff --git a/font_service/module_fonts.h b/font_service/module_fonts.h
new file mode 100644
index 0000000..48e8145
--- /dev/null
+++ b/font_service/module_fonts.h
@@ -0,0 +1,8 @@
+#ifndef MODULE_FONTS_INC
+#define MODULE_FONTS_INC
+
+void RegisterCListFonts();
+void RegisterSRMMFonts();
+void RegisterChatFonts();
+
+#endif
diff --git a/font_service/options.cpp b/font_service/options.cpp
new file mode 100644
index 0000000..b3e825a
--- /dev/null
+++ b/font_service/options.cpp
@@ -0,0 +1,689 @@
+#include "common.h"
+#include "services.h"
+
+FontIDWList font_id_list_w2, font_id_list_w3;
+ColourIDWList colour_id_list_w2, colour_id_list_w3;
+
+#define M_SETFONTGROUP (WM_USER + 101)
+#define TIMER_ID 11015
+
+extern void UpdateFontSettingsW(FontIDW *font_id, FontSettingsW *fontsettings);
+extern void UpdateColourSettingsW(ColourIDW *colour_id, COLORREF *colour);
+
+void WriteLine(HANDLE fhand, char *line) {
+ DWORD wrote;
+ strcat(line, "\r\n");
+ WriteFile(fhand, line, strlen(line), &wrote, 0);
+}
+
+bool ExportSettings(HWND hwndDlg, TCHAR *filename, FontIDWList flist, ColourIDWList clist) {
+ HANDLE fhand = CreateFile(filename, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0);
+ if(fhand == INVALID_HANDLE_VALUE) {
+ MessageBox(hwndDlg, filename, L"Failed to create file", MB_ICONWARNING | MB_OK);
+ return false;
+ }
+
+ char header[512], buff[1024], abuff[1024];
+ header[0] = 0;
+
+ strcpy(buff, "SETTINGS:\r\n");
+ WriteLine(fhand, buff);
+ FontIDSettingsWPair *it;
+ for (FontIDWList::Iterator lit = flist.start(); lit.has_val(); lit.next()) {
+ it = &lit.val();
+
+ strcpy(buff, "[");
+ strcat(buff, it->first.dbSettingsGroup);
+ strcat(buff, "]");
+ if(strcmp(buff, header) != 0) {
+ strcpy(header, buff);
+ WriteLine(fhand, buff);
+ }
+
+ if(it->first.flags & FIDF_APPENDNAME) {
+ wsprintfA(buff, "%sName", it->first.prefix);
+ } else {
+ wsprintfA(buff, "%s", it->first.prefix);
+ }
+ strcat(buff, "=s");
+ WideCharToMultiByte(code_page, 0, it->second.szFace, -1, abuff, 1024, 0, 0);
+ abuff[1023]=0;
+ strcat(buff, abuff);
+ WriteLine(fhand, buff);
+
+ wsprintfA(buff, "%sSize=b", it->first.prefix);
+ if(it->first.flags & FIDF_SAVEACTUALHEIGHT) {
+ HDC hdc;
+ SIZE size;
+ HFONT hFont, hOldFont;
+ LOGFONTW lf;
+ CreateFromFontSettingsW(&it->second, &lf, it->first.flags);
+ hFont = CreateFontIndirectW(&lf);
+ //hFont = CreateFontA(it->second.size, 0, 0, 0,
+ // it->second.style & DBFONTF_BOLD ? FW_BOLD : FW_NORMAL,
+ // it->second.style & DBFONTF_ITALIC ? 1 : 0, 0, 0, it->second.charset, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, it->second.szFace);
+ hdc = GetDC(hwndDlg);
+ hOldFont = (HFONT)SelectObject(hdc, hFont);
+ GetTextExtentPoint32(hdc, L"_W", 2, &size);
+ ReleaseDC(hwndDlg, hdc);
+ SelectObject(hdc, hOldFont);
+ DeleteObject(hFont);
+
+ strcat(buff, _itoa((BYTE)size.cy, abuff, 10));
+
+ } else if(it->first.flags & FIDF_SAVEPOINTSIZE) {
+ HDC hdc = GetDC(hwndDlg);
+ //lf->lfHeight = -MulDiv(lf->lfHeight,GetDeviceCaps(hdc, LOGPIXELSY), 72);
+ strcat(buff, _itoa((BYTE)-MulDiv(it->second.size, 72, GetDeviceCaps(hdc, LOGPIXELSY)), abuff, 10));
+ ReleaseDC(hwndDlg, hdc);
+ } else {
+ strcat(buff, _itoa((BYTE)it->second.size, abuff, 10));
+ }
+ WriteLine(fhand, buff);
+
+ wsprintfA(buff, "%sSty=b%d", it->first.prefix, (BYTE)it->second.style);
+ WriteLine(fhand, buff);
+ wsprintfA(buff, "%sSet=b%d", it->first.prefix, (BYTE)it->second.charset);
+ WriteLine(fhand, buff);
+ wsprintfA(buff, "%sCol=d%d", it->first.prefix, (DWORD)it->second.colour);
+ WriteLine(fhand, buff);
+ if(it->first.flags & FIDF_NOAS) {
+ wsprintfA(buff, "%sAs=w%d", it->first.prefix, (WORD)0x00FF);
+ WriteLine(fhand, buff);
+ }
+ wsprintfA(buff, "%sFlags=w%d", it->first.prefix, (WORD)it->first.flags);
+ WriteLine(fhand, buff);
+ }
+
+ header[0] = 0;
+ ColourIDColourWPair *cit;
+ for (ColourIDWList::Iterator lcit = clist.start(); lcit.has_val(); lcit.next()) {
+ cit = &lcit.val();
+ strcpy(buff, "[");
+ strcat(buff, cit->first.dbSettingsGroup);
+ strcat(buff, "]");
+ if(strcmp(buff, header) != 0) {
+ strcpy(header, buff);
+ WriteLine(fhand, buff);
+ }
+ wsprintfA(buff, "%s=d%d", cit->first.setting, (DWORD)cit->second);
+ WriteLine(fhand, buff);
+ }
+
+
+ CloseHandle(fhand);
+ return true;
+}
+
+void OptionsChanged() {
+#define INTM_RELOADOPTIONS (WM_USER+21)
+ HWND hWnd = FindWindowEx((HWND)CallService(MS_CLUI_GETHWND, 0, 0), 0, CLISTCONTROL_CLASS, 0);
+ if(hWnd) SendMessage(hWnd, INTM_RELOADOPTIONS, 0, 0);
+ NotifyEventHooks(hFontReloadEvent, 0, 0);
+ NotifyEventHooks(hColourReloadEvent, 0, 0);
+}
+
+TOOLINFO ti;
+int x, y;
+
+UINT_PTR CALLBACK CFHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) {
+ switch(uiMsg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hdlg);
+ return 0;
+ }
+
+ return 0;
+}
+
+
+static BOOL CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ static HBRUSH hBkgColourBrush = 0;
+
+ switch (msg) {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
+
+ /*
+ // create tooltip tool
+ ti.cbSize = sizeof(TOOLINFO);
+ ti.uFlags = TTF_IDISHWND | TTF_TRACK | TTF_ABSOLUTE;
+ ti.hwnd = GetDlgItem(hwndDlg, IDC_TOOLTIP);
+ ti.uId = (UINT)hwndDlg;
+ ti.hinst = hInstance;
+ ti.lpszText = L"hi there";
+ ti.rect.left = ti.rect.top = ti.rect.bottom = ti.rect.right = 0;
+
+ SendMessage(GetDlgItem(hwndDlg, IDC_TOOLTIP), TTM_ADDTOOL,0, (LPARAM)&ti);
+ */
+
+ font_id_list_w3 = font_id_list_w2 = font_id_list_w;
+ colour_id_list_w3 = colour_id_list_w2 = colour_id_list_w;
+
+ FontIDSettingsWPair *it;
+ for (FontIDWList::Iterator lit = font_id_list_w2.start(); lit.has_val(); lit.next()) {
+ it = &lit.val();
+ // sync settings with database
+ UpdateFontSettingsW(&it->first, &it->second);
+ if(SendDlgItemMessageW(hwndDlg, IDC_FONTGROUP, LB_FINDSTRINGEXACT, (WPARAM)-1, (WPARAM)it->first.group) == CB_ERR) {
+ SendDlgItemMessageW(hwndDlg, IDC_FONTGROUP, LB_ADDSTRING, (WPARAM)-1, (WPARAM)it->first.group);
+ }
+
+ }
+
+ ColourIDColourWPair *cit;
+ for (ColourIDWList::Iterator lcit = colour_id_list_w2.start(); lcit.has_val(); lcit.next()) {
+ cit = &lcit.val();
+ // sync settings with database
+ UpdateColourSettingsW(&cit->first, &cit->second);
+ }
+
+ SendDlgItemMessage(hwndDlg, IDC_BKGCOLOUR, CPM_SETDEFAULTCOLOUR, 0, (LPARAM)GetSysColor(COLOR_WINDOW));
+
+ if(font_id_list_w2.size()) SendDlgItemMessage(hwndDlg, IDC_FONTGROUP, LB_SETCURSEL, 0, 0);
+ SendMessage(hwndDlg, M_SETFONTGROUP, 0, 0);
+
+ return TRUE;
+ }
+ case M_SETFONTGROUP:
+ {
+ int sel = SendDlgItemMessage(hwndDlg, IDC_FONTGROUP, LB_GETCURSEL, 0, 0);
+ if(sel != -1) {
+ wchar_t group_buff[64];
+ SendDlgItemMessage(hwndDlg, IDC_FONTGROUP, LB_GETTEXT, sel, (LPARAM)group_buff);
+
+ SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_RESETCONTENT, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_COLOURLIST, CB_RESETCONTENT, 0, 0);
+ {
+ BOOL need_restart = false;
+ int fontId = 0, itemId;
+ int first_font_index = -1;
+ FontIDSettingsWPair *it;
+ for (FontIDWList::Iterator lit = font_id_list_w2.start(); lit.has_val(); lit.next(), fontId++) {
+ it = &lit.val();
+ if(wcsncmp(it->first.group, group_buff, 64) == 0) {
+ if(first_font_index == -1)
+ first_font_index = fontId;
+ //itemId = SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_ADDSTRING, -1, (LPARAM)"");
+ //SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_SETITEMDATA, itemId, fontId);
+ itemId = SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_ADDSTRING, (WPARAM)-1, fontId);
+ need_restart |= (it->first.flags & FIDF_NEEDRESTART);
+ //SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_SETITEMDATA, itemId, fontId);
+ }
+ }
+
+ ShowWindow(GetDlgItem(hwndDlg, IDC_STAT_RESTART), (need_restart ? SW_SHOW : SW_HIDE));
+
+ if(hBkgColourBrush) {
+ DeleteObject(hBkgColourBrush);
+ hBkgColourBrush = 0;
+ }
+ int colourId = 0;
+ int first_colour_index = -1;
+ ColourIDColourWPair *cit;
+ for (ColourIDWList::Iterator lcit = colour_id_list_w2.start(); lcit.has_val(); lcit.next(), colourId++) {
+ cit = &lcit.val();
+ if(wcsncmp(cit->first.group, group_buff, 64) == 0) {
+ if(first_colour_index == -1)
+ first_colour_index = colourId;
+ itemId = SendDlgItemMessage(hwndDlg, IDC_COLOURLIST, CB_ADDSTRING, (WPARAM)-1, (LPARAM) TranslateW(cit->first.name));
+ SendDlgItemMessage(hwndDlg, IDC_COLOURLIST, CB_SETITEMDATA, itemId, colourId);
+
+ if(wcscmp(cit->first.name, TranslateW(L"Background")) == 0) {
+ hBkgColourBrush = CreateSolidBrush(cit->second);
+ }
+ }
+ }
+ if(!hBkgColourBrush)
+ hBkgColourBrush = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
+
+ SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_SETSEL, TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_FONTCOLOUR, CPM_SETCOLOUR, 0, (LPARAM)font_id_list_w2[first_font_index].second.colour);
+ SendDlgItemMessage(hwndDlg, IDC_FONTCOLOUR, CPM_SETDEFAULTCOLOUR, 0, (LPARAM)font_id_list_w2[first_font_index].first.deffontsettings.colour);
+
+ if(font_id_list_w2[first_font_index].first.flags & FIDF_DEFAULTVALID) {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_RESET), TRUE);
+ } else
+ EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_RESET), FALSE);
+
+ if(first_colour_index == -1) {
+ HWND hw = GetDlgItem(hwndDlg, IDC_COLOURLIST);
+ EnableWindow(hw, FALSE);
+ hw = GetDlgItem(hwndDlg, IDC_BKGCOLOUR);
+ EnableWindow(hw, FALSE);
+
+ } else {
+ HWND hw = GetDlgItem(hwndDlg, IDC_COLOURLIST);
+ EnableWindow(hw, TRUE);
+ hw = GetDlgItem(hwndDlg, IDC_BKGCOLOUR);
+ EnableWindow(hw, TRUE);
+
+ SendDlgItemMessage(hwndDlg, IDC_COLOURLIST, CB_SETCURSEL, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_BKGCOLOUR, CPM_SETCOLOUR, 0, (LPARAM)colour_id_list_w2[first_colour_index].second);
+ SendDlgItemMessage(hwndDlg, IDC_BKGCOLOUR, CPM_SETDEFAULTCOLOUR, 0, colour_id_list_w2[first_colour_index].first.defcolour);
+
+ }
+ }
+ }
+ return TRUE;
+ }
+ case WM_CTLCOLORLISTBOX:
+ {
+ if((HWND)lParam == GetDlgItem(hwndDlg, IDC_FONTLIST)) {
+ return (BOOL) hBkgColourBrush;
+ }
+ }
+ break;
+ case WM_MEASUREITEM:
+ {
+ MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *) lParam;
+ if(mis->CtlID == IDC_FONTLIST && font_id_list_w2.size()) {
+ HFONT hFont, hoFont;
+ SIZE fontSize;
+ int iItem = mis->itemData;
+ //int iItem = SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETITEMDATA, mis->itemID, 0);
+ HDC hdc = GetDC(GetDlgItem(hwndDlg, mis->CtlID));
+ LOGFONTW lf;
+ CreateFromFontSettingsW(&font_id_list_w2[iItem].second, &lf, font_id_list_w2[iItem].first.flags);
+ hFont = CreateFontIndirectW(&lf);
+
+ //hFont = CreateFontA(font_id_list2[iItem].second.size, 0, 0, 0,
+ // font_id_list2[iItem].second.style & DBFONTF_BOLD ? FW_BOLD : FW_NORMAL,
+ // font_id_list2[iItem].second.style & DBFONTF_ITALIC ? 1 : 0, 0, 0, font_id_list2[iItem].second.charset, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, font_id_list2[iItem].second.szFace);
+ hoFont = (HFONT) SelectObject(hdc, hFont);
+ GetTextExtentPoint32W(hdc, font_id_list_w2[iItem].first.name, wcslen(font_id_list_w2[iItem].first.name), &fontSize);
+ SelectObject(hdc, hoFont);
+ ReleaseDC(GetDlgItem(hwndDlg, mis->CtlID), hdc);
+ DeleteObject(hFont);
+ mis->itemWidth = fontSize.cx;
+ mis->itemHeight = fontSize.cy;
+ return TRUE;
+ }
+ break;
+ }
+ case WM_DRAWITEM:
+ {
+ DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *) lParam;
+ if(dis->CtlID == IDC_FONTLIST && font_id_list_w2.size()) {
+ HFONT hFont, hoFont;
+ wchar_t *pszText;
+ int iItem = dis->itemData;
+ LOGFONTW lf;
+ CreateFromFontSettingsW(&font_id_list_w2[iItem].second, &lf, font_id_list_w2[iItem].first.flags);
+ hFont = CreateFontIndirectW(&lf);
+ //hFont = CreateFontA(font_id_list2[iItem].second.size, 0, 0, 0,
+ // font_id_list2[iItem].second.style & DBFONTF_BOLD ? FW_BOLD : FW_NORMAL,
+ // font_id_list2[iItem].second.style & DBFONTF_ITALIC ? 1 : 0, 0, 0, font_id_list2[iItem].second.charset, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, font_id_list2[iItem].second.szFace);
+ hoFont = (HFONT) SelectObject(dis->hDC, hFont);
+ SetBkMode(dis->hDC, TRANSPARENT);
+ FillRect(dis->hDC, &dis->rcItem, hBkgColourBrush);
+ if (dis->itemState & ODS_SELECTED)
+ FrameRect(dis->hDC, &dis->rcItem, GetSysColorBrush(COLOR_HIGHLIGHT));
+ SetTextColor(dis->hDC, font_id_list_w2[iItem].second.colour);
+ pszText = TranslateW(font_id_list_w2[iItem].first.name);
+ TextOutW(dis->hDC, dis->rcItem.left, dis->rcItem.top, pszText, wcslen(pszText));
+ SelectObject(dis->hDC, hoFont);
+ DeleteObject(hFont);
+ return TRUE;
+ }
+ break;
+ }
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_COLOURLIST:
+ if (HIWORD(wParam) == LBN_SELCHANGE) {
+ int sel = SendDlgItemMessage(hwndDlg, IDC_COLOURLIST, CB_GETCURSEL, 0, 0);
+ if(sel != -1) {
+ int i = SendDlgItemMessage(hwndDlg, IDC_COLOURLIST, CB_GETITEMDATA, sel, 0);
+ SendDlgItemMessage(hwndDlg, IDC_BKGCOLOUR, CPM_SETCOLOUR, 0, colour_id_list_w2[i].second);
+ SendDlgItemMessage(hwndDlg, IDC_BKGCOLOUR, CPM_SETDEFAULTCOLOUR, 0, colour_id_list_w2[i].first.defcolour);
+ }
+ }
+ if (HIWORD(wParam) != LBN_DBLCLK)
+ return TRUE;
+ //fall through
+ case IDC_BKGCOLOUR:
+
+ {
+ int sel = SendDlgItemMessage(hwndDlg, IDC_COLOURLIST, CB_GETCURSEL, 0, 0);
+ if(sel != -1) {
+ int i = SendDlgItemMessage(hwndDlg, IDC_COLOURLIST, CB_GETITEMDATA, sel, 0);
+ colour_id_list_w2[i].second = SendDlgItemMessage(hwndDlg, IDC_BKGCOLOUR, CPM_GETCOLOUR, 0, 0);
+ if(wcscmp(colour_id_list_w2[i].first.name, TranslateW(L"Background")) == 0) {
+ DeleteObject(hBkgColourBrush);
+ hBkgColourBrush = CreateSolidBrush(SendDlgItemMessage(hwndDlg, IDC_BKGCOLOUR, CPM_GETCOLOUR, 0, 0));
+ }
+ }
+ }
+ InvalidateRect(GetDlgItem(hwndDlg, IDC_FONTLIST), NULL, TRUE);
+ break;
+ case IDC_FONTGROUP:
+ if (HIWORD(wParam) == LBN_SELCHANGE) {
+ SendMessage(hwndDlg, M_SETFONTGROUP, 0, 0);
+ }
+ return TRUE;
+ case IDC_FONTLIST:
+ if (HIWORD(wParam) == LBN_SELCHANGE) {
+ if(font_id_list_w2.size()) {
+ int *selItems = (int *)mir_alloc(font_id_list_w2.size() * sizeof(int));
+ int sel, selCount, i;
+
+ selCount = SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETSELITEMS, (WPARAM)font_id_list_w2.size(), (LPARAM) selItems);
+
+ if (selCount > 1) {
+ SendDlgItemMessage(hwndDlg, IDC_FONTCOLOUR, CPM_SETCOLOUR, 0, GetSysColor(COLOR_3DFACE));
+ SendDlgItemMessage(hwndDlg, IDC_FONTCOLOUR, CPM_SETDEFAULTCOLOUR, 0, GetSysColor(COLOR_WINDOWTEXT));
+ BOOL show_default = FALSE;
+ for (sel = 0; sel < selCount; sel++) {
+ i = SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETITEMDATA, selItems[sel], 0);
+ show_default |= (font_id_list_w2[i].first.flags & FIDF_DEFAULTVALID);
+ }
+ if(show_default) {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_RESET), TRUE);
+ } else
+ EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_RESET), FALSE);
+ }
+ else {
+ int i = SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETITEMDATA,
+ SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETCURSEL, 0, 0), 0);
+ SendDlgItemMessage(hwndDlg, IDC_FONTCOLOUR, CPM_SETCOLOUR, 0, font_id_list_w2[i].second.colour);
+ SendDlgItemMessage(hwndDlg, IDC_FONTCOLOUR, CPM_SETDEFAULTCOLOUR, 0, (LPARAM)font_id_list_w2[i].first.deffontsettings.colour);
+
+ if(font_id_list_w2[i].first.flags & FIDF_DEFAULTVALID) {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_RESET), TRUE);
+ } else
+ EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_RESET), FALSE);
+ }
+ mir_free(selItems);
+ }
+ return TRUE;
+ }
+ if (HIWORD(wParam) != LBN_DBLCLK)
+ return TRUE;
+ //fall through
+ case IDC_CHOOSEFONT:
+ {
+ LOGFONTW lf = { 0 };
+ if(SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETCOUNT, 0, 0)) {
+ int sel = SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETCURSEL, 0, 0);
+ int i = SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETITEMDATA, sel, 0);
+
+ CreateFromFontSettingsW(&font_id_list_w2[i].second, &lf, font_id_list_w2[i].first.flags);
+ CreateFontIndirectW(&lf);
+
+ CHOOSEFONTW cf = { 0 };
+ cf.lStructSize = sizeof(cf);
+ cf.hwndOwner = hwndDlg;
+ cf.lpLogFont = &lf;
+ if(font_id_list_w2[i].first.flags & FIDF_ALLOWEFFECTS) {
+ cf.Flags = CF_FORCEFONTEXIST | CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS | CF_EFFECTS | CF_ENABLETEMPLATE | CF_ENABLEHOOK;
+ // use custom font dialog to disable colour selection
+ cf.hInstance = hInstance;
+ cf.lpTemplateName = MAKEINTRESOURCEW(IDD_CUSTOM_FONT);
+ cf.lpfnHook = CFHookProc;
+ } else {
+ cf.Flags = CF_FORCEFONTEXIST | CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
+ }
+
+ if (ChooseFontW(&cf)) {
+ int *selItems = (int *)mir_alloc(font_id_list_w2.size() * sizeof(int));
+ int sel, selCount;
+
+ selCount = SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETSELITEMS, (WPARAM)font_id_list_w2.size(), (LPARAM) selItems);
+ for (sel = 0; sel < selCount; sel++) {
+ i = SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETITEMDATA, selItems[sel], 0);
+ font_id_list_w2[i].second.size = (char)lf.lfHeight;
+ font_id_list_w2[i].second.style = (lf.lfWeight >= FW_BOLD ? DBFONTF_BOLD : 0) | (lf.lfItalic ? DBFONTF_ITALIC : 0) | (lf.lfUnderline ? DBFONTF_UNDERLINE : 0) | (lf.lfStrikeOut ? DBFONTF_STRIKEOUT : 0);
+ font_id_list_w2[i].second.charset = lf.lfCharSet;
+ wcscpy(font_id_list_w2[i].second.szFace, lf.lfFaceName);
+ {
+ MEASUREITEMSTRUCT mis = { 0 };
+ mis.CtlID = IDC_FONTLIST;
+ mis.itemData = i;
+ SendMessage(hwndDlg, WM_MEASUREITEM, 0, (LPARAM) & mis);
+ SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_SETITEMHEIGHT, selItems[sel], mis.itemHeight);
+ }
+ }
+ mir_free(selItems);
+ InvalidateRect(GetDlgItem(hwndDlg, IDC_FONTLIST), NULL, TRUE);
+ break;
+ }
+ }
+ return TRUE;
+ }
+ case IDC_FONTCOLOUR:
+ {
+ if(font_id_list_w2.size()) {
+ int *selItems = (int *)mir_alloc(font_id_list_w2.size() * sizeof(int));
+ int sel, selCount, i;
+
+ selCount = SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETSELITEMS, (WPARAM)font_id_list_w2.size(), (LPARAM) selItems);
+ for (sel = 0; sel < selCount; sel++) {
+ i = SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETITEMDATA, selItems[sel], 0);
+ font_id_list_w2[i].second.colour = SendDlgItemMessage(hwndDlg, IDC_FONTCOLOUR, CPM_GETCOLOUR, 0, 0);
+ }
+ mir_free(selItems);
+ InvalidateRect(GetDlgItem(hwndDlg, IDC_FONTLIST), NULL, FALSE);
+ }
+ break;
+ }
+ case IDC_BTN_RESET:
+ {
+ if(font_id_list_w2.size()) {
+ int *selItems = (int *)mir_alloc(font_id_list_w2.size() * sizeof(int));
+ int sel, selCount, i;
+
+ selCount = SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETSELITEMS, (WPARAM)font_id_list_w2.size(), (LPARAM) selItems);
+ for (sel = 0; sel < selCount; sel++) {
+ i = SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETITEMDATA, selItems[sel], 0);
+ if(font_id_list_w2[i].first.flags & FIDF_DEFAULTVALID) {
+ font_id_list_w2[i].second = font_id_list_w2[i].first.deffontsettings;
+ {
+ MEASUREITEMSTRUCT mis = { 0 };
+ mis.CtlID = IDC_FONTLIST;
+ mis.itemData = i;
+ SendMessage(hwndDlg, WM_MEASUREITEM, 0, (LPARAM) & mis);
+ SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_SETITEMHEIGHT, selItems[sel], mis.itemHeight);
+ }
+ }
+ }
+ if (selCount > 1) {
+ SendDlgItemMessage(hwndDlg, IDC_FONTCOLOUR, CPM_SETCOLOUR, 0, GetSysColor(COLOR_3DFACE));
+ SendDlgItemMessage(hwndDlg, IDC_FONTCOLOUR, CPM_SETDEFAULTCOLOUR, 0, GetSysColor(COLOR_WINDOWTEXT));
+ }
+ else {
+ int i = SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETITEMDATA,
+ SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETCURSEL, 0, 0), 0);
+ SendDlgItemMessage(hwndDlg, IDC_FONTCOLOUR, CPM_SETCOLOUR, 0, font_id_list_w2[i].second.colour);
+ }
+ mir_free(selItems);
+ InvalidateRect(GetDlgItem(hwndDlg, IDC_FONTLIST), NULL, FALSE);
+ }
+ break;
+ }
+ case IDC_BTN_UNDO:
+ {
+ font_id_list_w2 = font_id_list_w3;
+ colour_id_list_w2 = colour_id_list_w3;
+ EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_UNDO), FALSE);
+
+ SendDlgItemMessage(hwndDlg, IDC_FONTGROUP, LB_SETCURSEL, 0, 0);
+ SendMessage(hwndDlg, M_SETFONTGROUP, 0, 0);
+ break;
+ }
+ case IDC_BTN_EXPORT:
+ {
+ TCHAR fname_buff[MAX_PATH];
+ OPENFILENAME ofn = {0};
+ ofn.lStructSize = sizeof(ofn);
+ ofn.lpstrFile = fname_buff;
+ ofn.lpstrFile[0] = '\0';
+ ofn.nMaxFile = MAX_PATH;
+ ofn.hwndOwner = hwndDlg;
+ ofn.Flags = OFN_NOREADONLYRETURN | OFN_CREATEPROMPT | OFN_OVERWRITEPROMPT;
+ ofn.lpstrFilter = L"INI\0*.ini\0Text\0*.TXT\0All\0*.*\0";
+ ofn.nFilterIndex = 1;
+
+ ofn.lpstrDefExt = L"ini";
+
+ if(GetSaveFileName(&ofn) == TRUE) {
+ if(!ExportSettings(hwndDlg, ofn.lpstrFile, font_id_list_w, colour_id_list_w))
+ MessageBox(hwndDlg, L"Error writing file", L"Error", MB_ICONWARNING | MB_OK);
+ }
+
+ return TRUE;
+ }
+ }
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ case WM_NOTIFY:
+ switch (((LPNMHDR) lParam)->idFrom) {
+ case 0:
+ switch (((LPNMHDR) lParam)->code) {
+ case PSN_APPLY:
+
+ {
+ font_id_list_w3 = font_id_list_w;
+ colour_id_list_w3 = colour_id_list_w;
+ EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_UNDO), TRUE);
+
+ font_id_list_w = font_id_list_w2;
+ colour_id_list_w = colour_id_list_w2;
+
+ char str[32];
+ FontIDSettingsWPair *it;
+ for (FontIDWList::Iterator lit = font_id_list_w2.start(); lit.has_val(); lit.next()) {
+ it = &lit.val();
+ if(it->first.flags & FIDF_APPENDNAME) wsprintfA(str, "%sName", it->first.prefix);
+ else wsprintfA(str, "%s", it->first.prefix);
+
+ if(DBWriteContactSettingWString(NULL, it->first.dbSettingsGroup, str, it->second.szFace)) {
+ char buff[1024];
+ WideCharToMultiByte(code_page, 0, it->second.szFace, -1, buff, 1024, 0, 0);
+ DBWriteContactSettingString(NULL, it->first.dbSettingsGroup, str, buff);
+ }
+
+ wsprintfA(str, "%sSize", it->first.prefix);
+ if(it->first.flags & FIDF_SAVEACTUALHEIGHT) {
+ HDC hdc;
+ SIZE size;
+ HFONT hFont, hOldFont;
+ LOGFONTW lf;
+ CreateFromFontSettingsW(&it->second, &lf, it->first.flags);
+ hFont = CreateFontIndirectW(&lf);
+ //hFont = CreateFontA(it->second.size, 0, 0, 0,
+ // it->second.style & DBFONTF_BOLD ? FW_BOLD : FW_NORMAL,
+ // it->second.style & DBFONTF_ITALIC ? 1 : 0, 0, 0, it->second.charset, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, it->second.szFace);
+ hdc = GetDC(hwndDlg);
+ hOldFont = (HFONT)SelectObject(hdc, hFont);
+ GetTextExtentPoint32(hdc, L"_W", 2, &size);
+ ReleaseDC(hwndDlg, hdc);
+ SelectObject(hdc, hOldFont);
+ DeleteObject(hFont);
+
+ DBWriteContactSettingByte(NULL, it->first.dbSettingsGroup, str, (char)size.cy);
+ } else if(it->first.flags & FIDF_SAVEPOINTSIZE) {
+ HDC hdc = GetDC(hwndDlg);
+ //lf->lfHeight = -MulDiv(lf->lfHeight,GetDeviceCaps(hdc, LOGPIXELSY), 72);
+ DBWriteContactSettingByte(NULL, it->first.dbSettingsGroup, str, (BYTE)-MulDiv(it->second.size, 72, GetDeviceCaps(hdc, LOGPIXELSY)));
+ ReleaseDC(hwndDlg, hdc);
+ } else {
+ DBWriteContactSettingByte(NULL, it->first.dbSettingsGroup, str, it->second.size);
+ }
+ wsprintfA(str, "%sSty", it->first.prefix);
+ DBWriteContactSettingByte(NULL, it->first.dbSettingsGroup, str, it->second.style);
+ wsprintfA(str, "%sSet", it->first.prefix);
+ DBWriteContactSettingByte(NULL, it->first.dbSettingsGroup, str, it->second.charset);
+ wsprintfA(str, "%sCol", it->first.prefix);
+ DBWriteContactSettingDword(NULL, it->first.dbSettingsGroup, str, it->second.colour);
+ if(it->first.flags & FIDF_NOAS) {
+ wsprintfA(str, "%sAs", it->first.prefix);
+ DBWriteContactSettingWord(NULL, it->first.dbSettingsGroup, str, (WORD)0x00FF);
+ }
+ wsprintfA(str, "%sFlags", it->first.prefix);
+ DBWriteContactSettingWord(NULL, it->first.dbSettingsGroup, str, (WORD)it->first.flags);
+ }
+
+ ColourIDColourWPair *cit;
+ for(ColourIDWList::Iterator lcit = colour_id_list_w2.start(); lcit.has_val(); lcit.next()) {
+ cit = &lcit.val();
+ wsprintfA(str, "%s", cit->first.setting);
+ DBWriteContactSettingDword(NULL, cit->first.dbSettingsGroup, str, cit->second);
+ }
+
+ }
+
+ OptionsChanged();
+ return TRUE;
+ }
+ break;
+ }
+ break;
+/*
+// tooltip stuff
+
+ case WM_MOUSEMOVE:
+#define X_OFFSET 15
+#define Y_OFFSET 15
+ SendMessage(GetDlgItem(hwndDlg, IDC_TOOLTIP),TTM_TRACKACTIVATE,(WPARAM)FALSE,(LPARAM)&ti);
+ x = LOWORD(lParam);
+ y = HIWORD(lParam);
+ SendMessage(GetDlgItem(hwndDlg, IDC_TOOLTIP), TTM_TRACKPOSITION, 0, (LPARAM)MAKELPARAM(LOWORD(lParam) + X_OFFSET, HIWORD(lParam) + Y_OFFSET));
+ KillTimer(hwndDlg, TIMER_ID);
+ SetTimer(hwndDlg, TIMER_ID, 1000, 0);
+ break;
+ case WM_TIMER:
+ {
+*/
+ /*
+ //POINT p;
+ RECT r;
+ GetClientRect(GetDlgItem(hwndDlg, IDC_FONTLIST), &r);
+ DWORD lParam = MAKELPARAM(x - r.left, y - r.bottom);
+ DWORD res = SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_ITEMFROMPOINT, 0, lParam);
+ if(HIWORD(res) == 0 && HIWORD(res) >= 0) {
+ char buf[256];
+ int sel = LOWORD(res);
+ //SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETITEMRECT, (WPARAM)sel, (LPARAM)&r);
+ SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETTEXT, (WPARAM)sel, (LPARAM)buf);
+ */
+/*
+
+ KillTimer(hwndDlg, TIMER_ID);
+ SendMessage(GetDlgItem(hwndDlg, IDC_TOOLTIP),TTM_TRACKACTIVATE,(WPARAM)TRUE,(LPARAM)&ti);
+ MessageBox(hwndDlg, "Hi", "blah", MB_OK);
+ //}
+ break;
+ }
+*/
+ case WM_DESTROY:
+ KillTimer(hwndDlg, TIMER_ID);
+ DeleteObject(hBkgColourBrush);
+ break;
+ }
+ return FALSE;
+}
+
+
+
+int OptInit(WPARAM wParam, LPARAM lParam) {
+ OPTIONSDIALOGPAGE odp = {0};
+#define OPTIONPAGE_OLD_SIZE2 60
+
+ //odp.cbSize = sizeof(odp);
+ odp.cbSize = OPTIONPAGE_OLD_SIZE2;
+ odp.position = -790000000;
+ odp.hInstance = hInstance;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT2);
+ odp.pszTitle = Translate("Fonts");
+ odp.pszGroup = Translate("Customize");
+ odp.flags = ODPF_BOLDGROUPS;
+ odp.nIDBottomSimpleControl = 0;
+ odp.pfnDlgProc = DlgProcLogOptions;
+ CallService( MS_OPT_ADDPAGE, wParam,( LPARAM )&odp );
+
+ return 0;
+}
+
diff --git a/font_service/options.h b/font_service/options.h
new file mode 100644
index 0000000..f1e5cb3
--- /dev/null
+++ b/font_service/options.h
@@ -0,0 +1,3 @@
+
+int OptInit(WPARAM wParam, LPARAM lParam);
+
diff --git a/font_service/resource.h b/font_service/resource.h
new file mode 100644
index 0000000..7612d86
--- /dev/null
+++ b/font_service/resource.h
@@ -0,0 +1,50 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by resource.rc
+//
+#define IDD_DIALOG1 101
+#define IDD_OPT 101
+#define IDD_OPT2 102
+#define IDC_FONTGROUP 1000
+#define IDC_COLOURLIST 1003
+#define IDC_STAT_RESTART 1004
+#define IDC_BTN_RESET 1005
+#define IDC_BTN_UNDO 1006
+#define IDC_BTN_UNDO2 1007
+#define IDC_BTN_EXPORT 1007
+#define IDC_TOOLTIP 1008
+#define IDC_FONTLIST 1048
+#define IDC_CHOOSEFONT 1049
+#define IDC_FONTID 1256
+#define IDC_SAMETYPE 1257
+#define IDC_SAMESTYLE 1258
+#define IDC_SAMECOLOUR 1259
+#define IDC_SAMEAS 1260
+#define IDC_TYPEFACE 1261
+#define IDC_BOLD 1262
+#define IDC_ITALIC 1263
+#define IDC_COLOUR 1264
+#define IDC_UNDERLINE 1265
+#define IDC_SAMESIZE 1268
+#define IDC_BKGCOLOUR 1269
+#define IDC_FONTCOLOUR 1282
+#define IDC_SAMPLE 1292
+#define IDC_FONTSIZE 1293
+#define IDC_SCRIPT 1300
+#define IDC_STSAMETEXT 1382
+#define IDC_STASTEXT 1383
+#define IDC_STSIZETEXT 1384
+#define IDC_STCOLOURTEXT 1385
+#define IDC_STHORZBAR 1386
+#define IDD_CUSTOM_FONT 1543
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 103
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1009
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/font_service/resource.rc b/font_service/resource.rc
new file mode 100644
index 0000000..fb61593
--- /dev/null
+++ b/font_service/resource.rc
@@ -0,0 +1,133 @@
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (Australia) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENA)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_OPT2 DIALOGEX 0, 0, 293, 224
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ GROUPBOX "Fonts",IDC_STATIC,108,55,184,162
+ CONTROL "",IDC_BKGCOLOUR,"ColourPicker",WS_TABSTOP,236,23,43,12
+ LISTBOX IDC_FONTLIST,119,67,163,81,LBS_OWNERDRAWVARIABLE | LBS_NOINTEGRALHEIGHT | LBS_EXTENDEDSEL | WS_VSCROLL | WS_TABSTOP
+ CONTROL "",IDC_FONTCOLOUR,"ColourPicker",WS_TABSTOP,132,154,57,14
+ PUSHBUTTON "Choose font...",IDC_CHOOSEFONT,208,154,57,14
+ CTEXT "Select multiple fonts by dragging or by using the control key",IDC_STATIC,135,174,131,16
+ COMBOBOX IDC_COLOURLIST,122,23,102,107,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
+ GROUPBOX "Colours",IDC_STATIC,108,7,184,45
+ LTEXT "* you may need to restart for the changes to take effect",IDC_STAT_RESTART,113,39,176,8,NOT WS_VISIBLE
+ PUSHBUTTON "Reset to Default",IDC_BTN_RESET,142,195,117,14,WS_DISABLED | NOT WS_TABSTOP
+ PUSHBUTTON "Undo",IDC_BTN_UNDO,22,188,59,11,WS_DISABLED
+ LISTBOX IDC_FONTGROUP,4,17,94,169,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
+ GROUPBOX "Font Group",IDC_STATIC,0,7,103,194
+ PUSHBUTTON "Export...",IDC_BTN_EXPORT,0,204,104,14
+END
+
+IDD_CUSTOM_FONT DIALOG 13, 54, 287, 196
+STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_CONTEXTHELP | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Font"
+FONT 8, "MS Shell Dlg"
+BEGIN
+ LTEXT "&Font:",1088,7,7,40,9
+ COMBOBOX 1136,7,16,98,76,CBS_SIMPLE | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | CBS_DISABLENOSCROLL | WS_VSCROLL | WS_TABSTOP
+ LTEXT "Font st&yle:",1089,110,7,44,9
+ COMBOBOX 1137,110,16,74,76,CBS_SIMPLE | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
+ LTEXT "&Size:",1090,189,7,30,9
+ COMBOBOX 1138,190,16,36,76,CBS_SIMPLE | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | CBS_DISABLENOSCROLL | WS_VSCROLL | WS_TABSTOP
+ GROUPBOX "Effects",1072,7,97,98,72,WS_GROUP
+ CONTROL "Stri&keout",1040,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,110,49,10
+ CONTROL "&Underline",1041,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,123,51,10
+ LTEXT "&Color:",1091,13,136,30,9,NOT WS_VISIBLE
+ COMBOBOX 1139,13,146,82,100,CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_HASSTRINGS | NOT WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ GROUPBOX "Sample",1073,110,97,116,43,WS_GROUP
+ CTEXT "AaBbYyZz",1092,118,111,100,23,SS_NOPREFIX | NOT WS_VISIBLE
+ LTEXT "",1093,7,172,219,20,SS_NOPREFIX | NOT WS_GROUP
+ LTEXT "Sc&ript:",1094,110,147,30,9
+ COMBOBOX 1140,110,157,116,30,CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "OK",IDOK,231,16,45,14,WS_GROUP
+ PUSHBUTTON "Cancel",IDCANCEL,231,32,45,14,WS_GROUP
+ PUSHBUTTON "&Apply",1026,231,48,45,14,WS_GROUP
+ PUSHBUTTON "&Help",1038,231,64,45,14,WS_GROUP
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_OPT2, DIALOG
+ BEGIN
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 217
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+#endif // English (Australia) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/font_service/services.cpp b/font_service/services.cpp
new file mode 100644
index 0000000..c20b3b6
--- /dev/null
+++ b/font_service/services.cpp
@@ -0,0 +1,358 @@
+#include "common.h"
+#include "services.h"
+
+#include <algorithm>
+
+int code_page = CP_ACP;
+
+void ConvertFontSettings(FontSettings *fs, FontSettingsW *fsw) {
+ fsw->colour = fs->colour;
+ fsw->size = fs->size;
+ fsw->style = fs->style;
+ fsw->charset = fs->charset;
+
+ MultiByteToWideChar(code_page, 0, fs->szFace, -1, fsw->szFace, LF_FACESIZE);
+}
+
+void ConvertFontID(FontID *fid, FontIDW *fidw) {
+ fidw->cbSize = sizeof(FontIDW);
+ strcpy(fidw->dbSettingsGroup, fid->dbSettingsGroup);
+ strcpy(fidw->prefix, fid->prefix);
+ fidw->flags = fid->flags;
+ fidw->order = fid->order;
+ ConvertFontSettings(&fid->deffontsettings, &fidw->deffontsettings);
+
+ MultiByteToWideChar(code_page, 0, fid->group, -1, fidw->group, 64);
+ MultiByteToWideChar(code_page, 0, fid->name, -1, fidw->name, 64);
+}
+
+void ConvertColourID(ColourID *cid, ColourIDW *cidw) {
+ cidw->cbSize = sizeof(ColourIDW);
+
+ strcpy(cidw->dbSettingsGroup, cid->dbSettingsGroup);
+ strcpy(cidw->setting, cid->setting);
+ cidw->flags = cid->flags;
+ cidw->defcolour = cid->defcolour;
+ cidw->order = cid->order;
+
+ MultiByteToWideChar(code_page, 0, cid->group, -1, cidw->group, 64);
+ MultiByteToWideChar(code_page, 0, cid->name, -1, cidw->name, 64);
+}
+
+void ConvertLOGFONT(LOGFONTW *lfw, LOGFONTA *lfa) {
+ lfa->lfHeight = lfw->lfHeight;
+ lfa->lfWidth = lfw->lfWidth;
+ lfa->lfEscapement = lfw->lfEscapement;
+ lfa->lfOrientation = lfw->lfOrientation;
+ lfa->lfWeight = lfw->lfWeight;
+ lfa->lfItalic = lfw->lfItalic;
+ lfa->lfUnderline = lfw->lfUnderline;
+ lfa->lfStrikeOut = lfw->lfStrikeOut;
+ lfa->lfCharSet = lfw->lfCharSet;
+ lfa->lfOutPrecision = lfw->lfOutPrecision;
+ lfa->lfClipPrecision = lfw->lfClipPrecision;
+ lfa->lfQuality = lfw->lfQuality;
+ lfa->lfPitchAndFamily = lfw->lfPitchAndFamily;
+
+ WideCharToMultiByte(code_page, 0, lfw->lfFaceName, -1, lfa->lfFaceName, LF_FACESIZE, 0, 0);
+}
+
+bool operator <(const FontIDW &id1, const FontIDW &id2) {
+ int db_cmp = strncmp(id1.dbSettingsGroup, id2.dbSettingsGroup, sizeof(id1.dbSettingsGroup));
+ if(db_cmp) {
+ return db_cmp < 0;
+ }
+
+ return wcsncmp(id1.group, id2.group, sizeof(id1.group)) < 0
+ || (wcsncmp(id1.group, id2.group, sizeof(id1.group)) == 0 && id1.order < id2.order)
+ || (wcsncmp(id1.group, id2.group, sizeof(id1.group)) == 0 && id1.order == id2.order && wcsncmp(id1.name, id2.name, sizeof(id1.name)) < 0);
+}
+
+bool operator <(const ColourIDW &id1, const ColourIDW &id2) {
+ int db_cmp = strncmp(id1.dbSettingsGroup, id2.dbSettingsGroup, sizeof(id1.dbSettingsGroup));
+ if(db_cmp) {
+ return db_cmp < 0;
+ }
+
+ return wcsncmp(id1.group, id2.group, sizeof(id1.group)) < 0
+ || (wcsncmp(id1.group, id2.group, sizeof(id1.group)) == 0 && id1.order < id2.order)
+ || (wcsncmp(id1.group, id2.group, sizeof(id1.group)) == 0 && id1.order == id2.order && wcsncmp(id1.name, id2.name, sizeof(id1.name)) < 0);
+}
+
+bool operator ==(const FontIDW &id1, const FontIDW &id2) {
+ int db_cmp = strncmp(id1.dbSettingsGroup, id2.dbSettingsGroup, sizeof(id1.dbSettingsGroup));
+ if(db_cmp == 0) {
+ return true;
+ }
+
+ return wcsncmp(id1.group, id2.group, sizeof(id1.group)) == 0 && id1.order == id2.order && wcsncmp(id1.name, id2.name, sizeof(id1.name)) == 0;
+}
+
+bool operator ==(const ColourIDW &id1, const ColourIDW &id2) {
+ int db_cmp = strncmp(id1.dbSettingsGroup, id2.dbSettingsGroup, sizeof(id1.dbSettingsGroup));
+ if(db_cmp == 0) {
+ return true;
+ }
+
+ return wcsncmp(id1.group, id2.group, sizeof(id1.group)) == 0 && id1.order == id2.order && wcsncmp(id1.name, id2.name, sizeof(id1.name)) == 0;
+}
+
+/*
+bool operator <(const FontIDSettingsWPair &id1, const FontIDSettingsWPair &id2) {
+ return id1.first < id2.first;
+}
+
+bool operator <(const ColourIDColourWPair &id1, const ColourIDColourWPair &id2) {
+ return id1.first < id2.first;
+}
+*/
+
+FontIDWList font_id_list_w;
+ColourIDWList colour_id_list_w;
+
+static void GetDefaultFontSettingW(LOGFONTW * lf, COLORREF * colour)
+{
+ SystemParametersInfoW(SPI_GETICONTITLELOGFONT, sizeof(LOGFONTW), lf, FALSE);
+ if(colour) *colour = GetSysColor(COLOR_WINDOWTEXT);
+ lf->lfHeight = 10;
+
+ HDC hdc = GetDC(0);
+ lf->lfHeight = -MulDiv(lf->lfHeight,GetDeviceCaps(hdc, LOGPIXELSY), 72);
+ ReleaseDC(0, hdc);
+}
+
+int GetFontSettingFromDBW(char *settings_group, char *prefix, LOGFONTW * lf, COLORREF * colour, DWORD flags)
+{
+ DBVARIANT dbv;
+ char idstr[256];
+ BYTE style;
+ int retval = 0;
+
+ GetDefaultFontSettingW(lf, colour);
+
+ if(flags & FIDF_APPENDNAME) sprintf(idstr, "%sName", prefix);
+ else sprintf(idstr, "%s", prefix);
+
+ if (!DBGetContactSettingWString(NULL, settings_group, idstr, &dbv)) {
+ wcscpy(lf->lfFaceName, dbv.pwszVal);
+ mir_free(dbv.pwszVal);
+ } else if(!DBGetContactSetting(NULL, settings_group, idstr, &dbv)) {
+ if(dbv.type == DBVT_ASCIIZ) {
+ wchar_t buff[1024];
+ MultiByteToWideChar(code_page, 0, dbv.pszVal, -1, buff, 1024);
+ wcscpy(lf->lfFaceName, buff);
+ } else
+ retval = 1;
+ DBFreeVariant(&dbv);
+ } else
+ retval = 1;
+
+ if(colour) {
+ sprintf(idstr, "%sCol", prefix);
+ *colour = DBGetContactSettingDword(NULL, settings_group, idstr, *colour);
+ }
+
+ sprintf(idstr, "%sSize", prefix);
+ lf->lfHeight = (char)DBGetContactSettingByte(NULL, settings_group, idstr, lf->lfHeight);
+
+
+ //wsprintf(idstr, "%sFlags", prefix);
+ //if(DBGetContactSettingDword(NULL, settings_group, idstr, 0) & FIDF_SAVEACTUALHEIGHT) {
+ // HDC hdc = GetDC(0);
+ // lf->lfHeight = -lf->lfHeight;
+ // ReleaseDC(0, hdc);
+ //}
+
+ sprintf(idstr, "%sSty", prefix);
+ style = (BYTE) DBGetContactSettingByte(NULL, settings_group, idstr,
+ (lf->lfWeight == FW_NORMAL ? 0 : DBFONTF_BOLD) | (lf->lfItalic ? DBFONTF_ITALIC : 0) | (lf->lfUnderline ? DBFONTF_UNDERLINE : 0) | lf->lfStrikeOut ? DBFONTF_STRIKEOUT : 0);
+
+ lf->lfWidth = lf->lfEscapement = lf->lfOrientation = 0;
+ lf->lfWeight = style & DBFONTF_BOLD ? FW_BOLD : FW_NORMAL;
+ lf->lfItalic = (style & DBFONTF_ITALIC) != 0;
+ lf->lfUnderline = (style & DBFONTF_UNDERLINE) != 0;
+ lf->lfStrikeOut = (style & DBFONTF_STRIKEOUT) != 0;
+
+ sprintf(idstr, "%sSet", prefix);
+ lf->lfCharSet = DBGetContactSettingByte(NULL, settings_group, idstr, lf->lfCharSet);
+
+ lf->lfOutPrecision = OUT_DEFAULT_PRECIS;
+ lf->lfClipPrecision = CLIP_DEFAULT_PRECIS;
+ lf->lfQuality = DEFAULT_QUALITY;
+ lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
+
+ if(lf->lfHeight > 0) {
+ HDC hdc = GetDC(0);
+ if(flags & FIDF_SAVEPOINTSIZE) {
+ lf->lfHeight = -MulDiv(lf->lfHeight,GetDeviceCaps(hdc, LOGPIXELSY), 72);
+ } else { // assume SAVEACTUALHEIGHT
+ TEXTMETRIC tm;
+ HFONT hFont = CreateFontIndirectW(lf);
+ HFONT hOldFont = (HFONT)SelectObject(hdc, hFont);
+
+ GetTextMetrics(hdc, &tm);
+
+ lf->lfHeight = -(lf->lfHeight - tm.tmInternalLeading);
+
+ SelectObject(hdc, hOldFont);
+ DeleteObject(hFont);
+ }
+ //lf->lfHeight = -MulDiv(lf->lfHeight, GetDeviceCaps(hdc, LOGPIXELSY), 72);
+ ReleaseDC(0, hdc);
+ }
+
+ return retval;
+}
+
+int CreateFromFontSettingsW(FontSettingsW *fs, LOGFONTW *lf, DWORD flags) {
+ GetDefaultFontSettingW(lf, 0);
+
+ wcscpy(lf->lfFaceName, fs->szFace);
+
+ lf->lfWidth = lf->lfEscapement = lf->lfOrientation = 0;
+ lf->lfWeight = fs->style & DBFONTF_BOLD ? FW_BOLD : FW_NORMAL;
+ lf->lfItalic = (fs->style & DBFONTF_ITALIC) != 0;
+ lf->lfUnderline = (fs->style & DBFONTF_UNDERLINE) != 0;
+ lf->lfStrikeOut = (fs->style & DBFONTF_STRIKEOUT) != 0;;
+ lf->lfCharSet = fs->charset;
+ lf->lfOutPrecision = OUT_DEFAULT_PRECIS;
+ lf->lfClipPrecision = CLIP_DEFAULT_PRECIS;
+ lf->lfQuality = DEFAULT_QUALITY;
+ lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
+
+ lf->lfHeight = fs->size;
+ //if(flags & FIDF_SAVEACTUALHEIGHT) {
+ // HDC hdc = GetDC((HWND)CallService(MS_CLUI_GETHWND, 0, 0));
+ // lf->lfHeight = -MulDiv(lf->lfHeight, GetDeviceCaps(hdc, LOGPIXELSY), 72);
+ //}
+
+ return 0;
+}
+
+void UpdateFontSettingsW(FontIDW *font_id, FontSettingsW *fontsettings) {
+ LOGFONTW lf;
+ COLORREF colour;
+ if(GetFontSettingFromDBW(font_id->dbSettingsGroup, font_id->prefix, &lf, &colour, font_id->flags) && (font_id->flags & FIDF_DEFAULTVALID)) {
+ CreateFromFontSettingsW(&font_id->deffontsettings, &lf, font_id->flags);// & ~FIDF_SAVEACTUALHEIGHT);
+ colour = font_id->deffontsettings.colour;
+ }
+
+ fontsettings->style =
+ (lf.lfWeight == FW_NORMAL ? 0 : DBFONTF_BOLD) | (lf.lfItalic ? DBFONTF_ITALIC : 0) | (lf.lfUnderline ? DBFONTF_UNDERLINE : 0) | (lf.lfStrikeOut ? DBFONTF_STRIKEOUT : 0);
+
+ fontsettings->size = (char)lf.lfHeight;
+
+ fontsettings->charset = lf.lfCharSet;
+ fontsettings->colour = colour;
+ wcscpy(fontsettings->szFace, lf.lfFaceName);
+}
+
+int RegisterFontW(WPARAM wParam, LPARAM lParam) {
+ FontIDW *font_id = (FontIDW *)wParam;
+ FontSettingsW fontsettings;
+
+ for(FontIDWList::Iterator i = font_id_list_w.start(); i.has_val(); i.next()) {
+ if(wcscmp(i.val().first.group, font_id->group) == 0 && wcscmp(i.val().first.name, font_id->name) == 0)
+ if((i.val().first.flags & FIDF_ALLOWREREGISTER) == 0)
+ return 1;
+ }
+
+ char idstr[256];
+ sprintf(idstr, "%sFlags", font_id->prefix);
+ DBWriteContactSettingDword(0, font_id->dbSettingsGroup, idstr, font_id->flags);
+
+ UpdateFontSettingsW(font_id, &fontsettings);
+
+ FontIDSettingsWPair p(*font_id, fontsettings);
+ font_id_list_w.add(p);
+
+ return 0;
+}
+
+int RegisterFont(WPARAM wParam, LPARAM lParam) {
+ FontID *font_id = (FontID *)wParam;
+ FontIDW font_id_w;
+ ConvertFontID(font_id, &font_id_w);
+ return RegisterFontW((WPARAM)&font_id_w, 0);
+}
+
+int GetFontW(WPARAM wParam, LPARAM lParam) {
+ FontIDW *font_id = (FontIDW *)wParam;
+ LOGFONTW *lf = (LOGFONTW *)lParam;
+ COLORREF colour;
+
+ for(FontIDWList::Iterator i = font_id_list_w.start(); i.has_val(); i.next()) {
+ if(wcsncmp(i.val().first.name, font_id->name, 64) == 0
+ && wcsncmp(i.val().first.group, font_id->group, 64) == 0)
+ {
+ if(GetFontSettingFromDBW(i.val().first.dbSettingsGroup, i.val().first.prefix, lf, &colour, i.val().first.flags) && (i.val().first.flags & FIDF_DEFAULTVALID)) {
+ CreateFromFontSettingsW(&i.val().first.deffontsettings, lf, i.val().first.flags);
+ colour = i.val().first.deffontsettings.colour;
+ }
+
+ return (int)colour;
+ }
+ }
+
+ GetDefaultFontSettingW(lf, &colour);
+ return (int)colour;
+}
+
+int GetFont(WPARAM wParam, LPARAM lParam) {
+ FontID *font_id = (FontID *)wParam;
+ LOGFONTA *lf = (LOGFONTA *)lParam;
+
+ FontIDW font_id_w;
+ LOGFONTW lfw;
+ ConvertFontID(font_id, &font_id_w);
+ int ret = GetFontW((WPARAM)&font_id_w, (LPARAM)&lfw);
+ ConvertLOGFONT(&lfw, lf);
+ return ret;
+}
+
+void UpdateColourSettingsW(ColourIDW *colour_id, COLORREF *colour) {
+ *colour = (COLORREF)DBGetContactSettingDword(NULL, colour_id->dbSettingsGroup, colour_id->setting, colour_id->defcolour);
+}
+
+int RegisterColourW(WPARAM wParam, LPARAM lParam) {
+ ColourIDW *colour_id = (ColourIDW *)wParam;
+ COLORREF colour;
+
+ for(ColourIDWList::Iterator i = colour_id_list_w.start(); i.has_val(); i.next()) {
+ if(wcscmp(i.val().first.group, colour_id->group) == 0 && wcscmp(i.val().first.name, colour_id->name) == 0)
+ return 1;
+ }
+
+ UpdateColourSettingsW(colour_id, &colour);
+
+ ColourIDColourWPair p(*colour_id, colour);
+ colour_id_list_w.add(p);
+
+ return 0;
+}
+
+int RegisterColour(WPARAM wParam, LPARAM lParam) {
+ ColourID *colour_id = (ColourID *)wParam;
+ ColourIDW colour_id_w;
+ ConvertColourID(colour_id, &colour_id_w);
+ return RegisterColourW((WPARAM)&colour_id_w, 0);
+}
+
+int GetColourW(WPARAM wParam, LPARAM lParam) {
+ ColourIDW *colour_id = (ColourIDW *)wParam;
+ for(ColourIDWList::Iterator i = colour_id_list_w.start(); i.has_val(); i.next()) {
+ if(wcscmp(i.val().first.group, colour_id->group) == 0 && wcscmp(i.val().first.name, colour_id->name) == 0)
+ return (int)DBGetContactSettingDword(NULL, colour_id->dbSettingsGroup, colour_id->setting, i.val().first.defcolour);
+ }
+
+ return -1;
+}
+
+
+int GetColour(WPARAM wParam, LPARAM lParam) {
+ ColourID *colour_id = (ColourID *)wParam;
+ ColourIDW colour_id_w;
+ ConvertColourID(colour_id, &colour_id_w);
+ return GetColourW((WPARAM)&colour_id_w, 0);
+}
+
diff --git a/font_service/services.h b/font_service/services.h
new file mode 100644
index 0000000..dbafe16
--- /dev/null
+++ b/font_service/services.h
@@ -0,0 +1,46 @@
+#ifndef SERVICES_INC
+#define SERVICES_INC
+
+#include "m_fontservice.h"
+
+#include "collection.h"
+
+int RegisterFont(WPARAM wParam, LPARAM lParam);
+int GetFont(WPARAM wParam, LPARAM lParam);
+
+int RegisterColour(WPARAM wParam, LPARAM lParam);
+int GetColour(WPARAM wParam, LPARAM lParam);
+
+typedef Pair<FontID, FontSettings> FontIDSettingsPair;
+typedef Pair<ColourID, COLORREF> ColourIDColourPair;
+
+#include "m_fontservicew.h"
+
+typedef Pair<FontIDW, FontSettingsW> FontIDSettingsWPair;
+typedef Pair<ColourIDW, COLORREF> ColourIDColourWPair;
+
+typedef SortedDynamicArray< FontIDSettingsWPair > FontIDWList;
+typedef SortedDynamicArray< ColourIDColourWPair > ColourIDWList;
+
+bool operator <(const FontIDW &id1, const FontIDW &id2);
+bool operator <(const ColourIDW &id1, const ColourIDW &id2);
+bool operator ==(const FontIDW &id1, const FontIDW &id2);
+bool operator ==(const ColourIDW &id1, const ColourIDW &id2);
+
+//bool operator <(const FontIDSettingsWPair &id1, const FontIDSettingsWPair &id2);
+//bool operator <(const ColourIDColourWPair &id1, const ColourIDColourWPair &id2);
+
+extern FontIDWList font_id_list_w;
+extern ColourIDWList colour_id_list_w;
+
+int CreateFromFontSettingsW(FontSettingsW *fs, LOGFONTW *lf, DWORD flags);
+
+int RegisterFontW(WPARAM wParam, LPARAM lParam);
+int GetFontW(WPARAM wParam, LPARAM lParam);
+
+int RegisterColourW(WPARAM wParam, LPARAM lParam);
+int GetColourW(WPARAM wParam, LPARAM lParam);
+
+extern int code_page;
+
+#endif