Index: ch.vc90.sln =================================================================== diff -u -N -rd032934a99b3bf6a7db2e5953159688627919dba -rcb588a864d28da44cc192760595d3c5ad6f2fac9 --- ch.vc90.sln (.../ch.vc90.sln) (revision d032934a99b3bf6a7db2e5953159688627919dba) +++ ch.vc90.sln (.../ch.vc90.sln) (revision cb588a864d28da44cc192760595d3c5ad6f2fac9) @@ -3,6 +3,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ch", "src\ch\ch.vc90.vcproj", "{4B215B9A-58CA-4987-AC95-7DFC3043E100}" ProjectSection(ProjectDependencies) = postProject {5510B933-046F-4F75-8B46-5E8279C8CCDE} = {5510B933-046F-4F75-8B46-5E8279C8CCDE} + {DD1F3242-7EE4-4F41-8B8D-D833300C445F} = {DD1F3242-7EE4-4F41-8B8D-D833300C445F} {7CE8B0C5-8CD4-4551-ACBF-EC4749E15E69} = {7CE8B0C5-8CD4-4551-ACBF-EC4749E15E69} EndProjectSection EndProject @@ -13,6 +14,8 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libicpf", "src\libicpf\libicpf.vc90.vcproj", "{5510B933-046F-4F75-8B46-5E8279C8CCDE}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libictranslate", "src\libictranslate\libictranslate.vc90.vcproj", "{DD1F3242-7EE4-4F41-8B8D-D833300C445F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug-Unicode|Win32 = Debug-Unicode|Win32 @@ -45,6 +48,14 @@ {5510B933-046F-4F75-8B46-5E8279C8CCDE}.Release-Unicode|Win32.Build.0 = Release-Unicode|Win32 {5510B933-046F-4F75-8B46-5E8279C8CCDE}.Release-Unicode|x64.ActiveCfg = Release-Unicode|x64 {5510B933-046F-4F75-8B46-5E8279C8CCDE}.Release-Unicode|x64.Build.0 = Release-Unicode|x64 + {DD1F3242-7EE4-4F41-8B8D-D833300C445F}.Debug-Unicode|Win32.ActiveCfg = Debug-Unicode|Win32 + {DD1F3242-7EE4-4F41-8B8D-D833300C445F}.Debug-Unicode|Win32.Build.0 = Debug-Unicode|Win32 + {DD1F3242-7EE4-4F41-8B8D-D833300C445F}.Debug-Unicode|x64.ActiveCfg = Debug-Unicode|x64 + {DD1F3242-7EE4-4F41-8B8D-D833300C445F}.Debug-Unicode|x64.Build.0 = Debug-Unicode|x64 + {DD1F3242-7EE4-4F41-8B8D-D833300C445F}.Release-Unicode|Win32.ActiveCfg = Release-Unicode|Win32 + {DD1F3242-7EE4-4F41-8B8D-D833300C445F}.Release-Unicode|Win32.Build.0 = Release-Unicode|Win32 + {DD1F3242-7EE4-4F41-8B8D-D833300C445F}.Release-Unicode|x64.ActiveCfg = Release-Unicode|x64 + {DD1F3242-7EE4-4F41-8B8D-D833300C445F}.Release-Unicode|x64.Build.0 = Release-Unicode|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Index: src/ch/HelpLngDialog.cpp =================================================================== diff -u -N --- src/ch/HelpLngDialog.cpp (revision e701ed2460c2558eeefab55a1f3ed1d2c89a56c0) +++ src/ch/HelpLngDialog.cpp (revision 0) @@ -1,65 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - 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., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "HelpLngDialog.h" -#include "ch.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -///////////////////////////////////////////////////////////////////////////// -// CHLanguageDialog dialog - -BEGIN_MESSAGE_MAP(CHLanguageDialog, CLanguageDialog) - ON_WM_HELPINFO() - ON_WM_CONTEXTMENU() - ON_BN_CLICKED(IDC_HELP_BUTTON, OnHelpButton) -END_MESSAGE_MAP() - -BOOL CHLanguageDialog::OnHelpInfo(HELPINFO* pHelpInfo) -{ - if (pHelpInfo->iContextType == HELPINFO_WINDOW) - { - pHelpInfo->dwContextId=(m_uiResID << 16) | pHelpInfo->iCtrlId; - return GetApp()->HtmlHelp(HH_DISPLAY_TEXT_POPUP, (LPARAM)pHelpInfo); - } - else - return false; -} - -void CHLanguageDialog::OnContextMenu(CWnd* pWnd, CPoint point) -{ - HELPINFO hi; - hi.cbSize=sizeof(HELPINFO); - hi.iCtrlId=pWnd->GetDlgCtrlID(); - hi.dwContextId=(m_uiResID << 16) | hi.iCtrlId; - hi.hItemHandle=pWnd->m_hWnd; - hi.iContextType=HELPINFO_WINDOW; - hi.MousePos=point; - - GetApp()->HtmlHelp(HH_DISPLAY_TEXT_POPUP, (LPARAM)&hi); -} - -void CHLanguageDialog::OnHelpButton() -{ - GetApp()->HtmlHelp(HH_HELP_CONTEXT, m_uiResID+0x20000); -} Index: src/ch/HelpLngDialog.h =================================================================== diff -u -N --- src/ch/HelpLngDialog.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) +++ src/ch/HelpLngDialog.h (revision 0) @@ -1,40 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - 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., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#pragma once - -#include "LanguageDialog.h" - -///////////////////////////////////////////////////////////////////////////// -// CHLanguageDialog dialog - -class CHLanguageDialog : public CLanguageDialog -{ -// Construction -public: - CHLanguageDialog(bool* pLock=NULL) : CLanguageDialog(pLock) { }; - CHLanguageDialog(PCTSTR lpszTemplateName, CWnd* pParent = NULL, bool* pLock=NULL) : CLanguageDialog(lpszTemplateName, pParent, pLock) { }; // standard constructor - CHLanguageDialog(UINT uiIDTemplate, CWnd* pParent = NULL, bool* pLock=NULL) : CLanguageDialog(uiIDTemplate, pParent, pLock) { }; // standard constructor - - BOOL OnHelpInfo(HELPINFO* pHelpInfo); - void OnContextMenu(CWnd* pWnd, CPoint point); - void OnHelpButton(); - - DECLARE_MESSAGE_MAP() -}; \ No newline at end of file Index: src/ch/LanguageDialog.cpp =================================================================== diff -u -N --- src/ch/LanguageDialog.cpp (revision 4e2dd94e077c0462949fe72a7940295eea8423fa) +++ src/ch/LanguageDialog.cpp (revision 0) @@ -1,675 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - 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., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "LanguageDialog.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -///////////////////////////////////////////////////////////////////////////// -// CDlgTemplate -CDlgTemplate::CDlgTemplate(const DLGTEMPLATE* pDlgTemplate) -{ - Open(pDlgTemplate); -} - -CDlgTemplate::CDlgTemplate(const DLGTEMPLATEEX* pDlgTemplate) -{ - Open((DLGTEMPLATE*)pDlgTemplate); -} - -CDlgTemplate::~CDlgTemplate() -{ - delete [] m_pszMenu; - delete [] m_pszClass; - delete [] m_pszTitle; - delete [] m_pszFace; - - // items - vector<_ITEM>::iterator it; - for (it=m_vItems.begin();it != m_vItems.end();it++) - { - delete [] (*it).m_pbyCreationData; - delete [] (*it).m_pszClass; - delete [] (*it).m_pszTitle; - } -} - -bool CDlgTemplate::Open(const DLGTEMPLATE* pDlgTemplate) -{ - if (pDlgTemplate == NULL) - return false; - bool bExt=((DLGTEMPLATEEX*)pDlgTemplate)->signature == 0xffff; - const BYTE* pData=((BYTE*)pDlgTemplate); - if (bExt) - { - m_dlgTemplate=*((DLGTEMPLATEEX*)pDlgTemplate); - pData+=sizeof(DLGTEMPLATEEX); - } - else - { - ConvertDlgToEx(pDlgTemplate, &m_dlgTemplate); - pData+=sizeof(DLGTEMPLATE); - } - - // here is the menu, class and title - pData=ReadCompoundData(pData, &m_wMenu, &m_pszMenu); - pData=ReadCompoundData(pData, &m_wClass, &m_pszClass); - pData=ReadCompoundData(pData, &m_wTitle, &m_pszTitle); - - // font - if (m_dlgTemplate.style & DS_SETFONT || m_dlgTemplate.style & DS_SHELLFONT) - { - m_wFontSize=*((WORD*)pData); - pData+=sizeof(WORD); - if (bExt) - { - m_wWeight=*((WORD*)pData); - pData+=sizeof(WORD); - m_byItalic=*((BYTE*)pData); - pData+=sizeof(BYTE); - m_byCharset=*((BYTE*)pData); - pData+=sizeof(BYTE); - } - else - { - m_wWeight=FW_NORMAL; - m_byItalic=FALSE; - m_byCharset=DEFAULT_CHARSET; - } - DWORD dwLen=(DWORD)wcslen((wchar_t*)pData); - m_pszFace=new TCHAR[dwLen+1]; -#ifdef _UNICODE - _tcscpy(m_pszFace, (wchar_t*)pData); -#else - WideCharToMultiByte(CP_ACP, 0, (wchar_t*)pData, dwLen+1, m_pszFace, dwLen+1, NULL, NULL); -#endif - pData+=(dwLen+1)*sizeof(wchar_t); - } - else - { - m_wFontSize=0xffff; - m_pszFace=NULL; - } - - // items - _ITEM item; - for (int i=0;i 0) - { - item.m_wCreationDataSize-=sizeof(WORD); - item.m_pbyCreationData=new BYTE[item.m_wCreationDataSize]; - memcpy(item.m_pbyCreationData, pData, item.m_wCreationDataSize); - } - else - item.m_pbyCreationData=NULL; - - m_vItems.push_back(item); - } - - return true; -} - -void CDlgTemplate::ConvertItemToEx(const DLGITEMTEMPLATE* pSrc, DLGITEMTEMPLATEEX* pDst) -{ - pDst->helpID=0; - pDst->exStyle=pSrc->dwExtendedStyle; - pDst->style=pSrc->style; - pDst->x=pSrc->x; - pDst->y=pSrc->y; - pDst->cx=pSrc->cx; - pDst->cy=pSrc->cy; - pDst->id=pSrc->id; -} - -void CDlgTemplate::ConvertDlgToEx(const DLGTEMPLATE* pSrc, DLGTEMPLATEEX* pDst) -{ - pDst->dlgVer=1; - pDst->signature=0x0000; - pDst->helpID=(ULONG)0; - pDst->exStyle=pSrc->dwExtendedStyle; - pDst->style=pSrc->style; - pDst->cDlgItems=pSrc->cdit; - pDst->x=pSrc->x; - pDst->y=pSrc->y; - pDst->cx=pSrc->cx; - pDst->cy=pSrc->cy; -} - -const BYTE* CDlgTemplate::ReadCompoundData(const BYTE* pBuffer, WORD* pwData, PTSTR* ppszStr) -{ - if (*((WORD*)pBuffer) == 0xffff) - { - *pwData=*((WORD*)(pBuffer+2)); - *ppszStr=NULL; - - return pBuffer+4; - } - else - { - *pwData=0xffff; - DWORD dwLen=(DWORD)wcslen((wchar_t*)pBuffer); - *ppszStr=new TCHAR[dwLen+1]; -#ifdef _UNICODE - _tcscpy(*ppszStr, (wchar_t*)pBuffer); -#else - WideCharToMultiByte(CP_ACP, 0, (wchar_t*)pBuffer, dwLen+1, *ppszStr, dwLen+1, NULL, NULL); -#endif - return pBuffer+(dwLen+1)*sizeof(wchar_t); - } - -} - -///////////////////////////////////////////////////////////////////////////// -// CLanguageDialog dialog - -CResourceManager *CLanguageDialog::m_prm=NULL; - -/////////////////////////////////////////////////////////////// -// Standard constructor -// pLock [in] - specifies address of a bool value that'll be -// used to check if another instance of this window has -// already been shown. Should be declared in derived class -// as 'static bool m_xxx;' and initialized to 0. -/////////////////////////////////////////////////////////////// -CLanguageDialog::CLanguageDialog(bool* pLock) : CDialog() -{ - m_pszResName=NULL; - m_uiResID=0; - m_pParent=NULL; - m_cType=-1; - m_bAutoDelete=false; - m_pFont=NULL; - m_pbLock=pLock; - m_bLockChanged=false; - m_bLockInstance=false; - m_iBaseX=m_iBaseY=0; - _ASSERT(m_prm); // make sure the CLanguageDialog::SetResManager() has been called aready - m_prm->m_lhDialogs.push_back(this); -} - -/////////////////////////////////////////////////////////////// -// Constructor that takes string based template name -// lpszTemplateName [in] - specifies the template name to load -// and show as this dialog. -// pParent [in] - logical (everyone knows) -// pLock [in] - address of a bool for dialog instance checks -/////////////////////////////////////////////////////////////// -CLanguageDialog::CLanguageDialog(PCTSTR lpszTemplateName, CWnd* pParent, bool* pLock) : CDialog() -{ - m_pszResName=lpszTemplateName; - if (IS_INTRESOURCE(lpszTemplateName)) - m_uiResID=(WORD)lpszTemplateName; - else - m_uiResID=0; - m_pParent=pParent; - m_cType=-1; - m_bAutoDelete=false; - m_pFont=NULL; - m_pbLock=pLock; - m_bLockChanged=false; - m_bLockInstance=false; - m_iBaseX=m_iBaseY=0; - _ASSERT(m_prm); // make sure the CLanguageDialog::SetResManager() has been called aready - m_prm->m_lhDialogs.push_back(this); -} - -/////////////////////////////////////////////////////////////// -// Constructor that takes UINT based template name -// uiIDTemplate [in] - specifies the template ID to load -// and show as this dialog. -// pParent [in] - logical (everyone knows) -// pLock [in] - address of a bool for dialog instance checks -/////////////////////////////////////////////////////////////// -CLanguageDialog::CLanguageDialog(UINT uiIDTemplate, CWnd* pParent, bool* pLock) : CDialog() -{ - m_pszResName=MAKEINTRESOURCE(uiIDTemplate); - m_uiResID=uiIDTemplate; - m_pParent=pParent; - m_cType=-1; - m_bAutoDelete=false; - m_pFont=NULL; - m_pbLock=pLock; - m_bLockChanged=false; - m_bLockInstance=false; - m_iBaseX=m_iBaseY=0; - _ASSERT(m_prm); // make sure the CLanguageDialog::SetResManager() has been called aready - m_prm->m_lhDialogs.push_back(this); -} - -/////////////////////////////////////////////////////////////// -// Standard destructor -// Removes itself from a list in CWinApp (not to get any window -// messages anymore). -/////////////////////////////////////////////////////////////// -CLanguageDialog::~CLanguageDialog() -{ - list::iterator it=m_prm->m_lhDialogs.begin(); - while (it != m_prm->m_lhDialogs.end()) - { - if (*it == this) - { - m_prm->m_lhDialogs.erase(it); - break; - } - - it++; - } -} - -///////////////////////////////////////////////////////////////////////////// -// CLanguageDialog message handlers - -/////////////////////////////////////////////////////////////// -// Makes properly constructed dialog modal. -// RetVal [out] - value returned by dialog proc -/////////////////////////////////////////////////////////////// -INT_PTR CLanguageDialog::DoModal() -{ - if (m_pszResName) - { - HGLOBAL hDialog=m_prm->LoadResource(RT_DIALOG, m_pszResName); - if (!InitModalIndirect(hDialog)) - return -1; - } - m_cType=0; - return CDialog::DoModal(); -} - -/////////////////////////////////////////////////////////////// -// Creates (and shows probably) this constructed dialog. -// RetVal [out] - if creation succeeded -/////////////////////////////////////////////////////////////// -BOOL CLanguageDialog::Create() -{ - _ASSERT(m_pszResName); // nothing was set as a dialog template - - if (!m_bLockInstance || m_pbLock == NULL || !(*m_pbLock)) - { - HGLOBAL hDialog=m_prm->LoadResource(RT_DIALOG, m_pszResName); - - // modeless dialog - if (!CreateIndirect(hDialog, m_pParent)) - return FALSE; - - m_cType=1; - if (m_pbLock) - { - *m_pbLock=true; - m_bLockChanged=true; - } - - return TRUE; - } - else - { - m_bLockChanged=false; - Cleanup(); - return FALSE; - } -} - -/////////////////////////////////////////////////////////////// -// Changes values based on dialog units into the values in -// pixels. Change is based on std MapDialogRect if the language -// hasn't been changed otf or takes current font into -// consideration. -// pRect [in/out] - on [in] - dialog units, on [out] - pixels -/////////////////////////////////////////////////////////////// -void CLanguageDialog::MapRect(RECT* pRect) -{ - if (m_pFont) - { - pRect->left=MulDiv(pRect->left, m_iBaseX, 4); - pRect->right=MulDiv(pRect->right, m_iBaseX, 4); - pRect->top=MulDiv(pRect->top, m_iBaseY, 8); - pRect->bottom=MulDiv(pRect->bottom, m_iBaseY, 8); - } - else - MapDialogRect(pRect); -} - -/////////////////////////////////////////////////////////////// -// Helper function - called when this dialog receives message -// WM_RMNOTIFY (with WPARAM == RMNT_LANGCHANGE). Updates the -// dialog with data from a new template. Passes params to -// virtual function OnLanguageChanged. -// wOldLang [in] - specifies the old language code -// wNewLang [in] - specifies the new language code. -/////////////////////////////////////////////////////////////// -void CLanguageDialog::UpdateLanguage(WORD /*wOldLang*/, WORD /*wNewLang*/) -{ - // cannot update for string based template - if (m_uiResID == 0) - return; - - // set the title - SetWindowText(m_prm->LoadString((WORD)m_uiResID, 0)); - - // load the dialog template - CDlgTemplate dt; - if (!dt.Open(m_prm->LoadDialog(MAKEINTRESOURCE(m_uiResID)))) - { - TRACE("Cannot open dialog template in UpdateLanguage\n"); - return; - } - - // update the menu - if (GetMenu()) - m_prm->UpdateMenu(GetMenu()->m_hMenu, dt.m_wMenu); - - // font - if (!(GetLanguageUpdateOptions() & LDF_NODIALOGFONT)) - { - // dialog font - LOGFONT lf; - memset(&lf, 0, sizeof(LOGFONT)); - HDC hdc=::GetDC(NULL); - lf.lfHeight = -MulDiv(m_prm->m_ld.GetPointSize(), GetDeviceCaps(hdc, LOGPIXELSY), 72); - ::ReleaseDC(NULL, hdc); - lf.lfWeight = FW_NORMAL; - lf.lfCharSet = m_prm->m_ld.GetCharset(); - _tcscpy(lf.lfFaceName, m_prm->m_ld.GetFontFace()); - - delete m_pFont; - m_pFont=new CFont(); - m_pFont->CreateFontIndirect(&lf); - - // change base dlg units - CalcBaseUnits(dt.m_pszFace, dt.m_wFontSize); - } - - if (!(GetLanguageUpdateOptions() & LDF_NODIALOGSIZE)) - { - // dialog size - CRect rcWin; - GetWindowRect(&rcWin); - - CRect rcDialog(0, 0, dt.m_dlgTemplate.cx, dt.m_dlgTemplate.cy); - MapRect(&rcDialog); - rcDialog.bottom+=2*GetSystemMetrics(SM_CYDLGFRAME)+GetSystemMetrics(SM_CYCAPTION); - - // correct the height by a menu height - if ((dt.m_wMenu != 0xffff) || ((dt.m_pszMenu != NULL) && _tcslen(dt.m_pszMenu) != 0)) - rcDialog.bottom+=GetSystemMetrics(SM_CYMENU); - - rcDialog.right+=2*GetSystemMetrics(SM_CXDLGFRAME); - rcDialog.OffsetRect(rcWin.CenterPoint().x-rcDialog.Width()/2, rcWin.CenterPoint().y-rcDialog.Height()/2); - - //TEMP - TRACE("Old dlg pos/size: x=%lu, y=%lu, cx=%lu, cy=%lu; \n\tNew dlg pos/size: x=%lu, y=%lu, cx=%lu, cy=%lu\n", rcWin.left, rcWin.top, rcWin.Width(), rcWin.Height(), rcDialog.left, rcDialog.top, rcDialog.Width(), rcDialog.Height()); - SetWindowPos(NULL, rcDialog.left, rcDialog.top, rcDialog.Width(), rcDialog.Height(), SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE); - } - - // the controls - CWnd* pWnd; - vector::iterator it; - for (it=dt.m_vItems.begin();it != dt.m_vItems.end();it++) - { - // skip controls that cannot be modified - if ( (*it).m_itemTemplate.id == 0xffff || (pWnd=GetDlgItem((*it).m_itemTemplate.id)) == NULL) - continue; - - // the font - if (!(GetLanguageUpdateOptions() & LDF_NODIALOGFONT)) - pWnd->SetFont(m_pFont, FALSE); - - // style&ex style - // modify only the rtl/ltr reading order - LONG lStyleEx=::GetWindowLong(pWnd->m_hWnd, GWL_EXSTYLE); - if (lStyleEx & WS_EX_RTLREADING) - { - if (!m_prm->m_ld.GetDirection()) - lStyleEx &= ~WS_EX_RTLREADING; - } - else - { - if (m_prm->m_ld.GetDirection()) - lStyleEx |= WS_EX_RTLREADING; - } - - ::SetWindowLong(pWnd->m_hWnd, GWL_EXSTYLE, lStyleEx); - - // size - CRect rc((*it).m_itemTemplate.x, (*it).m_itemTemplate.y, (*it).m_itemTemplate.x+(*it).m_itemTemplate.cx, (*it).m_itemTemplate.y+(*it).m_itemTemplate.cy); - MapRect(&rc); - pWnd->SetWindowPos(NULL, rc.left, rc.top, rc.Width(), rc.Height(), SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE); - - // text/caption - if ( (*it).m_wClass == 0x0080 || (*it).m_wClass == 0x0082 || (*it).m_wClass == 0x0086 || ((*it).m_pszClass != NULL && _tcscmp((*it).m_pszClass, _T("STATICEX")) == 0) ) - pWnd->SetWindowText(m_prm->LoadString((WORD)m_uiResID, (*it).m_itemTemplate.id)); - } -} - -/////////////////////////////////////////////////////////////// -// Helper function - does the cleanup after destroying the -// dialog (that means releasing the instance lock, deleting -// unused fonts and in some cases deleting itself). -/////////////////////////////////////////////////////////////// -void CLanguageDialog::Cleanup() -{ - TRACE("CLanguageDialog::Cleanup()\n"); - - if (m_bLockChanged && m_pbLock) - *m_pbLock=false; - - delete m_pFont; - - if (m_bAutoDelete) - delete this; -} - -/////////////////////////////////////////////////////////////// -// Standard msg - initializes tool tip handling -/////////////////////////////////////////////////////////////// -BOOL CLanguageDialog::OnInitDialog() -{ - CDialog::OnInitDialog(); - - UpdateLanguage(0,0); // because initially all the texts are empty - - EnableToolTips(TRUE); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -/////////////////////////////////////////////////////////////// -// Standard handler for pressing cancel button in a dialog. -// For modeless dialog causes dialog to be destroyed. -/////////////////////////////////////////////////////////////// -void CLanguageDialog::OnCancel() -{ - switch (m_cType) - { - case 0: - CDialog::OnCancel(); - break; - case 1: - DestroyWindow(); - break; - } -} - -/////////////////////////////////////////////////////////////// -// Standard handler for pressing OK button in a dialog. -// For modeless dialog causes destruction of a dialog. -/////////////////////////////////////////////////////////////// -void CLanguageDialog::OnOK() -{ - switch(m_cType) - { - case 0: - CDialog::OnOK(); - break; - case 1: - DestroyWindow(); - break; - } -} - -/////////////////////////////////////////////////////////////// -// Standard override - calls cleanup. -/////////////////////////////////////////////////////////////// -void CLanguageDialog::PostNcDestroy() -{ - CDialog::PostNcDestroy(); - Cleanup(); -} - -/////////////////////////////////////////////////////////////// -// This dialog's window procedure handler - look at ms docs. -/////////////////////////////////////////////////////////////// -LRESULT CLanguageDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) -{ - switch(message) - { - case WM_RMNOTIFY: - if ((UINT)wParam == RMNT_LANGCHANGE) - { - UpdateLanguage(HIWORD(lParam), LOWORD(lParam)); - - // now update user controls (everybody has to do it him(her)self) - OnLanguageChanged(HIWORD(lParam), LOWORD(lParam)); - break; - } - case WM_NOTIFY: - { - NMHDR* pnmh=(NMHDR*)lParam; - if (pnmh->code == TTN_NEEDTEXT) - { - // establish the ID of a control - TOOLTIPTEXT *ppt=(TOOLTIPTEXT*)pnmh; - UINT nID; - if (ppt->uFlags & TTF_IDISHWND) - nID=(UINT)::GetDlgCtrlID((HWND)pnmh->idFrom); - else - nID=(UINT)pnmh->idFrom; - - return OnTooltipText(nID, ppt); - } - break; - } - } - - return CDialog::WindowProc(message, wParam, lParam); -} - -/////////////////////////////////////////////////////////////// -// Helper function. Recalculates current sizes of a dialog base -// units (font dependent) and stores in the internal members. -// pszFacename [in] - font's face name. -// wPointSize [in] - size of the font in points. -/////////////////////////////////////////////////////////////// -void CLanguageDialog::CalcBaseUnits(PCTSTR pszFacename, WORD wPointSize) -{ - LOGFONT lf; - HDC hDC = ::GetDC(NULL); - memset(&lf, 0, sizeof(LOGFONT)); - lf.lfHeight = -MulDiv(wPointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72); - lf.lfWeight = FW_NORMAL; - lf.lfCharSet = DEFAULT_CHARSET; - lstrcpy(lf.lfFaceName, pszFacename); - - HFONT hNewFont = CreateFontIndirect(&lf); - if (hNewFont != NULL) - { - HFONT hFontOld = (HFONT)SelectObject(hDC, hNewFont); - TEXTMETRIC tm; - GetTextMetrics(hDC, &tm); - m_iBaseY = tm.tmHeight + tm.tmExternalLeading; - SIZE size; - ::GetTextExtentPoint32(hDC, _T("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"), 52, &size); - m_iBaseX = (size.cx + 26) / 52; - SelectObject(hDC, hFontOld); - DeleteObject(hNewFont); - } - else - { - // Could not create the font so just use the system's values - m_iBaseX = LOWORD(GetDialogBaseUnits()); - m_iBaseY = HIWORD(GetDialogBaseUnits()); - } - ::ReleaseDC(NULL, hDC); -} \ No newline at end of file Index: src/ch/LanguageDialog.h =================================================================== diff -u -N --- src/ch/LanguageDialog.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) +++ src/ch/LanguageDialog.h (revision 0) @@ -1,202 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - 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., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -/************************************************************************* - CLanguageDialog template - - Files: LanguageDialog.h, LanguageDialog.cpp - Author: Ixen Gerthannes - Usage: - Derive your class from CLanguageDialog instead of CDialog, change all - calls from CDialog to CLanguageDialog, change call to base constructor - so it can take language as parameter. - Creating dialog class: - - derive class from CLanguageDialog - - change all occurences of CDialog to CLanguageDialog - - change parameters list of your default constructor so it can take - language as parameter (WORD wLang) - - modify call to base class constructor by putting into it declared - wLang from your constructor - Displaying dialog box: - - declare object as your dialog class - - eventually set public member m_bAutoDelete to true if you're - creating dialog with operator new, and it should be - automatically deleted when closed - - call DoModal/Create/CreateModeless member function for - modal/modeless/mixed mode dialog - Members: - Constructors - as described in CDialog constructors - language - specifies resource language to load - CLanguageDialog(); - CLanguageDialog(PCTSTR lpszTemplateName, CWnd* pParent = NULL); - CLanguageDialog(UINT uiIDTemplate, CWnd* pParent = NULL); - Functions: - int DoModal(); - like in CDialog - BOOL Create(); - creates modeless dialog box; this class - automatically handles DestroyWindow, and like - void Cleanup(); - function cleans unused data - use only when - window object wasn't created yet (in Create() and earlier) - WORD GetCurrentLanguage() const; - retrieves current language - setting for this dialog - Attributes: - bool m_bAutoDelete; - specifies whether this dialog should be - deleted (by 'delete this') when closed. -*************************************************************************/ -#pragma once - -#include "ResourceManager.h" - -#pragma pack(push, 1) -struct DLGTEMPLATEEX -{ - WORD dlgVer; - WORD signature; - DWORD helpID; - DWORD exStyle; - DWORD style; - WORD cDlgItems; - short x; - short y; - short cx; - short cy; -}; - -struct DLGITEMTEMPLATEEX -{ - DWORD helpID; - DWORD exStyle; - DWORD style; - short x; - short y; - short cx; - short cy; - WORD id; - WORD __DUMMY__; -}; -#pragma pack(pop) - -class CDlgTemplate -{ -public: - CDlgTemplate() { m_wMenu=(WORD)-1; m_pszMenu=NULL; m_wClass=(WORD)-1; m_pszClass=NULL, m_wTitle=(WORD)-1; m_pszTitle=NULL; m_wFontSize=0; m_wWeight=0; m_byItalic=0; m_byCharset=0; m_pszFace=NULL; }; - CDlgTemplate(const DLGTEMPLATE* pDlgTemplate); - CDlgTemplate(const DLGTEMPLATEEX* pDlgTemplate); - ~CDlgTemplate(); - - bool Open(const DLGTEMPLATE* pDlgTemplate); - -protected: - void ConvertItemToEx(const DLGITEMTEMPLATE* pSrc, DLGITEMTEMPLATEEX* pDst); // converts DLGITEMTEMPLATE to DLGITEMTEMPLATEEX - void ConvertDlgToEx(const DLGTEMPLATE* pSrc, DLGTEMPLATEEX* pDst); - - const BYTE* ReadCompoundData(const BYTE* pBuffer, WORD* pwData, PTSTR* ppszStr); - -public: - struct _ITEM - { - DLGITEMTEMPLATEEX m_itemTemplate; - - WORD m_wClass; - TCHAR *m_pszClass; - - WORD m_wTitle; - TCHAR *m_pszTitle; - - WORD m_wCreationDataSize; - BYTE *m_pbyCreationData; - }; - vector<_ITEM> m_vItems; - - DLGTEMPLATEEX m_dlgTemplate; - - WORD m_wMenu; - TCHAR *m_pszMenu; - - WORD m_wClass; - TCHAR *m_pszClass; - - WORD m_wTitle; // always -1 - TCHAR *m_pszTitle; - - // font - WORD m_wFontSize; - WORD m_wWeight; - BYTE m_byItalic; - BYTE m_byCharset; - TCHAR *m_pszFace; -}; - -///////////////////////////////////////////////////////////////////////////// -// CLanguageDialog dialog -#define LDF_NODIALOGSIZE 0x01 -#define LDF_NODIALOGFONT 0x02 - -class CLanguageDialog : public CDialog -{ -public: -// Construction/destruction - CLanguageDialog(bool* pLock=NULL); - CLanguageDialog(PCTSTR lpszTemplateName, CWnd* pParent = NULL, bool* pLock=NULL); // standard constructor - CLanguageDialog(UINT uiIDTemplate, CWnd* pParent = NULL, bool* pLock=NULL); // standard constructor - - ~CLanguageDialog(); - - // static members - initialize global pointer to a resource manager - static void SetResManager(CResourceManager* prm) { m_prm=prm; }; - - // creation - virtual INT_PTR DoModal(); - virtual BOOL Create(); - - void MapRect(RECT* pRect); - CFont* GetFont() { return m_pFont ? m_pFont : ((CDialog*)this)->GetFont(); }; - -protected: - void UpdateLanguage(WORD wOldLang, WORD wNewLang); - virtual UINT GetLanguageUpdateOptions() { return 0; }; - virtual void OnLanguageChanged(WORD /*wOld*/, WORD /*wNew*/) { }; - void Cleanup(); - - virtual BOOL OnTooltipText(UINT /*uiID*/, TOOLTIPTEXT* /*pTip*/) { return FALSE; }; - virtual BOOL OnInitDialog(); - virtual void OnCancel(); - virtual void OnOK(); - virtual void PostNcDestroy(); - virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); - -private: - void CalcBaseUnits(PCTSTR pszFacename, WORD wPointSize); - -// Attributes -public: - bool m_bAutoDelete; // deletes this dialog when exiting - bool m_bLockInstance; // allows only one instance of this dialog if set - -protected: - static CResourceManager* m_prm; // points to the resource manager instance - - bool *m_pbLock; // dialog box instance lock system - bool m_bLockChanged; // if this dialog changed the lock - PCTSTR m_pszResName; // resource (string) name of the dialog template - UINT m_uiResID; // resource ID if any of the dialog template - CWnd* m_pParent; // parent window ptr - char m_cType; // type of this dialog box - CFont* m_pFont; // currently used font - int m_iBaseX, m_iBaseY; -}; \ No newline at end of file Index: src/ch/ResourceManager.cpp =================================================================== diff -u -N --- src/ch/ResourceManager.cpp (revision 27474113d5f01439c44834bf6088c2e112187997) +++ src/ch/ResourceManager.cpp (revision 0) @@ -1,597 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) - - 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., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#include "stdafx.h" -#include "ResourceManager.h" -#include "../libicpf/cfg.h" -#include - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -#define EMPTY_STRING _t("") - -CLangData::CLangData() : - m_pszFilename(NULL), - m_pszLngName(NULL), - m_pszBaseFile(NULL), - m_pszFontFace(NULL), - m_pszHelpName(NULL), - m_pszAuthor(NULL), - m_pszVersion(NULL), - m_uiSectionID(0) -{ -} - -CLangData::~CLangData() -{ - delete [] m_pszFilename; - delete [] m_pszLngName; - delete [] m_pszBaseFile; - delete [] m_pszFontFace; - delete [] m_pszHelpName; - delete [] m_pszAuthor; - delete [] m_pszVersion; - - for(strings_map::iterator it = m_mStrings.begin(); it != m_mStrings.end(); it++) - { - delete [] (*it).second; - } -} - -void CLangData::Clear() -{ - delete [] m_pszFilename; - m_pszFilename = NULL; - delete [] m_pszLngName; - m_pszLngName = NULL; - delete [] m_pszBaseFile; - m_pszBaseFile = NULL; - delete [] m_pszFontFace; - m_pszFontFace = NULL; - delete [] m_pszHelpName; - m_pszHelpName = NULL; - delete [] m_pszAuthor; - m_pszAuthor = NULL; - delete [] m_pszVersion; - m_pszVersion = NULL; - - for(strings_map::iterator it = m_mStrings.begin(); it != m_mStrings.end(); it++) - { - delete [] (*it).second; - } - m_mStrings.clear(); -} - -CLangData::CLangData(const CLangData& ld) : - m_pszFilename(NULL), - m_pszLngName(NULL), - m_pszBaseFile(NULL), - m_pszFontFace(NULL), - m_pszHelpName(NULL), - m_pszAuthor(NULL), - m_pszVersion(NULL) -{ - SetFilename(ld.GetFilename(true)); - SetLangName(ld.GetLangName()); - SetLangCode(ld.GetLangCode()); - SetFontFace(ld.GetFontFace()); - SetCharset(ld.GetCharset()); - SetPointSize(ld.GetPointSize()); - SetDirection(ld.GetDirection()); - SetHelpName(ld.GetHelpName()); - SetAuthor(ld.GetAuthor()); - SetVersion(ld.GetVersion()); -} - -bool CLangData::ReadInfo(PCTSTR pszFile) -{ - try - { - icpf::config cfg(icpf::config::eIni); - const uint_t uiLangName = cfg.register_string(_T("Info/Lang Name"), _t("")); - const uint_t uiLangCode = cfg.register_signed_num(_T("Info/Lang Code"), 0, 0, 0xffff); - const uint_t uiBaseLanguage = cfg.register_string(_T("Info/Base Language"), _T("")); - const uint_t uiFontFace = cfg.register_string(_T("Info/Font Face"), _T("")); - const uint_t uiCharset = cfg.register_signed_num(_T("Info/Charset"), 0, 0, 0xffff); - const uint_t uiSize = cfg.register_signed_num(_T("Info/Size"), 0, 0, 0xffff); - const uint_t uiRTL = cfg.register_bool(_T("Info/RTL reading order"), false); - const uint_t uiHelpName = cfg.register_string(_T("Info/Help name"), _T("")); - const uint_t uiAuthor = cfg.register_string(_T("Info/Author"), _T("")); - const uint_t uiVersion = cfg.register_string(_T("Info/Version"), _T("")); - cfg.read(pszFile); - - const tchar_t* psz = cfg.get_string(uiLangName); - if(!psz || psz[0] == _t('\0')) - return false; - SetLangName(psz); - - ll_t ll = cfg.get_signed_num(uiLangCode); - if(ll == 0) - return false; - SetLangCode((WORD)ll); - - psz = cfg.get_string(uiBaseLanguage); - SetBaseFile(psz); - - psz = cfg.get_string(uiFontFace); - if(!psz || psz[0] == _t('\0')) - return false; - SetFontFace(psz); - - ll = cfg.get_signed_num(uiCharset); - if(ll == 0) - return false; - SetCharset((BYTE)ll); - - ll = cfg.get_signed_num(uiSize); - if(ll == 0) - return false; - SetPointSize((WORD)ll); - - SetDirection(cfg.get_bool(uiRTL)); - - psz = cfg.get_string(uiHelpName); - if(!psz || psz[0] == _t('\0')) - return false; - SetHelpName(psz); - - psz = cfg.get_string(uiAuthor); - if(!psz || psz[0] == _t('\0')) - return false; - SetAuthor(psz); - - psz = cfg.get_string(uiVersion); - if(!psz || psz[0] == _t('\0')) - return false; - SetVersion(psz); - - SetFilename(pszFile); - - return true; - } - catch(...) - { - return false; - } -} - -void CLangData::EnumAttributesCallback(bool bGroup, const tchar_t* pszName, const tchar_t* pszValue, ptr_t pData) -{ - CLangData* pLangData = (CLangData*)pData; - assert(pLangData); - assert(pszName); - if(!pLangData || !pszName) - return; - - if(bGroup && _tcsicmp(pszName, _t("Info")) == 0) - return; - if(bGroup) - { - // new section - remember in member - pLangData->m_uiSectionID = _ttoi(pszName); - } - else - { - uint_t uiVal = _ttoi(pszName); - if(pLangData->m_bUpdating) - { - // check if the entry already exists - strings_map::iterator it = pLangData->m_mStrings.find(pLangData->m_uiSectionID << 16 | uiVal); - if(it != pLangData->m_mStrings.end()) - return; - } - size_t stLen = _tcslen(pszValue); - tchar_t* pszStr = new tchar_t[stLen + 1]; - _tcscpy(pszStr, pszValue); - - // convert escape strings into escape sequences - CLangData::UnescapeString(pszStr); - - pLangData->m_mStrings.insert(strings_map::value_type(pLangData->m_uiSectionID << 16 | uiVal, pszStr)); - } -} - -void CLangData::UnescapeString(tchar_t* pszData) -{ - tchar_t* pszOut = pszData; - while (*pszData != 0) - { - if (*pszData == _T('\\')) - { - pszData++; - switch(*pszData++) - { - case _T('t'): - *pszOut++ = _T('\t'); - break; - case _T('r'): - *pszOut++ = _T('\r'); - break; - case _T('n'): - *pszOut++ = _T('\n'); - break; - default: - *pszOut++ = _T('\\'); - } - } - else - *pszOut++ = *pszData++; - } - *pszOut = _T('\0'); - -} - -bool CLangData::ReadTranslation(PCTSTR pszFile, bool bUpdate) -{ - try - { - if(!bUpdate) - Clear(); - - // load data from file - icpf::config cfg(icpf::config::eIni); - const uint_t uiLangName = cfg.register_string(_T("Info/Lang Name"), _t("")); - const uint_t uiLangCode = cfg.register_signed_num(_T("Info/Lang Code"), 0, 0, 0xffff); - const uint_t uiBaseLanguage = cfg.register_string(_T("Info/Base Language"), _T("")); - const uint_t uiFontFace = cfg.register_string(_T("Info/Font Face"), _T("")); - const uint_t uiCharset = cfg.register_signed_num(_T("Info/Charset"), 0, 0, 0xffff); - const uint_t uiSize = cfg.register_signed_num(_T("Info/Size"), 0, 0, 0xffff); - const uint_t uiRTL = cfg.register_bool(_T("Info/RTL reading order"), false); - const uint_t uiHelpName = cfg.register_string(_T("Info/Help name"), _T("")); - const uint_t uiAuthor = cfg.register_string(_T("Info/Author"), _T("")); - const uint_t uiVersion = cfg.register_string(_T("Info/Version"), _T("")); - cfg.read(pszFile); - - TCHAR szData[512]; - if(!bUpdate) - { - const tchar_t* psz = cfg.get_string(uiLangName); - if(!psz || psz[0] == _t('\0')) - return false; - SetLangName(psz); - - ll_t ll = cfg.get_signed_num(uiLangCode); - if(ll == 0) - return false; - SetLangCode((WORD)ll); - - psz = cfg.get_string(uiBaseLanguage); - SetBaseFile(psz); - - psz = cfg.get_string(uiFontFace); - if(!psz || psz[0] == _t('\0')) - return false; - SetFontFace(psz); - - ll = cfg.get_signed_num(uiCharset); - if(ll == 0) - return false; - SetCharset((BYTE)ll); - - ll = cfg.get_signed_num(uiSize); - if(ll == 0) - return false; - SetPointSize((WORD)ll); - - SetDirection(cfg.get_bool(uiRTL)); - - psz = cfg.get_string(uiHelpName); - if(!psz || psz[0] == _t('\0')) - return false; - SetHelpName(psz); - - psz = cfg.get_string(uiAuthor); - if(!psz || psz[0] == _t('\0')) - return false; - SetAuthor(psz); - - psz = cfg.get_string(uiVersion); - if(!psz || psz[0] == _t('\0')) - return false; - SetVersion(psz); - } - - m_bUpdating = bUpdate; - m_uiSectionID = 0; - if(!cfg.enum_properties(_t("*"), EnumAttributesCallback, this)) - { - m_bUpdating = false; - return false; - } - m_bUpdating = false; - - if(!bUpdate) - { - // remember the filename - SetFilename(pszFile); - - // establish path to the base file - if (_tcslen(GetBaseFile()) != 0) - { - const TCHAR* pszName=_tcsrchr(pszFile, _T('\\')); - if (pszName) - { - _tcsncpy(szData, pszFile, pszName-pszFile+1); - _tcscpy(szData+(pszName-pszFile+1), GetBaseFile()); - TRACE(_t("Base (update) path=%s\n"), szData); - ReadTranslation(szData, true); - } - } - } - - return true; - } - catch(...) - { - return false; - } -} - -PCTSTR CLangData::GetString(WORD wHiID, WORD wLoID) -{ - strings_map::iterator it=m_mStrings.find((wHiID << 16) | wLoID); - if (it != m_mStrings.end()) - return (*it).second; - else - return EMPTY_STRING; -} - -void CLangData::SetFilename(PCTSTR psz) -{ - if (m_pszFilename) - delete [] m_pszFilename; - - // copy - m_pszFilename=new TCHAR[_tcslen(psz)+1]; - _tcscpy(m_pszFilename, psz); -} - -PCTSTR CLangData::GetFilename(bool bFullPath) const -{ - if (bFullPath) - return m_pszFilename; - else - { - TCHAR *pszFnd=_tcsrchr(m_pszFilename, _T('\\')); - if (pszFnd) - return pszFnd+1; - else - return m_pszFilename; - } -} - -void CLangData::SetFnameData(PTSTR *ppszDst, PCTSTR pszSrc) -{ - if (*ppszDst) - delete [] (*ppszDst); - const TCHAR* pszLast=NULL; - if ( (pszLast=_tcsrchr(pszSrc, _T('\\'))) != NULL) - pszLast++; - else - pszLast=pszSrc; - - // copy - *ppszDst=new TCHAR[_tcslen(pszLast)+1]; - _tcscpy(*ppszDst, pszLast); -} - -// requires the param with ending '\\' -void CResourceManager::Scan(LPCTSTR pszFolder, vector* pvData) -{ - assert(pszFolder); - assert(pvData); - if(!pszFolder || !pvData) - return; - - TCHAR szPath[_MAX_PATH]; - _tcscpy(szPath, pszFolder); - _tcscat(szPath, _T("*.lng")); - - WIN32_FIND_DATA wfd; - HANDLE hFind=::FindFirstFile(szPath, &wfd); - BOOL bFound=TRUE; - CLangData ld; - while (bFound && hFind != INVALID_HANDLE_VALUE) - { - if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) - { - _tcscpy(szPath, pszFolder); - _tcscat(szPath, wfd.cFileName); - if (ld.ReadInfo(szPath)) - pvData->push_back(ld); - } - - bFound=::FindNextFile(hFind, &wfd); - } - - if (hFind != INVALID_HANDLE_VALUE) - ::FindClose(hFind); -} - -bool CResourceManager::SetLanguage(PCTSTR pszPath) -{ - EnterCriticalSection(&m_cs); - WORD wOldLang=m_ld.GetLangCode(); - bool bRet=m_ld.ReadTranslation(pszPath); - WORD wNewLang=m_ld.GetLangCode(); - LeaveCriticalSection(&m_cs); - if (!bRet) - return false; - - // update registered dialog boxes - list::iterator it=m_lhDialogs.begin(); - while (it != m_lhDialogs.end()) - { - if (::IsWindow((*it)->m_hWnd)) - (*it)->PostMessage(WM_RMNOTIFY, RMNT_LANGCHANGE, (LPARAM)(wOldLang << 16 | wNewLang)); - it++; - } - - // send the notification stuff to the others - if (m_pfnCallback) - (*m_pfnCallback)(ROT_EVERYWHERE, WM_RMNOTIFY, RMNT_LANGCHANGE, (LPARAM)(wOldLang << 16 | wNewLang)); - - return bRet; -} - -HGLOBAL CResourceManager::LoadResource(LPCTSTR pszType, LPCTSTR pszName) -{ - EnterCriticalSection(&m_cs); - - // find resource - HGLOBAL hRet=NULL; - HRSRC hr=FindResource(m_hRes, pszName, pszType); - if (hr) - hRet=::LoadResource(m_hRes, hr); - - LeaveCriticalSection(&m_cs); - return hRet; -} - -HACCEL CResourceManager::LoadAccelerators(LPCTSTR pszName) -{ - return ::LoadAccelerators(m_hRes, pszName); -} - -HBITMAP CResourceManager::LoadBitmap(LPCTSTR pszName) -{ - return ::LoadBitmap(m_hRes, pszName); -} - -HCURSOR CResourceManager::LoadCursor(LPCTSTR pszName) -{ - return ::LoadCursor(m_hRes, pszName); -} - -HICON CResourceManager::LoadIcon(LPCTSTR pszName) -{ - return ::LoadIcon(m_hRes, pszName); -} - -void CResourceManager::UpdateMenu(HMENU hMenu, WORD wMenuID) -{ - // change the strings inside the menu to the one from txt res file - int iCount=::GetMenuItemCount(hMenu); - MENUITEMINFO mif; - WORD wLoID; - TCHAR szItem[1024]; - memset(szItem, 0, 1024); - for (int i=0;i -#include -#include -#include "af_defs.h" -#include "../libicpf/gen_types.h" - -using namespace std; - -///////////////////////////////////////////////////////////////////////// -// types of notifications -// RMNT_LANGCHANGE, LPARAM - HIWORD - old language, LOWORD - new language -#define RMNT_LANGCHANGE 0x0001 - -/////////////////////////////////////////////////////////// -// language description structure -typedef map strings_map; - -class CLangData -{ -public: -// construction/destruction - CLangData(); - ~CLangData(); - CLangData(const CLangData& ld); - - void Clear(); -// operations - bool ReadInfo(PCTSTR pszFile); - bool ReadTranslation(PCTSTR pszFile, bool bUpdate=false); - - PCTSTR GetString(WORD wHiID, WORD wLoID); - -// attributes - void SetFilename(PCTSTR psz); - PCTSTR GetFilename(bool bFullPath) const; - - void SetLangName(PCTSTR psz) { if (m_pszLngName) delete [] m_pszLngName; m_pszLngName=new TCHAR[_tcslen(psz)+1]; _tcscpy(m_pszLngName, psz); }; - PCTSTR GetLangName() const { return m_pszLngName; }; - - void SetBaseFile(PCTSTR psz) { SetFnameData(&m_pszBaseFile, psz); }; - PCTSTR GetBaseFile() const { return m_pszBaseFile; }; - - void SetLangCode(WORD wLang) { m_wLangCode=wLang; }; - WORD GetLangCode() const { return m_wLangCode; }; - - void SetFontFace(PCTSTR psz) { if (m_pszFontFace) delete [] m_pszFontFace; m_pszFontFace=new TCHAR[_tcslen(psz)+1]; _tcscpy(m_pszFontFace, psz); }; - PCTSTR GetFontFace() const { return m_pszFontFace; }; - - void SetCharset(BYTE byChar) { m_byCharset=byChar; }; - BYTE GetCharset() const { return m_byCharset; }; - - void SetPointSize(WORD wSize) { m_wPointSize=wSize; }; - WORD GetPointSize() const { return m_wPointSize; }; - - void SetDirection(bool brtl) { m_bRTL=brtl; }; - bool GetDirection() const { return m_bRTL; }; - - void SetHelpName(PCTSTR psz) { SetFnameData(&m_pszHelpName, psz); }; - PCTSTR GetHelpName() const { return m_pszHelpName; }; - - void SetAuthor(PCTSTR psz) { if (m_pszAuthor) delete [] m_pszAuthor; m_pszAuthor=new TCHAR[_tcslen(psz)+1]; _tcscpy(m_pszAuthor, psz); }; - PCTSTR GetAuthor() const { return m_pszAuthor; }; - - void SetVersion(PCTSTR psz) { if (m_pszVersion) delete [] m_pszVersion; m_pszVersion=new TCHAR[_tcslen(psz)+1]; _tcscpy(m_pszVersion, psz); }; - PCTSTR GetVersion() const { return m_pszVersion; }; - -// void SetStringData(PCTSTR psz, size_t tCnt) { tCount=tCnt; if (pszStrings) delete [] pszStrings; if (tCount > 0) { pszStrings=new TCHAR[tCnt]; memcpy(pszStrings, psz, tCnt*sizeof(TCHAR)); } }; - -protected: - void SetFnameData(PTSTR *ppszDst, PCTSTR pszSrc); - static void EnumAttributesCallback(bool bGroup, const tchar_t* pszName, const tchar_t* pszValue, ptr_t pData); - static void UnescapeString(tchar_t* pszData); - -public: - TCHAR *m_pszFilename; // file name of the language data (with path) - TCHAR *m_pszLngName; // name of the language (ie. Chinese (PRC)) - TCHAR *m_pszBaseFile; // file with base language data (wo path) - TCHAR *m_pszFontFace; // face name of the font that will be used in dialogs - WORD m_wLangCode; // language code - WORD m_wPointSize; // font point size - TCHAR *m_pszHelpName; // help name (wo the directory) for this language - TCHAR *m_pszAuthor; // author name - TCHAR *m_pszVersion; // version of this file - BYTE m_byCharset; // charset for use with the font - bool m_bRTL; // does the language require right-to-left reading order ? - - // strings (for controls in dialog boxes the ID contains hi:dlg ID, lo:ctrl ID, for strings hi part is 0) - strings_map m_mStrings; // maps string ID to the offset in pszStrings - -private: - uint_t m_uiSectionID; ///< ID of the currently processed section - bool m_bUpdating; ///< Are we updating the language with base language ? -}; - -///////////////////////////////////////////////////////////////////////////////////// - -class CResourceManager -{ -public: - CResourceManager() { m_pfnCallback=NULL; m_hRes=NULL; InitializeCriticalSection(&m_cs); }; - ~CResourceManager() { DeleteCriticalSection(&m_cs); }; - - void Init(HMODULE hrc) { m_hRes=hrc; }; - - void SetCallback(PFNNOTIFYCALLBACK pfn) { m_pfnCallback=pfn; }; - - void Scan(LPCTSTR pszFolder, vector* pvData); - bool SetLanguage(PCTSTR pszPath); - - // loading functions - HGLOBAL LoadResource(LPCTSTR pszType, LPCTSTR pszName); - HACCEL LoadAccelerators(LPCTSTR pszName); - HBITMAP LoadBitmap(LPCTSTR pszName); - HCURSOR LoadCursor(LPCTSTR pszName); - HICON LoadIcon(LPCTSTR pszName); - HANDLE LoadImage(LPCTSTR lpszName, UINT uType, int cxDesired, int cyDesired, UINT fuLoad); - HMENU LoadMenu(LPCTSTR pszName); - LPDLGTEMPLATE LoadDialog(LPCTSTR pszName); - - PCTSTR LoadString(UINT uiID); - PCTSTR LoadString(WORD wGroup, WORD wID); - PTSTR LoadStringCopy(UINT uiID, PTSTR pszStr, UINT uiMax); - - // res updating functions - void UpdateMenu(HMENU hMenu, WORD wMenuID); - -public: - CLangData m_ld; // current language data - list m_lhDialogs; // currently displayed dialog boxes (even hidden) - - HMODULE m_hRes; - PFNNOTIFYCALLBACK m_pfnCallback; -// UINT m_uiMsg; - CRITICAL_SECTION m_cs; -}; - -#endif \ No newline at end of file Index: src/ch/ch.vc90.vcproj =================================================================== diff -u -N -rd18b1dfe96f1e207748e2b522fc4fb6ac03f180d -rcb588a864d28da44cc192760595d3c5ad6f2fac9 --- src/ch/ch.vc90.vcproj (.../ch.vc90.vcproj) (revision d18b1dfe96f1e207748e2b522fc4fb6ac03f180d) +++ src/ch/ch.vc90.vcproj (.../ch.vc90.vcproj) (revision cb588a864d28da44cc192760595d3c5ad6f2fac9) @@ -916,14 +916,6 @@ > - - - - @@ -968,10 +960,6 @@ > - - @@ -1177,18 +1165,10 @@ > - - - - @@ -1325,10 +1305,6 @@ > - -