Changed popup menu style to match the main window menus.

This commit is contained in:
leo 2012-02-08 01:48:46 +00:00
parent 32b598ce1b
commit 256001076f
6 changed files with 77 additions and 192 deletions

View file

@ -132,6 +132,10 @@ public:
void RemoveView(View* view);
void UpdateAllViews();
bool SetActiveView(View* view);
View* GetActiveView() const
{
return m_ActiveView;
}
// Implementation
protected:

View file

@ -394,11 +394,11 @@ BEGIN
MENUITEM "Rotate View", ID_ACTION_ROTATE_VIEW
MENUITEM "Roll", ID_ACTION_ROLL
MENUITEM "Zoom Region", ID_ACTION_ZOOM_REGION
MENUITEM "Zoom Extents", ID_ACTION_ZOOM_EXTENTS
MENUITEM "Zoom Extents", ID_ZOOM_EXTENTS
END
POPUP "Cameras"
BEGIN
MENUITEM "Dummy", ID_VIEW_CAMERAS_DUMMY
MENUITEM "Dummy", ID_CAMERA_FIRST
END
MENUITEM SEPARATOR
MENUITEM "Split Horizontally", ID_VIEW_SPLITHORIZONTALLY

View file

@ -8,6 +8,7 @@
#include "MainFrm.h"
#include "Camera.h"
#include "project.h"
#include "view.h"
#include "message.h"
#include "globals.h"
#include "mainwnd.h"
@ -129,6 +130,7 @@ BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx)
ON_UPDATE_COMMAND_UI_RANGE(ID_ACTION_SELECT, ID_ACTION_ROLL, OnUpdateAction)
ON_UPDATE_COMMAND_UI_RANGE(ID_SNAP_SNAPX, ID_SNAP_SNAPNONE, OnUpdateSnap)
ON_UPDATE_COMMAND_UI_RANGE(ID_LOCK_LOCKX, ID_LOCK_UNLOCKALL, OnUpdateLock)
ON_UPDATE_COMMAND_UI_RANGE(ID_CAMERA_FIRST, ID_CAMERA_LAST, OnUpdateCamera)
ON_COMMAND(ID_VIEW_SPLITVERTICALLY, OnViewSplitVertically)
ON_COMMAND(ID_VIEW_SPLITHORIZONTALLY, OnViewSplitHorizontally)
ON_COMMAND(ID_VIEW_DELETEVIEW, OnViewDeleteView)
@ -242,6 +244,7 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
if (m_wndInvisibleToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, ID_VIEW_INVISIBLE_BAR))
{
VERIFY(m_wndInvisibleToolBar.LoadToolBar(IDR_INVISIBLE));
m_wndInvisibleToolBar.SetMaskMode(TRUE);
}
if (!m_wndProperties.Create("Properties", this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_PROPERTIES_BAR, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI))
@ -381,6 +384,16 @@ void CMainFrame::OnUpdateLock(CCmdUI* pCmdUI)
}
}
void CMainFrame::OnUpdateCamera(CCmdUI* pCmdUI)
{
Project* project = lcGetActiveProject();
Camera* ActiveCamera = project->GetActiveView()->m_Camera;
Camera* MenuCamera = project->GetCamera(pCmdUI->m_nID - ID_CAMERA_FIRST);
pCmdUI->SetRadio(MenuCamera == ActiveCamera);
}
// lParam = update pieces, wParam = update colors
LONG CMainFrame::OnUpdateList(UINT lParam, LONG wParam)
{
@ -663,6 +676,53 @@ void CMainFrame::OnFilePrintPieceList()
AfxBeginThread(PrintPiecesFunction, this);
}
BOOL CMainFrame::OnShowPopupMenu(CMFCPopupMenu* pMenuPopup)
{
if (!CMFCToolBar::IsCustomizeMode() && pMenuPopup != NULL && pMenuPopup->GetHMenu() != NULL)
{
HMENU hMenuPop = pMenuPopup->GetHMenu();
BOOL bIsCamerawMenu = FALSE;
int iItemMax = ::GetMenuItemCount(hMenuPop);
for (int iItemPop = 0; !bIsCamerawMenu && iItemPop < iItemMax; iItemPop ++)
{
UINT nID = ::GetMenuItemID( hMenuPop, iItemPop);
bIsCamerawMenu = (nID >= ID_CAMERA_FIRST && nID <= ID_CAMERA_LAST);
}
if (bIsCamerawMenu)
{
Project* project = lcGetActiveProject();
Camera* camera = project->GetCamera(0);
int NumCameras = 0;
pMenuPopup->RemoveAllItems();
for (; camera && NumCameras < 7; camera = camera->m_pNext, NumCameras++)
{
CMFCToolBarMenuButton newButton(ID_CAMERA_FIRST + NumCameras, NULL, -1, camera->GetName());
pMenuPopup->InsertItem(newButton);
}
if (camera)
{
pMenuPopup->InsertSeparator();
for (; camera; camera = camera->m_pNext, NumCameras++)
{
CMFCToolBarMenuButton newButton(ID_CAMERA_FIRST + NumCameras, NULL, -1, camera->GetName());
pMenuPopup->InsertItem(newButton);
}
}
pMenuPopup->InsertSeparator();
pMenuPopup->InsertItem(CMFCToolBarMenuButton(ID_VIEW_CAMERAS_RESET, NULL, -1, "Reset"));
}
}
return CFrameWndEx::OnShowPopupMenu(pMenuPopup);
}
// Pass all commands to the project.
BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam)
{

View file

@ -40,6 +40,8 @@ public:
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
//}}AFX_VIRTUAL
virtual BOOL OnShowPopupMenu(CMFCPopupMenu* pMenuPopup);
// Implementation
public:
virtual ~CMainFrame();
@ -97,6 +99,7 @@ protected:
afx_msg void OnUpdateAction(CCmdUI* pCmdUI);
afx_msg void OnUpdateSnap(CCmdUI* pCmdUI);
afx_msg void OnUpdateLock(CCmdUI* pCmdUI);
afx_msg void OnUpdateCamera(CCmdUI* pCmdUI);
afx_msg LONG OnUpdateList(UINT lParam, LONG wParam);
afx_msg LONG OnPopupClose(UINT lParam, LONG wParam);

View file

@ -51,8 +51,6 @@ bool lcAssert(const char* FileName, int Line, const char* Expression, const char
return false;
}
static CMenu menuPopups;
static CStepDlg* StepModeless = NULL;
static UINT ClipboardFormat = 0;
@ -397,45 +395,6 @@ void SystemInit()
// initialize wait cursor state
g_nWaitCursorCount = 0;
g_hcurWaitCursorRestore = NULL;
menuPopups.LoadMenu(IDR_POPUPS);
// attempt to load special bitmap, else default to arrow
CSize size = GetMenuCheckMarkDimensions();
ASSERT(size.cx > 4 && size.cy > 5); // not too small please
if (size.cx > 32)
size.cx = 32;
int iwRow = (size.cx + 15) >> 4; // # of WORDs per raster line
int nShift = (size.cx - DOT_WIDTH) / 2; // # of bits to shift over
nShift += ((iwRow * 16) - size.cx); // padding for word alignment
if (nShift > 16 - DOT_WIDTH)
nShift = 16 - DOT_WIDTH; // maximum shift for 1 word
if (size.cy > 32)
size.cy = 32;
// bitmap 2/4/4/4/2 pixels wide - centered (0 => black)
BYTE rgbBitmap[32 * 2 * sizeof(WORD)];
memset(rgbBitmap, 0xff, sizeof(rgbBitmap));
BYTE* pbOut = &rgbBitmap[iwRow * sizeof(WORD) *
((size.cy - (DOT_HEIGHT+1)) >> 1)];
const BYTE* pbIn = rgbDot;
for (int y = 0; y < DOT_HEIGHT; y++)
{
WORD w = (WORD)~(((DWORD)*pbIn++) << nShift);
// bitmaps are always hi-lo
pbOut[0] = HIBYTE(w);
pbOut[1] = LOBYTE(w);
pbOut += iwRow * sizeof(WORD);
}
hbmMenuDot = CreateBitmap(size.cx, size.cy, 1, 1, (LPVOID)&rgbBitmap);
if (hbmMenuDot == NULL)
{
#define OBM_MNARROW 32739
hbmMenuDot = LoadBitmap(NULL, MAKEINTRESOURCE(OBM_MNARROW));
}
}
// Viewport menu.
@ -865,154 +824,10 @@ void SystemUpdateAnimation(bool bAnimation, bool bAddKeys)
void SystemUpdateCurrentCamera(Camera* pOld, Camera* pNew, Camera* pCamera)
{
/*
CMenu* Menu = GetMainMenu(2);
if (!Menu)
return;
CMenu* pMainMenu = Menu->GetSubMenu(13);
CMenu* pPopupMenu = menuPopups.GetSubMenu(1)->GetSubMenu(3);
int i;
for (i = 0; pCamera; i++, pCamera = pCamera->m_pNext)
{
if (pOld == pCamera)
{
pPopupMenu->CheckMenuItem(i + ID_CAMERA_FIRST, MF_BYCOMMAND | MF_UNCHECKED);
pMainMenu->CheckMenuItem(i + ID_CAMERA_FIRST, MF_BYCOMMAND | MF_UNCHECKED);
}
if (pNew == pCamera)
{
pPopupMenu->CheckMenuItem(i + ID_CAMERA_FIRST, MF_BYCOMMAND | MF_CHECKED);
pMainMenu->CheckMenuItem(i + ID_CAMERA_FIRST, MF_BYCOMMAND | MF_CHECKED);
SetMenuItemBitmaps(pPopupMenu->m_hMenu, i + ID_CAMERA_FIRST, MF_BYCOMMAND, NULL, hbmMenuDot);
SetMenuItemBitmaps(pMainMenu->m_hMenu, i + ID_CAMERA_FIRST, MF_BYCOMMAND, NULL, hbmMenuDot);
}
}
*/
}
// Update the list of cameras
void SystemUpdateCameraMenu(Camera* pCamera)
{
CMenu* Menu = GetMainMenu(2);
if (!Menu)
return;
CMenu* pMainMenu = Menu->GetSubMenu(13);
CMenu* pPopupMenu = menuPopups.GetSubMenu(1)->GetSubMenu(3);
Camera* pFirst = pCamera;
int i;
CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
if (!pFrame)
return;
CMFCMenuBar& MenuBar = pFrame->m_wndMenuBar;
CMFCToolBarButton* pEditButton = MenuBar.GetButton(2);
CMFCToolBarMenuButton* pEditMenuButton = DYNAMIC_DOWNCAST(CMFCToolBarMenuButton, pEditButton);
const CObList& editCommands = pEditMenuButton->GetCommands();
CMFCToolBarMenuButton* pMainMenuButton = NULL;
for (POSITION pos = editCommands.GetHeadPosition(); pos != NULL && pMainMenuButton == NULL;)
{
CMFCToolBarMenuButton* pSubButton = (CMFCToolBarMenuButton*)editCommands.GetNext(pos);
ASSERT_VALID(pSubButton);
const CObList& subCommands = pSubButton->GetCommands();
for (POSITION pos2 = subCommands.GetHeadPosition(); pos2 != NULL;)
{
CMFCToolBarMenuButton* pSubMenuButton = (CMFCToolBarMenuButton*)subCommands.GetNext(pos2);
ASSERT_VALID(pSubMenuButton);
if (pSubMenuButton->m_nID == ID_VIEW_CAMERAS_RESET)
{
// CMFCPopupMenuBar* pParentMenu = DYNAMIC_DOWNCAST(CMFCPopupMenuBar, pSubMenuButton->GetParentWnd());
pMainMenuButton = pSubButton;
break;
}
}
}
if (!pMainMenuButton)
return;
CObList& cameraCommands = (CObList&)pMainMenuButton->GetCommands();
for (POSITION pos = cameraCommands.GetHeadPosition(); pos != NULL && pMainMenuButton != NULL;)
{
POSITION posSave = pos;
CMFCToolBarMenuButton* pSubButton = (CMFCToolBarMenuButton*)cameraCommands.GetNext(pos);
ASSERT_VALID(pSubButton);
cameraCommands.RemoveAt(posSave);
delete pSubButton;
}
while (pPopupMenu->GetMenuItemCount())
pPopupMenu->DeleteMenu(0, MF_BYPOSITION);
POSITION posAdd = NULL;
for (i = 0; pCamera; i++, pCamera = pCamera->m_pNext)
if (i > 6)
{
CMFCToolBarMenuButton* newButton = new CMFCToolBarMenuButton(ID_CAMERA_FIRST + i, NULL, -1, pCamera->GetName());
if (posAdd)
posAdd = cameraCommands.InsertAfter(posAdd, newButton);
else
posAdd = cameraCommands.AddHead(newButton);
pPopupMenu->AppendMenu(MF_STRING, i + ID_CAMERA_FIRST, pCamera->GetName());
}
if (i > 7)
{
if (posAdd)
{
CMFCToolBarMenuButton* pButton = new CMFCToolBarMenuButton();
pButton->m_nStyle = TBBS_SEPARATOR;
posAdd = cameraCommands.InsertAfter(posAdd, pButton);
}
pPopupMenu->AppendMenu(MF_SEPARATOR);
}
pCamera = pFirst;
for (i = 0; pCamera && (i < 7); i++, pCamera = pCamera->m_pNext)
{
CMFCToolBarMenuButton* newButton = new CMFCToolBarMenuButton(ID_CAMERA_FIRST + i, NULL, -1, pCamera->GetName());
if (posAdd)
posAdd = cameraCommands.InsertAfter(posAdd, newButton);
else
posAdd = cameraCommands.AddHead(newButton);
// pMainMenu->AppendMenu(MF_STRING, i + ID_CAMERA_FIRST, pCamera->GetName());
pPopupMenu->AppendMenu(MF_STRING, i + ID_CAMERA_FIRST, pCamera->GetName());
// pMainMenu->ChangeMenuItemShortcut("str", i + ID_CAMERA_FIRST);
}
if (posAdd)
{
CMFCToolBarMenuButton* pButton = new CMFCToolBarMenuButton();
pButton->m_nStyle = TBBS_SEPARATOR;
posAdd = cameraCommands.InsertAfter(posAdd, pButton);
}
CMFCToolBarMenuButton* newButton = new CMFCToolBarMenuButton(ID_VIEW_CAMERAS_RESET, NULL, -1, "Reset");
cameraCommands.AddTail(newButton);
pPopupMenu->AppendMenu(MF_SEPARATOR);
pPopupMenu->AppendMenu(MF_STRING, ID_VIEW_CAMERAS_RESET, "Reset");
// pMainMenu->AppendODMenu("Adjust...\t", MF_ENABLED, ID_VIEW_VIEWPOINT);
// pPopupMenu->AppendODMenu("Adjust...\t", MF_ENABLED, ID_VIEW_VIEWPOINT);
((CMainFrame*)AfxGetMainWnd())->UpdateMenuAccelerators();
}
void SystemUpdateCategories(bool SearchOnly)
@ -1033,7 +848,9 @@ void SystemUpdateRecentMenu(char names[4][MAX_PATH])
// if x = -1, get cursor pos
void SystemDoPopupMenu(int nMenu, int x, int y)
{
CMenu* pPopup;
CMenu PopupMenus;
PopupMenus.LoadMenu(IDR_POPUPS);
POINT pt;
if (x != -1)
@ -1044,8 +861,8 @@ void SystemDoPopupMenu(int nMenu, int x, int y)
else
GetCursorPos(&pt);
pPopup = menuPopups.GetSubMenu(nMenu);
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, pt.x, pt.y, AfxGetMainWnd());
CMFCPopupMenu* Popup = new CMFCPopupMenu();
Popup->Create(AfxGetMainWnd(), pt.x, pt.y, PopupMenus.GetSubMenu(nMenu)->Detach());
}
// Private MFC function only sets the title if it's different

View file

@ -402,8 +402,8 @@
#define IDC_KEYDLG_CMDLIST 1230
#define IDC_MF_SHOELANGLE 1231
#define IDC_MF_SHOERANGLE 1232
#define IDC_MF_HATSPIN 1234
#define IDC_KEYDLG_REMOVE 1233
#define IDC_MF_HATSPIN 1234
#define IDC_MF_HEADSPIN 1235
#define IDC_MF_ARMLSPIN 1236
#define IDC_KEYDLG_RESET 1236
@ -662,6 +662,7 @@
#define ID_VIEW_SPLIT_HORIZONTALLY 33177
#define ID_TOOLBARS_PROPERTIES 33178
#define ID_FILE_IMPORTFOLDER 33179
#define ID_C 33180
#define ID_VIEW_PIECES_BAR 59425
#define ID_VIEW_TOOLS_BAR 59426
#define ID_VIEW_ANIMATION_BAR 59427
@ -675,7 +676,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 242
#define _APS_NEXT_COMMAND_VALUE 33180
#define _APS_NEXT_COMMAND_VALUE 33181
#define _APS_NEXT_CONTROL_VALUE 1247
#define _APS_NEXT_SYMED_VALUE 121
#endif