Index: src/ch/FilterDlg.cpp =================================================================== diff -u -r4fe995b304ea342b50293f92d3c1992b43b820f7 -r19b135b50b55b75d008526a799344bda9a62dc22 --- src/ch/FilterDlg.cpp (.../FilterDlg.cpp) (revision 4fe995b304ea342b50293f92d3c1992b43b820f7) +++ src/ch/FilterDlg.cpp (.../FilterDlg.cpp) (revision 19b135b50b55b75d008526a799344bda9a62dc22) @@ -32,7 +32,7 @@ // CFilterDlg dialog CFilterDlg::CFilterDlg() - :ictranslate::CLanguageDialog(IDD_FILTER_DIALOG) + :CLanguageDialog(IDD_FILTER_DIALOG) { //{{AFX_DATA_INIT(CFilterDlg) m_iArchive = FALSE; Index: src/ch/OptionsDlg.cpp =================================================================== diff -u -r5aac942a83e4a308ff401cca43be501b1bbdfb6a -r19b135b50b55b75d008526a799344bda9a62dc22 --- src/ch/OptionsDlg.cpp (.../OptionsDlg.cpp) (revision 5aac942a83e4a308ff401cca43be501b1bbdfb6a) +++ src/ch/OptionsDlg.cpp (.../OptionsDlg.cpp) (revision 19b135b50b55b75d008526a799344bda9a62dc22) @@ -252,7 +252,7 @@ // lang CString strLangs; size_t stIndex=0; - for (vector::iterator it=m_vld.begin();it != m_vld.end();++it) + for (std::vector::iterator it=m_vld.begin();it != m_vld.end();++it) { strLangs+=(*it).GetLangName(); strLangs+=_T("!"); Index: src/ch/OptionsDlg.h =================================================================== diff -u -r12ee49f6bf1f8921500ee2078e0a8c2d7b6d2a45 -r19b135b50b55b75d008526a799344bda9a62dc22 --- src/ch/OptionsDlg.h (.../OptionsDlg.h) (revision 12ee49f6bf1f8921500ee2078e0a8c2d7b6d2a45) +++ src/ch/OptionsDlg.h (.../OptionsDlg.h) (revision 19b135b50b55b75d008526a799344bda9a62dc22) @@ -68,7 +68,7 @@ std::vector m_cvShortcuts; // for languages - vector m_vld; + std::vector m_vld; CPropertyListCtrl m_ctlProperties; }; Index: src/ch/TMsgBox.cpp =================================================================== diff -u -rd9527df01ee91b35d9a5fdccb80ded25a9c8265f -r19b135b50b55b75d008526a799344bda9a62dc22 --- src/ch/TMsgBox.cpp (.../TMsgBox.cpp) (revision d9527df01ee91b35d9a5fdccb80ded25a9c8265f) +++ src/ch/TMsgBox.cpp (.../TMsgBox.cpp) (revision 19b135b50b55b75d008526a799344bda9a62dc22) @@ -21,8 +21,6 @@ #include "ch.h" #include "resource.h" -using namespace ictranslate; - IMPLEMENT_DYNAMIC(TMsgBox, CLanguageDialog) BEGIN_MESSAGE_MAP(TMsgBox, CLanguageDialog) Index: src/libictranslate/LanguageDialog.cpp =================================================================== diff -u -rb26ced3298e3e7e51d91f3ac70b56746786da83b -r19b135b50b55b75d008526a799344bda9a62dc22 --- src/libictranslate/LanguageDialog.cpp (.../LanguageDialog.cpp) (revision b26ced3298e3e7e51d91f3ac70b56746786da83b) +++ src/libictranslate/LanguageDialog.cpp (.../LanguageDialog.cpp) (revision 19b135b50b55b75d008526a799344bda9a62dc22) @@ -23,905 +23,904 @@ #define new DEBUG_NEW #endif -BEGIN_ICTRANSLATE_NAMESPACE - -///////////////////////////////////////////////////////////////////////////// -// CDlgTemplate -ictranslate::CDlgTemplate::CDlgTemplate() : - m_dlgTemplate({ 0 }) +namespace ictranslate { -} - -CDlgTemplate::CDlgTemplate(const DLGTEMPLATE* pDlgTemplate) : - m_dlgTemplate({ 0 }) -{ - Open(pDlgTemplate); -} - -CDlgTemplate::CDlgTemplate(const DLGTEMPLATEEX* pDlgTemplate) : - m_dlgTemplate({ 0 }) -{ - 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) + ///////////////////////////////////////////////////////////////////////////// + // CDlgTemplate + CDlgTemplate::CDlgTemplate() : + m_dlgTemplate({ 0 }) { - delete [] (*it).m_pbyCreationData; - delete [] (*it).m_pszClass; - delete [] (*it).m_pszTitle; } -} -bool CDlgTemplate::Open(const DLGTEMPLATE* pDlgTemplate) -{ - if (pDlgTemplate == nullptr) - return false; - bool bExt=((DLGTEMPLATEEX*)pDlgTemplate)->signature == 0xffff; - const BYTE* pData=((BYTE*)pDlgTemplate); - if (bExt) + CDlgTemplate::CDlgTemplate(const DLGTEMPLATE* pDlgTemplate) : + m_dlgTemplate({ 0 }) { - m_dlgTemplate=*((DLGTEMPLATEEX*)pDlgTemplate); - pData+=sizeof(DLGTEMPLATEEX); + Open(pDlgTemplate); } - else + + CDlgTemplate::CDlgTemplate(const DLGTEMPLATEEX* pDlgTemplate) : + m_dlgTemplate({ 0 }) { - ConvertDlgToEx(pDlgTemplate, &m_dlgTemplate); - pData+=sizeof(DLGTEMPLATE); + Open((DLGTEMPLATE*)pDlgTemplate); } - - // 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) + CDlgTemplate::~CDlgTemplate() { - m_wFontSize=*((WORD*)pData); - pData+=sizeof(WORD); - if (bExt) + delete[] m_pszMenu; + delete[] m_pszClass; + delete[] m_pszTitle; + delete[] m_pszFace; + + // items + std::vector<_ITEM>::iterator it; + for(it = m_vItems.begin(); it != m_vItems.end(); ++it) { - m_wWeight=*((WORD*)pData); - pData+=sizeof(WORD); - m_byItalic=*((BYTE*)pData); - pData+=sizeof(BYTE); - m_byCharset=*((BYTE*)pData); - pData+=sizeof(BYTE); + delete[](*it).m_pbyCreationData; + delete[](*it).m_pszClass; + delete[](*it).m_pszTitle; } - 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, nullptr, nullptr); -#endif - pData+=(dwLen+1)*sizeof(wchar_t); } - else - { - m_wFontSize=0xffff; - m_pszFace=nullptr; - } - // items - _ITEM item; - for (int i=0;isignature == 0xffff; + const BYTE* pData = ((BYTE*)pDlgTemplate); + if(bExt) { - item.m_itemTemplate=*((DLGITEMTEMPLATEEX*)pData); - pData+=sizeof(DLGITEMTEMPLATEEX); + m_dlgTemplate = *((DLGTEMPLATEEX*)pDlgTemplate); + pData += sizeof(DLGTEMPLATEEX); } else { - ConvertItemToEx((DLGITEMTEMPLATE*)pData, &item.m_itemTemplate); - pData+=sizeof(DLGITEMTEMPLATE); + ConvertDlgToEx(pDlgTemplate, &m_dlgTemplate); + pData += sizeof(DLGTEMPLATE); } - pData=ReadCompoundData(pData, &item.m_wClass, &item.m_pszClass); - if (item.m_wClass == 0xffff && item.m_pszClass != nullptr) + // 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) { - // check the class strings and translate to atom values - if (_tcscmp(item.m_pszClass, _T("STATIC")) == 0) + m_wFontSize = *((WORD*)pData); + pData += sizeof(WORD); + if(bExt) { - item.m_wClass=0x0082; - delete [] item.m_pszClass; - item.m_pszClass=nullptr; + m_wWeight = *((WORD*)pData); + pData += sizeof(WORD); + m_byItalic = *((BYTE*)pData); + pData += sizeof(BYTE); + m_byCharset = *((BYTE*)pData); + pData += sizeof(BYTE); } - else if (_tcscmp(item.m_pszClass, _T("BUTTON")) == 0) + else { - item.m_wClass=0x0080; - delete [] item.m_pszClass; - item.m_pszClass=nullptr; + m_wWeight = FW_NORMAL; + m_byItalic = FALSE; + m_byCharset = DEFAULT_CHARSET; } - else if (_tcscmp(item.m_pszClass, _T("EDIT")) == 0) + 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, nullptr, nullptr); +#endif + pData += (dwLen + 1) * sizeof(wchar_t); + } + else + { + m_wFontSize = 0xffff; + m_pszFace = nullptr; + } + + // items + _ITEM item; + for(int i = 0; i < m_dlgTemplate.cDlgItems; i++) + { + // align to the nearest DWORD + pData = (BYTE*)((LONG_PTR)(pData + 3) & ~3); + + // item + if(bExt) { - item.m_wClass=0x0081; - delete [] item.m_pszClass; - item.m_pszClass=nullptr; + item.m_itemTemplate = *((DLGITEMTEMPLATEEX*)pData); + pData += sizeof(DLGITEMTEMPLATEEX); } - else if (_tcscmp(item.m_pszClass, _T("COMBOBOX")) == 0) + else { - item.m_wClass=0x0085; - delete [] item.m_pszClass; - item.m_pszClass=nullptr; + ConvertItemToEx((DLGITEMTEMPLATE*)pData, &item.m_itemTemplate); + pData += sizeof(DLGITEMTEMPLATE); } - else if (_tcscmp(item.m_pszClass, _T("LISTBOX")) == 0) + + pData = ReadCompoundData(pData, &item.m_wClass, &item.m_pszClass); + if(item.m_wClass == 0xffff && item.m_pszClass != nullptr) { - item.m_wClass=0x0083; - delete [] item.m_pszClass; - item.m_pszClass=nullptr; + // check the class strings and translate to atom values + if(_tcscmp(item.m_pszClass, _T("STATIC")) == 0) + { + item.m_wClass = 0x0082; + delete[] item.m_pszClass; + item.m_pszClass = nullptr; + } + else if(_tcscmp(item.m_pszClass, _T("BUTTON")) == 0) + { + item.m_wClass = 0x0080; + delete[] item.m_pszClass; + item.m_pszClass = nullptr; + } + else if(_tcscmp(item.m_pszClass, _T("EDIT")) == 0) + { + item.m_wClass = 0x0081; + delete[] item.m_pszClass; + item.m_pszClass = nullptr; + } + else if(_tcscmp(item.m_pszClass, _T("COMBOBOX")) == 0) + { + item.m_wClass = 0x0085; + delete[] item.m_pszClass; + item.m_pszClass = nullptr; + } + else if(_tcscmp(item.m_pszClass, _T("LISTBOX")) == 0) + { + item.m_wClass = 0x0083; + delete[] item.m_pszClass; + item.m_pszClass = nullptr; + } + else if(_tcscmp(item.m_pszClass, _T("SCROLLBAR")) == 0) + { + item.m_wClass = 0x0084; + delete[] item.m_pszClass; + item.m_pszClass = nullptr; + } } - else if (_tcscmp(item.m_pszClass, _T("SCROLLBAR")) == 0) + pData = ReadCompoundData(pData, &item.m_wTitle, &item.m_pszTitle); + + // creation data + item.m_wCreationDataSize = (*((WORD*)pData)); + pData += sizeof(WORD); + if(item.m_wCreationDataSize > 0) { - item.m_wClass=0x0084; - delete [] item.m_pszClass; - item.m_pszClass=nullptr; + item.m_wCreationDataSize -= sizeof(WORD); + item.m_pbyCreationData = new BYTE[ item.m_wCreationDataSize ]; + memcpy(item.m_pbyCreationData, pData, item.m_wCreationDataSize); } - } - pData=ReadCompoundData(pData, &item.m_wTitle, &item.m_pszTitle); + else + item.m_pbyCreationData = nullptr; - // creation data - item.m_wCreationDataSize=(*((WORD*)pData)); - pData+=sizeof(WORD); - if (item.m_wCreationDataSize > 0) - { - item.m_wCreationDataSize-=sizeof(WORD); - item.m_pbyCreationData=new BYTE[item.m_wCreationDataSize]; - memcpy(item.m_pbyCreationData, pData, item.m_wCreationDataSize); + m_vItems.push_back(item); } - else - item.m_pbyCreationData=nullptr; - m_vItems.push_back(item); + return true; } - 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) + void CDlgTemplate::ConvertItemToEx(const DLGITEMTEMPLATE* pSrc, DLGITEMTEMPLATEEX* pDst) { - *pwData=*((WORD*)(pBuffer+2)); - *ppszStr=nullptr; + 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; + } - return pBuffer+4; + 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; } - else + + const BYTE* CDlgTemplate::ReadCompoundData(const BYTE* pBuffer, WORD* pwData, PTSTR* ppszStr) { - *pwData=0xffff; - DWORD dwLen=(DWORD)wcslen((wchar_t*)pBuffer); - *ppszStr=new TCHAR[dwLen+1]; + if(*((WORD*)pBuffer) == 0xffff) + { + *pwData = *((WORD*)(pBuffer + 2)); + *ppszStr = nullptr; + + 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); + _tcscpy(*ppszStr, (wchar_t*)pBuffer); #else - WideCharToMultiByte(CP_ACP, 0, (wchar_t*)pBuffer, dwLen+1, *ppszStr, dwLen+1, nullptr, nullptr); + WideCharToMultiByte(CP_ACP, 0, (wchar_t*)pBuffer, dwLen + 1, *ppszStr, dwLen + 1, nullptr, nullptr); #endif - return pBuffer+(dwLen+1)*sizeof(wchar_t); + return pBuffer + (dwLen + 1) * sizeof(wchar_t); + } + } -} + ///////////////////////////////////////////////////////////////////////////// + // CControlResizeInfo dialog -///////////////////////////////////////////////////////////////////////////// -// CControlResizeInfo dialog + // ============================================================================ + /// ictranslate::CControlResizeInfo::CControlResizeInfo + /// @date 2009/04/18 + /// + /// @brief Constructs the control resize information object. + /// @param[in] iCtrlID Control ID. + /// @param[in] dXPosFactor Multiplier for the dialog width change - used for x-offset. + /// @param[in] dYPosFactor Multiplier for the dialog height change - used for y-offset. + /// @param[in] dXScaleFactor Multiplier for the dialog width change - used for x-size. + /// @param[in] dYScaleFactor Multiplier for the dialog height change - used for y-size. + // ============================================================================ + CControlResizeInfo::CControlResizeInfo(int iCtrlID, double dXPosFactor, double dYPosFactor, double dXScaleFactor, double dYScaleFactor) : + m_iControlID(iCtrlID), + m_rcInitialPosition(0, 0, 0, 0), + m_dXOffsetFactor(dXPosFactor), + m_dYOffsetFactor(dYPosFactor), + m_dXScaleFactor(dXScaleFactor), + m_dYScaleFactor(dYScaleFactor) + { + } -// ============================================================================ -/// ictranslate::CControlResizeInfo::CControlResizeInfo -/// @date 2009/04/18 -/// -/// @brief Constructs the control resize information object. -/// @param[in] iCtrlID Control ID. -/// @param[in] dXPosFactor Multiplier for the dialog width change - used for x-offset. -/// @param[in] dYPosFactor Multiplier for the dialog height change - used for y-offset. -/// @param[in] dXScaleFactor Multiplier for the dialog width change - used for x-size. -/// @param[in] dYScaleFactor Multiplier for the dialog height change - used for y-size. -// ============================================================================ -CControlResizeInfo::CControlResizeInfo(int iCtrlID, double dXPosFactor, double dYPosFactor, double dXScaleFactor, double dYScaleFactor) : - m_iControlID(iCtrlID), - m_rcInitialPosition(0, 0, 0, 0), - m_dXOffsetFactor(dXPosFactor), - m_dYOffsetFactor(dYPosFactor), - m_dXScaleFactor(dXScaleFactor), - m_dYScaleFactor(dYScaleFactor) -{ -} + // ============================================================================ + /// ictranslate::CControlResizeInfo::SetInitialPosition + /// @date 2009/04/18 + /// + /// @brief Sets the initial position of control. + /// @param[in] rcPos Control position. + // ============================================================================ + void CControlResizeInfo::SetInitialPosition(const CRect& rcPos) + { + m_rcInitialPosition = rcPos; + } -// ============================================================================ -/// ictranslate::CControlResizeInfo::SetInitialPosition -/// @date 2009/04/18 -/// -/// @brief Sets the initial position of control. -/// @param[in] rcPos Control position. -// ============================================================================ -void CControlResizeInfo::SetInitialPosition(const CRect& rcPos) -{ - m_rcInitialPosition = rcPos; -} + // ============================================================================ + /// ictranslate::CControlResizeInfo::GetNewControlPlacement + /// @date 2009/04/18 + /// + /// @brief Calculates new control position based on dialog positions and placement factors. + /// @param[in] rcDlgInitial Initial dialog size. + /// @param[in] rcDlgCurrent Current dialog size. + /// @param[out] rcNewPlacement Receives the new control position and size. + // ============================================================================ + void CControlResizeInfo::GetNewControlPlacement(const CRect& rcDlgInitial, const CRect& rcDlgCurrent, CRect& rcNewPlacement) + { + long stXOffset = rcDlgCurrent.Width() - rcDlgInitial.Width(); + long stYOffset = rcDlgCurrent.Height() - rcDlgInitial.Height(); -// ============================================================================ -/// ictranslate::CControlResizeInfo::GetNewControlPlacement -/// @date 2009/04/18 -/// -/// @brief Calculates new control position based on dialog positions and placement factors. -/// @param[in] rcDlgInitial Initial dialog size. -/// @param[in] rcDlgCurrent Current dialog size. -/// @param[out] rcNewPlacement Receives the new control position and size. -// ============================================================================ -void CControlResizeInfo::GetNewControlPlacement(const CRect& rcDlgInitial, const CRect& rcDlgCurrent, CRect& rcNewPlacement) -{ - long stXOffset = rcDlgCurrent.Width() - rcDlgInitial.Width(); - long stYOffset = rcDlgCurrent.Height() - rcDlgInitial.Height(); + rcNewPlacement.left = m_rcInitialPosition.left + (long)(m_dXOffsetFactor * stXOffset); + rcNewPlacement.top = m_rcInitialPosition.top + (long)(m_dYOffsetFactor * stYOffset); - rcNewPlacement.left = m_rcInitialPosition.left + (long)(m_dXOffsetFactor * stXOffset); - rcNewPlacement.top = m_rcInitialPosition.top + (long)(m_dYOffsetFactor * stYOffset); + rcNewPlacement.right = rcNewPlacement.left + m_rcInitialPosition.Width() + (long)(m_dXScaleFactor * stXOffset); + rcNewPlacement.bottom = rcNewPlacement.top + m_rcInitialPosition.Height() + (long)(m_dYScaleFactor * stYOffset); + } - rcNewPlacement.right = rcNewPlacement.left + m_rcInitialPosition.Width() + (long)(m_dXScaleFactor * stXOffset); - rcNewPlacement.bottom = rcNewPlacement.top + m_rcInitialPosition.Height() + (long)(m_dYScaleFactor * stYOffset); -} + // ============================================================================ + /// ictranslate::CControlResizeInfo::ResetInitState + /// @date 2009/04/18 + /// + /// @brief Resets the state of this control information object (resets the initial position). + // ============================================================================ + void CControlResizeInfo::ResetInitState() + { + m_rcInitialPosition.left = 0; + m_rcInitialPosition.top = 0; + m_rcInitialPosition.right = 0; + m_rcInitialPosition.bottom = 0; + } -// ============================================================================ -/// ictranslate::CControlResizeInfo::ResetInitState -/// @date 2009/04/18 -/// -/// @brief Resets the state of this control information object (resets the initial position). -// ============================================================================ -void CControlResizeInfo::ResetInitState() -{ - m_rcInitialPosition.left = 0; - m_rcInitialPosition.top = 0; - m_rcInitialPosition.right = 0; - m_rcInitialPosition.bottom = 0; -} + // ============================================================================ + /// ictranslate::CControlResizeInfo::IsInitialized + /// @date 2009/04/18 + /// + /// @brief Checks if control information object has been initialized with initial control position. + /// @return True if initial position has been set, false otherwise. + // ============================================================================ + bool CControlResizeInfo::IsInitialized() const + { + return m_rcInitialPosition.Width() != 0 && m_rcInitialPosition.Height() != 0; + } -// ============================================================================ -/// ictranslate::CControlResizeInfo::IsInitialized -/// @date 2009/04/18 -/// -/// @brief Checks if control information object has been initialized with initial control position. -/// @return True if initial position has been set, false otherwise. -// ============================================================================ -bool CControlResizeInfo::IsInitialized() const -{ - return m_rcInitialPosition.Width() != 0 && m_rcInitialPosition.Height() != 0; -} + ///////////////////////////////////////////////////////////////////////////// + // CLanguageDialog dialog -///////////////////////////////////////////////////////////////////////////// -// CLanguageDialog dialog + BEGIN_MESSAGE_MAP(CLanguageDialog, CDialog) + ON_WM_HELPINFO() + ON_WM_CONTEXTMENU() + ON_BN_CLICKED(IDHELP, OnHelpButton) + END_MESSAGE_MAP() -BEGIN_MESSAGE_MAP(CLanguageDialog, CDialog) - ON_WM_HELPINFO() - ON_WM_CONTEXTMENU() - ON_BN_CLICKED(IDHELP, OnHelpButton) -END_MESSAGE_MAP() + CResourceManager *CLanguageDialog::m_prm = nullptr; -CResourceManager *CLanguageDialog::m_prm=nullptr; + /////////////////////////////////////////////////////////////// + // 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 = nullptr; + m_uiResID = 0; + m_pParent = nullptr; + m_cType = -1; + m_bAutoDelete = false; + m_pFont = nullptr; + 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 + if(m_prm) + m_prm->m_lhDialogs.push_back(this); + } -/////////////////////////////////////////////////////////////// -// 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=nullptr; - m_uiResID=0; - m_pParent=nullptr; - m_cType=-1; - m_bAutoDelete=false; - m_pFont=nullptr; - 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 - if(m_prm) - 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)(ULONG_PTR)lpszTemplateName; + else + m_uiResID = 0; + m_pParent = pParent; + m_cType = -1; + m_bAutoDelete = false; + m_pFont = nullptr; + 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 + if(m_prm) + 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)(ULONG_PTR)lpszTemplateName; - else - m_uiResID=0; - m_pParent=pParent; - m_cType=-1; - m_bAutoDelete=false; - m_pFont=nullptr; - 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 - if(m_prm) - 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 = nullptr; + 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 + if(m_prm) + 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=nullptr; - 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 - if(m_prm) - 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()) + /////////////////////////////////////////////////////////////// + // Standard destructor + // Removes itself from a list in CWinApp (not to get any window + // messages anymore). + /////////////////////////////////////////////////////////////// + CLanguageDialog::~CLanguageDialog() { - if (*it == this) + std::list::iterator it = m_prm->m_lhDialogs.begin(); + while(it != m_prm->m_lhDialogs.end()) { - m_prm->m_lhDialogs.erase(it); - break; + if(*it == this) + { + m_prm->m_lhDialogs.erase(it); + break; + } + + ++it; } - ++it; + delete m_pFont; } - delete m_pFont; -} + ///////////////////////////////////////////////////////////////////////////// + // CLanguageDialog message handlers -///////////////////////////////////////////////////////////////////////////// -// CLanguageDialog message handlers - -/////////////////////////////////////////////////////////////// -// Makes properly constructed dialog modal. -// RetVal [out] - value returned by dialog proc -/////////////////////////////////////////////////////////////// -INT_PTR CLanguageDialog::DoModal() -{ - if (m_pszResName) + /////////////////////////////////////////////////////////////// + // Makes properly constructed dialog modal. + // RetVal [out] - value returned by dialog proc + /////////////////////////////////////////////////////////////// + INT_PTR CLanguageDialog::DoModal() { - HGLOBAL hDialog=m_prm->LoadResource(RT_DIALOG, m_pszResName); - if (!InitModalIndirect(hDialog)) - return -1; + if(m_pszResName) + { + HGLOBAL hDialog = m_prm->LoadResource(RT_DIALOG, m_pszResName); + if(!InitModalIndirect(hDialog)) + return -1; + } + m_cType = 0; + return CDialog::DoModal(); } - 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 == nullptr || !(*m_pbLock)) + /////////////////////////////////////////////////////////////// + // Creates (and shows probably) this constructed dialog. + // RetVal [out] - if creation succeeded + /////////////////////////////////////////////////////////////// + BOOL CLanguageDialog::Create() { - HGLOBAL hDialog=m_prm->LoadResource(RT_DIALOG, m_pszResName); + _ASSERT(m_pszResName); // nothing was set as a dialog template - // modeless dialog - if (!CreateIndirect(hDialog, m_pParent)) - return FALSE; + if(!m_bLockInstance || m_pbLock == nullptr || !(*m_pbLock)) + { + HGLOBAL hDialog = m_prm->LoadResource(RT_DIALOG, m_pszResName); - m_cType=1; - if (m_pbLock) + // 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_pbLock=true; - m_bLockChanged=true; + m_bLockChanged = false; + Cleanup(); + return FALSE; } - - return TRUE; } - else + + /////////////////////////////////////////////////////////////// + // 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) { - m_bLockChanged=false; - Cleanup(); - return FALSE; + 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); } -} -/////////////////////////////////////////////////////////////// -// 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) + /////////////////////////////////////////////////////////////// + // 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() { - 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); -} + // cannot update for string based template + if(m_uiResID == 0) + return; -/////////////////////////////////////////////////////////////// -// 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() -{ - // cannot update for string based template - if (m_uiResID == 0) - return; + // set the title + SetWindowText(m_prm->LoadString((WORD)m_uiResID, 0)); - // 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; + } - // 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); - // 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(nullptr); + lf.lfHeight = -MulDiv(m_prm->m_ld.GetPointSize(), GetDeviceCaps(hdc, LOGPIXELSY), 72); + ::ReleaseDC(nullptr, hdc); + lf.lfWeight = FW_NORMAL; + lf.lfCharSet = DEFAULT_CHARSET; + _tcsncpy_s(lf.lfFaceName, LF_FACESIZE, m_prm->m_ld.GetFontFace(), _TRUNCATE); - // font - if (!(GetLanguageUpdateOptions() & LDF_NODIALOGFONT)) - { - // dialog font - LOGFONT lf; - memset(&lf, 0, sizeof(LOGFONT)); - HDC hdc=::GetDC(nullptr); - lf.lfHeight = -MulDiv(m_prm->m_ld.GetPointSize(), GetDeviceCaps(hdc, LOGPIXELSY), 72); - ::ReleaseDC(nullptr, hdc); - lf.lfWeight = FW_NORMAL; - lf.lfCharSet = DEFAULT_CHARSET; - _tcsncpy_s(lf.lfFaceName, LF_FACESIZE, m_prm->m_ld.GetFontFace(), _TRUNCATE); + delete m_pFont; + m_pFont = new CFont(); + m_pFont->CreateFontIndirect(&lf); - delete m_pFont; - m_pFont=new CFont(); - m_pFont->CreateFontIndirect(&lf); + // change base dlg units + CalcBaseUnits(dt.m_pszFace, dt.m_wFontSize); + } - // change base dlg units - CalcBaseUnits(dt.m_pszFace, dt.m_wFontSize); - } + if(!(GetLanguageUpdateOptions() & LDF_NODIALOGSIZE)) + { + // dialog size + CRect rcWin; + GetWindowRect(&rcWin); - if (!(GetLanguageUpdateOptions() & LDF_NODIALOGSIZE)) - { - // dialog size - CRect rcWin; - GetWindowRect(&rcWin); - - CRect rcDialog(0, 0, dt.m_dlgTemplate.cx, dt.m_dlgTemplate.cy); - MapRect(&rcDialog); + CRect rcDialog(0, 0, dt.m_dlgTemplate.cx, dt.m_dlgTemplate.cy); + MapRect(&rcDialog); - BOOL bHasMenu = ((dt.m_wMenu != 0xffff) || ((dt.m_pszMenu != nullptr) && _tcslen(dt.m_pszMenu) != 0)); + BOOL bHasMenu = ((dt.m_wMenu != 0xffff) || ((dt.m_pszMenu != nullptr) && _tcslen(dt.m_pszMenu) != 0)); - AdjustWindowRectEx(&rcDialog, GetStyle(), bHasMenu, GetWindowLong(GetSafeHwnd(), GWL_EXSTYLE)); - rcDialog.OffsetRect(-rcDialog.left, -rcDialog.top); - rcDialog.OffsetRect(rcWin.CenterPoint().x - rcDialog.Width() / 2, rcWin.CenterPoint().y - rcDialog.Height() / 2); + AdjustWindowRectEx(&rcDialog, GetStyle(), bHasMenu, GetWindowLong(GetSafeHwnd(), GWL_EXSTYLE)); + rcDialog.OffsetRect(-rcDialog.left, -rcDialog.top); + 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(nullptr, rcDialog.left, rcDialog.top, rcDialog.Width(), rcDialog.Height(), SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE); - } - - // the controls - vector::iterator it; - for (it=dt.m_vItems.begin();it != dt.m_vItems.end();++it) - { - CWnd* pWnd = nullptr; - // skip controls that cannot be modified - if ( (*it).m_itemTemplate.id == 0xffff || (pWnd=GetDlgItem((*it).m_itemTemplate.id)) == nullptr) - 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; + //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(nullptr, rcDialog.left, rcDialog.top, rcDialog.Width(), rcDialog.Height(), SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE); } - else + + // the controls + std::vector::iterator it; + for(it = dt.m_vItems.begin(); it != dt.m_vItems.end(); ++it) { - if (m_prm->m_ld.GetDirection()) - lStyleEx |= WS_EX_RTLREADING; + CWnd* pWnd = nullptr; + // skip controls that cannot be modified + if((*it).m_itemTemplate.id == 0xffff || (pWnd = GetDlgItem((*it).m_itemTemplate.id)) == nullptr) + 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; + } + + ::SetWindowLongPtr(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(nullptr, 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 != nullptr && _tcscmp((*it).m_pszClass, _T("STATICEX")) == 0)) + pWnd->SetWindowText(m_prm->LoadString((WORD)m_uiResID, (*it).m_itemTemplate.id)); } - - ::SetWindowLongPtr(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(nullptr, 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 != nullptr && _tcscmp((*it).m_pszClass, _T("STATICEX")) == 0) ) - pWnd->SetWindowText(m_prm->LoadString((WORD)m_uiResID, (*it).m_itemTemplate.id)); + + // ensure that we have current placement of dialog and controls remembered to allow safe repositioning later + InitializeResizableControls(); } - // ensure that we have current placement of dialog and controls remembered to allow safe repositioning later - InitializeResizableControls(); -} + /////////////////////////////////////////////////////////////// + // 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"); -/////////////////////////////////////////////////////////////// -// 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; - if (m_bLockChanged && m_pbLock) - *m_pbLock=false; + delete m_pFont; + m_pFont = nullptr; - delete m_pFont; - m_pFont = nullptr; + if(m_bAutoDelete) + delete this; + } - if(m_bAutoDelete) - delete this; -} + /////////////////////////////////////////////////////////////// + // Standard msg - initializes tool tip handling + /////////////////////////////////////////////////////////////// + BOOL CLanguageDialog::OnInitDialog() + { + CDialog::OnInitDialog(); -/////////////////////////////////////////////////////////////// -// Standard msg - initializes tool tip handling -/////////////////////////////////////////////////////////////// -BOOL CLanguageDialog::OnInitDialog() -{ - CDialog::OnInitDialog(); + UpdateLanguage(); // because initially all the texts are empty - UpdateLanguage(); // because initially all the texts are empty + EnableToolTips(TRUE); - EnableToolTips(TRUE); + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE + } - 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 cancel button in a dialog. -// For modeless dialog causes dialog to be destroyed. -/////////////////////////////////////////////////////////////// -void CLanguageDialog::OnCancel() -{ - switch (m_cType) + /////////////////////////////////////////////////////////////// + // Standard handler for pressing OK button in a dialog. + // For modeless dialog causes destruction of a dialog. + /////////////////////////////////////////////////////////////// + void CLanguageDialog::OnOK() { - case 0: - CDialog::OnCancel(); - break; - case 1: - DestroyWindow(); - break; + switch(m_cType) + { + case 0: + CDialog::OnOK(); + 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) + /////////////////////////////////////////////////////////////// + // Standard override - calls cleanup. + /////////////////////////////////////////////////////////////// + void CLanguageDialog::PostNcDestroy() { - case 0: - CDialog::OnOK(); - break; - case 1: - DestroyWindow(); - break; + CDialog::PostNcDestroy(); + Cleanup(); } -} -/////////////////////////////////////////////////////////////// -// 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) + /////////////////////////////////////////////////////////////// + // This dialog's window procedure handler - look at ms docs. + /////////////////////////////////////////////////////////////// + LRESULT CLanguageDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { - case WM_RMNOTIFY: - if ((UINT)wParam == RMNT_LANGCHANGE) + switch(message) { - UpdateLanguage(); + case WM_RMNOTIFY: + if((UINT)wParam == RMNT_LANGCHANGE) + { + UpdateLanguage(); - // now update user controls (everybody has to do it him(her)self) - OnLanguageChanged(); - break; - } - case WM_NOTIFY: + // now update user controls (everybody has to do it him(her)self) + OnLanguageChanged(); + break; + } + case WM_NOTIFY: { - NMHDR* pnmh=(NMHDR*)lParam; - if (pnmh->code == TTN_NEEDTEXT) + NMHDR* pnmh = (NMHDR*)lParam; + if(pnmh->code == TTN_NEEDTEXT) { // establish the ID of a control - TOOLTIPTEXT *ppt=(TOOLTIPTEXT*)pnmh; + TOOLTIPTEXT *ppt = (TOOLTIPTEXT*)pnmh; UINT nID; - if (ppt->uFlags & TTF_IDISHWND) - nID=(UINT)::GetDlgCtrlID((HWND)pnmh->idFrom); + if(ppt->uFlags & TTF_IDISHWND) + nID = (UINT)::GetDlgCtrlID((HWND)pnmh->idFrom); else - nID=(UINT)pnmh->idFrom; + nID = (UINT)pnmh->idFrom; return OnTooltipText(nID, ppt); } break; } - case WM_SIZE: + case WM_SIZE: { RepositionResizableControls(); break; } + } + + return CDialog::WindowProc(message, wParam, lParam); } - 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(nullptr); + memset(&lf, 0, sizeof(LOGFONT)); + lf.lfHeight = -MulDiv(wPointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72); + lf.lfWeight = FW_NORMAL; + lf.lfCharSet = DEFAULT_CHARSET; + _tcsncpy_s(lf.lfFaceName, LF_FACESIZE, pszFacename, _TRUNCATE); -/////////////////////////////////////////////////////////////// -// 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(nullptr); - memset(&lf, 0, sizeof(LOGFONT)); - lf.lfHeight = -MulDiv(wPointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72); - lf.lfWeight = FW_NORMAL; - lf.lfCharSet = DEFAULT_CHARSET; - _tcsncpy_s(lf.lfFaceName, LF_FACESIZE, pszFacename, _TRUNCATE); + HFONT hNewFont = CreateFontIndirect(&lf); + if(hNewFont != nullptr) + { + 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(nullptr, hDC); + } - HFONT hNewFont = CreateFontIndirect(&lf); - if (hNewFont != nullptr) + BOOL CLanguageDialog::OnHelpInfo(HELPINFO* pHelpInfo) { - 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); + if(pHelpInfo->iContextType == HELPINFO_WINDOW) + { + pHelpInfo->dwContextId = (m_uiResID << 16) | pHelpInfo->iCtrlId; + AfxGetApp()->HtmlHelp((DWORD_PTR)pHelpInfo, HH_DISPLAY_TEXT_POPUP); + return true; + } + else + return false; } - else + + void CLanguageDialog::OnContextMenu(CWnd* pWnd, CPoint point) { - // Could not create the font so just use the system's values - m_iBaseX = LOWORD(GetDialogBaseUnits()); - m_iBaseY = HIWORD(GetDialogBaseUnits()); + 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; + + AfxGetApp()->HtmlHelp((DWORD_PTR)&hi, HH_DISPLAY_TEXT_POPUP); } - ::ReleaseDC(nullptr, hDC); -} -BOOL CLanguageDialog::OnHelpInfo(HELPINFO* pHelpInfo) -{ - if (pHelpInfo->iContextType == HELPINFO_WINDOW) + void CLanguageDialog::OnHelpButton() { - pHelpInfo->dwContextId=(m_uiResID << 16) | pHelpInfo->iCtrlId; - AfxGetApp()->HtmlHelp((DWORD_PTR)pHelpInfo, HH_DISPLAY_TEXT_POPUP); - return true; + AfxGetApp()->HtmlHelp(m_uiResID + 0x20000, HH_HELP_CONTEXT); } - else - return false; -} -void CLanguageDialog::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; + // ============================================================================ + /// ictranslate::CLanguageDialog::InitializeResizableControls + /// @date 2009/04/18 + /// + /// @brief Initializes resizable controls using current dialog as a base. + // ============================================================================ + void CLanguageDialog::InitializeResizableControls() + { + // remember current dialog position as the base one + GetClientRect(&m_rcDialogInitialPosition); - AfxGetApp()->HtmlHelp((DWORD_PTR)&hi, HH_DISPLAY_TEXT_POPUP); -} + // enum through the controls to get their current positions + CRect rcControl; -void CLanguageDialog::OnHelpButton() -{ - AfxGetApp()->HtmlHelp(m_uiResID+0x20000, HH_HELP_CONTEXT); -} - -// ============================================================================ -/// ictranslate::CLanguageDialog::InitializeResizableControls -/// @date 2009/04/18 -/// -/// @brief Initializes resizable controls using current dialog as a base. -// ============================================================================ -void CLanguageDialog::InitializeResizableControls() -{ - // remember current dialog position as the base one - GetClientRect(&m_rcDialogInitialPosition); - - // enum through the controls to get their current positions - CRect rcControl; - - std::map::iterator iterControl = m_mapResizeInfo.begin(); - while(iterControl != m_mapResizeInfo.end()) - { - // get the control if exists - CWnd* pWnd = GetDlgItem((*iterControl).second.GetControlID()); - if(!(*iterControl).second.IsInitialized()) + std::map::iterator iterControl = m_mapResizeInfo.begin(); + while(iterControl != m_mapResizeInfo.end()) { - if(pWnd && ::IsWindow(pWnd->m_hWnd)) + // get the control if exists + CWnd* pWnd = GetDlgItem((*iterControl).second.GetControlID()); + if(!(*iterControl).second.IsInitialized()) { - pWnd->GetWindowRect(&rcControl); - ScreenToClient(&rcControl); + if(pWnd && ::IsWindow(pWnd->m_hWnd)) + { + pWnd->GetWindowRect(&rcControl); + ScreenToClient(&rcControl); - (*iterControl).second.SetInitialPosition(rcControl); + (*iterControl).second.SetInitialPosition(rcControl); + } + else + (*iterControl).second.ResetInitState(); } - else - (*iterControl).second.ResetInitState(); - } - else if(!pWnd) - (*iterControl).second.ResetInitState(); // mark control as uninitialized when it does not exist + else if(!pWnd) + (*iterControl).second.ResetInitState(); // mark control as uninitialized when it does not exist - ++iterControl; + ++iterControl; + } } -} -// ============================================================================ -/// ictranslate::CLanguageDialog::ClearResizableControls -/// @date 2009/04/18 -/// -/// @brief Clears the list of resizable controls. -// ============================================================================ -void CLanguageDialog::ClearResizableControls() -{ - m_mapResizeInfo.clear(); -} - -// ============================================================================ -/// ictranslate::CLanguageDialog::AddResizableControl -/// @date 2009/04/18 -/// -/// @brief Adds the control to the list of resizable controls. -/// @param[in] iCtrlID Control ID. -/// @param[in] dXPosFactor X position multiply factor. -/// @param[in] dYPosFactor Y position multiply factor. -/// @param[in] dXScaleFactor X size multiply factor. -/// @param[in] dYScaleFactor y size multiply factor. -/// @return -// ============================================================================ -void CLanguageDialog::AddResizableControl(int iCtrlID, double dXPosFactor, double dYPosFactor, double dXScaleFactor, double dYScaleFactor) -{ - CControlResizeInfo cri(iCtrlID, dXPosFactor, dYPosFactor, dXScaleFactor, dYScaleFactor); - - // read position if possible - CRect rcControl; - CWnd* pWnd = GetDlgItem(iCtrlID); - if(pWnd && ::IsWindow(pWnd->m_hWnd)) + // ============================================================================ + /// ictranslate::CLanguageDialog::ClearResizableControls + /// @date 2009/04/18 + /// + /// @brief Clears the list of resizable controls. + // ============================================================================ + void CLanguageDialog::ClearResizableControls() { - pWnd->GetWindowRect(&rcControl); - ScreenToClient(&rcControl); - - cri.SetInitialPosition(rcControl); + m_mapResizeInfo.clear(); } - m_mapResizeInfo.insert(std::make_pair(iCtrlID, cri)); -} + // ============================================================================ + /// ictranslate::CLanguageDialog::AddResizableControl + /// @date 2009/04/18 + /// + /// @brief Adds the control to the list of resizable controls. + /// @param[in] iCtrlID Control ID. + /// @param[in] dXPosFactor X position multiply factor. + /// @param[in] dYPosFactor Y position multiply factor. + /// @param[in] dXScaleFactor X size multiply factor. + /// @param[in] dYScaleFactor y size multiply factor. + /// @return + // ============================================================================ + void CLanguageDialog::AddResizableControl(int iCtrlID, double dXPosFactor, double dYPosFactor, double dXScaleFactor, double dYScaleFactor) + { + CControlResizeInfo cri(iCtrlID, dXPosFactor, dYPosFactor, dXScaleFactor, dYScaleFactor); -// ============================================================================ -/// ictranslate::CLanguageDialog::RepositionResizableControls -/// @date 2009/04/18 -/// -/// @brief Repositions all resizable controls according to the size change. -// ============================================================================ -void CLanguageDialog::RepositionResizableControls() -{ - // retrieve current dialog size - CRect rcControl; - CWnd* pWnd = nullptr; + // read position if possible + CRect rcControl; + CWnd* pWnd = GetDlgItem(iCtrlID); + if(pWnd && ::IsWindow(pWnd->m_hWnd)) + { + pWnd->GetWindowRect(&rcControl); + ScreenToClient(&rcControl); - CRect rcCurrentDlgPos; - GetClientRect(&rcCurrentDlgPos); + cri.SetInitialPosition(rcControl); + } - std::map::iterator iterControl = m_mapResizeInfo.begin(); - while(iterControl != m_mapResizeInfo.end()) + m_mapResizeInfo.insert(std::make_pair(iCtrlID, cri)); + } + + // ============================================================================ + /// ictranslate::CLanguageDialog::RepositionResizableControls + /// @date 2009/04/18 + /// + /// @brief Repositions all resizable controls according to the size change. + // ============================================================================ + void CLanguageDialog::RepositionResizableControls() { - if((*iterControl).second.IsInitialized()) + // retrieve current dialog size + CRect rcControl; + CWnd* pWnd = nullptr; + + CRect rcCurrentDlgPos; + GetClientRect(&rcCurrentDlgPos); + + std::map::iterator iterControl = m_mapResizeInfo.begin(); + while(iterControl != m_mapResizeInfo.end()) { - pWnd = GetDlgItem((*iterControl).second.GetControlID()); - if(pWnd && ::IsWindow(pWnd->m_hWnd)) + if((*iterControl).second.IsInitialized()) { - (*iterControl).second.GetNewControlPlacement(m_rcDialogInitialPosition, rcCurrentDlgPos, rcControl); - pWnd->SetWindowPos(nullptr, rcControl.left, rcControl.top, rcControl.Width(), rcControl.Height(), SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS); + pWnd = GetDlgItem((*iterControl).second.GetControlID()); + if(pWnd && ::IsWindow(pWnd->m_hWnd)) + { + (*iterControl).second.GetNewControlPlacement(m_rcDialogInitialPosition, rcCurrentDlgPos, rcControl); + pWnd->SetWindowPos(nullptr, rcControl.left, rcControl.top, rcControl.Width(), rcControl.Height(), SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS); + } } - } - ++iterControl; + ++iterControl; + } } } - -END_ICTRANSLATE_NAMESPACE Index: src/libictranslate/LanguageDialog.h =================================================================== diff -u -rb26ced3298e3e7e51d91f3ac70b56746786da83b -r19b135b50b55b75d008526a799344bda9a62dc22 --- src/libictranslate/LanguageDialog.h (.../LanguageDialog.h) (revision b26ced3298e3e7e51d91f3ac70b56746786da83b) +++ src/libictranslate/LanguageDialog.h (.../LanguageDialog.h) (revision 19b135b50b55b75d008526a799344bda9a62dc22) @@ -62,186 +62,203 @@ #include "libictranslate.h" #include "ResourceManager.h" -BEGIN_ICTRANSLATE_NAMESPACE - -#pragma pack(push, 1) -struct DLGTEMPLATEEX +namespace ictranslate { - WORD dlgVer; - WORD signature; - DWORD helpID; - DWORD exStyle; - DWORD style; - WORD cDlgItems; - short x; - short y; - short cx; - short cy; -}; +#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__; -}; + 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(); - explicit CDlgTemplate(const DLGTEMPLATE* pDlgTemplate); - explicit CDlgTemplate(const DLGTEMPLATEEX* pDlgTemplate); - ~CDlgTemplate(); + class CDlgTemplate + { + public: + CDlgTemplate(); + explicit CDlgTemplate(const DLGTEMPLATE* pDlgTemplate); + explicit CDlgTemplate(const DLGTEMPLATEEX* pDlgTemplate); + ~CDlgTemplate(); - bool Open(const DLGTEMPLATE* pDlgTemplate); + bool Open(const DLGTEMPLATE* pDlgTemplate); -protected: - void ConvertItemToEx(const DLGITEMTEMPLATE* pSrc, DLGITEMTEMPLATEEX* pDst); // converts DLGITEMTEMPLATE to DLGITEMTEMPLATEEX - void ConvertDlgToEx(const DLGTEMPLATE* pSrc, DLGTEMPLATEEX* pDst); + 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); + const BYTE* ReadCompoundData(const BYTE* pBuffer, WORD* pwData, PTSTR* ppszStr); -public: - struct _ITEM - { - DLGITEMTEMPLATEEX m_itemTemplate; - - WORD m_wClass = 0; - TCHAR *m_pszClass = nullptr; + public: + struct _ITEM + { + DLGITEMTEMPLATEEX m_itemTemplate; - WORD m_wTitle = 0; - TCHAR *m_pszTitle = 0; + WORD m_wClass = 0; + TCHAR *m_pszClass = nullptr; - WORD m_wCreationDataSize = 0; - BYTE *m_pbyCreationData = nullptr; - }; - vector<_ITEM> m_vItems; + WORD m_wTitle = 0; + TCHAR *m_pszTitle = 0; - DLGTEMPLATEEX m_dlgTemplate; + WORD m_wCreationDataSize = 0; + BYTE *m_pbyCreationData = nullptr; + }; - WORD m_wMenu = (WORD)-1; - TCHAR *m_pszMenu = nullptr; + std::vector<_ITEM> m_vItems; - WORD m_wClass = (WORD)-1; - TCHAR *m_pszClass = nullptr; + DLGTEMPLATEEX m_dlgTemplate; - WORD m_wTitle = (WORD)-1; // always -1 - TCHAR *m_pszTitle = nullptr; - - // font - WORD m_wFontSize = 0; - WORD m_wWeight = 0; - BYTE m_byItalic = 0; - BYTE m_byCharset = 0; - TCHAR *m_pszFace = nullptr; -}; + WORD m_wMenu = (WORD)-1; + TCHAR *m_pszMenu = nullptr; -// class stores information about control initial position and offset and scaling factors -class CControlResizeInfo -{ -public: - CControlResizeInfo(int iCtrlID, double dXPosFactor, double dYPosFactor, double dXScaleFactor, double dYScaleFactor); + WORD m_wClass = (WORD)-1; + TCHAR *m_pszClass = nullptr; - void SetInitialPosition(const CRect& rcPos); - void GetNewControlPlacement(const CRect& rcDlgInitial, const CRect& rcDlgCurrent, CRect& rcNewPlacement); + WORD m_wTitle = (WORD)-1; // always -1 + TCHAR *m_pszTitle = nullptr; - void ResetInitState(); - bool IsInitialized() const; + // font + WORD m_wFontSize = 0; + WORD m_wWeight = 0; + BYTE m_byItalic = 0; + BYTE m_byCharset = 0; + TCHAR *m_pszFace = nullptr; + }; - int GetControlID() const { return m_iControlID; } + // class stores information about control initial position and offset and scaling factors + class CControlResizeInfo + { + public: + CControlResizeInfo(int iCtrlID, double dXPosFactor, double dYPosFactor, double dXScaleFactor, double dYScaleFactor); -protected: - int m_iControlID; - CRect m_rcInitialPosition; - double m_dXOffsetFactor; - double m_dYOffsetFactor; - double m_dXScaleFactor; - double m_dYScaleFactor; -}; + void SetInitialPosition(const CRect& rcPos); + void GetNewControlPlacement(const CRect& rcDlgInitial, const CRect& rcDlgCurrent, CRect& rcNewPlacement); -///////////////////////////////////////////////////////////////////////////// -// CLanguageDialog dialog + void ResetInitState(); + bool IsInitialized() const; + + int GetControlID() const + { + return m_iControlID; + } + + protected: + int m_iControlID; + CRect m_rcInitialPosition; + double m_dXOffsetFactor; + double m_dYOffsetFactor; + double m_dXScaleFactor; + double m_dYScaleFactor; + }; + + ///////////////////////////////////////////////////////////////////////////// + // CLanguageDialog dialog #define LDF_NODIALOGSIZE 0x01 #define LDF_NODIALOGFONT 0x02 -class LIBICTRANSLATE_API CLanguageDialog : public CDialog -{ -public: -// Construction/destruction - explicit CLanguageDialog(bool* pLock=nullptr); - explicit CLanguageDialog(PCTSTR lpszTemplateName, CWnd* pParent = nullptr, bool* pLock=nullptr); // standard constructor - explicit CLanguageDialog(UINT uiIDTemplate, CWnd* pParent = nullptr, bool* pLock=nullptr); // standard constructor - CLanguageDialog(const CLanguageDialog&) = delete; + class LIBICTRANSLATE_API CLanguageDialog : public CDialog + { + public: + // Construction/destruction + explicit CLanguageDialog(bool* pLock = nullptr); + explicit CLanguageDialog(PCTSTR lpszTemplateName, CWnd* pParent = nullptr, bool* pLock = nullptr); // standard constructor + explicit CLanguageDialog(UINT uiIDTemplate, CWnd* pParent = nullptr, bool* pLock = nullptr); // standard constructor + CLanguageDialog(const CLanguageDialog&) = delete; - CLanguageDialog& operator=(const CLanguageDialog&) = delete; - - ~CLanguageDialog(); + CLanguageDialog& operator=(const CLanguageDialog&) = delete; - // static members - initialize global pointer to a resource manager - static void SetResManager(CResourceManager* prm) { m_prm=prm; }; + ~CLanguageDialog(); - // creation - INT_PTR DoModal() override; - virtual BOOL Create(); + // static members - initialize global pointer to a resource manager + static void SetResManager(CResourceManager* prm) + { + m_prm = prm; + }; - void MapRect(RECT* pRect); - CFont* GetFont() { return m_pFont ? m_pFont : ((CDialog*)this)->GetFont(); }; + // creation + INT_PTR DoModal() override; + virtual BOOL Create(); - afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo); - afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); - void OnHelpButton(); + void MapRect(RECT* pRect); + CFont* GetFont() + { + return m_pFont ? m_pFont : ((CDialog*)this)->GetFont(); + }; - // Controls resize support - void InitializeResizableControls(); - void ClearResizableControls(); - void AddResizableControl(int iCtrlID, double dXPosFactor, double dYPosFactor, double dXScaleFactor, double dYScaleFactor); - void RepositionResizableControls(); + afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + void OnHelpButton(); -protected: - void UpdateLanguage(); - virtual UINT GetLanguageUpdateOptions() { return 0; }; - virtual void OnLanguageChanged() { }; - void Cleanup(); + // Controls resize support + void InitializeResizableControls(); + void ClearResizableControls(); + void AddResizableControl(int iCtrlID, double dXPosFactor, double dYPosFactor, double dXScaleFactor, double dYScaleFactor); + void RepositionResizableControls(); - virtual BOOL OnTooltipText(UINT /*uiID*/, TOOLTIPTEXT* /*pTip*/) { return FALSE; }; - BOOL OnInitDialog() override; - void OnCancel() override; - void OnOK() override; - void PostNcDestroy() override; - LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam) override; + protected: + void UpdateLanguage(); + virtual UINT GetLanguageUpdateOptions() + { + return 0; + }; + virtual void OnLanguageChanged() + { + }; + void Cleanup(); - DECLARE_MESSAGE_MAP() -private: - void CalcBaseUnits(PCTSTR pszFacename, WORD wPointSize); + virtual BOOL OnTooltipText(UINT /*uiID*/, TOOLTIPTEXT* /*pTip*/) + { + return FALSE; + }; + BOOL OnInitDialog() override; + void OnCancel() override; + void OnOK() override; + void PostNcDestroy() override; + LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam) override; -// Attributes -public: - bool m_bAutoDelete; // deletes this dialog when exiting - bool m_bLockInstance; // allows only one instance of this dialog if set + DECLARE_MESSAGE_MAP() + private: + void CalcBaseUnits(PCTSTR pszFacename, WORD wPointSize); -protected: - static CResourceManager* m_prm; // points to the resource manager instance + // Attributes + public: + bool m_bAutoDelete; // deletes this dialog when exiting + bool m_bLockInstance; // allows only one instance of this dialog if set - 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; + protected: + static CResourceManager* m_prm; // points to the resource manager instance - // controls resizing capabilities - CRect m_rcDialogInitialPosition; - std::map m_mapResizeInfo; -}; + 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; -END_ICTRANSLATE_NAMESPACE + // controls resizing capabilities + CRect m_rcDialogInitialPosition; + std::map m_mapResizeInfo; + }; +} Index: src/libictranslate/ResourceManager.cpp =================================================================== diff -u -rd9527df01ee91b35d9a5fdccb80ded25a9c8265f -r19b135b50b55b75d008526a799344bda9a62dc22 --- src/libictranslate/ResourceManager.cpp (.../ResourceManager.cpp) (revision d9527df01ee91b35d9a5fdccb80ded25a9c8265f) +++ src/libictranslate/ResourceManager.cpp (.../ResourceManager.cpp) (revision 19b135b50b55b75d008526a799344bda9a62dc22) @@ -28,1072 +28,1070 @@ #endif #define TRANSLATION_FORMAT_VERSION _T("2") - -BEGIN_ICTRANSLATE_NAMESPACE - #define EMPTY_STRING _T("") -CResourceManager CResourceManager::S_ResourceManager; - -CFormat::CFormat(const wchar_t* pszFormat) : - m_strText(pszFormat) +namespace ictranslate { -} + CResourceManager CResourceManager::S_ResourceManager; -CFormat::CFormat() -{ -} + CFormat::CFormat(const wchar_t* pszFormat) : + m_strText(pszFormat) + { + } -CFormat::~CFormat() -{ -} + CFormat::CFormat() + { + } -void CFormat::SetFormat(const wchar_t* pszFormat) -{ - m_strText = pszFormat; -} + CFormat::~CFormat() + { + } -CFormat& CFormat::SetParam(PCTSTR pszName, PCTSTR pszText) -{ - assert(pszName); - if(!pszName) - return *this; - - size_t stLen = _tcslen(pszName); - std::wstring::size_type stPos = 0; - while((stPos = m_strText.find(pszName)) != std::wstring::npos) + void CFormat::SetFormat(const wchar_t* pszFormat) { - m_strText.replace(stPos, stLen, pszText); + m_strText = pszFormat; } - return *this; -} + CFormat& CFormat::SetParam(PCTSTR pszName, PCTSTR pszText) + { + assert(pszName); + if(!pszName) + return *this; -CFormat& CFormat::SetParam(PCTSTR pszName, unsigned long long ullData) -{ - wchar_t szBuffer[64]; - _sntprintf(szBuffer, 63, L"%I64u", ullData); - szBuffer[63] = _T('\0'); + size_t stLen = _tcslen(pszName); + std::wstring::size_type stPos = 0; + while((stPos = m_strText.find(pszName)) != std::wstring::npos) + { + m_strText.replace(stPos, stLen, pszText); + } - return SetParam(pszName, szBuffer); -} + return *this; + } -CFormat& CFormat::SetParam(PCTSTR pszName, long long llData) -{ - wchar_t szBuffer[64]; - _sntprintf(szBuffer, 63, L"%I64d", llData); - szBuffer[63] = _T('\0'); + CFormat& CFormat::SetParam(PCTSTR pszName, unsigned long long ullData) + { + wchar_t szBuffer[ 64 ]; + _sntprintf(szBuffer, 63, L"%I64u", ullData); + szBuffer[ 63 ] = _T('\0'); - return SetParam(pszName, szBuffer); -} + return SetParam(pszName, szBuffer); + } -CFormat& CFormat::SetParam(PCTSTR pszName, unsigned long ulData) -{ - wchar_t szBuffer[64]; - _sntprintf(szBuffer, 63, L"%lu", ulData); - szBuffer[63] = _T('\0'); + CFormat& CFormat::SetParam(PCTSTR pszName, long long llData) + { + wchar_t szBuffer[ 64 ]; + _sntprintf(szBuffer, 63, L"%I64d", llData); + szBuffer[ 63 ] = _T('\0'); - return SetParam(pszName, szBuffer); -} + return SetParam(pszName, szBuffer); + } -CFormat& CFormat::SetParam(PCTSTR pszName, unsigned int uiData) -{ - wchar_t szBuffer[64]; - _sntprintf(szBuffer, 63, L"%u", uiData); - szBuffer[63] = _T('\0'); + CFormat& CFormat::SetParam(PCTSTR pszName, unsigned long ulData) + { + wchar_t szBuffer[ 64 ]; + _sntprintf(szBuffer, 63, L"%lu", ulData); + szBuffer[ 63 ] = _T('\0'); - return SetParam(pszName, szBuffer); -} + return SetParam(pszName, szBuffer); + } -CFormat& CFormat::SetParam(PCTSTR pszName, int iData) -{ - wchar_t szBuffer[64]; - _sntprintf(szBuffer, 63, L"%d", iData); - szBuffer[63] = _T('\0'); + CFormat& CFormat::SetParam(PCTSTR pszName, unsigned int uiData) + { + wchar_t szBuffer[ 64 ]; + _sntprintf(szBuffer, 63, L"%u", uiData); + szBuffer[ 63 ] = _T('\0'); - return SetParam(pszName, szBuffer); -} + return SetParam(pszName, szBuffer); + } -CFormat& CFormat::SetParam(PCTSTR pszName, bool bData) -{ - wchar_t szBuffer[64]; - _sntprintf(szBuffer, 63, L"%hu", (unsigned short)bData); - szBuffer[63] = _T('\0'); + CFormat& CFormat::SetParam(PCTSTR pszName, int iData) + { + wchar_t szBuffer[ 64 ]; + _sntprintf(szBuffer, 63, L"%d", iData); + szBuffer[ 63 ] = _T('\0'); - return SetParam(pszName, szBuffer); -} + return SetParam(pszName, szBuffer); + } -CTranslationItem::CTranslationItem() -{ -} - -CTranslationItem::CTranslationItem(const wchar_t* pszText, unsigned int uiChecksum) -{ - if(pszText) + CFormat& CFormat::SetParam(PCTSTR pszName, bool bData) { - m_stTextLength = _tcslen(pszText); - if(m_stTextLength > 0) - { - m_pszText = new wchar_t[m_stTextLength + 1]; - _tcscpy(m_pszText, pszText); + wchar_t szBuffer[ 64 ]; + _sntprintf(szBuffer, 63, L"%hu", (unsigned short)bData); + szBuffer[ 63 ] = _T('\0'); - UnescapeString(); - } + return SetParam(pszName, szBuffer); + } - m_uiChecksum = uiChecksum; + CTranslationItem::CTranslationItem() + { } -} -ictranslate::CTranslationItem::CTranslationItem(const CTranslationItem& rSrc) -{ - if(rSrc.m_pszText) + CTranslationItem::CTranslationItem(const wchar_t* pszText, unsigned int uiChecksum) { - m_stTextLength = _tcslen(rSrc.m_pszText); - if(m_stTextLength > 0) + if(pszText) { - m_pszText = new wchar_t[ m_stTextLength + 1 ]; - _tcscpy(m_pszText, rSrc.m_pszText); + m_stTextLength = _tcslen(pszText); + if(m_stTextLength > 0) + { + m_pszText = new wchar_t[ m_stTextLength + 1 ]; + _tcscpy(m_pszText, pszText); - UnescapeString(); + UnescapeString(); + } + + m_uiChecksum = uiChecksum; } } -} -CTranslationItem::~CTranslationItem() -{ - Clear(); -} - -CTranslationItem& CTranslationItem::operator=(const CTranslationItem& rSrc) -{ - if(this != &rSrc) + ictranslate::CTranslationItem::CTranslationItem(const CTranslationItem& rSrc) { - Clear(); if(rSrc.m_pszText) { - m_stTextLength = rSrc.m_stTextLength; + m_stTextLength = _tcslen(rSrc.m_pszText); if(m_stTextLength > 0) { - m_pszText = new wchar_t[rSrc.m_stTextLength + 1]; + m_pszText = new wchar_t[ m_stTextLength + 1 ]; _tcscpy(m_pszText, rSrc.m_pszText); + + UnescapeString(); } } - m_uiChecksum = rSrc.m_uiChecksum; } - return *this; -} + CTranslationItem::~CTranslationItem() + { + Clear(); + } -void CTranslationItem::Clear() -{ - delete [] m_pszText; - m_pszText = nullptr; - m_stTextLength = 0; - m_uiChecksum = 0; -} - -const wchar_t* CTranslationItem::GetText() const -{ - return m_pszText ? m_pszText : _T(""); -} - -void CTranslationItem::SetText(const wchar_t* pszText, bool bUnescapeString) -{ - delete [] m_pszText; - if(pszText) + CTranslationItem& CTranslationItem::operator=(const CTranslationItem& rSrc) { - m_stTextLength = _tcslen(pszText); - if(m_stTextLength > 0) + if(this != &rSrc) { - m_pszText = new wchar_t[m_stTextLength + 1]; - _tcscpy(m_pszText, pszText); - if(bUnescapeString) - UnescapeString(); - return; + Clear(); + if(rSrc.m_pszText) + { + m_stTextLength = rSrc.m_stTextLength; + if(m_stTextLength > 0) + { + m_pszText = new wchar_t[ rSrc.m_stTextLength + 1 ]; + _tcscpy(m_pszText, rSrc.m_pszText); + } + } + m_uiChecksum = rSrc.m_uiChecksum; } + + return *this; } - m_pszText = nullptr; - m_stTextLength = 0; -} + void CTranslationItem::Clear() + { + delete[] m_pszText; + m_pszText = nullptr; + m_stTextLength = 0; + m_uiChecksum = 0; + } -void CTranslationItem::UnescapeString() -{ - if(!m_pszText) - return; + const wchar_t* CTranslationItem::GetText() const + { + return m_pszText ? m_pszText : _T(""); + } - const wchar_t* pszIn = m_pszText; - wchar_t* pszOut = m_pszText; - while (*pszIn != 0) + void CTranslationItem::SetText(const wchar_t* pszText, bool bUnescapeString) { - if (*pszIn == _T('\\')) + delete[] m_pszText; + if(pszText) { - pszIn++; - switch(*pszIn++) + m_stTextLength = _tcslen(pszText); + if(m_stTextLength > 0) { - case _T('t'): - *pszOut++ = _T('\t'); - break; - case _T('r'): - *pszOut++ = _T('\r'); - break; - case _T('n'): - *pszOut++ = _T('\n'); - break; - default: - *pszOut++ = _T('\\'); + m_pszText = new wchar_t[ m_stTextLength + 1 ]; + _tcscpy(m_pszText, pszText); + if(bUnescapeString) + UnescapeString(); + return; } } - else - *pszOut++ = *pszIn++; + + m_pszText = nullptr; + m_stTextLength = 0; } - *pszOut = _T('\0'); -} -CTranslationItem::ECompareResult CTranslationItem::Compare(const CTranslationItem& rReferenceItem) -{ - if(!m_pszText || !rReferenceItem.m_pszText) - return eResult_Invalid; + void CTranslationItem::UnescapeString() + { + if(!m_pszText) + return; - if(m_uiChecksum != rReferenceItem.m_uiChecksum) - return eResult_Invalid; + const wchar_t* pszIn = m_pszText; + wchar_t* pszOut = m_pszText; + while(*pszIn != 0) + { + if(*pszIn == _T('\\')) + { + pszIn++; + switch(*pszIn++) + { + 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++ = *pszIn++; + } + *pszOut = _T('\0'); + } - // space check - if(rReferenceItem.m_pszText[0] == _T(' ') && m_pszText[0] != _T(' ')) - return eResult_ContentWarning; - - size_t stReferenceLen = _tcslen(rReferenceItem.m_pszText); - size_t stOwnLen = _tcslen(m_pszText); - if(stReferenceLen > 0 && stOwnLen > 0 && rReferenceItem.m_pszText[stReferenceLen - 1] == _T(' ') && m_pszText[stOwnLen - 1] != _T(' ')) - return eResult_ContentWarning; + CTranslationItem::ECompareResult CTranslationItem::Compare(const CTranslationItem& rReferenceItem) + { + if(!m_pszText || !rReferenceItem.m_pszText) + return eResult_Invalid; - // formatting strings check - std::set setRefFmt; - if(!rReferenceItem.GetFormatStrings(setRefFmt)) - return eResult_ContentWarning; + if(m_uiChecksum != rReferenceItem.m_uiChecksum) + return eResult_Invalid; - std::set setThisFmt; - if(!GetFormatStrings(setThisFmt)) - return eResult_ContentWarning; + // space check + if(rReferenceItem.m_pszText[ 0 ] == _T(' ') && m_pszText[ 0 ] != _T(' ')) + return eResult_ContentWarning; - if(setRefFmt != setThisFmt) - return eResult_ContentWarning; + size_t stReferenceLen = _tcslen(rReferenceItem.m_pszText); + size_t stOwnLen = _tcslen(m_pszText); + if(stReferenceLen > 0 && stOwnLen > 0 && rReferenceItem.m_pszText[ stReferenceLen - 1 ] == _T(' ') && m_pszText[ stOwnLen - 1 ] != _T(' ')) + return eResult_ContentWarning; - return eResult_Valid; -} + // formatting strings check + std::set setRefFmt; + if(!rReferenceItem.GetFormatStrings(setRefFmt)) + return eResult_ContentWarning; -bool CTranslationItem::GetFormatStrings(std::set& setFmtStrings) const -{ - setFmtStrings.clear(); + std::set setThisFmt; + if(!GetFormatStrings(setThisFmt)) + return eResult_ContentWarning; - const wchar_t* pszData = m_pszText; - const size_t stMaxFmt = 256; - wchar_t szFmt[stMaxFmt]; - while((pszData = _tcschr(pszData, _T('%'))) != nullptr) - { - pszData++; // it works assuming the string is null-terminated + if(setRefFmt != setThisFmt) + return eResult_ContentWarning; - // search the end of fmt string - const wchar_t* pszNext = pszData; - while(*pszNext && isalpha(*pszNext)) - pszNext++; + return eResult_Valid; + } - // if we have bigger buffer needs than is available - if(pszNext - pszData >= stMaxFmt) - return false; + bool CTranslationItem::GetFormatStrings(std::set& setFmtStrings) const + { + setFmtStrings.clear(); - // copy data - _tcsncpy(szFmt, pszData, pszNext - pszData); - szFmt[pszNext - pszData] = _T('\0'); + const wchar_t* pszData = m_pszText; + const size_t stMaxFmt = 256; + wchar_t szFmt[ stMaxFmt ]; + while((pszData = _tcschr(pszData, _T('%'))) != nullptr) + { + pszData++; // it works assuming the string is null-terminated - setFmtStrings.insert(std::wstring(szFmt)); - } + // search the end of fmt string + const wchar_t* pszNext = pszData; + while(*pszNext && isalpha(*pszNext)) + pszNext++; - return true; -} + // if we have bigger buffer needs than is available + if(pszNext - pszData >= stMaxFmt) + return false; -CLangData::CLangData() : - m_pszFilename(nullptr), - m_pszLngName(nullptr), - m_pszFontFace(nullptr), - m_wPointSize(0), - m_pszHelpName(nullptr), - m_pszAuthor(nullptr), - m_bRTL(false), - m_uiSectionID(0), - m_bUpdating(false), - m_bModified(false) -{ -} + // copy data + _tcsncpy(szFmt, pszData, pszNext - pszData); + szFmt[ pszNext - pszData ] = _T('\0'); -CLangData::~CLangData() -{ - delete [] m_pszFilename; - delete [] m_pszLngName; - delete [] m_pszFontFace; - delete [] m_pszHelpName; - delete [] m_pszAuthor; -} + setFmtStrings.insert(std::wstring(szFmt)); + } -void CLangData::Clear() -{ - delete [] m_pszFilename; - m_pszFilename = nullptr; - delete [] m_pszLngName; - m_pszLngName = nullptr; - delete [] m_pszFontFace; - m_pszFontFace = nullptr; - delete [] m_pszHelpName; - m_pszHelpName = nullptr; - delete [] m_pszAuthor; - m_pszAuthor = nullptr; - m_bModified = false; - m_bRTL = false; - m_bUpdating = false; - m_uiSectionID = 0; - m_wPointSize = 0; + return true; + } - m_mapTranslation.clear(); -} + CLangData::CLangData() : + m_pszFilename(nullptr), + m_pszLngName(nullptr), + m_pszFontFace(nullptr), + m_wPointSize(0), + m_pszHelpName(nullptr), + m_pszAuthor(nullptr), + m_bRTL(false), + m_uiSectionID(0), + m_bUpdating(false), + m_bModified(false) + { + } -CLangData::CLangData(const CLangData& ld) : - m_pszFilename(nullptr), - m_pszLngName(nullptr), - m_pszFontFace(nullptr), - m_wPointSize(ld.m_wPointSize), - m_pszHelpName(nullptr), - m_pszAuthor(nullptr), - m_bRTL(ld.m_bRTL), - m_uiSectionID(ld.m_uiSectionID), - m_bUpdating(ld.m_bUpdating), - m_bModified(false) -{ - SetFilename(ld.GetFilename(true)); - SetLangName(ld.GetLangName()); - SetFontFace(ld.GetFontFace()); - SetPointSize(ld.GetPointSize()); - SetDirection(ld.GetDirection()); - SetHelpName(ld.GetHelpName()); - SetAuthor(ld.GetAuthor()); + CLangData::~CLangData() + { + delete[] m_pszFilename; + delete[] m_pszLngName; + delete[] m_pszFontFace; + delete[] m_pszHelpName; + delete[] m_pszAuthor; + } - m_mapTranslation.insert(ld.m_mapTranslation.begin(), ld.m_mapTranslation.end()); -} - -CLangData& CLangData::operator=(const CLangData& rSrc) -{ - if(this != &rSrc) + void CLangData::Clear() { - SetFilename(rSrc.GetFilename(true)); - SetLangName(rSrc.GetLangName()); - SetFontFace(rSrc.GetFontFace()); - SetPointSize(rSrc.GetPointSize()); - SetDirection(rSrc.GetDirection()); - SetHelpName(rSrc.GetHelpName()); - SetAuthor(rSrc.GetAuthor()); - m_bRTL = rSrc.m_bRTL; - m_bUpdating = rSrc.m_bUpdating; - m_uiSectionID = rSrc.m_uiSectionID; - m_wPointSize = rSrc.m_wPointSize; + delete[] m_pszFilename; + m_pszFilename = nullptr; + delete[] m_pszLngName; + m_pszLngName = nullptr; + delete[] m_pszFontFace; + m_pszFontFace = nullptr; + delete[] m_pszHelpName; + m_pszHelpName = nullptr; + delete[] m_pszAuthor; + m_pszAuthor = nullptr; m_bModified = false; + m_bRTL = false; + m_bUpdating = false; + m_uiSectionID = 0; + m_wPointSize = 0; - m_mapTranslation.insert(rSrc.m_mapTranslation.begin(), rSrc.m_mapTranslation.end()); + m_mapTranslation.clear(); } - return *this; -} + CLangData::CLangData(const CLangData& ld) : + m_pszFilename(nullptr), + m_pszLngName(nullptr), + m_pszFontFace(nullptr), + m_wPointSize(ld.m_wPointSize), + m_pszHelpName(nullptr), + m_pszAuthor(nullptr), + m_bRTL(ld.m_bRTL), + m_uiSectionID(ld.m_uiSectionID), + m_bUpdating(ld.m_bUpdating), + m_bModified(false) + { + SetFilename(ld.GetFilename(true)); + SetLangName(ld.GetLangName()); + SetFontFace(ld.GetFontFace()); + SetPointSize(ld.GetPointSize()); + SetDirection(ld.GetDirection()); + SetHelpName(ld.GetHelpName()); + SetAuthor(ld.GetAuthor()); -bool CLangData::ReadInfo(PCTSTR pszFile) -{ - try + m_mapTranslation.insert(ld.m_mapTranslation.begin(), ld.m_mapTranslation.end()); + } + + CLangData& CLangData::operator=(const CLangData& rSrc) { - Clear(); + if(this != &rSrc) + { + SetFilename(rSrc.GetFilename(true)); + SetLangName(rSrc.GetLangName()); + SetFontFace(rSrc.GetFontFace()); + SetPointSize(rSrc.GetPointSize()); + SetDirection(rSrc.GetDirection()); + SetHelpName(rSrc.GetHelpName()); + SetAuthor(rSrc.GetAuthor()); + m_bRTL = rSrc.m_bRTL; + m_bUpdating = rSrc.m_bUpdating; + m_uiSectionID = rSrc.m_uiSectionID; + m_wPointSize = rSrc.m_wPointSize; + m_bModified = false; - config cfg(config::eIni); - const unsigned int uiLangName = cfg.register_string(_T("Info/Lang Name"), _T("")); - const unsigned int uiFontFace = cfg.register_string(_T("Info/Font Face"), _T("")); - const unsigned int uiSize = cfg.register_signed_num(_T("Info/Size"), 0, 0, 0xffff); - const unsigned int uiRTL = cfg.register_bool(_T("Info/RTL reading order"), false); - const unsigned int uiHelpName = cfg.register_string(_T("Info/Help name"), _T("")); - const unsigned int uiAuthor = cfg.register_string(_T("Info/Author"), _T("")); - const unsigned int uiVersion = cfg.register_string(_T("Info/Format version"), _T("1")); + m_mapTranslation.insert(rSrc.m_mapTranslation.begin(), rSrc.m_mapTranslation.end()); + } - cfg.read(pszFile); - - // we don't support old language versions - const wchar_t* pszVersion = cfg.get_string(uiVersion); - if(_tcscmp(pszVersion, TRANSLATION_FORMAT_VERSION) != 0) - return false; + return *this; + } - const wchar_t* psz = cfg.get_string(uiLangName); - if(!psz || psz[0] == _T('\0')) - return false; - SetLangName(psz); + bool CLangData::ReadInfo(PCTSTR pszFile) + { + try + { + Clear(); - psz = cfg.get_string(uiFontFace); - if(!psz || psz[0] == _T('\0')) - return false; - SetFontFace(psz); + config cfg(config::eIni); + const unsigned int uiLangName = cfg.register_string(_T("Info/Lang Name"), _T("")); + const unsigned int uiFontFace = cfg.register_string(_T("Info/Font Face"), _T("")); + const unsigned int uiSize = cfg.register_signed_num(_T("Info/Size"), 0, 0, 0xffff); + const unsigned int uiRTL = cfg.register_bool(_T("Info/RTL reading order"), false); + const unsigned int uiHelpName = cfg.register_string(_T("Info/Help name"), _T("")); + const unsigned int uiAuthor = cfg.register_string(_T("Info/Author"), _T("")); + const unsigned int uiVersion = cfg.register_string(_T("Info/Format version"), _T("1")); - long long ll = cfg.get_signed_num(uiSize); - if(ll == 0) - return false; - SetPointSize((WORD)ll); + cfg.read(pszFile); - SetDirection(cfg.get_bool(uiRTL)); + // we don't support old language versions + const wchar_t* pszVersion = cfg.get_string(uiVersion); + if(_tcscmp(pszVersion, TRANSLATION_FORMAT_VERSION) != 0) + return false; - psz = cfg.get_string(uiHelpName); - if(!psz || psz[0] == _T('\0')) - return false; - SetHelpName(psz); + const wchar_t* psz = cfg.get_string(uiLangName); + if(!psz || psz[ 0 ] == _T('\0')) + return false; + SetLangName(psz); - psz = cfg.get_string(uiAuthor); - if(!psz || psz[0] == _T('\0')) - return false; - SetAuthor(psz); + psz = cfg.get_string(uiFontFace); + if(!psz || psz[ 0 ] == _T('\0')) + return false; + SetFontFace(psz); - SetFilename(pszFile); + long long ll = cfg.get_signed_num(uiSize); + if(ll == 0) + return false; + SetPointSize((WORD)ll); - m_bModified = false; + SetDirection(cfg.get_bool(uiRTL)); - return true; - } - catch(...) - { - return false; - } -} + psz = cfg.get_string(uiHelpName); + if(!psz || psz[ 0 ] == _T('\0')) + return false; + SetHelpName(psz); -void CLangData::EnumAttributesCallback(bool bGroup, const wchar_t* pszName, const wchar_t* pszValue, void* pData) -{ - CLangData* pLangData = (CLangData*)pData; - assert(pLangData); - assert(pszName); - if(!pLangData || !pszName) - return; + psz = cfg.get_string(uiAuthor); + if(!psz || psz[ 0 ] == _T('\0')) + return false; + SetAuthor(psz); - if(bGroup && _tcsicmp(pszName, _T("Info")) == 0) - return; - if(bGroup) - { - // new section - remember in member - pLangData->m_uiSectionID = _ttoi(pszName); + SetFilename(pszFile); + + m_bModified = false; + + return true; + } + catch(...) + { + return false; + } } - else + + void CLangData::EnumAttributesCallback(bool bGroup, const wchar_t* pszName, const wchar_t* pszValue, void* pData) { - unsigned int uiID = 0; - unsigned int uiChecksum = 0; + CLangData* pLangData = (CLangData*)pData; + assert(pLangData); + assert(pszName); + if(!pLangData || !pszName) + return; - // parse the pszName to get both the string id and checksum - const wchar_t* pszChecksum = _tcschr(pszName, _T('[')); - if(pszChecksum == nullptr) + if(bGroup && _tcsicmp(pszName, _T("Info")) == 0) + return; + if(bGroup) { - TRACE(_T("Warning! Old-style translation string %s.\n"), pszName); - - int iCount = _stscanf(pszName, L"%u", &uiID); - if(iCount != 1) - { - TRACE(_T("Warning! Problem retrieving id from string '%s'\n"), pszName); - return; - } + // new section - remember in member + pLangData->m_uiSectionID = _ttoi(pszName); } else { - int iCount = _stscanf(pszName, L"%u[0x%x]", &uiID, &uiChecksum); - if(iCount != 2) + unsigned int uiID = 0; + unsigned int uiChecksum = 0; + + // parse the pszName to get both the string id and checksum + const wchar_t* pszChecksum = _tcschr(pszName, _T('[')); + if(pszChecksum == nullptr) { - TRACE(_T("Warning! Problem retrieving id/checksum from string '%s'\n"), pszName); - return; + TRACE(_T("Warning! Old-style translation string %s.\n"), pszName); + + int iCount = _stscanf(pszName, L"%u", &uiID); + if(iCount != 1) + { + TRACE(_T("Warning! Problem retrieving id from string '%s'\n"), pszName); + return; + } } - } + else + { + int iCount = _stscanf(pszName, L"%u[0x%x]", &uiID, &uiChecksum); + if(iCount != 2) + { + TRACE(_T("Warning! Problem retrieving id/checksum from string '%s'\n"), pszName); + return; + } + } - unsigned int uiKey = pLangData->m_uiSectionID << 16 | uiID; - translation_map::iterator itTranslation = pLangData->m_mapTranslation.end(); - if(pLangData->m_bUpdating) - { - // check if the checksum exists and matches - itTranslation = pLangData->m_mapTranslation.find(uiKey); - if(itTranslation == pLangData->m_mapTranslation.end()) + unsigned int uiKey = pLangData->m_uiSectionID << 16 | uiID; + translation_map::iterator itTranslation = pLangData->m_mapTranslation.end(); + if(pLangData->m_bUpdating) { - TRACE(_T("Warning! Superfluous entry %lu in processed language file\n"), uiKey); - return; // entry not found - probably superfluous entry in the language file + // check if the checksum exists and matches + itTranslation = pLangData->m_mapTranslation.find(uiKey); + if(itTranslation == pLangData->m_mapTranslation.end()) + { + TRACE(_T("Warning! Superfluous entry %lu in processed language file\n"), uiKey); + return; // entry not found - probably superfluous entry in the language file + } + + if((*itTranslation).second.GetChecksum() != uiChecksum) + { + TRACE(_T("Warning! Invalid checksum for string ID %lu in processed language file\n"), uiKey); + return; // entry has invalid checksum (older version of translation) + } } + else + { + std::pair pairTranslation = pLangData->m_mapTranslation.insert(translation_map::value_type(uiKey, CTranslationItem())); + itTranslation = pairTranslation.first; + } - if((*itTranslation).second.GetChecksum() != uiChecksum) + assert(itTranslation != pLangData->m_mapTranslation.end()); + if(itTranslation != pLangData->m_mapTranslation.end()) { - TRACE(_T("Warning! Invalid checksum for string ID %lu in processed language file\n"), uiKey); - return; // entry has invalid checksum (older version of translation) + (*itTranslation).second.SetText(pszValue, true); + if(!pLangData->m_bUpdating) + (*itTranslation).second.SetChecksum(uiChecksum); } } - else - { - std::pair pairTranslation = pLangData->m_mapTranslation.insert(translation_map::value_type(uiKey, CTranslationItem())); - itTranslation = pairTranslation.first; - } + } - assert(itTranslation != pLangData->m_mapTranslation.end()); - if(itTranslation != pLangData->m_mapTranslation.end()) + void CLangData::UnescapeString(wchar_t* pszData) + { + wchar_t* pszOut = pszData; + while(*pszData != 0) { - (*itTranslation).second.SetText(pszValue, true); - if(!pLangData->m_bUpdating) - (*itTranslation).second.SetChecksum(uiChecksum); + 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'); + } -} -void CLangData::UnescapeString(wchar_t* pszData) -{ - wchar_t* pszOut = pszData; - while (*pszData != 0) + bool CLangData::ReadTranslation(PCTSTR pszFile, bool bUpdateTranslation, bool bIgnoreVersion) { - if (*pszData == _T('\\')) + try { - pszData++; - switch(*pszData++) + if(!bUpdateTranslation) + Clear(); + + // load data from file + config cfg(config::eIni); + const unsigned int uiLangName = cfg.register_string(_T("Info/Lang Name"), _T("")); + const unsigned int uiFontFace = cfg.register_string(_T("Info/Font Face"), _T("")); + const unsigned int uiSize = cfg.register_signed_num(_T("Info/Size"), 0, 0, 0xffff); + const unsigned int uiRTL = cfg.register_bool(_T("Info/RTL reading order"), false); + const unsigned int uiHelpName = cfg.register_string(_T("Info/Help name"), _T("")); + const unsigned int uiAuthor = cfg.register_string(_T("Info/Author"), _T("")); + const unsigned int uiVersion = cfg.register_string(_T("Info/Format version"), _T("1")); + + cfg.read(pszFile); + + // we don't support old language versions unless requested specifically + if(!bIgnoreVersion) { - case _T('t'): - *pszOut++ = _T('\t'); - break; - case _T('r'): - *pszOut++ = _T('\r'); - break; - case _T('n'): - *pszOut++ = _T('\n'); - break; - default: - *pszOut++ = _T('\\'); + const wchar_t* pszVersion = cfg.get_string(uiVersion); + if(_tcscmp(pszVersion, TRANSLATION_FORMAT_VERSION) != 0) + return false; } - } - else - *pszOut++ = *pszData++; - } - *pszOut = _T('\0'); -} + const wchar_t* psz = cfg.get_string(uiLangName); + if(!psz || psz[ 0 ] == _T('\0')) + return false; + SetLangName(psz); -bool CLangData::ReadTranslation(PCTSTR pszFile, bool bUpdateTranslation, bool bIgnoreVersion) -{ - try - { - if(!bUpdateTranslation) - Clear(); + psz = cfg.get_string(uiFontFace); + if(!psz || psz[ 0 ] == _T('\0')) + return false; + SetFontFace(psz); - // load data from file - config cfg(config::eIni); - const unsigned int uiLangName = cfg.register_string(_T("Info/Lang Name"), _T("")); - const unsigned int uiFontFace = cfg.register_string(_T("Info/Font Face"), _T("")); - const unsigned int uiSize = cfg.register_signed_num(_T("Info/Size"), 0, 0, 0xffff); - const unsigned int uiRTL = cfg.register_bool(_T("Info/RTL reading order"), false); - const unsigned int uiHelpName = cfg.register_string(_T("Info/Help name"), _T("")); - const unsigned int uiAuthor = cfg.register_string(_T("Info/Author"), _T("")); - const unsigned int uiVersion = cfg.register_string(_T("Info/Format version"), _T("1")); + long long ll = cfg.get_signed_num(uiSize); + if(ll == 0) + return false; + SetPointSize((WORD)ll); - cfg.read(pszFile); + SetDirection(cfg.get_bool(uiRTL)); - // we don't support old language versions unless requested specifically - if(!bIgnoreVersion) - { - const wchar_t* pszVersion = cfg.get_string(uiVersion); - if(_tcscmp(pszVersion, TRANSLATION_FORMAT_VERSION) != 0) + psz = cfg.get_string(uiHelpName); + if(!psz || psz[ 0 ] == _T('\0')) return false; - } + SetHelpName(psz); - const wchar_t* psz = cfg.get_string(uiLangName); - if(!psz || psz[0] == _T('\0')) - return false; - SetLangName(psz); + psz = cfg.get_string(uiAuthor); + if(!psz || psz[ 0 ] == _T('\0')) + return false; + SetAuthor(psz); - psz = cfg.get_string(uiFontFace); - if(!psz || psz[0] == _T('\0')) - return false; - SetFontFace(psz); + m_bUpdating = bUpdateTranslation; + m_uiSectionID = 0; + if(!cfg.enum_properties(_T("*"), EnumAttributesCallback, this)) + { + m_bUpdating = false; + return false; + } + m_bUpdating = false; - long long ll = cfg.get_signed_num(uiSize); - if(ll == 0) - return false; - SetPointSize((WORD)ll); + SetFilename(pszFile); - SetDirection(cfg.get_bool(uiRTL)); + m_bModified = false; - psz = cfg.get_string(uiHelpName); - if(!psz || psz[0] == _T('\0')) + return true; + } + catch(...) + { return false; - SetHelpName(psz); + } + } - psz = cfg.get_string(uiAuthor); - if(!psz || psz[0] == _T('\0')) - return false; - SetAuthor(psz); + void CLangData::WriteTranslation(PCTSTR pszPath) + { + if(!IsValidDescription()) + throw std::runtime_error("Invalid translation information (author, name or point size)"); - m_bUpdating = bUpdateTranslation; - m_uiSectionID = 0; - if(!cfg.enum_properties(_T("*"), EnumAttributesCallback, this)) + // real writing + const int iBufferSize = 256; + wchar_t szTemp[ iBufferSize ]; + + // load data from file + config cfg(config::eIni); + cfg.set_string(_T("Info/Lang Name"), m_pszLngName); + cfg.set_string(_T("Info/Font Face"), m_pszFontFace); + cfg.set_string(_T("Info/Size"), _itot(m_wPointSize, szTemp, 10)); + cfg.set_string(_T("Info/RTL reading order"), m_bRTL ? _T("1") : _T("0")); + cfg.set_string(_T("Info/Help name"), m_pszHelpName); + cfg.set_string(_T("Info/Author"), m_pszAuthor); + cfg.set_string(_T("Info/Format version"), TRANSLATION_FORMAT_VERSION); + + std::wstring strText; + for(translation_map::iterator it = m_mapTranslation.begin(); it != m_mapTranslation.end(); ++it) { - m_bUpdating = false; - return false; + unsigned int uiKey = (*it).first; + _sntprintf(szTemp, iBufferSize - 1, L"%u/%u[0x%x]", (uiKey >> 16), uiKey & 0x0000ffff, (*it).second.GetChecksum()); + + strText = (*it).second.GetText(); + std::wstring::size_type stPos; + while((stPos = strText.find_first_of(_T("\r\n\t"))) != std::wstring::npos) + { + switch(strText[ stPos ]) + { + case _T('\r'): + strText.replace(stPos, 1, _T("\\r")); + break; + case _T('\n'): + strText.replace(stPos, 1, _T("\\n")); + break; + case _T('\t'): + strText.replace(stPos, 1, _T("\\t")); + break; + } + } + + cfg.set_string(szTemp, strText.c_str()); } - m_bUpdating = false; - SetFilename(pszFile); + if(pszPath == nullptr) + pszPath = m_pszFilename; + else + SetFilename(pszPath); + cfg.write(pszPath); m_bModified = false; - - return true; } - catch(...) + + PCTSTR CLangData::GetString(WORD wHiID, WORD wLoID) { - return false; + translation_map::const_iterator it = m_mapTranslation.find((wHiID << 16) | wLoID); + if(it != m_mapTranslation.end()) + return (*it).second.GetText(); + else + return EMPTY_STRING; } -} -void CLangData::WriteTranslation(PCTSTR pszPath) -{ - if(!IsValidDescription()) - throw std::runtime_error("Invalid translation information (author, name or point size)"); - - // real writing - const int iBufferSize = 256; - wchar_t szTemp[iBufferSize]; - - // load data from file - config cfg(config::eIni); - cfg.set_string(_T("Info/Lang Name"), m_pszLngName); - cfg.set_string(_T("Info/Font Face"), m_pszFontFace); - cfg.set_string(_T("Info/Size"), _itot(m_wPointSize, szTemp, 10)); - cfg.set_string(_T("Info/RTL reading order"), m_bRTL ? _T("1") : _T("0")); - cfg.set_string(_T("Info/Help name"), m_pszHelpName); - cfg.set_string(_T("Info/Author"), m_pszAuthor); - cfg.set_string(_T("Info/Format version"), TRANSLATION_FORMAT_VERSION); - - std::wstring strText; - for(translation_map::iterator it = m_mapTranslation.begin(); it != m_mapTranslation.end(); ++it) + void CLangData::EnumStrings(PFNENUMCALLBACK pfnCallback, void* pData) { - unsigned int uiKey = (*it).first; - _sntprintf(szTemp, iBufferSize - 1, L"%u/%u[0x%x]", (uiKey >> 16), uiKey & 0x0000ffff, (*it).second.GetChecksum()); + for(translation_map::const_iterator iterTranslation = m_mapTranslation.begin(); iterTranslation != m_mapTranslation.end(); ++iterTranslation) + { + (*pfnCallback)((*iterTranslation).first, &(*iterTranslation).second, pData); + } + } - strText = (*it).second.GetText(); - std::wstring::size_type stPos; - while((stPos = strText.find_first_of(_T("\r\n\t"))) != std::wstring::npos) + CTranslationItem* CLangData::GetTranslationItem(unsigned int uiTranslationKey, bool bCreate) + { + translation_map::iterator iterTranslation = m_mapTranslation.find(uiTranslationKey); + if(iterTranslation != m_mapTranslation.end()) + return &(*iterTranslation).second; + else { - switch(strText[stPos]) + if(bCreate) { - case _T('\r'): - strText.replace(stPos, 1, _T("\\r")); - break; - case _T('\n'): - strText.replace(stPos, 1, _T("\\n")); - break; - case _T('\t'): - strText.replace(stPos, 1, _T("\\t")); - break; + std::pair pairTranslation = m_mapTranslation.insert(std::make_pair(uiTranslationKey, CTranslationItem())); + if(pairTranslation.second) + { + m_bModified = true; + return &(*pairTranslation.first).second; + } } } - cfg.set_string(szTemp, strText.c_str()); + return nullptr; } - if(pszPath == nullptr) - pszPath = m_pszFilename; - else - SetFilename(pszPath); - cfg.write(pszPath); - - m_bModified = false; -} - -PCTSTR CLangData::GetString(WORD wHiID, WORD wLoID) -{ - translation_map::const_iterator it=m_mapTranslation.find((wHiID << 16) | wLoID); - if (it != m_mapTranslation.end()) - return (*it).second.GetText(); - else - return EMPTY_STRING; -} - -void CLangData::EnumStrings(PFNENUMCALLBACK pfnCallback, void* pData) -{ - for(translation_map::const_iterator iterTranslation = m_mapTranslation.begin(); iterTranslation != m_mapTranslation.end(); ++iterTranslation) + bool CLangData::Exists(unsigned int uiTranslationKey) const { - (*pfnCallback)((*iterTranslation).first, &(*iterTranslation).second, pData); + return m_mapTranslation.find(uiTranslationKey) != m_mapTranslation.end(); } -} -CTranslationItem* CLangData::GetTranslationItem(unsigned int uiTranslationKey, bool bCreate) -{ - translation_map::iterator iterTranslation = m_mapTranslation.find(uiTranslationKey); - if(iterTranslation != m_mapTranslation.end()) - return &(*iterTranslation).second; - else + // removes strings that does not exist in the reference translation + void CLangData::CleanupTranslation(const CLangData& rReferenceTranslation) { - if(bCreate) + translation_map::iterator iterTranslation = m_mapTranslation.begin(); + while(iterTranslation != m_mapTranslation.end()) { - std::pair pairTranslation = m_mapTranslation.insert(std::make_pair(uiTranslationKey, CTranslationItem())); - if(pairTranslation.second) + if(!rReferenceTranslation.Exists((*iterTranslation).first)) { m_bModified = true; - return &(*pairTranslation.first).second; + m_mapTranslation.erase(iterTranslation++); } + else + ++iterTranslation; } } - return nullptr; -} + void CLangData::SetFilename(PCTSTR psz) + { + if(m_pszFilename) + delete[] m_pszFilename; -bool CLangData::Exists(unsigned int uiTranslationKey) const -{ - return m_mapTranslation.find(uiTranslationKey) != m_mapTranslation.end(); -} + // copy + m_pszFilename = new TCHAR[ _tcslen(psz) + 1 ]; + _tcscpy(m_pszFilename, psz); -// removes strings that does not exist in the reference translation -void CLangData::CleanupTranslation(const CLangData& rReferenceTranslation) -{ - translation_map::iterator iterTranslation = m_mapTranslation.begin(); - while(iterTranslation != m_mapTranslation.end()) + m_bModified = true; + } + + PCTSTR CLangData::GetFilename(bool bFullPath) const { - if(!rReferenceTranslation.Exists((*iterTranslation).first)) + if(bFullPath) + return m_pszFilename; + else { - m_bModified = true; - m_mapTranslation.erase(iterTranslation++); + if(m_pszFilename) + { + TCHAR *pszFnd = _tcsrchr(m_pszFilename, _T('\\')); + if(pszFnd) + return pszFnd + 1; + } + + return m_pszFilename; } - else - ++iterTranslation; } -} -void CLangData::SetFilename(PCTSTR psz) -{ - if (m_pszFilename) - delete [] m_pszFilename; + void CLangData::SetLangName(PCTSTR psz) + { + if(m_pszLngName) + delete[] m_pszLngName; + m_pszLngName = new TCHAR[ _tcslen(psz) + 1 ]; + _tcscpy(m_pszLngName, psz); + m_bModified = true; + } - // copy - m_pszFilename=new TCHAR[_tcslen(psz)+1]; - _tcscpy(m_pszFilename, psz); + void CLangData::SetFontFace(PCTSTR psz) + { + if(m_pszFontFace) + delete[] m_pszFontFace; + m_pszFontFace = new TCHAR[ _tcslen(psz) + 1 ]; + _tcscpy(m_pszFontFace, psz); + m_bModified = true; + } - m_bModified = true; -} + void CLangData::SetHelpName(PCTSTR psz) + { + SetFnameData(&m_pszHelpName, psz); + m_bModified = true; + } -PCTSTR CLangData::GetFilename(bool bFullPath) const -{ - if (bFullPath) - return m_pszFilename; - else + void CLangData::SetAuthor(PCTSTR psz) { - if(m_pszFilename) - { - TCHAR *pszFnd=_tcsrchr(m_pszFilename, _T('\\')); - if (pszFnd) - return pszFnd+1; - } + if(m_pszAuthor) + delete[] m_pszAuthor; + m_pszAuthor = new TCHAR[ _tcslen(psz) + 1 ]; + _tcscpy(m_pszAuthor, psz); + m_bModified = true; + } - return m_pszFilename; + bool CLangData::IsValidDescription() const + { + // basic sanity checks + if(!m_pszAuthor || m_pszAuthor[ 0 ] == _T('\0') || + !m_pszLngName || m_pszLngName[ 0 ] == _T('\0') || + !m_pszFontFace || m_pszFontFace[ 0 ] == _T('\0') || + m_wPointSize == 0) + return false; + return true; } -} -void CLangData::SetLangName(PCTSTR psz) -{ - if (m_pszLngName) - delete [] m_pszLngName; - m_pszLngName=new TCHAR[_tcslen(psz)+1]; - _tcscpy(m_pszLngName, psz); - m_bModified = true; -} + void CLangData::SetFnameData(PTSTR *ppszDst, PCTSTR pszSrc) + { + if(*ppszDst) + delete[](*ppszDst); + const TCHAR* pszLast = nullptr; + if((pszLast = _tcsrchr(pszSrc, _T('\\'))) != nullptr) + pszLast++; + else + pszLast = pszSrc; -void CLangData::SetFontFace(PCTSTR psz) -{ - if (m_pszFontFace) - delete [] m_pszFontFace; - m_pszFontFace=new TCHAR[_tcslen(psz)+1]; - _tcscpy(m_pszFontFace, psz); - m_bModified = true; -} + // copy + *ppszDst = new TCHAR[ _tcslen(pszLast) + 1 ]; + _tcscpy(*ppszDst, pszLast); + } -void CLangData::SetHelpName(PCTSTR psz) -{ - SetFnameData(&m_pszHelpName, psz); - m_bModified = true; -} + CResourceManager::CResourceManager() : + m_hRes(nullptr), + m_pfnCallback(nullptr) + { + InitializeCriticalSection(&m_cs); + } -void CLangData::SetAuthor(PCTSTR psz) -{ - if (m_pszAuthor) - delete [] m_pszAuthor; - m_pszAuthor=new TCHAR[_tcslen(psz)+1]; - _tcscpy(m_pszAuthor, psz); - m_bModified = true; -} + CResourceManager::~CResourceManager() + { + DeleteCriticalSection(&m_cs); + } -bool CLangData::IsValidDescription() const -{ - // basic sanity checks - if(!m_pszAuthor || m_pszAuthor[0] == _T('\0') || - !m_pszLngName || m_pszLngName[0] == _T('\0') || - !m_pszFontFace || m_pszFontFace[0] == _T('\0') || - m_wPointSize == 0) - return false; - return true; -} + CResourceManager& CResourceManager::Acquire() + { + return CResourceManager::S_ResourceManager; + } -void CLangData::SetFnameData(PTSTR *ppszDst, PCTSTR pszSrc) -{ - if (*ppszDst) - delete [] (*ppszDst); - const TCHAR* pszLast=nullptr; - if ( (pszLast=_tcsrchr(pszSrc, _T('\\'))) != nullptr) - pszLast++; - else - pszLast=pszSrc; + void CResourceManager::Init(HMODULE hrc) + { + m_hRes = hrc; + } - // copy - *ppszDst=new TCHAR[_tcslen(pszLast)+1]; - _tcscpy(*ppszDst, pszLast); -} + // requires the param with ending '\\' + void CResourceManager::Scan(LPCTSTR pszFolder, std::vector* pvData) + { + assert(pszFolder); + assert(pvData); + if(!pszFolder || !pvData) + return; -CResourceManager::CResourceManager() : - m_hRes(nullptr), - m_pfnCallback(nullptr) -{ - InitializeCriticalSection(&m_cs); -} + CString strPath = pszFolder; + strPath += _T("*.lng"); -CResourceManager::~CResourceManager() -{ - DeleteCriticalSection(&m_cs); -} + WIN32_FIND_DATA wfd; + HANDLE hFind = ::FindFirstFile(strPath, &wfd); + BOOL bFound = TRUE; + CLangData ld; + while(bFound && hFind != INVALID_HANDLE_VALUE) + { + if(!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) + { + strPath = pszFolder; + strPath += wfd.cFileName; + if(ld.ReadInfo(strPath)) + pvData->push_back(ld); + } -CResourceManager& CResourceManager::Acquire() -{ - return CResourceManager::S_ResourceManager; -} + bFound = ::FindNextFile(hFind, &wfd); + } -void CResourceManager::Init(HMODULE hrc) -{ - m_hRes=hrc; -} + if(hFind != INVALID_HANDLE_VALUE) + ::FindClose(hFind); + } -// requires the param with ending '\\' -void CResourceManager::Scan(LPCTSTR pszFolder, vector* pvData) -{ - assert(pszFolder); - assert(pvData); - if(!pszFolder || !pvData) - return; - - CString strPath = pszFolder; - strPath += _T("*.lng"); - - WIN32_FIND_DATA wfd; - HANDLE hFind=::FindFirstFile(strPath, &wfd); - BOOL bFound=TRUE; - CLangData ld; - while (bFound && hFind != INVALID_HANDLE_VALUE) + bool CResourceManager::SetLanguage(PCTSTR pszPath) { - if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) + CString strBasePath; + CString strRealPath = pszPath; + + // parse the path to allow reading the English language first + const CString strEnglishFileName = _T("english.lng"); + + CString strTestPath = pszPath; + strTestPath.MakeLower(); + if(strTestPath.Right(strEnglishFileName.GetLength()) != strEnglishFileName) { - strPath = pszFolder; - strPath += wfd.cFileName; - if (ld.ReadInfo(strPath)) - pvData->push_back(ld); + int iPos = strRealPath.ReverseFind(L'\\'); + if(iPos <= 0) + strBasePath = strEnglishFileName; + else + strBasePath = strRealPath.Left(iPos + 1) + strEnglishFileName; } + else + { + strBasePath = strRealPath; + strRealPath.Empty(); + } - bFound=::FindNextFile(hFind, &wfd); - } + // and load everything + bool bRet = true; - if (hFind != INVALID_HANDLE_VALUE) - ::FindClose(hFind); -} + EnterCriticalSection(&m_cs); + try + { + if(!strBasePath.IsEmpty()) + bRet = m_ld.ReadTranslation(strBasePath); // base language + if(bRet && !strRealPath.IsEmpty()) + bRet = m_ld.ReadTranslation(strRealPath, true); // real language + } + catch(...) + { + LeaveCriticalSection(&m_cs); + return false; + } + LeaveCriticalSection(&m_cs); + if(!bRet) + return false; -bool CResourceManager::SetLanguage(PCTSTR pszPath) -{ - CString strBasePath; - CString strRealPath = pszPath; + // update registered dialog boxes + std::list::iterator it = m_lhDialogs.begin(); + while(it != m_lhDialogs.end()) + { + if(::IsWindow((*it)->m_hWnd)) + (*it)->PostMessage(WM_RMNOTIFY, RMNT_LANGCHANGE, 0); + ++it; + } - // parse the path to allow reading the English language first - const CString strEnglishFileName = _T("english.lng"); + // send the notification stuff to the others + if(m_pfnCallback) + (*m_pfnCallback)(RMNT_LANGCHANGE); - CString strTestPath = pszPath; - strTestPath.MakeLower(); - if(strTestPath.Right(strEnglishFileName.GetLength()) != strEnglishFileName) + return bRet; + } + + HGLOBAL CResourceManager::LoadResource(LPCTSTR pszType, LPCTSTR pszName) { - int iPos = strRealPath.ReverseFind(L'\\'); - if(iPos <= 0) - strBasePath = strEnglishFileName; - else - strBasePath = strRealPath.Left(iPos + 1) + strEnglishFileName; + EnterCriticalSection(&m_cs); + + // find resource + HGLOBAL hRet = nullptr; + HRSRC hr = FindResource(m_hRes, pszName, pszType); + if(hr) + hRet = ::LoadResource(m_hRes, hr); + + LeaveCriticalSection(&m_cs); + return hRet; } - else + + HACCEL CResourceManager::LoadAccelerators(LPCTSTR pszName) { - strBasePath = strRealPath; - strRealPath.Empty(); + return ::LoadAccelerators(m_hRes, pszName); } - // and load everything - bool bRet = true; - - EnterCriticalSection(&m_cs); - try + HBITMAP CResourceManager::LoadBitmap(LPCTSTR pszName) { - if(!strBasePath.IsEmpty()) - bRet = m_ld.ReadTranslation(strBasePath); // base language - if(bRet && !strRealPath.IsEmpty()) - bRet=m_ld.ReadTranslation(strRealPath, true); // real language + return ::LoadBitmap(m_hRes, pszName); } - catch(...) + + HCURSOR CResourceManager::LoadCursor(LPCTSTR pszName) { - LeaveCriticalSection(&m_cs); - return false; + return ::LoadCursor(m_hRes, pszName); } - LeaveCriticalSection(&m_cs); - if (!bRet) - return false; - - // update registered dialog boxes - list::iterator it=m_lhDialogs.begin(); - while (it != m_lhDialogs.end()) + + HICON CResourceManager::LoadIcon(LPCTSTR pszName) { - if (::IsWindow((*it)->m_hWnd)) - (*it)->PostMessage(WM_RMNOTIFY, RMNT_LANGCHANGE, 0); - ++it; + return ::LoadIcon(m_hRes, pszName); } - - // send the notification stuff to the others - if (m_pfnCallback) - (*m_pfnCallback)(RMNT_LANGCHANGE); - return bRet; -} - -HGLOBAL CResourceManager::LoadResource(LPCTSTR pszType, LPCTSTR pszName) -{ - EnterCriticalSection(&m_cs); - - // find resource - HGLOBAL hRet=nullptr; - 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 -using namespace std; - -BEGIN_ICTRANSLATE_NAMESPACE - -///////////////////////////////////////////////////////////////////////// -// types of notifications +namespace ictranslate +{ + ///////////////////////////////////////////////////////////////////////// + // types of notifications #define WM_RMNOTIFY (WM_USER + 2) // RMNT_LANGCHANGE, LPARAM - HIWORD - old language, LOWORD - new language #define RMNT_LANGCHANGE 0x0001 -typedef void(*PFNNOTIFYCALLBACK)(unsigned int); + typedef void(*PFNNOTIFYCALLBACK)(unsigned int); -class LIBICTRANSLATE_API CFormat -{ -public: - CFormat(); - explicit CFormat(const wchar_t* pszFormat); - ~CFormat(); + class LIBICTRANSLATE_API CFormat + { + public: + CFormat(); + explicit CFormat(const wchar_t* pszFormat); + ~CFormat(); - void SetFormat(const wchar_t* pszFormat); + void SetFormat(const wchar_t* pszFormat); - CFormat& SetParam(PCTSTR pszName, PCTSTR pszText); - CFormat& SetParam(PCTSTR pszName, unsigned long long ullData); - CFormat& SetParam(PCTSTR pszName, long long llData); - CFormat& SetParam(PCTSTR pszName, unsigned long ulData); - CFormat& SetParam(PCTSTR pszName, unsigned int uiData); - CFormat& SetParam(PCTSTR pszName, int iData); - CFormat& SetParam(PCTSTR pszName, bool bData); + CFormat& SetParam(PCTSTR pszName, PCTSTR pszText); + CFormat& SetParam(PCTSTR pszName, unsigned long long ullData); + CFormat& SetParam(PCTSTR pszName, long long llData); + CFormat& SetParam(PCTSTR pszName, unsigned long ulData); + CFormat& SetParam(PCTSTR pszName, unsigned int uiData); + CFormat& SetParam(PCTSTR pszName, int iData); + CFormat& SetParam(PCTSTR pszName, bool bData); - operator const wchar_t*() const { return m_strText.c_str(); } + operator const wchar_t*() const + { + return m_strText.c_str(); + } -protected: - std::wstring m_strText; -}; + protected: + std::wstring m_strText; + }; -/////////////////////////////////////////////////////////// -// language description structure -class LIBICTRANSLATE_API CTranslationItem -{ -public: - enum ECompareResult + /////////////////////////////////////////////////////////// + // language description structure + class LIBICTRANSLATE_API CTranslationItem { - eResult_Valid, // valid translation - eResult_Invalid, // Invalid checksum or translation - eResult_ContentWarning // the translation is suspicious - }; -public: - CTranslationItem(); - CTranslationItem(const CTranslationItem& rSrc); - CTranslationItem(const wchar_t* pszText, unsigned int uiChecksum); - ~CTranslationItem(); + public: + enum ECompareResult + { + eResult_Valid, // valid translation + eResult_Invalid, // Invalid checksum or translation + eResult_ContentWarning // the translation is suspicious + }; + public: + CTranslationItem(); + CTranslationItem(const CTranslationItem& rSrc); + CTranslationItem(const wchar_t* pszText, unsigned int uiChecksum); + ~CTranslationItem(); - CTranslationItem& operator=(const CTranslationItem& rSrc); + CTranslationItem& operator=(const CTranslationItem& rSrc); - void Clear(); + void Clear(); - const wchar_t* GetText() const; - void SetText(const wchar_t* pszText, bool bUnescapeString); - unsigned int GetChecksum() const { return m_uiChecksum; } - void SetChecksum(unsigned int uiChecksum) { m_uiChecksum = uiChecksum; } + const wchar_t* GetText() const; + void SetText(const wchar_t* pszText, bool bUnescapeString); + unsigned int GetChecksum() const + { + return m_uiChecksum; + } + void SetChecksum(unsigned int uiChecksum) + { + m_uiChecksum = uiChecksum; + } - void UnescapeString(); + void UnescapeString(); - ECompareResult Compare(const CTranslationItem& rReferenceItem); + ECompareResult Compare(const CTranslationItem& rReferenceItem); -protected: - bool GetFormatStrings(std::set& setFmtStrings) const; + protected: + bool GetFormatStrings(std::set& setFmtStrings) const; -protected: - wchar_t* m_pszText = nullptr; - size_t m_stTextLength = 0; - unsigned int m_uiChecksum = 0; -}; + protected: + wchar_t* m_pszText = nullptr; + size_t m_stTextLength = 0; + unsigned int m_uiChecksum = 0; + }; -typedef void(*PFNENUMCALLBACK)(unsigned int, const CTranslationItem*, void*); -typedef std::map translation_map; + typedef void(*PFNENUMCALLBACK)(unsigned int, const CTranslationItem*, void*); + typedef std::map translation_map; -class LIBICTRANSLATE_API CLangData -{ -public: -// construction/destruction - CLangData(); - CLangData(const CLangData& ld); - ~CLangData(); + class LIBICTRANSLATE_API CLangData + { + public: + // construction/destruction + CLangData(); + CLangData(const CLangData& ld); + ~CLangData(); - CLangData& operator=(const CLangData& rSrc); + CLangData& operator=(const CLangData& rSrc); - void Clear(); -// operations - bool ReadInfo(PCTSTR pszFile); - bool ReadTranslation(PCTSTR pszFile, bool bReadBase = false, bool bIgnoreVersion = false); - void WriteTranslation(PCTSTR pszPath); + void Clear(); + // operations + bool ReadInfo(PCTSTR pszFile); + bool ReadTranslation(PCTSTR pszFile, bool bReadBase = false, bool bIgnoreVersion = false); + void WriteTranslation(PCTSTR pszPath); -// translation retrieving/setting - const wchar_t* GetString(WORD wHiID, WORD wLoID); // retrieves string using group id and string id - void EnumStrings(PFNENUMCALLBACK pfnCallback, void* pData); // retrieves all translation items + // translation retrieving/setting + const wchar_t* GetString(WORD wHiID, WORD wLoID); // retrieves string using group id and string id + void EnumStrings(PFNENUMCALLBACK pfnCallback, void* pData); // retrieves all translation items - CTranslationItem* GetTranslationItem(unsigned int uiTranslationKey, bool bCreate); // retrieves pointer to the single translation item - bool Exists(unsigned int uiTranslationKey) const; - void CleanupTranslation(const CLangData& rReferenceTranslation); + CTranslationItem* GetTranslationItem(unsigned int uiTranslationKey, bool bCreate); // retrieves pointer to the single translation item + bool Exists(unsigned int uiTranslationKey) const; + void CleanupTranslation(const CLangData& rReferenceTranslation); -// attributes - void SetFilename(PCTSTR psz); - PCTSTR GetFilename(bool bFullPath) const; + // attributes + void SetFilename(PCTSTR psz); + PCTSTR GetFilename(bool bFullPath) const; - void SetLangName(PCTSTR psz); - PCTSTR GetLangName() const { return m_pszLngName; }; + void SetLangName(PCTSTR psz); + PCTSTR GetLangName() const + { + return m_pszLngName; + }; - void SetFontFace(PCTSTR psz); - PCTSTR GetFontFace() const { return m_pszFontFace; }; + void SetFontFace(PCTSTR psz); + PCTSTR GetFontFace() const + { + return m_pszFontFace; + }; - void SetPointSize(WORD wSize) { m_wPointSize=wSize; m_bModified = true; }; - WORD GetPointSize() const { return m_wPointSize; }; + void SetPointSize(WORD wSize) + { + m_wPointSize = wSize; m_bModified = true; + }; + WORD GetPointSize() const + { + return m_wPointSize; + }; - void SetDirection(bool brtl) { m_bRTL=brtl; m_bModified = true; }; - bool GetDirection() const { return m_bRTL; }; + void SetDirection(bool brtl) + { + m_bRTL = brtl; m_bModified = true; + }; + bool GetDirection() const + { + return m_bRTL; + }; - void SetHelpName(PCTSTR psz); - PCTSTR GetHelpName() const { return m_pszHelpName; }; + void SetHelpName(PCTSTR psz); + PCTSTR GetHelpName() const + { + return m_pszHelpName; + }; - void SetAuthor(PCTSTR psz); - PCTSTR GetAuthor() const { return m_pszAuthor; }; + void SetAuthor(PCTSTR psz); + PCTSTR GetAuthor() const + { + return m_pszAuthor; + }; - bool IsModified() const { return m_bModified; } - void SetModified() { m_bModified = true; } + bool IsModified() const + { + return m_bModified; + } + void SetModified() + { + m_bModified = true; + } - bool IsValidDescription() const; + bool IsValidDescription() const; -protected: - void SetFnameData(PTSTR *ppszDst, PCTSTR pszSrc); - static void EnumAttributesCallback(bool bGroup, const wchar_t* pszName, const wchar_t* pszValue, void* pData); - static void UnescapeString(wchar_t* pszData); + protected: + void SetFnameData(PTSTR *ppszDst, PCTSTR pszSrc); + static void EnumAttributesCallback(bool bGroup, const wchar_t* pszName, const wchar_t* pszValue, void* pData); + static void UnescapeString(wchar_t* pszData); -protected: - TCHAR *m_pszFilename; // file name of the language data (with path) - TCHAR *m_pszLngName; // name of the language (ie. Chinese (PRC)) - TCHAR *m_pszFontFace; // face name of the font that will be used in dialogs - WORD m_wPointSize; // font point size - TCHAR *m_pszHelpName; // help name (wo the directory) for this language - TCHAR *m_pszAuthor; // author name - bool m_bRTL; // does the language require right-to-left reading order ? + protected: + TCHAR *m_pszFilename; // file name of the language data (with path) + TCHAR *m_pszLngName; // name of the language (ie. Chinese (PRC)) + TCHAR *m_pszFontFace; // face name of the font that will be used in dialogs + WORD m_wPointSize; // font point size + TCHAR *m_pszHelpName; // help name (wo the directory) for this language + TCHAR *m_pszAuthor; // author name + 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) - translation_map m_mapTranslation; // maps string ID to the offset in pszStrings + // strings (for controls in dialog boxes the ID contains hi:dlg ID, lo:ctrl ID, for strings hi part is 0) + translation_map m_mapTranslation; // maps string ID to the offset in pszStrings -private: - unsigned int m_uiSectionID; ///< ID of the currently processed section - bool m_bUpdating; ///< Are we updating the language with base language ? - bool m_bModified; ///< States if the translation has been modified -}; + private: + unsigned int m_uiSectionID; ///< ID of the currently processed section + bool m_bUpdating; ///< Are we updating the language with base language ? + bool m_bModified; ///< States if the translation has been modified + }; -///////////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////////////// -class LIBICTRANSLATE_API CResourceManager -{ -protected: - CResourceManager(); - ~CResourceManager(); + class LIBICTRANSLATE_API CResourceManager + { + protected: + CResourceManager(); + ~CResourceManager(); -public: - static CResourceManager& Acquire(); + public: + static CResourceManager& Acquire(); - void Init(HMODULE hrc); + void Init(HMODULE hrc); - void SetCallback(PFNNOTIFYCALLBACK pfn) { m_pfnCallback=pfn; }; + void SetCallback(PFNNOTIFYCALLBACK pfn) + { + m_pfnCallback = pfn; + }; - void Scan(LPCTSTR pszFolder, vector* pvData); - bool SetLanguage(PCTSTR pszPath); + void Scan(LPCTSTR pszFolder, std::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); + // 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); + PCTSTR LoadString(UINT uiID); + PCTSTR LoadString(WORD wGroup, WORD wID); - // res updating functions - void UpdateMenu(HMENU hMenu, WORD wMenuID); + // res updating functions + void UpdateMenu(HMENU hMenu, WORD wMenuID); - const CLangData* GetLanguageData() const { return &m_ld; } + const CLangData* GetLanguageData() const + { + return &m_ld; + } -public: - CLangData m_ld; // current language data - list m_lhDialogs; // currently displayed dialog boxes (even hidden) + public: + CLangData m_ld; // current language data + std::list m_lhDialogs; // currently displayed dialog boxes (even hidden) - HMODULE m_hRes; - PFNNOTIFYCALLBACK m_pfnCallback; - CRITICAL_SECTION m_cs; + HMODULE m_hRes; + PFNNOTIFYCALLBACK m_pfnCallback; + CRITICAL_SECTION m_cs; -protected: - static CResourceManager S_ResourceManager; -}; + protected: + static CResourceManager S_ResourceManager; + }; +} -END_ICTRANSLATE_NAMESPACE - -#endif \ No newline at end of file +#endif Index: src/libictranslate/libictranslate.h =================================================================== diff -u -r8443d0d98d380facaf07b540c8d98da08365b816 -r19b135b50b55b75d008526a799344bda9a62dc22 --- src/libictranslate/libictranslate.h (.../libictranslate.h) (revision 8443d0d98d380facaf07b540c8d98da08365b816) +++ src/libictranslate/libictranslate.h (.../libictranslate.h) (revision 19b135b50b55b75d008526a799344bda9a62dc22) @@ -48,9 +48,4 @@ #define LIBICTRANSLATE_API #endif -/// Begins ch namespace -#define BEGIN_ICTRANSLATE_NAMESPACE namespace ictranslate { -/// Ends ch namespace -#define END_ICTRANSLATE_NAMESPACE } - #endif Index: src/rc2lng/rc2lng.h =================================================================== diff -u -r8443d0d98d380facaf07b540c8d98da08365b816 -r19b135b50b55b75d008526a799344bda9a62dc22 --- src/rc2lng/rc2lng.h (.../rc2lng.h) (revision 8443d0d98d380facaf07b540c8d98da08365b816) +++ src/rc2lng/rc2lng.h (.../rc2lng.h) (revision 19b135b50b55b75d008526a799344bda9a62dc22) @@ -28,7 +28,6 @@ #include #include #include -using namespace std; #pragma warning(disable : 4786)