| |
1 |
1 |
|
| |
2 |
2 |
|
| |
3 |
3 |
|
| |
4 |
4 |
#include "stdafx.h" |
| |
5 |
5 |
#include "ictranslate.h" |
| |
6 |
6 |
#include "ICTranslateDlg.h" |
| |
7 |
7 |
#include <assert.h> |
| |
8 |
8 |
#include <set> |
| |
|
9 |
#include "../libicpf/exception.h" |
| |
9 |
10 |
|
| |
10 |
11 |
#ifdef _DEBUG |
| |
11 |
12 |
#define new DEBUG_NEW |
| |
12 |
13 |
#endif |
| |
13 |
14 |
|
| |
14 |
15 |
#define IMAGE_INVALID 0 |
| |
15 |
16 |
#define IMAGE_NONEXISTENT 1 |
| |
16 |
17 |
#define IMAGE_OVERFLUOUS 2 |
| |
17 |
18 |
#define IMAGE_VALID 3 |
| |
18 |
19 |
#define IMAGE_WARNING 4 |
| |
19 |
20 |
|
| |
20 |
21 |
|
| |
21 |
22 |
|
| |
22 |
23 |
class CAboutDlg : public CDialog |
| |
23 |
24 |
{ |
| |
24 |
25 |
public: |
| |
25 |
26 |
CAboutDlg(); |
| |
26 |
27 |
|
| |
27 |
28 |
|
| |
28 |
29 |
enum { IDD = IDD_ABOUTBOX }; |
|
| |
616 |
617 |
|
| |
617 |
618 |
void CICTranslateDlg::OnEditCleanupTranslation() |
| |
618 |
619 |
{ |
| |
619 |
620 |
m_ldCustom.CleanupTranslation(m_ldBase); |
| |
620 |
621 |
UpdateCustomLanguageList(); |
| |
621 |
622 |
} |
| |
622 |
623 |
|
| |
623 |
624 |
void CICTranslateDlg::OnFileNewTranslation() |
| |
624 |
625 |
{ |
| |
625 |
626 |
|
| |
626 |
627 |
if(!WarnModified()) |
| |
627 |
628 |
return; |
| |
628 |
629 |
|
| |
629 |
630 |
|
| |
630 |
631 |
m_ldCustom.Clear(); |
| |
631 |
632 |
UpdateCustomLanguageList(); |
| |
632 |
633 |
} |
| |
633 |
634 |
|
| |
634 |
635 |
void CICTranslateDlg::OnFileSaveTranslationAs() |
| |
635 |
636 |
{ |
| |
|
637 |
if(!m_ldCustom.IsValidDescription()) |
| |
|
638 |
{ |
| |
|
639 |
AfxMessageBox(_T("Please fill the Author, Language name and font with correct values before saving.")); |
| |
|
640 |
return; |
| |
|
641 |
} |
| |
|
642 |
|
| |
636 |
643 |
CString strFilename = m_ldCustom.GetFilename(false); |
| |
637 |
644 |
CString strPath = m_ldCustom.GetFilename(true); |
| |
638 |
645 |
|
| |
639 |
646 |
CFileDialog dlg(FALSE, _T(".lng"), strFilename, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T("Language files (*.lng)|*.lng|All files (*.*)|*.*||"), this); |
| |
640 |
647 |
if(dlg.DoModal() == IDOK) |
| |
641 |
648 |
{ |
| |
642 |
649 |
|
| |
643 |
650 |
CString str; |
| |
644 |
651 |
m_ctlDstAuthor.GetWindowText(str); |
| |
645 |
652 |
m_ldCustom.SetAuthor(str); |
| |
646 |
653 |
m_ctlDstLanguageName.GetWindowText(str); |
| |
647 |
654 |
m_ldCustom.SetLangName(str); |
| |
648 |
655 |
m_ctlDstHelpFilename.GetWindowText(str); |
| |
649 |
656 |
m_ldCustom.SetHelpName(str); |
| |
650 |
657 |
bool bRTL = (m_ctlDstRTL.GetCheck() == BST_CHECKED); |
| |
651 |
658 |
m_ldCustom.SetDirection(bRTL); |
| |
652 |
659 |
|
| |
653 |
660 |
|
| |
|
661 |
try |
| |
|
662 |
{ |
| |
654 |
663 |
m_ldCustom.WriteTranslation(dlg.GetPathName()); |
| |
|
664 |
} |
| |
|
665 |
catch(icpf::exception& e) |
| |
|
666 |
{ |
| |
|
667 |
CString strInfo; |
| |
|
668 |
strInfo.Format(_T("Cannot write translation file.\nReason: %s"), e.get_desc()); |
| |
|
669 |
AfxMessageBox(strInfo); |
| |
|
670 |
return; |
| |
|
671 |
} |
| |
655 |
672 |
m_ctlDstFilename.SetWindowText(m_ldCustom.GetFilename(true)); |
| |
656 |
673 |
} |
| |
657 |
674 |
} |
| |
658 |
675 |
|
| |
659 |
676 |
void CICTranslateDlg::OnFileSaveTranslation() |
| |
660 |
677 |
{ |
| |
|
678 |
|
| |
|
679 |
if(!m_ldCustom.IsValidDescription()) |
| |
|
680 |
{ |
| |
|
681 |
AfxMessageBox(_T("Please fill the Author, Language name and font with correct values before saving.")); |
| |
|
682 |
return; |
| |
|
683 |
} |
| |
|
684 |
|
| |
661 |
685 |
CString strPath = m_ldCustom.GetFilename(true); |
| |
662 |
686 |
if(strPath.IsEmpty()) |
| |
663 |
687 |
{ |
| |
664 |
688 |
OnFileSaveTranslationAs(); |
| |
665 |
689 |
} |
| |
666 |
690 |
else |
| |
667 |
691 |
{ |
| |
668 |
692 |
|
| |
669 |
693 |
CString str; |
| |
670 |
694 |
m_ctlDstAuthor.GetWindowText(str); |
| |
671 |
695 |
m_ldCustom.SetAuthor(str); |
| |
672 |
696 |
m_ctlDstLanguageName.GetWindowText(str); |
| |
673 |
697 |
m_ldCustom.SetLangName(str); |
| |
674 |
698 |
m_ctlDstHelpFilename.GetWindowText(str); |
| |
675 |
699 |
m_ldCustom.SetHelpName(str); |
| |
676 |
700 |
bool bRTL = (m_ctlDstRTL.GetCheck() == BST_CHECKED); |
| |
677 |
701 |
m_ldCustom.SetDirection(bRTL); |
| |
678 |
702 |
|
| |
|
703 |
try |
| |
|
704 |
{ |
| |
679 |
705 |
m_ldCustom.WriteTranslation(NULL); |
| |
|
706 |
} |
| |
|
707 |
catch(icpf::exception& e) |
| |
|
708 |
{ |
| |
|
709 |
CString strInfo; |
| |
|
710 |
strInfo.Format(_T("Cannot write translation file.\nReason: %s"), e.get_desc()); |
| |
|
711 |
AfxMessageBox(strInfo); |
| |
|
712 |
return; |
| |
|
713 |
} |
| |
680 |
714 |
m_ctlDstFilename.SetWindowText(m_ldCustom.GetFilename(true)); |
| |
681 |
715 |
} |
| |
682 |
716 |
} |
| |
683 |
717 |
|
| |
684 |
718 |
bool CICTranslateDlg::WarnModified() const |
| |
685 |
719 |
{ |
| |
686 |
720 |
|
| |
687 |
721 |
if(m_ldCustom.IsModified()) |
| |
688 |
722 |
{ |
| |
689 |
723 |
int iRes = AfxMessageBox(_T("You have modified the translation file. If you continue, the changes might be lost. Do you want to continue ?"), MB_YESNO | MB_ICONQUESTION); |
| |
690 |
724 |
return iRes == IDYES; |
| |
691 |
725 |
} |
| |
692 |
726 |
else |
| |
693 |
727 |
return true; |
| |
694 |
728 |
} |
| |
695 |
729 |
|
| |
696 |
730 |
void CICTranslateDlg::OnCancel() |
| |
697 |
731 |
{ |
| |
698 |
732 |
if(WarnModified()) |
| |
699 |
733 |
CDialog::OnCancel(); |