Esempio n. 1
0
void CMainFrame::UpdateContextTabFromObject(CDrawObjList& list)
{
	int count = (int) list.GetCount();
	if (count == 0)
	{
		return;
	}

	COLORREF clrFill = (COLORREF)-1;
	COLORREF clrLine = (COLORREF)-1;
	int nLineWeight  = -1;
	if (count == 1)
	{
		CDrawObj* pObj = list.GetHead();
		if (pObj->CanChangeFillColor() && pObj->IsEnableFill())
		{
			clrFill = pObj->GetFillColor();
		}
		if (pObj->CanChangeLineColor() && pObj->IsEnableLine())
		{
			clrLine = pObj->GetLineColor();
		}
		if (pObj->CanChangeLineWeight() && pObj->IsEnableLine())
		{
			nLineWeight = pObj->GetLineWeight() - 1;
		}
	}

	{
		CArray<CMFCRibbonBaseElement*, CMFCRibbonBaseElement*> arButtons;
		m_wndRibbonBar.GetElementsByID(ID_OBJECT_FILLCOLOR, arButtons);

		if (arButtons.GetSize() > 0)
		{
			for (int i = 0; i < arButtons.GetSize(); i++)
			{
				CMFCRibbonColorButton* pButton = DYNAMIC_DOWNCAST
					(CMFCRibbonColorButton, arButtons[i]
				);
				pButton->SetColor(clrFill);
			}
		}
	}

	{
		CArray<CMFCRibbonBaseElement*, CMFCRibbonBaseElement*> arButtons;
		m_wndRibbonBar.GetElementsByID(ID_OBJECT_LINECOLOR, arButtons);

		if (arButtons.GetSize() > 0)
		{
			for (int i = 0; i < arButtons.GetSize(); i++)
			{
				CMFCRibbonColorButton* pButton = DYNAMIC_DOWNCAST
					(CMFCRibbonColorButton, arButtons[i]
				);
				pButton->SetColor(clrLine);
			}
		}
	}

	{
		CArray<CMFCRibbonBaseElement*, CMFCRibbonBaseElement*> arButtons;
		m_wndRibbonBar.GetElementsByID(ID_OBJECT_LINEWEIGHT, arButtons);

		if (arButtons.GetSize() > 0)
		{
			for (int i = 0; i < arButtons.GetSize(); i++)
			{
				CRibbonListButton* pButton = DYNAMIC_DOWNCAST
					(CRibbonListButton, arButtons[i]
				);
				pButton->SelectItem(nLineWeight);
			}
		}
	}

	m_wndRibbonBar.RedrawWindow();
}
Esempio n. 2
0
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CMDIFrameWndEx::OnCreate(lpCreateStruct) == -1)
		return -1;

	// set the visual manager and style based on persisted value
	OnApplicationLook(theApp.m_nAppLook);

	CMDITabInfo mdiTabParams;
	mdiTabParams.m_style = CMFCTabCtrl::STYLE_3D; // other styles available...
	mdiTabParams.m_bActiveTabCloseButton = TRUE;      // set to FALSE to place close button at right of tab area
	mdiTabParams.m_bTabIcons = FALSE;    // set to TRUE to enable document icons on MDI taba
	mdiTabParams.m_bAutoColor = FALSE;    // set to FALSE to disable auto-coloring of MDI tabs
	mdiTabParams.m_bDocumentMenu = TRUE; // enable the document menu at the right edge of the tab area
	EnableMDITabbedGroups(TRUE, mdiTabParams);

	m_wndRibbonBar.Create(this);
	m_wndRibbonBar.LoadFromResource(IDR_RIBBON);

	// enable Visual Studio 2005 style docking window behavior
	CDockingManager::SetDockingMode(DT_IMMEDIATE);
	// enable Visual Studio 2005 style docking window auto-hide behavior
	EnableAutoHidePanes(CBRS_ALIGN_ANY);

	// create docking windows
	if (!CreateDockingWindows())
	{
		TRACE0("Failed to create docking windows\n");
		return -1;
	}

	// Enable enhanced windows management dialog
	EnableWindowsDialog(ID_WINDOW_MANAGER, ID_WINDOW_MANAGER, TRUE);

	// Switch the order of document name and application name on the window title bar. This
	// improves the usability of the taskbar because the document name is visible with the thumbnail.
	ModifyStyle(0, FWS_PREFIXTITLE);

	//Update Colors
	CMFCRibbonColorButton* pColor;
	pColor = (CMFCRibbonColorButton*)m_wndRibbonBar.FindByID(ID_BUTTON_CBACKGROUND); pColor->SetColor(crBackground);
	pColor = (CMFCRibbonColorButton*)m_wndRibbonBar.FindByID(ID_BUTTON_CSELECT); pColor->SetColor(crSelect);
	pColor = (CMFCRibbonColorButton*)m_wndRibbonBar.FindByID(ID_BUTTON_CHIDDEN); pColor->SetColor(crHidden);
	pColor = (CMFCRibbonColorButton*)m_wndRibbonBar.FindByID(ID_BUTTON_COFFSET); pColor->SetColor(crOffset);
	pColor = (CMFCRibbonColorButton*)m_wndRibbonBar.FindByID(ID_BUTTON_CADDRESS); pColor->SetColor(crAddress);
	pColor = (CMFCRibbonColorButton*)m_wndRibbonBar.FindByID(ID_BUTTON_CTYPE); pColor->SetColor(crType);
	pColor = (CMFCRibbonColorButton*)m_wndRibbonBar.FindByID(ID_BUTTON_CNAME); pColor->SetColor(crName);
	pColor = (CMFCRibbonColorButton*)m_wndRibbonBar.FindByID(ID_BUTTON_CINDEX); pColor->SetColor(crIndex);
	pColor = (CMFCRibbonColorButton*)m_wndRibbonBar.FindByID(ID_BUTTON_CVALUE); pColor->SetColor(crValue);
	pColor = (CMFCRibbonColorButton*)m_wndRibbonBar.FindByID(ID_BUTTON_CCOMMENT); pColor->SetColor(crComment);
	pColor = (CMFCRibbonColorButton*)m_wndRibbonBar.FindByID(ID_BUTTON_CVTABLE); pColor->SetColor(crVTable);
	pColor = (CMFCRibbonColorButton*)m_wndRibbonBar.FindByID(ID_BUTTON_CFUNCTION); pColor->SetColor(crFunction);
	pColor = (CMFCRibbonColorButton*)m_wndRibbonBar.FindByID(ID_BUTTON_CTEXT); pColor->SetColor(crChar);
	pColor = (CMFCRibbonColorButton*)m_wndRibbonBar.FindByID(ID_BUTTON_CCUSTOM); pColor->SetColor(crCustom);
	pColor = (CMFCRibbonColorButton*)m_wndRibbonBar.FindByID(ID_BUTTON_CHEX); pColor->SetColor(crHex);

	//CreateConsole( );

	// Why?
	SetTimer( 69, 5000, NULL );

	return 0;
}
Esempio n. 3
0
void CMainFrame::AddContextTab_Format()
{
	CMFCRibbonCategory* pCategory = m_wndRibbonBar.AddContextCategory(_T("Format"), _T("Drawing tools"), ID_FORMAT_CONTEXT_TAB, AFX_CategoryColor_Orange, IDB_RIBBON_FORMATSMALL, IDB_RIBBON_FORMATLARGE);
	pCategory->SetKeys(_T("jd"));

	// Create "Styles" panel
	CMFCRibbonPanel* pPanelStyles = pCategory->AddPanel(_T("Styles\nzs"), m_PanelImages.ExtractIcon(8));

	// <snippet6>
	CMFCRibbonGallery* pBtnStyles = new CMFCRibbonGallery(ID_OBJECT_STYLES, _T("Styles\nk"), 0, 0, IDB_STYLES, 40);
	pBtnStyles->SetIconsInRow(7);
	pBtnStyles->EnableMenuResize(TRUE, TRUE);
	pBtnStyles->EnableMenuSideBar();
	pBtnStyles->SetButtonMode(false);
	pBtnStyles->RedrawIcons();
	// </snippet6>

	pPanelStyles->Add(pBtnStyles);

	CMFCRibbonColorButton* pBtnFillColor = new CMFCRibbonColorButton(ID_OBJECT_FILLCOLOR, _T("Fill Color\nsf"), FALSE, 1, -1);
	pBtnFillColor->SetDefaultCommand(FALSE);
	pBtnFillColor->EnableAutomaticButton(_T("&Automatic"), RGB(128, 128, 128));
	pBtnFillColor->EnableOtherButton(_T("&More Fill Colors..."), _T("More Fill Colors"));
	pBtnFillColor->SetColumns(10);
	pBtnFillColor->SetColorBoxSize(CSize(17, 17));
	pBtnFillColor->AddColorsGroup(_T("Theme Colors"), m_lstMainColors);
	pBtnFillColor->AddColorsGroup(_T(""), m_lstAdditionalColors, TRUE);
	pBtnFillColor->AddColorsGroup(_T("Standard Colors"), m_lstStandardColors);
	pBtnFillColor->AddSubItem(new CMFCRibbonButton(ID_OBJECT_NOFILL, _T("&No Fill\nn"), 2));
	pBtnFillColor->SetColor((COLORREF)-1);
	pPanelStyles->Add(pBtnFillColor);

	CMFCRibbonColorButton* pBtnLineColor = new CMFCRibbonColorButton(ID_OBJECT_LINECOLOR, _T("Line Color\nso"), FALSE, 3, -1);
	pBtnLineColor->SetDefaultCommand(FALSE);
	pBtnLineColor->EnableAutomaticButton(_T("&Automatic"), RGB(0, 0, 0));
	pBtnLineColor->EnableOtherButton(_T("&More Line Colors..."), _T("More Line Colors"));
	pBtnLineColor->SetColumns(10);
	pBtnLineColor->SetColorBoxSize(CSize(17, 17));
	pBtnLineColor->AddColorsGroup(_T("Theme Colors"), m_lstMainColors);
	pBtnLineColor->AddColorsGroup(_T(""), m_lstAdditionalColors, TRUE);
	pBtnLineColor->AddColorsGroup(_T("Standard Colors"), m_lstStandardColors);
	pBtnLineColor->AddSubItem(new CMFCRibbonButton(ID_OBJECT_NOLINE, _T("&No Line\nn"), 2));
	pBtnLineColor->SetColor((COLORREF)-1);
	pPanelStyles->Add(pBtnLineColor);

	CStringArray sa;
	sa.Add(_T("1 pt"));
	sa.Add(_T("2 pt"));
	sa.Add(_T("3 pt"));
	sa.Add(_T("4 pt"));
	sa.Add(_T("5 pt"));
	sa.Add(_T("6 pt"));
	sa.Add(_T("7 pt"));
	CRibbonListButton* pBtnLineWeight = new CRibbonListButton(ID_OBJECT_LINEWEIGHT, _T("Line Weight\nsw"), 4, -1, IDB_LINEWEIGHT, 96, sa);
	pBtnLineWeight->AddSubItem(new CMFCRibbonButton(ID_OBJECT_LINEWEIGHT_MORE, _T("More &Lines..."), 5, -1));
	pBtnLineWeight->EnableMenuResize(TRUE, TRUE); // Vertical only
	pPanelStyles->Add(pBtnLineWeight);

	// Create "Arrange" panel
	CMFCRibbonPanel* pPanelArrange = pCategory->AddPanel(_T("Arrange\nzj"), m_PanelImages.ExtractIcon(3));

	pPanelArrange->Add(new CMFCRibbonButton(ID_OBJECT_MOVETOFRONT, _T("Move to Front\nmf"), 7, 1));
	pPanelArrange->Add(new CMFCRibbonButton(ID_OBJECT_MOVEFORWARD, _T("Move Forward\nmw"), 9, 3));
	pPanelArrange->Add(new CMFCRibbonButton(ID_OBJECT_MOVEBACK, _T("Move Backward\nmd"), 10, 4));
	pPanelArrange->Add(new CMFCRibbonButton(ID_OBJECT_MOVETOBACK, _T("Move to Back\nmb"), 8, 2));
}