void CScreenEditView::DoContextMenu(CPoint point) { CFEManDoc* pDoc = GetDocument(); Screen *pWorkScreen; ScreenObject *pScreenObject; // Save the position of this last right click. lastRightClick = point; // Keep this click in client coordinates? ScreenToClient(&lastRightClick); // These are the types of context menus in this pane; // 1: Default context menu. // 2: Screen Object context menu. // Load the Screen Object context menu. pWorkScreen = pDoc->GetFirstSelectedScreen(); if(!pWorkScreen) return; pScreenObject = pWorkScreen->PointOnScreenObject(&lastRightClick); if(pScreenObject) { CMenu contextMenu, *pContextMenu; if(!pWorkScreen->IsSelectedScreenObject(pScreenObject)) { pWorkScreen->ClearAllSelectedScreenObjects(); } pWorkScreen->SelectScreenObject(pScreenObject); Invalidate(); if(pScreenObject->GetType() == ScreenObject::SOT_SCREENOBJECTRECT) { contextMenu.LoadMenu(IDR_SCREENOBJECTRECT); pContextMenu = contextMenu.GetSubMenu(0); // Disable properties if there is more than one item selected. if(pWorkScreen->GetNumSelectedScreenObjects() > 1) { pContextMenu->EnableMenuItem(ID_SOR_PROPERTIES, MF_GRAYED); } // Disable delete if one of the screens is the default page. // Delete screen won't delete this screen anyway. if(pWorkScreen->IsObjectDefaultPage(pScreenObject)) { pContextMenu->EnableMenuItem(ID_SOR_DELETESELECTEDSCREENS, MF_GRAYED); } pContextMenu->TrackPopupMenu(TPM_LEFTALIGN, point.x, point.y, GetParent()); } else if(pScreenObject->GetType() == ScreenObject::SOT_SCREENOBJECTBITMAP) { contextMenu.LoadMenu(IDR_SCREENOBJECTBITMAP); pContextMenu = contextMenu.GetSubMenu(0); // Disable properties if there is more than one item selected. if(pWorkScreen->GetNumSelectedScreenObjects() > 1) { pContextMenu->EnableMenuItem(ID_SOB_PROPERTIES, MF_GRAYED); } pContextMenu->TrackPopupMenu(TPM_LEFTALIGN, point.x, point.y, GetParent()); } else if(pScreenObject->GetType() == ScreenObject::SOT_SCREENOBJECTSTRING) { contextMenu.LoadMenu(IDR_SCREENOBJECTSTRING); pContextMenu = contextMenu.GetSubMenu(0); // Disable properties if there is more than one item selected. if(pWorkScreen->GetNumSelectedScreenObjects() > 1) { pContextMenu->EnableMenuItem(ID_SOS_PROPERTIES, MF_GRAYED); } pContextMenu->TrackPopupMenu(TPM_LEFTALIGN, point.x, point.y, GetParent()); } } // Load the default context menu. else { CMenu contextMenu, *pContextMenu; pWorkScreen->ClearAllSelectedScreenObjects(); Invalidate(); contextMenu.LoadMenu(IDR_SCREENEDITDEFAULT); pContextMenu = contextMenu.GetSubMenu(0); pContextMenu->CheckMenuItem(ID_SED_GRID, MF_BYCOMMAND | (pDoc->gridActive ? MF_CHECKED : MF_UNCHECKED)); pContextMenu->TrackPopupMenu(TPM_LEFTALIGN, point.x, point.y, GetParent()); } }
void CScreenEditView::OnLButtonDown(UINT nFlags, CPoint point) { CFEManDoc* pDoc = GetDocument(); Screen *pWorkScreen; ScreenObject *pScreenObject; // Only draw the screen object if there is one screen selected. if(pDoc->GetNumSelectedScreenIcons() != 1) return; // Left button is pressed. We have several choices. // 1: Pressed on nothing. Start dragging a selection window. // 2: Pressed on a ScreenObject. Select the screen object and drag it. // 4: Pressed on an already selected Screen Object. Drag all selected items. if(pDoc->gridActive) { CPoint tempPoint; tempPoint.x = point.x - DEFAULT_SCREEN_OFFSET_X; tempPoint.y = point.y - DEFAULT_SCREEN_OFFSET_Y; unsigned long xRes = tempPoint.x / pDoc->gridSpacing; unsigned long yRes = tempPoint.y / pDoc->gridSpacing; lastLeftClick.x = pDoc->gridSpacing * xRes; lastLeftClick.y = pDoc->gridSpacing * yRes; lastLeftClick.x += DEFAULT_SCREEN_OFFSET_X; lastLeftClick.y += DEFAULT_SCREEN_OFFSET_Y; } else { lastLeftClick = point; } switch(lButtonStatus) { case LBS_NORMAL: // Nothing special. // Find out where I clicked and choose one of the tracking modes. pWorkScreen = pDoc->GetFirstSelectedScreen(); pScreenObject = pWorkScreen->PointOnScreenObject(&point); if(pScreenObject) { // Clicked on a screen object. // If nothing selected, OR this screen object is not // selected, clear all other selections and drag this screen. if((pWorkScreen->GetNumSelectedScreenObjects() == 0) || (!pWorkScreen->IsSelectedScreenObject(pScreenObject))) { pWorkScreen->ClearAllSelectedScreenObjects(); pWorkScreen->SelectScreenObject(pScreenObject); } // Only do this if there is just one screen object selected. if(pWorkScreen->GetNumSelectedScreenObjects() == 1) { lButtonStatus = pScreenObject->CheckSelectionDragGizmos(&point); } else { // If this screen selected, drag all selected items. lButtonStatus = LBS_SCREENOBJECTCLICK; } } else { // Didn't click on a screen object. Start Dragging the selection widow. // Clear all the selections and start dragging a selection window. pWorkScreen->ClearAllSelectedScreenObjects(); lButtonStatus = LBS_WINDOWCLICK; selectionWindow.left = lastLeftClick.x; selectionWindow.top = lastLeftClick.y; selectionWindow.right = lastLeftClick.x; selectionWindow.bottom = lastLeftClick.y; } // Make sure we redraw to reflect the changes. Invalidate(); break; case LBS_SCREENOBJECTCLICK: // Clicked on a screen object. // In a tracking mode. Probably do nothing. break; } ChooseMouseCursor(&point); }