Browse Source

changes for multiple language and show short key text dynamically
[SAB]


git-svn-id: svn://svn.code.sf.net/p/ditto-cp/code/trunk@185 595ec19a-5cb4-439b-94a8-42fb3063c22c

sabrogden 20 years ago
parent
commit
4b73ce3ebb
8 changed files with 213 additions and 12 deletions
  1. 10 10
      CP_Main.rc
  2. 33 0
      OptionsGeneral.cpp
  3. 1 0
      OptionsGeneral.h
  4. 73 1
      QPasteWnd.cpp
  5. 8 0
      QPasteWnd.h
  6. 2 1
      Resource.h
  7. 85 0
      WndEx.cpp
  8. 1 0
      WndEx.h

+ 10 - 10
CP_Main.rc

@@ -171,8 +171,8 @@ BEGIN
     BEGIN
         POPUP "Groups"
         BEGIN
-            MENUITEM "New Group\tCtrl-F7",          ID_MENU_NEWGROUP
-            MENUITEM "New Group Selection\tF7",     ID_MENU_NEWGROUPSELECTION
+            MENUITEM "New Group",                   ID_MENU_NEWGROUP
+            MENUITEM "New Group Selection",         ID_MENU_NEWGROUPSELECTION
 
             MENUITEM "Move to Group",               ID_MENU_GROUPS_MOVETOGROUP
 
@@ -254,7 +254,7 @@ BEGIN
                                                         ID_MENU_QUICKOPTIONS_DOUBLECLICKINGONCAPTION_TOGGLESALWAYSSHOWDESCRIPTION
 
             END
-            MENUITEM "Always on Top\tCtrl-Space",   ID_MENU_ALLWAYSONTOP
+            MENUITEM "Always on Top",               ID_MENU_ALLWAYSONTOP
             MENUITEM "Auto Roll-up",                ID_MENU_AUTOHIDE
             MENUITEM "Always Show Description",     ID_MENU_QUICKOPTIONS_ALLWAYSSHOWDESCRIPTION
 
@@ -311,15 +311,14 @@ BEGIN
             MENUITEM "Prompt for IP",               ID_MENU_SENTTO_PROMPTFORIP
 
         END
-        MENUITEM "View Full Description\tF3",   ID_MENU_VIEWFULLDESCRIPTION
-        MENUITEM "View Groups\tCtrl-G",         ID_MENU_VIEWGROUPS
-        MENUITEM "Paste Plain Text Only\tShift-Enter", 
-                                                ID_MENU_PASTEPLAINTEXTONLY
+        MENUITEM "View Full Description",       ID_MENU_VIEWFULLDESCRIPTION
+        MENUITEM "View Groups",                 ID_MENU_VIEWGROUPS
+        MENUITEM "Paste Plain Text Only",       ID_MENU_PASTEPLAINTEXTONLY
         MENUITEM "Paste HTML as Plain Text",    ID_MENU_PASTEHTMLASPLAINTEXT
         MENUITEM SEPARATOR
-        MENUITEM "Delete Entry\tDel",           ID_MENU_DELETE
+        MENUITEM "Delete Entry",                ID_MENU_DELETE
         MENUITEM SEPARATOR
-        MENUITEM "Properties\tAlt-Enter",       ID_MENU_PROPERTIES
+        MENUITEM "Properties",                  ID_MENU_PROPERTIES
         POPUP "Quick Properties"
         BEGIN
             MENUITEM "Never Auto Delete",           ID_MENU_QUICKPROPERTIES_SETTONEVERAUTODELETE
@@ -581,11 +580,12 @@ BEGIN
     LTEXT           "(Leave blank for no limit)",IDC_STATIC_NO_LIMIT,176,202,
                     78,8
     LTEXT           "Lanuage",IDC_STATIC_LANGUAGE,23,66,36,10
-    COMBOBOX        IDC_COMBO_LANGUAGE,71,65,130,95,CBS_DROPDOWNLIST | 
+    COMBOBOX        IDC_COMBO_LANGUAGE,65,65,130,95,CBS_DROPDOWNLIST | 
                     CBS_SORT | WS_VSCROLL | WS_TABSTOP
     LTEXT           "Ignore copies that occur X milliseconds from the last copy (1000 ms = 1 sec)",
                     IDC_STATIC_SAVE_DELAY,23,215,186,19
     EDITTEXT        IDC_EDIT_SAVE_DELAY,209,214,38,12,ES_AUTOHSCROLL
+    PUSHBUTTON      "About Language",IDC_BUTTON_ABOUT,204,65,58,12
 END
 
 IDD_SELECT_DB DIALOG DISCARDABLE  0, 0, 276, 46

+ 33 - 0
OptionsGeneral.cpp

@@ -70,6 +70,7 @@ BEGIN_MESSAGE_MAP(COptionsGeneral, CPropertyPage)
 	ON_BN_CLICKED(IDC_GET_PATH, OnGetPath)
 	ON_BN_CLICKED(IDC_SELECT_SOUND, OnSelectSound)
 	ON_BN_CLICKED(IDC_BUTTON_PLAY, OnButtonPlay)
+	ON_BN_CLICKED(IDC_BUTTON_ABOUT, OnButtonAbout)
 	//}}AFX_MSG_MAP
 END_MESSAGE_MAP()
 
@@ -358,3 +359,35 @@ void COptionsGeneral::OnButtonPlay()
 
 	PlaySound(m_csPlaySound, NULL, SND_FILENAME|SND_ASYNC);
 }
+
+void COptionsGeneral::OnButtonAbout() 
+{
+	CMultiLanguage Lang;
+
+	CString csLanguage;
+	m_cbLanguage.GetLBText(m_cbLanguage.GetCurSel(), csLanguage);
+
+	Lang.SetOnlyGetHeader(true);
+		
+	if(Lang.LoadLanguageFile(csLanguage))
+	{
+		CString csMessage;
+
+		csMessage.Format("Language -  %s\n"
+						 "Version -   %d\n"
+						 "Author -   %s\n"
+						 "Notes -   %s", csLanguage, 
+									   Lang.GetVersion(), 
+									   Lang.GetAuthor(), 
+									   Lang.GetNotes());
+
+		MessageBox(csMessage, "Ditto", MB_OK);
+	}
+	else
+	{
+		CString csError;
+		csError.Format("Error loading language file - %s - reason = ", csLanguage, Lang.m_csLastError);
+
+		MessageBox(csError, "Ditto", MB_OK);
+	}
+}

+ 1 - 0
OptionsGeneral.h

@@ -79,6 +79,7 @@ protected:
 	afx_msg void OnGetPath();
 	afx_msg void OnSelectSound();
 	afx_msg void OnButtonPlay();
+	afx_msg void OnButtonAbout();
 	//}}AFX_MSG
 	DECLARE_MESSAGE_MAP()
 

+ 73 - 1
QPasteWnd.cpp

@@ -124,6 +124,14 @@ BEGIN_MESSAGE_MAP(CQPasteWnd, CWndEx)
 	ON_COMMAND(ID_MENU_QUICKOPTIONS_ENSUREENTIREWINDOWISVISIBLE, OnMenuQuickoptionsEnsureentirewindowisvisible)
 	ON_COMMAND(ID_MENU_QUICKOPTIONS_SHOWCLIPSTHATAREINGROUPSINMAINLIST, OnMenuQuickoptionsShowclipsthatareingroupsinmainlist)
 	ON_COMMAND(ID_MENU_PASTEHTMLASPLAINTEXT, OnMenuPastehtmlasplaintext)
+	ON_UPDATE_COMMAND_UI(ID_MENU_NEWGROUP, OnUpdateMenuNewgroup)
+	ON_UPDATE_COMMAND_UI(ID_MENU_NEWGROUPSELECTION, OnUpdateMenuNewgroupselection)
+	ON_UPDATE_COMMAND_UI(ID_MENU_ALLWAYSONTOP, OnUpdateMenuAllwaysontop)
+	ON_UPDATE_COMMAND_UI(ID_MENU_VIEWFULLDESCRIPTION, OnUpdateMenuViewfulldescription)
+	ON_UPDATE_COMMAND_UI(ID_MENU_VIEWGROUPS, OnUpdateMenuViewgroups)
+	ON_UPDATE_COMMAND_UI(ID_MENU_PASTEPLAINTEXTONLY, OnUpdateMenuPasteplaintextonly)
+	ON_UPDATE_COMMAND_UI(ID_MENU_DELETE, OnUpdateMenuDelete)
+	ON_UPDATE_COMMAND_UI(ID_MENU_PROPERTIES, OnUpdateMenuProperties)
 	//}}AFX_MSG_MAP
 	ON_MESSAGE(NM_SELECT, OnListSelect)
 	ON_MESSAGE(NM_END, OnListEnd)
@@ -2249,4 +2257,68 @@ LRESULT CQPasteWnd::OnToolTipWndInactive(WPARAM wParam, LPARAM lParam)
 	}
 
 	return TRUE;
-}
+}
+
+void CQPasteWnd::OnUpdateMenuNewgroup(CCmdUI* pCmdUI) 
+{
+	CString cs;
+	pCmdUI->m_pMenu->GetMenuString(pCmdUI->m_nID, cs, MF_BYCOMMAND);
+	cs += "\tCtrl-F7";
+	pCmdUI->SetText(cs);
+}
+
+void CQPasteWnd::OnUpdateMenuNewgroupselection(CCmdUI* pCmdUI) 
+{
+	CString cs;
+	pCmdUI->m_pMenu->GetMenuString(pCmdUI->m_nID, cs, MF_BYCOMMAND);
+	cs += "\tF7";
+	pCmdUI->SetText(cs);	
+}
+
+void CQPasteWnd::OnUpdateMenuAllwaysontop(CCmdUI* pCmdUI) 
+{
+	CString cs;
+	pCmdUI->m_pMenu->GetMenuString(pCmdUI->m_nID, cs, MF_BYCOMMAND);
+	cs += "\tCtrl-Space";
+	pCmdUI->SetText(cs);
+}
+
+void CQPasteWnd::OnUpdateMenuViewfulldescription(CCmdUI* pCmdUI) 
+{
+	CString cs;
+	pCmdUI->m_pMenu->GetMenuString(pCmdUI->m_nID, cs, MF_BYCOMMAND);
+	cs += "\tF3";
+	pCmdUI->SetText(cs);
+}
+
+void CQPasteWnd::OnUpdateMenuViewgroups(CCmdUI* pCmdUI) 
+{
+	CString cs;
+	pCmdUI->m_pMenu->GetMenuString(pCmdUI->m_nID, cs, MF_BYCOMMAND);
+	cs += "\tCtrl-G";
+	pCmdUI->SetText(cs);	
+}
+
+void CQPasteWnd::OnUpdateMenuPasteplaintextonly(CCmdUI* pCmdUI) 
+{
+	CString cs;
+	pCmdUI->m_pMenu->GetMenuString(pCmdUI->m_nID, cs, MF_BYCOMMAND);
+	cs += "\tShift-Enter";
+	pCmdUI->SetText(cs);	
+}
+
+void CQPasteWnd::OnUpdateMenuDelete(CCmdUI* pCmdUI) 
+{
+	CString cs;
+	pCmdUI->m_pMenu->GetMenuString(pCmdUI->m_nID, cs, MF_BYCOMMAND);
+	cs += "\tDel";
+	pCmdUI->SetText(cs);
+}
+
+void CQPasteWnd::OnUpdateMenuProperties(CCmdUI* pCmdUI) 
+{
+	CString cs;
+	pCmdUI->m_pMenu->GetMenuString(pCmdUI->m_nID, cs, MF_BYCOMMAND);
+	cs += "\tAlt-Enter";
+	pCmdUI->SetText(cs);
+}

+ 8 - 0
QPasteWnd.h

@@ -175,6 +175,14 @@ protected:
 	afx_msg void OnMenuQuickoptionsEnsureentirewindowisvisible();
 	afx_msg void OnMenuQuickoptionsShowclipsthatareingroupsinmainlist();
 	afx_msg void OnMenuPastehtmlasplaintext();
+	afx_msg void OnUpdateMenuNewgroup(CCmdUI* pCmdUI);
+	afx_msg void OnUpdateMenuNewgroupselection(CCmdUI* pCmdUI);
+	afx_msg void OnUpdateMenuAllwaysontop(CCmdUI* pCmdUI);
+	afx_msg void OnUpdateMenuViewfulldescription(CCmdUI* pCmdUI);
+	afx_msg void OnUpdateMenuViewgroups(CCmdUI* pCmdUI);
+	afx_msg void OnUpdateMenuPasteplaintextonly(CCmdUI* pCmdUI);
+	afx_msg void OnUpdateMenuDelete(CCmdUI* pCmdUI);
+	afx_msg void OnUpdateMenuProperties(CCmdUI* pCmdUI);
 	//}}AFX_MSG
 	afx_msg LRESULT OnListSelect(WPARAM wParam, LPARAM lParam);
 	afx_msg LRESULT OnListEnd(WPARAM wParam, LPARAM lParam);

+ 2 - 1
Resource.h

@@ -190,6 +190,7 @@
 #define IDC_COMBO_LANGUAGE              2070
 #define IDC_EDIT_SAVE_DELAY             2071
 #define IDC_STATIC_SAVE_DELAY           2072
+#define IDC_BUTTON_ABOUT                2073
 #define ID_FIRST_OPTION                 32771
 #define ID_FIRST_EXIT                   32772
 #define ID_FIRST_SHOWQUICKPASTE         32773
@@ -275,7 +276,7 @@
 #define _APS_3D_CONTROLS                     1
 #define _APS_NEXT_RESOURCE_VALUE        157
 #define _APS_NEXT_COMMAND_VALUE         32852
-#define _APS_NEXT_CONTROL_VALUE         2073
+#define _APS_NEXT_CONTROL_VALUE         2074
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif

+ 85 - 0
WndEx.cpp

@@ -103,6 +103,7 @@ BEGIN_MESSAGE_MAP(CWndEx, CWnd)
 	ON_WM_ERASEBKGND()
 	ON_WM_TIMER()
 	ON_WM_WINDOWPOSCHANGING()
+	ON_WM_INITMENUPOPUP() 
 //}}AFX_MSG_MAP
 ON_WM_SIZE()
 END_MESSAGE_MAP()
@@ -1080,3 +1081,87 @@ void CWndEx::OnSize(UINT nType, int cx, int cy)
 	
 	SetRegion();
 }
+
+
+void CWndEx::OnInitMenuPopup(CMenu *pPopupMenu, UINT nIndex,BOOL bSysMenu)
+{
+    ASSERT(pPopupMenu != NULL);
+    // Check the enabled state of various menu items.
+	
+    CCmdUI state;
+    state.m_pMenu = pPopupMenu;
+    ASSERT(state.m_pOther == NULL);
+    ASSERT(state.m_pParentMenu == NULL);
+	
+    // Determine if menu is popup in top-level menu and set m_pOther to
+    // it if so (m_pParentMenu == NULL indicates that it is secondary popup).
+    HMENU hParentMenu;
+    if (AfxGetThreadState()->m_hTrackingMenu == pPopupMenu->m_hMenu)
+	{
+        state.m_pParentMenu = pPopupMenu;    // Parent == child for tracking popup.
+	}
+    else if ((hParentMenu = ::GetMenu(m_hWnd)) != NULL)
+    {
+        CWnd* pParent = this;
+		// Child windows don't have menus--need to go to the top!
+        if (pParent != NULL &&
+			(hParentMenu = ::GetMenu(pParent->m_hWnd)) != NULL)
+        {
+			int nIndexMax = ::GetMenuItemCount(hParentMenu);
+			for (int nIndex = 0; nIndex < nIndexMax; nIndex++)
+			{
+				if (::GetSubMenu(hParentMenu, nIndex) == pPopupMenu->m_hMenu)
+				{
+					// When popup is found, m_pParentMenu is containing menu.
+					state.m_pParentMenu = CMenu::FromHandle(hParentMenu);
+					break;
+				}
+			}
+        }
+    }
+	
+    state.m_nIndexMax = pPopupMenu->GetMenuItemCount();
+    for (state.m_nIndex = 0; state.m_nIndex < state.m_nIndexMax;
+	state.m_nIndex++)
+    {
+        state.m_nID = pPopupMenu->GetMenuItemID(state.m_nIndex);
+        if (state.m_nID == 0)
+			continue; // Menu separator or invalid cmd - ignore it.
+		
+        ASSERT(state.m_pOther == NULL);
+        ASSERT(state.m_pMenu != NULL);
+        if (state.m_nID == (UINT)-1)
+        {
+			// Possibly a popup menu, route to first item of that popup.
+			state.m_pSubMenu = pPopupMenu->GetSubMenu(state.m_nIndex);
+			if (state.m_pSubMenu == NULL ||
+				(state.m_nID = state.m_pSubMenu->GetMenuItemID(0)) == 0 ||
+				state.m_nID == (UINT)-1)
+			{
+				continue;       // First item of popup can't be routed to.
+			}
+			state.DoUpdate(this, TRUE);   // Popups are never auto disabled.
+        }
+        else
+        {
+			// Normal menu item.
+			// Auto enable/disable if frame window has m_bAutoMenuEnable
+			// set and command is _not_ a system command.
+			state.m_pSubMenu = NULL;
+			state.DoUpdate(this, FALSE);
+        }
+		
+        // Adjust for menu deletions and additions.
+        UINT nCount = pPopupMenu->GetMenuItemCount();
+        if (nCount < state.m_nIndexMax)
+        {
+			state.m_nIndex -= (state.m_nIndexMax - nCount);
+			while (state.m_nIndex < nCount &&
+				pPopupMenu->GetMenuItemID(state.m_nIndex) == state.m_nID)
+			{
+				state.m_nIndex++;
+			}
+        }
+        state.m_nIndexMax = nCount;
+    }
+} 

+ 1 - 0
WndEx.h

@@ -93,6 +93,7 @@ protected:
 	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
 	afx_msg void OnTimer(UINT nIDEvent);
 	afx_msg void OnWindowPosChanging(WINDOWPOS* lpwndpos);
+	afx_msg void OnInitMenuPopup(CMenu *pPopupMenu, UINT nIndex,BOOL bSysMenu);
 	//}}AFX_MSG
 	DECLARE_MESSAGE_MAP()
 public: