Index: src/ictranslate/ICTranslateDlg.cpp =================================================================== diff -u -rd88dd04e423f5dea23b1678fe9febac78e8e551b -r454505cd84bed489de72fb95d514be8834388ff8 --- src/ictranslate/ICTranslateDlg.cpp (.../ICTranslateDlg.cpp) (revision d88dd04e423f5dea23b1678fe9febac78e8e551b) +++ src/ictranslate/ICTranslateDlg.cpp (.../ICTranslateDlg.cpp) (revision 454505cd84bed489de72fb95d514be8834388ff8) @@ -55,7 +55,8 @@ CICTranslateDlg::CICTranslateDlg(CWnd* pParent /*=NULL*/) - : CDialog(CICTranslateDlg::IDD, pParent) + : CDialog(CICTranslateDlg::IDD, pParent), + m_hAccel(NULL) { m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } @@ -101,6 +102,10 @@ ON_EN_KILLFOCUS(IDC_DST_LANGUAGE_NAME_EDIT, &CICTranslateDlg::OnEnKillFocusDstLanguageNameEdit) ON_EN_KILLFOCUS(IDC_DST_HELP_FILENAME_EDIT, &CICTranslateDlg::OnEnKillFocusDstHelpFilenameEdit) ON_BN_CLICKED(IDC_DST_RTL_CHECK, &CICTranslateDlg::OnBnClickedDstRtlCheck) + ON_COMMAND(ID_EDIT_PREVIOUS_TO_TRANSLATE, &CICTranslateDlg::OnEditPreviousToTranslate) + ON_COMMAND(ID_EDIT_NEXT_TO_TRANSLATE, &CICTranslateDlg::OnEditNextToTranslate) + ON_COMMAND(ID_EDIT_APPLY_CHANGE, &CICTranslateDlg::OnEditApplyChange) + ON_COMMAND(ID_EDIT_APPLY_AND_NEXT, &CICTranslateDlg::OnEditApplyAndNext) END_MESSAGE_MAP() @@ -167,6 +172,8 @@ m_ctlBaseLanguageList.InsertColumn(1, &lvc); m_ctlCustomLanguageList.InsertColumn(1, &lvc); + m_hAccel = LoadAccelerators(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_ACCELERATOR)); + return TRUE; // return TRUE unless you set the focus to a control } @@ -288,7 +295,11 @@ if(pNMLV->uNewState & LVIS_SELECTED) { // set the text to the edit box - m_ctlSrcText.SetWindowText(m_ctlBaseLanguageList.GetItemText(pNMLV->iItem, 1)); + ictranslate::CTranslationItem* pTranslationItem = m_ldBase.GetTranslationItem(pNMLV->lParam, false); + if(pTranslationItem && pTranslationItem->GetText()) + m_ctlSrcText.SetWindowText(pTranslationItem->GetText()); + else + m_ctlSrcText.SetWindowText(m_ctlBaseLanguageList.GetItemText(pNMLV->iItem, 1)); uint_t uiID = pNMLV->lParam; @@ -331,7 +342,11 @@ if(pNMLV->uNewState & LVIS_SELECTED) { // set the text to the edit box - m_ctlDstText.SetWindowText(m_ctlCustomLanguageList.GetItemText(pNMLV->iItem, 1)); + ictranslate::CTranslationItem* pTranslationItem = m_ldCustom.GetTranslationItem(pNMLV->lParam, false); + if(pTranslationItem && pTranslationItem->GetText()) + m_ctlDstText.SetWindowText(pTranslationItem->GetText()); + else + m_ctlDstText.SetWindowText(m_ctlCustomLanguageList.GetItemText(pNMLV->iItem, 1)); uint_t uiID = pNMLV->lParam; @@ -344,7 +359,6 @@ if(uiID == uiCurrentID) return; } -// m_ctlBaseLanguageList.SetItemState(-1, 0, LVIS_SELECTED); // search in the second list for the specified id int iCount = m_ctlBaseLanguageList.GetItemCount(); @@ -766,3 +780,83 @@ bool bRTL = (m_ctlDstRTL.GetCheck() == BST_CHECKED); m_ldCustom.SetDirection(bRTL); } + +void CICTranslateDlg::OnEditPreviousToTranslate() +{ + // find selection + int iItem = 0; + POSITION pos = m_ctlCustomLanguageList.GetFirstSelectedItemPosition(); + if(pos) + iItem = m_ctlCustomLanguageList.GetNextSelectedItem(pos); + + // find previous element to translate + LVITEM lvi; + for(int i = iItem - 1; i >= 0; i--) + { + lvi.iItem = i; + lvi.iSubItem = 0; + lvi.mask = LVIF_IMAGE; + + BOOL bRes = m_ctlCustomLanguageList.GetItem(&lvi); + if(bRes && lvi.iImage != IMAGE_OVERFLUOUS && lvi.iImage != IMAGE_VALID) + { + m_ctlDstText.SetWindowText(_T("")); + m_ctlCustomLanguageList.SetItemState(i, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); + m_ctlCustomLanguageList.EnsureVisible(i, FALSE); + m_ctlDstText.SetFocus(); + break; + } + } +} + +void CICTranslateDlg::OnEditNextToTranslate() +{ + // find selection + int iItem = 0; + POSITION pos = m_ctlCustomLanguageList.GetFirstSelectedItemPosition(); + if(pos) + iItem = m_ctlCustomLanguageList.GetNextSelectedItem(pos); + + // find previous element to translate + LVITEM lvi; + int iCount = m_ctlCustomLanguageList.GetItemCount(); + for(int i = iItem + 1; i < iCount; i++) + { + lvi.iItem = i; + lvi.iSubItem = 0; + lvi.mask = LVIF_IMAGE; + + BOOL bRes = m_ctlCustomLanguageList.GetItem(&lvi); + if(bRes && lvi.iImage != IMAGE_OVERFLUOUS && lvi.iImage != IMAGE_VALID) + { + m_ctlDstText.SetWindowText(_T("")); + m_ctlCustomLanguageList.SetItemState(i, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); + m_ctlCustomLanguageList.EnsureVisible(i, FALSE); + m_ctlDstText.SetFocus(); + break; + } + } +} + +void CICTranslateDlg::OnEditApplyChange() +{ + // apply change + OnBnClickedApply(); +} + +void CICTranslateDlg::OnEditApplyAndNext() +{ + OnBnClickedApply(); + OnEditNextToTranslate(); +} + +BOOL CICTranslateDlg::PreTranslateMessage(MSG* pMsg) +{ + if(m_hAccel) + { + if(TranslateAccelerator(m_hWnd, m_hAccel, pMsg) != 0) + return TRUE; + } + + return CDialog::PreTranslateMessage(pMsg); +} Index: src/ictranslate/ICTranslateDlg.h =================================================================== diff -u -r5c56f25198545656fc8e2c53980c6e6c1ba1f788 -r454505cd84bed489de72fb95d514be8834388ff8 --- src/ictranslate/ICTranslateDlg.h (.../ICTranslateDlg.h) (revision 5c56f25198545656fc8e2c53980c6e6c1ba1f788) +++ src/ictranslate/ICTranslateDlg.h (.../ICTranslateDlg.h) (revision 454505cd84bed489de72fb95d514be8834388ff8) @@ -39,6 +39,8 @@ ictranslate::CLangData m_ldBase; ictranslate::CLangData m_ldCustom; + HACCEL m_hAccel; + // Generated message map functions virtual BOOL OnInitDialog(); afx_msg void OnSysCommand(UINT nID, LPARAM lParam); @@ -80,4 +82,9 @@ afx_msg void OnEnKillFocusDstLanguageNameEdit(); afx_msg void OnEnKillFocusDstHelpFilenameEdit(); afx_msg void OnBnClickedDstRtlCheck(); + afx_msg void OnEditPreviousToTranslate(); + afx_msg void OnEditNextToTranslate(); + afx_msg void OnEditApplyChange(); + afx_msg void OnEditApplyAndNext(); + virtual BOOL PreTranslateMessage(MSG* pMsg); }; Index: src/ictranslate/ictranslate.rc =================================================================== diff -u -rf6fe924675e9de6120b6c1eac2430fa5b2946251 -r454505cd84bed489de72fb95d514be8834388ff8 --- src/ictranslate/ictranslate.rc (.../ictranslate.rc) (revision f6fe924675e9de6120b6c1eac2430fa5b2946251) +++ src/ictranslate/ictranslate.rc (.../ictranslate.rc) (revision 454505cd84bed489de72fb95d514be8834388ff8) @@ -86,18 +86,40 @@ BEGIN POPUP "&File" BEGIN - MENUITEM "&New translation...", ID_FILE_NEWTRANSLATION - MENUITEM "&Open base translation...", ID_FILE_OPENBASETRANSLATION - MENUITEM "Open your translation...", ID_FILE_OPENYOURTRANSLATION - MENUITEM "&Save translation", ID_FILE_SAVETRANSLATION + MENUITEM "&New translation...\tCtrl+N", ID_FILE_NEWTRANSLATION + MENUITEM "&Open base translation...\tCtrl+O", ID_FILE_OPENBASETRANSLATION + MENUITEM "Open your translation...\tCtrl+T", ID_FILE_OPENYOURTRANSLATION + MENUITEM "&Save translation\tCtrl+S", ID_FILE_SAVETRANSLATION MENUITEM "S&ave translation as...", ID_FILE_SAVETRANSLATIONAS END POPUP "&Edit" BEGIN MENUITEM "&Cleanup translation", ID_EDIT_CLEANUP_TRANSLATION + MENUITEM SEPARATOR + MENUITEM "&Previous to translate\tCtrl+Up", ID_EDIT_PREVIOUS_TO_TRANSLATE + MENUITEM "&Next to translate\tCtrl+Down", ID_EDIT_NEXT_TO_TRANSLATE + MENUITEM "&Apply change", ID_EDIT_APPLY_CHANGE + MENUITEM "Apply&&next to t&ranslate\tCtrl+Enter", ID_EDIT_APPLY_AND_NEXT END END + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +IDR_ACCELERATOR ACCELERATORS +BEGIN + VK_DOWN, ID_EDIT_NEXT_TO_TRANSLATE, VIRTKEY, CONTROL, NOINVERT + VK_RETURN, ID_EDIT_APPLY_AND_NEXT, VIRTKEY, CONTROL, NOINVERT + "^S", ID_FILE_SAVETRANSLATION, ASCII, NOINVERT + "^N", ID_FILE_NEWTRANSLATION, ASCII, NOINVERT + VK_UP, ID_EDIT_PREVIOUS_TO_TRANSLATE, VIRTKEY, CONTROL, NOINVERT + "^O", ID_FILE_OPENBASETRANSLATION, ASCII, NOINVERT + "^T", ID_FILE_OPENYOURTRANSLATION, ASCII, NOINVERT +END + #endif // Polish resources ///////////////////////////////////////////////////////////////////////////// Index: src/ictranslate/resource.h =================================================================== diff -u -rf6fe924675e9de6120b6c1eac2430fa5b2946251 -r454505cd84bed489de72fb95d514be8834388ff8 --- src/ictranslate/resource.h (.../resource.h) (revision f6fe924675e9de6120b6c1eac2430fa5b2946251) +++ src/ictranslate/resource.h (.../resource.h) (revision 454505cd84bed489de72fb95d514be8834388ff8) @@ -13,6 +13,7 @@ #define IDI_INVALID_ICON 132 #define IDI_OVERFLUOUS_ICON 133 #define IDI_WARNING_ICON 134 +#define IDR_ACCELERATOR 135 #define IDC_DSTDATA_LIST 1000 #define IDC_SRCDATA_LIST 1001 #define IDC_SRCDATA_EDIT 1002 @@ -40,13 +41,21 @@ #define ID_FILE_OPENBASETRANSLATION 32776 #define ID_EDIT_CLEANUPTRANSLATION 32777 #define ID_EDIT_CLEANUP_TRANSLATION 32778 +#define ID_EDIT_APLLYCHANGE 32779 +#define ID_EDIT_NEXTTOTRANSLATE 32780 +#define ID_EDIT_PREVIOUSTOTRANSLATE 32781 +#define ID_EDIT_APPLYNEXTTOTRANSLATE 32782 +#define ID_EDIT_PREVIOUS_TO_TRANSLATE 32783 +#define ID_EDIT_NEXT_TO_TRANSLATE 32784 +#define ID_EDIT_APPLY_CHANGE 32785 +#define ID_EDIT_APPLY_AND_NEXT 32786 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 135 -#define _APS_NEXT_COMMAND_VALUE 32779 +#define _APS_NEXT_RESOURCE_VALUE 136 +#define _APS_NEXT_COMMAND_VALUE 32796 #define _APS_NEXT_CONTROL_VALUE 1026 #define _APS_NEXT_SYMED_VALUE 101 #endif