[commit] r2807 - trunk/GME/Gme

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Fri Oct 1 11:44:47 CDT 2021


Author: ksmyth
Date: Fri Oct  1 11:44:47 2021
New Revision: 2807

Log:
Add right-click menu to model editor tabs

Modified:
   trunk/GME/Gme/ChildFrm.cpp
   trunk/GME/Gme/GME.rc
   trunk/GME/Gme/resource.h

Modified: trunk/GME/Gme/ChildFrm.cpp
==============================================================================
--- trunk/GME/Gme/ChildFrm.cpp	Fri Oct  1 11:44:43 2021	(r2806)
+++ trunk/GME/Gme/ChildFrm.cpp	Fri Oct  1 11:44:47 2021	(r2807)
@@ -194,11 +194,11 @@
 
 BOOL CChildFrame::PreTranslateMessage(MSG* pMsg)
 {
+	long xPos = GET_X_LPARAM(pMsg->lParam);
+	long yPos = GET_Y_LPARAM(pMsg->lParam);
 
-	if (pMsg->message == WM_MBUTTONUP) {
+	auto& GetChildFrame = [&]() {
 		CMFCTabCtrl* tabCtrl = GetRelatedTabGroup();
-		long xPos = GET_X_LPARAM(pMsg->lParam);
-		long yPos = GET_Y_LPARAM(pMsg->lParam);
 		CPoint point(xPos, yPos);
 		if (tabCtrl->IsPtInTabArea(point)) {
 			int i = tabCtrl->GetTabFromPoint(point);
@@ -206,10 +206,58 @@
 				CWnd* tabCtrlWnd = tabCtrl->GetTabWnd(i);
 				if (tabCtrlWnd != NULL && tabCtrlWnd->IsKindOf(RUNTIME_CLASS(CChildFrame))) {
 					CChildFrame* cf = STATIC_DOWNCAST(CChildFrame, tabCtrlWnd);
-					cf->PostMessage(WM_CLOSE);
+					return cf;
 				}
 			}
 		}
+		return (CChildFrame*)nullptr;
+	};
+
+	CChildFrame* cf;
+	if (pMsg->message == WM_MBUTTONUP && (cf = GetChildFrame())) {
+		if (cf) {
+			cf->PostMessage(WM_CLOSE);
+			return TRUE;
+		}
+	}
+	else if (pMsg->message == WM_RBUTTONUP && (cf = GetChildFrame())) {
+		CMenu menu;
+		menu.LoadMenu(IDR_TAB_MENU);
+		CMenu *submenu = menu.GetSubMenu(0);
+		CPoint screen = { xPos, yPos };
+		::ClientToScreen(pMsg->hwnd, &screen);
+
+		int cmd = (int)submenu->TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_RIGHTBUTTON,
+			screen.x, screen.y, GetParent());
+		switch (cmd) {
+		case ID_CLOSEOTHERS_CLOSE:
+			cf->PostMessage(WM_CLOSE);
+			return TRUE;
+		case ID_CLOSEOTHERS_CLOSETOTHERIGHT: // fallthrough
+		case ID_CLOSEOTHERS_CLOSEOTHERS:
+		{
+			CMFCTabCtrl* tabCtrl = GetRelatedTabGroup();
+			int currentTab = 0;
+			for (int i = 0; i < tabCtrl->GetTabsNum(); i++) {
+				CWnd* tab = tabCtrl->GetTabWnd(i);
+				if (tab == cf) {
+					currentTab = i;
+				}
+			}
+			for (int i = 0; i < tabCtrl->GetTabsNum(); i++) {
+				CWnd* tab = tabCtrl->GetTabWnd(i);
+				CRect rect;
+				tabCtrl->GetTabRect(i, rect);
+
+				if (tab == cf) {
+				}
+				else if (cmd != ID_CLOSEOTHERS_CLOSETOTHERIGHT || i > currentTab) {
+					tab->PostMessage(WM_CLOSE);
+				}
+			}
+			return TRUE;
+		}
+		}
 	}
 
 	return CMDIChildWndEx::PreTranslateMessage(pMsg);

Modified: trunk/GME/Gme/GME.rc
==============================================================================
--- trunk/GME/Gme/GME.rc	Fri Oct  1 11:44:43 2021	(r2806)
+++ trunk/GME/Gme/GME.rc	Fri Oct  1 11:44:47 2021	(r2807)
@@ -651,6 +651,16 @@
     END
 END
 
+IDR_TAB_MENU MENU
+BEGIN
+    POPUP "Tab menu"
+    BEGIN
+        MENUITEM "&Close",                       ID_CLOSEOTHERS_CLOSE
+        MENUITEM "Close &others",                ID_CLOSEOTHERS_CLOSEOTHERS
+        MENUITEM "Close to the &right",          ID_CLOSEOTHERS_CLOSETOTHERIGHT
+    END
+END
+
 
 /////////////////////////////////////////////////////////////////////////////
 //

Modified: trunk/GME/Gme/resource.h
==============================================================================
--- trunk/GME/Gme/resource.h	Fri Oct  1 11:44:43 2021	(r2806)
+++ trunk/GME/Gme/resource.h	Fri Oct  1 11:44:47 2021	(r2807)
@@ -103,6 +103,7 @@
 #define IDD_PRINT_DIALOG                229
 #define IDD_PRINTSETUP_DIALOG           230
 #define IDD_PARADIGMPROPERTIES_DIALOG   231
+#define IDR_TAB_MENU                    232
 #define IDC_NAME                        1000
 #define IDC_TYPENAME                    1001
 #define IDC_KINDNAME                    1002
@@ -520,6 +521,9 @@
 #define ID_CONNCNTX_REVERSE             33270
 #define ID_VIEW_SHOWCONNECTEDPORTSONLY  33271
 #define ID_PORTCNTX_DELETE              33272
+#define ID_CLOSEOTHERS_CLOSETOTHERIGHT  33273
+#define ID_CLOSEOTHERS_CLOSE            33274
+#define ID_CLOSEOTHERS_CLOSEOTHERS      33275
 #pragma region Help IDs
 #define ID_HELP_PARADIGMHELP            0x9000
 #define ID_HELP_PARADIGMHELP_FIRST      0x9001
@@ -542,8 +546,8 @@
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_3D_CONTROLS                     1
-#define _APS_NEXT_RESOURCE_VALUE        232
-#define _APS_NEXT_COMMAND_VALUE         33273
+#define _APS_NEXT_RESOURCE_VALUE        233
+#define _APS_NEXT_COMMAND_VALUE         33276
 #define _APS_NEXT_CONTROL_VALUE         1139
 #define _APS_NEXT_SYMED_VALUE           119
 #endif


More information about the gme-commit mailing list