void CExtDockBar::_ContextMenuTrack()
{
	// find any control bar
CControlBar * pBar = NULL;
	for( int nPos = 0; nPos < m_arrBars.GetSize(); nPos++ )
	{
		pBar = GetDockedControlBar(nPos);
		if( pBar != NULL )
		{
			ASSERT_VALID( pBar );
			break;
		}
	}
	if( pBar == NULL )
		return;

CFrameWnd * pFrame = _GetDockingFrameImpl();
CPoint point;
	VERIFY( ::GetCursorPos(&point) );
CExtPopupMenuWnd * pPopup =
		new CExtPopupMenuWnd;
	VERIFY( pPopup->CreatePopupMenu( pBar->GetOwner()->GetSafeHwnd() ) );
	_ContextMenuBuild(
		pFrame,
		pPopup
		);
	pPopup->TrackPopupMenu(
		0,
		point.x,point.y,
		pBar->GetOwner()->GetSafeHwnd() // pFrame->GetSafeHwnd()
		);
}
void InsertObjectDialog::OnRClickList(NMHDR* pNMHDR, LRESULT* pResult) 
{
	POSITION listpos = objects.GetFirstSelectedItemPosition();
	int item = objects.GetNextSelectedItem(listpos);
	CString itemtext = objects.GetItemText(item, 0);

	if (itemtext == "") return;

	// Mouse position
	POINT cursorPosition;
	GetCursorPos(&cursorPosition);

	CExtPopupMenuWnd * popup =  new CExtPopupMenuWnd;
	popup->LoadMenu(m_hWnd, IDR_OBJECT, true, false);

	UINT ChosenItem = 0;
	popup->TrackPopupMenu(TPMX_DO_MESSAGE_LOOP|TPMX_NO_WM_COMMAND|TPMX_NO_CMD_UI, cursorPosition.x, cursorPosition.y, NULL, NULL, NULL, &ChosenItem);

	// Open info dialog
	if (ChosenItem == ID_OBJECTINFO)
	{
		CObjectInfoDlg objInfo;
		objInfo.objname = itemtext;
		objInfo.DoModal();
	}	

	// Open website address
	else if (ChosenItem == ID_MENU_VISITURL)
	{
		CPlugin Plugin = GetPluginByFile((const char*)objects.GetItemData(item));
		ShellExecute(NULL, "open", Plugin.m_WebLink, NULL, NULL, NULL);
	}

	*pResult = 0;
}
void CExtStatusControlBar::OnContextMenu(CWnd* pWnd, CPoint point) 
{
#if (!defined __EXT_MFC_NO_CUSTOMIZE)
CExtCustomizeSite * pSite =
		CExtCustomizeSite::GetCustomizeSite( m_hWnd );
	if(		pSite != NULL
		&&	pSite->IsCustomizeMode()
		)
		return;
#endif // (!defined __EXT_MFC_NO_CUSTOMIZE)

	if( CExtControlBar::FindHelpMode(this) )
		return;

CFrameWnd * pFrame = _GetDockingFrameImpl();
	if( pFrame == NULL )
	{
		CStatusBar::OnContextMenu( pWnd, point );
		return;
	}

	ASSERT_VALID( pFrame );
HWND hWndTrack = GetOwner()->GetSafeHwnd();
	ASSERT( hWndTrack != NULL && ::IsWindow(hWndTrack) );
CExtPopupMenuWnd * pPopup =
		new CExtPopupMenuWnd;
	VERIFY( pPopup->CreatePopupMenu(hWndTrack) );

	if(	! CExtDockBar::_ConstructDockSiteControlBarPopupMenu(
			pFrame,
			pPopup,
			CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_STATUSBAR_CTX,
			this,
			WM_CONTEXTMENU,
			NULL
			)
		)
	{
		delete pPopup;
		return;
	}
	if( pPopup->ItemGetCount() == 0 )
	{
		delete pPopup;
		return;
	}
	::SetFocus( hWndTrack );
	if( ! pPopup->TrackPopupMenu(
			TPMX_OWNERDRAW_FIXED,
			point.x,
			point.y
			)
		)
	{
		delete pPopup;
	}
}
Exemple #4
0
bool CExtButton::_OnTrackPopup()
{
	if( m_menu.GetSafeHmenu() == NULL )
		return false;
	ASSERT( ::IsMenu(m_menu.GetSafeHmenu()) );
	VERIFY(
		g_CmdManager->UpdateFromMenu(
			g_CmdManager->ProfileNameFromWnd( GetSafeHwnd() ),
			m_menu.GetSafeHmenu()
			)
		);
CExtPopupMenuWnd * pPopup = new CExtPopupMenuWnd;
CWnd * pWnd = GetParent();
	ASSERT( pWnd != NULL );
	ASSERT_VALID( pWnd );
	VERIFY(
		pPopup->UpdateFromMenu( pWnd->GetSafeHwnd(), &m_menu )
		);
CRect wr;
	GetWindowRect( &wr );
CPoint pt = wr.CenterPoint();
	pPopup->TrackPopupMenu(
		m_nMenuOpt,
		pt.x,
		pt.y,
		pWnd->GetSafeHwnd(),
		&wr,
		true, // bSelectAny
		true, // bPerformMessageLoop
		false, // bForceExpandRarelyUsed
		CExtPopupMenuWnd::__COMBINE_DEFAULT,
		this,
		_CbPaintCombinedContent
		);
	return true;
}
void CJazzUpTellTaleButton::OnRButtonUp(UINT nFlags, CPoint point)
{
	// Mouse position
	POINT cursorPosition;
	GetCursorPos(&cursorPosition);

	CParametersDlg* ParamDlg = dynamic_cast<CParametersDlg*>(GetParent()->GetParent());
	if(!ParamDlg) return;

	int index = GetWindowLong(m_hWnd,GWL_ID);

	int type = ParamDlg->m_Stack.m_arrPanes[index]->type;

	if (type == EDITORPARAM_GLOBALVARIABLE)
		return;

	CExtPopupMenuWnd* popup =  new CExtPopupMenuWnd;
	popup->CreatePopupMenu(m_hWnd);
	popup->ItemInsertCommand(1,-1, "Use Expression",NULL,NULL);
	popup->ItemInsert(CExtPopupMenuWnd::TYPE_SEPARATOR);
	popup->ItemInsertCommand(2,-1, "Default",NULL,NULL);
	UINT Item = 0;
	if(!popup->TrackPopupMenu(TPMX_DO_MESSAGE_LOOP|TPMX_NO_WM_COMMAND|TPMX_NO_CMD_UI, cursorPosition.x, cursorPosition.y, NULL, NULL, NULL, &Item))
		return;

	if(ParamDlg && Item != 0 && Item != -1)
	{
		CString paraminfo = ParamDlg->m_Stack.m_arrPanes[index]->GetParameterString();
		ParamDlg->SetRedraw(false);
		ParamDlg->m_Stack.m_arrPanes[index]->content_window->DestroyWindow();

		int type = EDITORPARAM_USERPARAM;
		if(Item == 2)
			type = ParamDlg->m_pACEEntry->params.at(index).type;
		
		ParamDlg->CreateParameter(index,&ParamDlg->m_Stack,*ParamDlg->m_Stack.m_arrPanes[index], type, paraminfo);
			
		
		ParamDlg->m_Stack.RearrangeStack();
		ParamDlg->SetRedraw(true);
		ParamDlg->Invalidate();
	}
	else
	{
		CErrorDlg dlg;
		dlg.Error("Construct Error", "Error in JazzUpTellTaleButton - parent window could not be found");
	}


}
Exemple #6
0
LRESULT CPageToolbars::OnExtMenuPrepare(WPARAM wParam, LPARAM lParam)
{
	lParam;
	CExtPopupMenuWnd::MsgPrepareMenuData_t * pData =
		reinterpret_cast
			< CExtPopupMenuWnd::MsgPrepareMenuData_t * >
			( wParam );
	ASSERT( pData != NULL );
	CExtPopupMenuWnd * pPopup = pData->m_pPopup;
	ASSERT( pPopup != NULL );

	INT nReplacePos =
		pPopup->ItemFindPosForCmdID(ID_COLOR_CTRL);
	
	if( nReplacePos >= 0 )
	{
		CExtPopupColorMenuWnd * pColorPopup = new CExtPopupColorMenuWnd;
		pColorPopup->m_lParamCookie = LPARAM(ID_COLOR_CTRL);
		pColorPopup->m_hWndNotifyColorChanged = GetSafeHwnd();
		pColorPopup->m_clrDefault = COLORREF(-1);
		pColorPopup->m_clrInitial =	m_clrColorCtrl;
		VERIFY(
			pPopup->ItemInsertSpecPopup(
			pColorPopup,
			nReplacePos + 1,
			pPopup->ItemGetText(nReplacePos),
			pPopup->ItemGetIcon(nReplacePos)
			)
			);
		pPopup->ItemSetDisplayed( nReplacePos + 1, true );
		VERIFY( pPopup->ItemRemove(nReplacePos) );
	} // if( nReplacePos >= 0 )

#if (!defined __EXT_MFC_NO_DATE_PICKER)
	nReplacePos =
		pPopup->ItemFindPosForCmdID(ID_DATE_PICKER_CTRL);
	
	if( nReplacePos >= 0 )
	{
		CExtPopupControlMenuWnd::g_bControlMenuWithShadows = true;
		CExtPopupDatePickerMenuWnd * pDatePickerPopup = new CExtPopupDatePickerMenuWnd;
		VERIFY(
			pPopup->ItemInsertSpecPopup(
			pDatePickerPopup,
			nReplacePos + 1,
			pPopup->ItemGetText(nReplacePos),
			pPopup->ItemGetIcon(nReplacePos)
			)
			);
		pPopup->ItemSetDisplayed( nReplacePos + 1, true );
		VERIFY( pPopup->ItemRemove(nReplacePos) );
	} // if( nReplacePos >= 0 )
#endif // #if (!defined __EXT_MFC_NO_DATE_PICKER)	
	
	return TRUE;
}
BOOL CExtResizableDialog::_TrackDialogSystemMenu(
	CPoint * pPoint,
	BOOL bSelectAny
	)
{
	if( (GetStyle() & WS_POPUP) == 0 )
		return FALSE;
	if(	CExtPopupMenuWnd::IsMenuTracking() )
		CExtPopupMenuWnd::CancelMenuTracking();
	m_bSysMenuTracking = FALSE;

CMenu * pSysMenu =
		GetSystemMenu( FALSE );
	if( pSysMenu == NULL )
		return FALSE;
	ASSERT( ::IsMenu(pSysMenu->GetSafeHmenu()) );
CExtPopupMenuWnd * pPopup = new CExtPopupMenuWnd;
	if( !pPopup->CreatePopupMenu( GetSafeHwnd() ) )
	{
		ASSERT( FALSE );
		return FALSE;
	}
	if( !pPopup->UpdateFromMenu(
			GetSafeHwnd(),
			pSysMenu,
			false
			)
		)
	{
		ASSERT( FALSE );
		return FALSE;
	}

CPoint point;
	if( pPoint != NULL)
		point = *pPoint;
	else
	{
		CRect rcWnd, rcClient, rcHelper;
		GetWindowRect( &rcWnd );
		GetClientRect( &rcClient );
		rcHelper = rcWnd;
		ScreenToClient( &rcHelper );
		ASSERT( rcHelper.top <= rcClient.top );
		int yDiff = rcClient.top - rcHelper.top;
		point = rcWnd.TopLeft();
		point.x += GetSystemMetrics(SM_CXFRAME);
		point.y += yDiff;
	}
	m_bSysMenuTracking =
		pPopup->TrackPopupMenu(
			TPMX_BOTTOMALIGN,
			point.x,point.y,
			GetSafeHwnd(),
			NULL,
			bSelectAny ? true : false
			) ? true : false;

	if( m_bSysMenuTracking )
		SetTimer( ID_TIMER_SYS_TRACKING, 20, NULL );
	return TRUE;
}
void ObjectBarDialog::OnRClickObject(NMHDR *pNMHDR, LRESULT *pResult)
{
	POSITION Pos = objects.GetFirstSelectedItemPosition();
	int Item = objects.GetNextSelectedItem(Pos);

	// Check if we're right clicking a blank space
	if (Item == -1)
	{
		POINT MousePosition;
		GetCursorPos(&MousePosition);

		CExtPopupMenuWnd * popup = new CExtPopupMenuWnd;

		//object filter
		CExtPopupMenuWnd * objfilterlist = new CExtPopupMenuWnd;
		for (int i=0 ; i < application->object_folders.size(); i++)
		{
			int sel = (i==folderfilter)?3:0;
			if (folderfilter==-1 && application->object_folders[i].name == "Default")
				sel = 3;
			objfilterlist->ItemInsertCommand(100+i, -1, application->object_folders[i].name, NULL, NULL, false, sel);
		}

		popup->LoadMenu(m_hWnd, IDR_BLANK, true, false);
		popup->ItemRemove(0);

		UINT item = 0;

		if (parent.m_tabs.SelectionGet() == 0 && parent.m_tabs.ItemGetCount() == 2)
		{
			popup->ItemInsertCommand(1, -1, "Insert an object", NULL, NULL);
			popup->ItemInsert();
		}

		if (view == ob_large_icons)
		{
			popup->ItemInsertCommand(2, -1, "Show large icons", NULL, NULL, false, 3);
			popup->ItemInsertCommand(3, -1, "Show small icons", NULL, NULL, false, 0);
			popup->ItemInsertCommand(4, -1, "Show small icons (horizontal)", NULL, NULL, false, 0);
			//popup->ItemInsertCommand(5, -1, "Show object tree", NULL, NULL, false, 0);
		}

		else if (view == ob_small_icons)
		{
			popup->ItemInsertCommand(2, -1, "Show large icons", NULL, NULL, false, 0);
			popup->ItemInsertCommand(3, -1, "Show small icons", NULL, NULL, false, 3);
			popup->ItemInsertCommand(4, -1, "Show small icons (horizontal)", NULL, NULL, false, 0);
			//popup->ItemInsertCommand(5, -1, "Show object tree", NULL, NULL, false, 0);
		}

		else if (view == ob_small_icons_horizontal)
		{
			popup->ItemInsertCommand(2, -1, "Show large icons", NULL, NULL, false, 0);
			popup->ItemInsertCommand(3, -1, "Show small icons", NULL, NULL, false, 0);
			popup->ItemInsertCommand(4, -1, "Show small icons (horizontal)", NULL, NULL, false, 3);
			//popup->ItemInsertCommand(5, -1, "Show object tree", NULL, NULL, false, 0);
		}

		else
		{
			popup->ItemInsertCommand(2, -1, "Show large icons", NULL, NULL, false, 0);
			popup->ItemInsertCommand(3, -1, "Show small icons", NULL, NULL, false, 0);
			popup->ItemInsertCommand(4, -1, "Show small icons (horizontal)", NULL, NULL, false, 0);
		//	popup->ItemInsertCommand(5, -1, "Show object tree", NULL, NULL, false, 3);
		}

		popup->ItemInsert();

		if (sorting == ob_sort_az)
		{
			popup->ItemInsertCommand(6, -1, "Sort A-Z", NULL, NULL, false, 3);
			popup->ItemInsertCommand(7, -1, "Sort Z-A", NULL, NULL, false, 0);
			popup->ItemInsertCommand(8, -1, "Sort by Z-Order", NULL, NULL, false, 0);
		}

		else if (sorting == ob_sort_za)
		{
			popup->ItemInsertCommand(6, -1, "Sort A-Z", NULL, NULL, false, 0);
			popup->ItemInsertCommand(7, -1, "Sort Z-A", NULL, NULL, false, 3);
			popup->ItemInsertCommand(8, -1, "Sort by Z-Order", NULL, NULL, false, 0);
		}

		else
		{
			popup->ItemInsertCommand(6, -1, "Sort A-Z", NULL, NULL, false, 0);
			popup->ItemInsertCommand(7, -1, "Sort Z-A", NULL, NULL, false, 0);
			popup->ItemInsertCommand(8, -1, "Sort by Z-Order", NULL, NULL, false, 3);
		}

		popup->ItemInsert();

		if (show_only_selected_layer)
			popup->ItemInsertCommand(9, -1, "Show only objects on the selected layer", NULL, NULL, false, 1);
		else
			popup->ItemInsertCommand(9, -1, "Show only objects on the selected layer", NULL, NULL, false, 0);

		if (show_nonlayout_objects)
			popup->ItemInsertCommand(10, -1, "Show non-layout objects", NULL, NULL, false, 1);
		else
			popup->ItemInsertCommand(10, -1, "Show non-layout objects", NULL, NULL, false, 0);

		if (folderfilter > -2)
			popup->ItemInsertCommand(99, -1, "Use Folders", NULL, NULL, false, 1);
		else
			popup->ItemInsertCommand(99, -1, "Use Folders", NULL, NULL, false, 0);

		popup->ItemInsertSpecPopup(objfilterlist, -1, "Filter by Object Folder", NULL);

		// show menu
		popup->TrackPopupMenu(TPMX_DO_MESSAGE_LOOP | TPMX_NO_WM_COMMAND | TPMX_NO_CMD_UI, MousePosition.x, MousePosition.y, NULL, NULL, NULL, &item);
			
		if (item == 1)
			parent.layout_editor[0][0]->OnFrameAction(IDFR_INSERT);

		else if (item == 2)
		{
			view = ob_large_icons;
			ListView_SetView(objects.m_hWnd, LV_VIEW_ICON);		
			
			objects.ShowWindow(SW_SHOW);
			object_tree.ShowWindow(SW_HIDE);
		}

		else if (item == 3)
		{
			view = ob_small_icons;
			ListView_SetView(objects.m_hWnd, LV_VIEW_DETAILS);		
			
			objects.ShowWindow(SW_SHOW);
			object_tree.ShowWindow(SW_HIDE);
		}

		else if (item == 4)
		{
			view = ob_small_icons_horizontal;
			ListView_SetView(objects.m_hWnd, LV_VIEW_LIST);		

			objects.ShowWindow(SW_SHOW);
			object_tree.ShowWindow(SW_HIDE);
		}

		else if (item == 5)
		{
			view = ob_object_tree;
			
			objects.ShowWindow(SW_HIDE);
			object_tree.ShowWindow(SW_SHOW);
		}

		else if (item == 6)
		{
			sorting = ob_sort_az;
			Refresh();
		}

		else if (item == 7)
		{
			sorting = ob_sort_za;
			Refresh();
		}

		else if (item == 8)
		{
			sorting = ob_sort_zorder;
			Refresh();
		}

		else if (item == 9)
		{
			show_only_selected_layer = !show_only_selected_layer;
			Refresh();
		}

		else if (item == 10)
		{
			show_nonlayout_objects = !show_nonlayout_objects;
			Refresh();
		}

		else if (item == 99)
		{
			if(folderfilter == -2)
				folderfilter=-1;
			else
				folderfilter=-2;
			g_MainFrame->m_INI.WriteInt("General", "ObjectFolder", folderfilter);
			Refresh();
		}
		else if (item >= 100)
		{
			folderfilter=item-100;
			if(application->object_folders[folderfilter].name=="Default")
				folderfilter=-1;
			g_MainFrame->m_INI.WriteInt("General", "ObjectFolder", -1);
			Refresh();
		}
	}

	else
	{
		if (parent.m_tabs.SelectionGet() == 0 && parent.m_tabs.ItemGetCount() == 2)
		{
			parent.layout_editor[0][0]->m_sel.RemoveAll();

			CObjType* pType;
			long ID = objects.GetItemData(Item);

			if (ID == -1)
				return; //folder

			application->object_types.Lookup(ID, pType);

			CLayout* pLayout = parent.layout_editor[0][0]->layout;

			// Iterate each instance
			POSITION instancePos = pLayout->objects.GetStartPosition();
			long unused = 0;

			while (instancePos)
			{
				CObj* pObj;
				pLayout->objects.GetNextAssoc(instancePos, unused, pObj);

				// Add 
				if (pObj->editObject->ObjectIdentifier == pType->ObjectIdentifier)
					parent.layout_editor[0][0]->m_sel.AddTail(unused);
			}

			parent.layout_editor[0][0]->OnRButtonUp(0, CPoint(0,0));
		}
	}
}
Exemple #9
0
void AnimatorBar::OnRClickFilmStrip(NMHDR *pNMHDR, LRESULT *pResult)
{
	if (m_pCurrentAnimation == NULL)
		return;

	POINT MousePosition;
	GetCursorPos(&MousePosition);

	CExtPopupMenuWnd * popup = new CExtPopupMenuWnd;
	popup->LoadMenu(m_hWnd, IDR_BLANK, true, false);
	popup->ItemRemove(0);

	UINT ChosenItem = 0;

	// Add frame
	popup->ItemInsertCommand(1, -1, "Add frame", NULL, NULL);

	bool bIsSel = false;

	POSITION Pos = film_strip.GetFirstSelectedItemPosition();

	if(!m_pCurrentAnimation)
		return;

	if(!m_pCurrentAnimation->supportsFrames())
		return;

	while(Pos)
	{
		int Item = film_strip.GetNextSelectedItem(Pos);
		if (Item != -1)
			bIsSel = true;
	}

	// Import
	popup->ItemInsertCommand(3, -1, AB_IMPORTFRAME, NULL, NULL);
	popup->ItemBoldGet(0);

	// Copy/paste
	popup->ItemInsertCommand();

	// Remove frame(s)
	if (bIsSel)
		popup->ItemInsertCommand(2, -1, AB_REMOVEFRAME, NULL, NULL);

	if (film_strip.GetItemCount() != 1)
		popup->ItemInsertCommand(7, -1, AB_CUTFRAMES, NULL, NULL);

	popup->ItemInsertCommand(4, -1, AB_COPYFRAMES, NULL, NULL);
	popup->ItemInsertCommand(5, -1, AB_PASTEFRAMES, NULL, NULL);
	popup->ItemInsertCommand(10, -1, AB_DUPLICATEFRAMES, NULL, NULL);

	popup->ItemInsertCommand();

	// flip vertical/horizontal
	popup->ItemInsertCommand(8, -1, AB_MIRRORFRAMES, NULL, NULL);
	popup->ItemInsertCommand(9, -1, AB_FLIPFRAMES, NULL, NULL);

	// Explore
	popup->ItemInsertCommand();
	popup->ItemInsertCommand(6, -1, AB_LAUNCHEXPLORER, NULL, NULL);

	// Explore
	popup->ItemInsertCommand();
	popup->ItemInsertCommand(11, -1, AB_COPYCOLLISIONMASKTOEACHFRAME, NULL, NULL);


	// Show menu
	popup->TrackPopupMenu(TPMX_DO_MESSAGE_LOOP | TPMX_NO_WM_COMMAND | TPMX_NO_CMD_UI, MousePosition.x, MousePosition.y, NULL, NULL, NULL, &ChosenItem);
		
	if (ChosenItem == 1)
		AddFrame();

	else if (ChosenItem == 2)
		RemoveFrame();

	else if (ChosenItem == 3)
	{
		CImportImagesDlg ImportDlg;
		if (ImportDlg.DoModal() == IDOK)
		{			
			for(list<CImageResource>::iterator i = ImportDlg.m_Images.begin(); i!= ImportDlg.m_Images.end(); i++)
			{
				int id = layout->AddImage(i->bitmap.GetWidth(), i->bitmap.GetHeight());

				m_pCurrentAnimation->m_Images.push_back(id);
				m_pCurrentAnimation->m_FrameTimes.push_back(1.0);

				CImageResource* image = application->resources.FindImageResourceFromNumber(id);
				image->bitmap.Copy(i->bitmap);

				image->m_Action = i->m_Action;
				image->m_Hotspot = i->m_Hotspot;
				image->m_Collision = i->m_Collision;
				
			}
			
			UpdateFilmStrip();
		}
	}

	// copy
	else if (ChosenItem == 4)
	{	
		CAnimEdFrame* pFrames = new CAnimEdFrame;
		pFrames->m_anim_ed = this;
		DROPEFFECT de = DROPEFFECT_NONE;
		m_pDDMgr.PrepareDrop(DO_CLIPBOARD, "Construct Frames", pFrames, &de);
	}

	// cut
	else if (ChosenItem == 7)
	{
		CAnimEdFrame* pFrames = new CAnimEdFrame;
		pFrames->m_anim_ed = this;
		DROPEFFECT de = DROPEFFECT_NONE;
		m_pDDMgr.PrepareDrop(DO_CLIPBOARD, "Construct Frames", pFrames, &de);

		RemoveFrame();
	}

	// paste
	else if (ChosenItem == 5)
	{
		if (m_pDDMgr.OkToPaste())
		{
			CAnimEdFrame pFrames;
			pFrames.m_anim_ed = this;
			m_pDDMgr.DoDrop(&pFrames,
							  NULL,
							  "Construct Frames");
		}
	}

	// duplicate
	else if (ChosenItem == 10)
	{	
		CAnimEdFrame* pFrames = new CAnimEdFrame;
		pFrames->m_anim_ed = this;
		DROPEFFECT de = DROPEFFECT_NONE;
		m_pDDMgr.PrepareDrop(DO_CLIPBOARD, "Construct Frames", pFrames, &de);

		if (m_pDDMgr.OkToPaste())
		{
			CAnimEdFrame pFrames;
			pFrames.m_anim_ed = this;
			m_pDDMgr.DoDrop(&pFrames,
							  NULL,
							  "Construct Frames");
		}
	}
	// Copy collision mask to every other frame
	else if (ChosenItem == 11)
	{
		// Get the frame we right clicked on
		POSITION pos = film_strip.GetFirstSelectedItemPosition();
		if(pos)
		{
			int nItem = film_strip.GetNextSelectedItem(pos);
			int handle = m_pCurrentAnimation->m_Images.at(nItem);
		
			int result = MessageBox("Click 'OK' to confirm you want to copy the collision mask of this selected frame to every other frame in the animation package", "Construct", MB_OKCANCEL);

			if(result == IDOK){
				CImageResource* res = application->resources.FindImageResourceFromNumber(handle);
				if(!res)
					MessageBox("Error. Image resource could not be found for this animation frame");
				else
				{
					if(!res->m_Collision.IsValid())
						res->m_Collision = res->bitmap; // copy
					
					application->resources.CopyCollisionMaskToEveryFrameInAnimation(m_pAnimation, res); 

				}
			
				
		}
		}

	}

	// Launch explorer
	else if (ChosenItem == 6)
	{
		CPath Path;
		Path.SetToCurrentDirectory();
		
		CString InfoPath;
		InfoPath.Format("%sImages\\", Path.GetFullPath());

		// make sure directory exists
		::CreateDirectory(InfoPath, NULL);

		// now open file
		InfoPath += "frames.txt";
		CFile File(InfoPath, CFile::modeWrite | CFile::modeCreate);
	

		int index = 0;
		for(vector<int>::iterator i = m_pCurrentAnimation->m_Images.begin(); i!= m_pCurrentAnimation->m_Images.end(); i++)
		{
			CImageResource* img = application->resources.FindImageResourceFromNumber(*i);
			if(img)
			{
				CString nl;
				nl.Format("%c%c", 13,10);
				index ++;
				CString SavePath;
				SavePath.Format("%sImages\\Frame %d.png", Path.GetFullPath(), index);
				CxImage backup = img->bitmap;
				img->Predivide();
				img->bitmap.Save(SavePath,CXIMAGE_FORMAT_PNG);
				img->bitmap = backup;

				if(img->m_Collision.IsValid())
				{
					SavePath.Format("%sImages\\Mask %d.png", Path.GetFullPath(), index);
					img->m_Collision.Save(SavePath,CXIMAGE_FORMAT_PNG);
				}
				else
				{
					SavePath.Format("%sImages\\Mask %d.png", Path.GetFullPath(), index);
					img->bitmap.Save(SavePath,CXIMAGE_FORMAT_PNG);
				}


				CString Info;
				Info.Format("Frame %d%sPivotX%s%d%sPivotY%s%d%s", index, nl,nl, img->m_Hotspot.x, nl,nl, img->m_Hotspot.y, nl);
				for(map<CString, CPoint>::iterator a = img->m_Action.begin(); a!= img->m_Action.end(); a++)
				{
					Info.Format("%s%s%s%d%s%d%s", Info, a->first, nl, a->second.x, nl, a->second.y, nl);
				}
				Info += nl;
				File.Write((const char*)Info, Info.GetLength() * sizeof(char));


			}
		}
		File.Close();

		CString LaunchPath;
		LaunchPath.Format("%sImages\\", Path.GetFullPath());

		ShellExecute(NULL,  "open", LaunchPath, NULL, NULL, SW_SHOW);

		int result = MessageBox("Click 'OK' to reimport the images that have been exported to Explorer.", "Construct", MB_OKCANCEL);

		if(result == IDOK)
		{
			int result2 = MessageBox("Import collision mask?", "Construct", MB_YESNOCANCEL);
			int index = 0;
			for(vector<int>::iterator i = m_pCurrentAnimation->m_Images.begin(); i!= m_pCurrentAnimation->m_Images.end(); i++)
			{
				index ++;
				CImageResource* img = application->resources.FindImageResourceFromNumber(*i);
			
				CString SavePath;
				SavePath.Format("%sImages\\Frame %d.png", Path.GetFullPath(), index);			
				
				img->bitmap.Load(SavePath,CXIMAGE_FORMAT_PNG);
				img->Premultiply();

				if(result2 == IDYES)
				{
				SavePath.Format("%sImages\\Mask %d.png", Path.GetFullPath(), index);			
				img->m_Collision.Load(SavePath,CXIMAGE_FORMAT_PNG);
				}
				if(result2 == IDNO)
				{
					if(img->m_Collision.IsValid())
						img->m_Collision.Destroy();
				}

				application->m_image_to_texture.erase(img->m_FixedID);

				img->small_thumbnail.Destroy();
				img->large_thumbnail.Destroy();
			}

			application->resources.images_changed = true;

			AnimationHasChanged();
			UpdateFilmStrip();
		}
	}

	else if (ChosenItem == 8)
	{
		// mirror
		POSITION position = film_strip.GetFirstSelectedItemPosition();

		if(!m_pCurrentAnimation)
			return;

		vector<int>& images = m_pCurrentAnimation->m_Images;

		while(position)
		{
			int item = film_strip.GetNextSelectedItem(position);

			if (item == -1) break;

			CImageResource* image = application->resources.FindImageResourceFromNumber(images[item]);
			image->Mirror();

			application->resources.images_changed = true;
		}

		AnimationHasChanged();
		UpdateFilmStrip();
	}

	else if (ChosenItem == 9)
	{
		// mirror
		POSITION position = film_strip.GetFirstSelectedItemPosition();

		if(!m_pCurrentAnimation)
			return;

		vector<int>& images = m_pCurrentAnimation->m_Images;

		while(position)
		{
			int item = film_strip.GetNextSelectedItem(position);

			if (item == -1) break;

			CImageResource* image = application->resources.FindImageResourceFromNumber(images[item]);
			image->Flip();

			application->resources.images_changed = true;
		}

		AnimationHasChanged();
		UpdateFilmStrip();
	}
}
Exemple #10
0
void AnimatorBar::OnRClickAnimation(NMHDR *pNMHDR, LRESULT *pResult)
{
	if (application == NULL)
		return;

	CPoint Pt;
	GetCursorPos(&Pt);
	animations.ScreenToClient(&Pt);
	if (animations.HitTest(Pt))
		animations.SelectItem(animations.HitTest(Pt));

	curHTreeItem = animations.GetSelectedItem();

	if(animations.GetCount() == 0)
		return; //Theres no animations in this tree, so the object doesn't have animations

	// Check for this
	if (!animations.HitTest(Pt))
	{
		curHTreeItem = TVI_ROOT;
		m_pCurrentAnimation = m_pAnimation;
	}

	else
		m_pCurrentAnimation = (CAnimation*)animations.GetItemData(curHTreeItem);

	POINT MousePosition;
	GetCursorPos(&MousePosition);

	CExtPopupMenuWnd * popup = new CExtPopupMenuWnd;
	popup->LoadMenu(m_hWnd, IDR_BLANK, true, false);
	popup->ItemRemove(0);

	UINT ChosenItem = 0;

	// Add menu items
	popup->ItemInsertCommand(1, -1, AB_ADDNEWANIMATION, NULL, NULL);
	
	if (curHTreeItem != TVI_ROOT)
		popup->ItemInsertCommand(2, -1, AB_ADDSUBANIMATION, NULL, NULL);

	if (curHTreeItem != TVI_ROOT)
	{
		popup->ItemInsert();
		popup->ItemInsertCommand(3, -1, AB_ADDNEWANGLE, NULL, NULL);
	}

	if (curHTreeItem != TVI_ROOT)
	{
		popup->ItemInsert();
		popup->ItemInsertCommand(4, -1, REMOVE, NULL, NULL);
	}

	popup->TrackPopupMenu(TPMX_DO_MESSAGE_LOOP | TPMX_NO_WM_COMMAND | TPMX_NO_CMD_UI, MousePosition.x, MousePosition.y, NULL, NULL, NULL, &ChosenItem);
		
	if (ChosenItem == 1)
		AddAnimation();

	else if (ChosenItem == 2)
		AddSubAnimation();

	else if (ChosenItem == 3)
		AddAngle();

	else if (ChosenItem == 4)
		RemoveAnimation();
}
void CExtMiniDockFrameWnd::OnNcRButtonDown(UINT nHitTest, CPoint point)
{
	if( _ResizingIsInProgress() )
	{
		_ResizingEnd();
		return;
	}
	if( nHitTest == HTCAPTION )
	{
#if (!defined __EXT_MFC_NO_CUSTOMIZE)
		CExtCustomizeSite * pSite =
			CExtCustomizeSite::GetCustomizeSite( m_hWnd );
		if(		pSite != NULL
			&&	pSite->IsCustomizeMode()
			)
			return;
#endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
		if( CExtControlBar::FindHelpMode(this) )
			return;
		CExtControlBar * pExtBar =
			GetControlBarExt();
		if( pExtBar != NULL )
		{
			ASSERT_VALID( pExtBar );
			
			CFrameWnd * pFrame = pExtBar->_GetDockingFrameImpl();
			ASSERT_VALID( pFrame );

			CPoint point;
			if( ! ::GetCursorPos(&point) )
				return;
			HWND hWndTrack = pFrame-> /*pExtBar->GetOwner()->*/ GetSafeHwnd();
			ASSERT( hWndTrack != NULL && ::IsWindow(hWndTrack) );
			CExtPopupMenuWnd * pPopup = new CExtPopupMenuWnd;
			VERIFY( pPopup->CreatePopupMenu(hWndTrack) );
			if(	! CExtDockBar::_ConstructDockSiteControlBarPopupMenu(
					pFrame,
					pPopup,
					CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_MINIFRAME_NC_CTX,
					pExtBar,
					WM_NCRBUTTONDOWN,
					NULL
					)
				)
			{
				delete pPopup;
				return;
			}
			if( pPopup->ItemGetCount() == 0 )
			{
				delete pPopup;
				return;
			}
			//::SetFocus( hWndTrack );
			if( ! pPopup->TrackPopupMenu(
					TPMX_OWNERDRAW_FIXED,
					point.x,
					point.y
					)
				)
			{
				delete pPopup;
			}
			return;
		} // if( pExtBar != NULL )
	} // if( nHitTest == HTCAPTION )
	CMiniDockFrameWnd::OnNcRButtonDown(nHitTest,point);
}
Exemple #12
0
LRESULT CMainFrame::OnExtMenuPrepare(WPARAM wParam, LPARAM lParam)
{
	wParam;
	lParam;
#if (defined _AFXDLL && !defined __STATPROFUIS_WITH_DLLMFC__)

	//////////////////////////////////////////////////////////////////////////
	// Add "Windows..." command
	//////////////////////////////////////////////////////////////////////////
	
	CExtPopupMenuWnd::MsgPrepareMenuData_t * pData =
		reinterpret_cast
		< CExtPopupMenuWnd::MsgPrepareMenuData_t * >
		( wParam );
	ASSERT( pData != NULL );
	CExtPopupMenuWnd * pPopup = pData->m_pPopup;
	ASSERT( pPopup != NULL );
	
	INT nItemPos;
	INT nNewPos = -1;
	
	nItemPos = pPopup->ItemFindPosForCmdID( __ID_MDIWND_DLGWINDOWS );
	if( nItemPos > 0 )
	{
		// "More Windows..." command found
		pPopup->ItemRemove( nItemPos );
		nNewPos = nItemPos;
	}
	else
	{
		int nMaxCmdID = 0;
		for( int nCmdID = __ID_MDIWNDLIST_FIRST; nCmdID <= __ID_MDIWNDLIST_LAST; nCmdID++ ){
			nItemPos = pPopup->ItemFindPosForCmdID( nCmdID );
			if( nItemPos > 0 ){
				if( nCmdID > nMaxCmdID ){
					nMaxCmdID = nCmdID;
					nNewPos = nItemPos;
				}
			}
		}
		if( nNewPos > 0 ){
			pPopup->ItemInsert(
				(UINT)CExtPopupMenuWnd::TYPE_SEPARATOR,
				++nNewPos
				);
			nNewPos++;
		}
	}
	if( nNewPos > 0 )
	{
		UINT nCmdID = ID_WINDOWS_LIST;
		CExtCmdItem * pCmdItem =
			g_CmdManager->CmdGetPtr(
			g_CmdManager->ProfileNameFromWnd( this->GetSafeHwnd() ),
			nCmdID
			);
		if( pCmdItem == NULL ){
			pCmdItem = 
				g_CmdManager->CmdAllocPtr( 
				g_CmdManager->ProfileNameFromWnd( this->GetSafeHwnd() ), 
				nCmdID 
				);
		}
		ASSERT( pCmdItem != NULL );
		if( pCmdItem != NULL )
		{
			CString sMoreWindows(_T("Windows..."));
			CString sManageWindows(_T("Manages the currently open windows"));
			pCmdItem->m_sMenuText = sMoreWindows;
			pCmdItem->m_sToolbarText = pCmdItem->m_sMenuText;
			pCmdItem->m_sTipTool = sManageWindows;
			pCmdItem->m_sTipStatus = pCmdItem->m_sTipTool;
			pCmdItem->StateSetBasic( true );
			
			pPopup->ItemInsert(
				nCmdID,
				nNewPos,
				sMoreWindows,
				NULL,
				m_hWnd
				);
		}
	}
	
#endif // #if (defined _AFXDLL && !defined __STATPROFUIS_WITH_DLLMFC__)
	return 1;
}
BOOL CExtThemeSwitcherToolControlBar::PreTranslateMessage( MSG * pMsg )
{
	if(		m_bCommandProfileInitialized
		&&	GetSafeHwnd() != NULL
		&&	pMsg->message == CExtPopupMenuWnd::g_nMsgPrepareOneMenuLevel
		)
	{
		CExtPopupMenuWnd::MsgPrepareMenuData_t * pData =
			reinterpret_cast
			< CExtPopupMenuWnd::MsgPrepareMenuData_t * >
			( pMsg->wParam );
		ASSERT( pData != NULL );
		CExtPopupMenuWnd * pPopup = pData->m_pPopup;
		ASSERT( pPopup != NULL );
#if (!defined __EXT_MFC_NO_CUSTOMIZE)
		bool bCustomizeMode = false;
		CExtPopupMenuWnd * pTestPopup = pPopup;
		for( ; pTestPopup != NULL ; pTestPopup = pTestPopup->GetParentMenuWnd() )
		{
			if( (pPopup->TrackFlagsGet()&TPMX_CUSTOMIZE_MODE) != 0 )
			{
				bCustomizeMode = true;
				break;
			}
		}
		if( ! bCustomizeMode )
		{
			CExtCustomizeSite * pSite =
				CExtCustomizeSite::GetCustomizeSite( m_hWnd );
			if( pSite != NULL )
			{
				bCustomizeMode = pSite->IsCustomizeMode();
				if( ! bCustomizeMode )
					bCustomizeMode = ( pSite->DraggedNodeGet() != NULL ) ? true : false;
			}
		}
		if( ! bCustomizeMode )
#endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
		{
			for( ; true; )
			{
				INT nReplacePos =
					pPopup->ItemFindPosForCmdID( m_nMenuMarkerID );
				if( nReplacePos < 0 )
					break;
				pData->m_bMenuChanged = true;
				pPopup->ItemRemove( nReplacePos );
				INT nIndex, nCount = GetButtonsCount();
				for( nIndex = 0; nIndex < nCount; nIndex++ )
				{
					CExtBarButton * pQueueTBB = GetButton( nIndex );
					ASSERT_VALID( pQueueTBB );
					CExtThemeSwitcherToolButton * pTBB =
						DYNAMIC_DOWNCAST(
							CExtThemeSwitcherToolButton,
							pQueueTBB
							);
					if( pTBB == NULL )
						continue;
					ThemeSwitcher_OnButtonUpdate( pTBB );
					pTBB->PutToPopupMenu( pPopup );
				} // for( nIndex = 0; nIndex < nCount; nIndex++ )
			}
		}
	}
	return FALSE;
}