//******************************************************************************
void CBCGPRibbonSlider::NotifyCommand ()
{
	ASSERT_VALID (this);

	if (m_nID == 0 || m_nID == (UINT)-1)
	{
		return;
	}

	CBCGPRibbonBar* pRibbonBar = GetTopLevelRibbonBar ();
	if (pRibbonBar == NULL)
	{
		return;
	}

	ASSERT_VALID (pRibbonBar);

	CWnd* pWndParent = pRibbonBar->GetParent ();
	if (pWndParent == NULL)
	{
		return;
	}

	pWndParent->SendMessage (WM_COMMAND, m_nID);
}
예제 #2
0
//**************************************************************************
BOOL CBCGPRibbonComboBox::SelectItem (int iIndex)
{
	ASSERT_VALID (this);

	if (iIndex >= m_lstItems.GetCount ())
	{
		return FALSE;
	}

	m_iSelIndex = max (-1, iIndex);
	
	LPCTSTR lpszText = GetItem (m_iSelIndex);

	m_strEdit = lpszText == NULL ? _T("") : lpszText;

	if (m_pWndEdit->GetSafeHwnd () != NULL)
	{
		m_pWndEdit->SetWindowText (m_strEdit);
	}

	if (!m_bDontNotify)
	{
		CBCGPRibbonBar* pRibbonBar = GetTopLevelRibbonBar ();
		if (pRibbonBar != NULL)
		{
			ASSERT_VALID (pRibbonBar);

			CArray<CBCGPBaseRibbonElement*, CBCGPBaseRibbonElement*> arButtons;
			pRibbonBar->GetElementsByID (m_nID, arButtons, TRUE);

			for (int i = 0; i < arButtons.GetSize (); i++)
			{
				CBCGPRibbonComboBox* pOther =
					DYNAMIC_DOWNCAST (CBCGPRibbonComboBox, arButtons [i]);

				if (pOther != NULL && pOther != this)
				{
					ASSERT_VALID (pOther);

					pOther->m_bDontNotify = TRUE;
					pOther->SelectItem (iIndex);
					pOther->m_bDontNotify = FALSE;
					pOther->m_RecentChangeEvt = m_RecentChangeEvt;
				}
			}
		}
	}

	Redraw ();
	return TRUE;
}
//**************************************************************************
void CBCGPRibbonBackstageViewItemPropertySheet::SetLayoutReady(BOOL bReady)
{
	ASSERT_VALID (this);

	CBCGPPropertySheetCtrl* pPropSheet = DYNAMIC_DOWNCAST(CBCGPPropertySheetCtrl, m_pWndForm);
	if (pPropSheet == NULL)
	{
		return;
	}

	ASSERT_VALID(pPropSheet);

	pPropSheet->m_bIsReady = bReady;

	if (m_bUseDefaultPageTransitionEffect && GetTopLevelRibbonBar() != NULL)
	{
		pPropSheet->EnablePageTransitionEffect(
			GetTopLevelRibbonBar()->GetBackstagePageTransitionEffect(),
			GetTopLevelRibbonBar()->GetBackstagePageTransitionTime());
	}
	else
	{
		pPropSheet->EnablePageTransitionEffect(m_PageTransitionEffect, m_nPageTransitionTime);
	}

	if (bReady)
	{
		pPropSheet->AdjustControlsLayout();
	
		CBCGPPropertyPage* pPage = DYNAMIC_DOWNCAST(CBCGPPropertyPage, pPropSheet->GetActivePage());
		if (pPage != NULL)
		{
			pPage->AdjustControlsLayout();
		}
	}
}
예제 #4
0
void CRibbonListButton::OnShowPopupMenu ()
{
	ASSERT_VALID (this);

	CBCGPBaseRibbonElement::OnShowPopupMenu ();

	if (m_sizeMaxText == CSize (0, 0))
	{
		CBCGPRibbonBar* pRibbonBar = GetTopLevelRibbonBar ();
		ASSERT_VALID (pRibbonBar);

		CClientDC dc (pRibbonBar);

		CFont* pOldFont = dc.SelectObject (pRibbonBar->GetFont ());
		ASSERT (pOldFont != NULL);

		int i = 0;

		for (i = 0; i < m_arLabels.GetSize (); i++)
		{
			CSize szText = dc.GetTextExtent (m_arLabels [i]);

			m_sizeMaxText.cx = max (m_sizeMaxText.cx, szText.cx);
			m_sizeMaxText.cy = max (m_sizeMaxText.cy, szText.cy);
		}

		const int cxImage = m_listImages.GetImageSize ().cx;

		for (i = 0; i < m_arSubItems.GetSize (); i++)
		{
			CBCGPBaseRibbonElement* pButton = m_arSubItems [i];
			ASSERT_VALID (pButton);

			CString strText = pButton->GetText ();
			CSize szText = dc.GetTextExtent (strText);

			m_sizeMaxText.cx = max (m_sizeMaxText.cx, szText.cx - cxImage);
		}

		dc.SelectObject (pOldFont);
	}

	CBCGPRibbonPaletteButton::OnShowPopupMenu ();
}
예제 #5
0
void CRibbonListFontButton::OnShowPopupMenu ()
{
	ASSERT_VALID (this);

	CBCGPBaseRibbonElement::OnShowPopupMenu ();

	if (m_sizeMaxText == CSize (0, 0))
	{
		CBCGPRibbonBar* pRibbonBar = GetTopLevelRibbonBar ();
		ASSERT_VALID (pRibbonBar);

		CClientDC dc (pRibbonBar);
		CFont* pOldFont = dc.SelectObject (&globalData.fontBold);

		for (int i = 0; i < m_arItems.GetSize (); i++)
		{
			CSize szText = dc.GetTextExtent (m_arItems [i].m_Caption);

			for (int j = 0; j < 2; j++)
			{
				LOGFONT& lf = m_arItems [i].m_Font[j];

				CFont font;
				font.CreateFontIndirect (&lf);
				dc.SelectObject (&font);

				CSize szText2 = dc.GetTextExtent (lf.lfFaceName);

				szText.cx = max (szText.cx, szText2.cx);
				szText.cy += szText2.cy;
			}

			m_arItems [i].m_Height = szText.cy;

			m_sizeMaxText.cx = max (m_sizeMaxText.cx, szText.cx);
			m_sizeMaxText.cy = max (m_sizeMaxText.cy, szText.cy);
		}

		dc.SelectObject (pOldFont);
	}

	CBCGPRibbonPaletteButton::OnShowPopupMenu ();
}
//*****************************************************************************
void CBCGPRibbonSlider::SetPos (int nPos, BOOL bRedraw)
{
	ASSERT_VALID (this);

	m_nPos = min (max (m_nMin, nPos), m_nMax);
	SetThumbRect ();

	if (!m_bDontNotify)
	{
		CBCGPRibbonBar* pRibbonBar = GetTopLevelRibbonBar ();
		if (pRibbonBar != NULL)
		{
			ASSERT_VALID (pRibbonBar);

			CArray<CBCGPBaseRibbonElement*, CBCGPBaseRibbonElement*> arButtons;
			pRibbonBar->GetElementsByID (m_nID, arButtons);

			for (int i = 0; i < arButtons.GetSize (); i++)
			{
				CBCGPRibbonSlider* pOther =
					DYNAMIC_DOWNCAST (CBCGPRibbonSlider, arButtons [i]);

				if (pOther != NULL && pOther != this)
				{
					ASSERT_VALID (pOther);

					pOther->m_bDontNotify = TRUE;
					pOther->SetPos (nPos);
					pOther->m_bDontNotify = FALSE;
				}
			}
		}
	}

	if (bRedraw)
	{
		Redraw ();
	}
}
예제 #7
0
//**************************************************************************
void CBCGPRibbonComboBox::OnAfterChangeRect (CDC* pDC)
{
	ASSERT_VALID (this);
	ASSERT_VALID (pDC);

	CBCGPRibbonButton::OnAfterChangeRect (pDC);

	if (m_rect.IsRectEmpty ())
	{
		if (m_pWndEdit->GetSafeHwnd () != NULL)
		{
			m_pWndEdit->ShowWindow (SW_HIDE);
		}

		if (m_pBtnClear->GetSafeHwnd () != NULL)
		{
			m_pBtnClear->ShowWindow (SW_HIDE);
		}
		return;
	}

	CRect rectCommandOld = m_rectCommand;

	m_Location = RibbonElementSingleInGroup;

	m_rectMenu = m_rect;
	m_rectMenu.left = m_rectMenu.right - GetDropDownImageWidth () - 2 * m_nMenuArrowMargin;
	
	m_rectCommand = m_rect;
	m_rectCommand.right = m_rectMenu.left;
	m_rectCommand.left += m_nLabelImageWidth;

	int cx = m_bFloatyMode ? m_nWidthFloaty : m_nWidth;
	if (globalData.GetRibbonImageScale () > 1.)
	{
		cx = (int)(.5 + globalData.GetRibbonImageScale () * cx);
	}

	if (m_rectCommand.Width () > cx)
	{
		m_rectCommand.left = m_rectCommand.right - cx;
	}

	m_rectMenu.DeflateRect (1, 1);

	m_bMenuOnBottom = FALSE;

	if (!m_bHasEditBox)
	{
		return;
	}

	if (m_pWndEdit == NULL)
	{
		DWORD dwEditStyle = WS_CHILD | ES_WANTRETURN | 
							ES_AUTOHSCROLL | WS_TABSTOP;

		dwEditStyle |= m_nAlign;

		CWnd* pWndParent = GetParentWnd ();
		ASSERT_VALID (pWndParent);

		if ((m_pWndEdit = CreateEdit (pWndParent, dwEditStyle)) == NULL)
		{
			return;
		}

		m_pWndEdit->SendMessage (EM_SETTEXTMODE, TM_PLAINTEXT);
		m_pWndEdit->SetEventMask (m_pWndEdit->GetEventMask () | ENM_CHANGE);
		m_pWndEdit->SetFont (GetTopLevelRibbonBar ()->GetFont ());
		m_pWndEdit->SetWindowText (m_strEdit);
	}

	if (rectCommandOld != m_rectCommand || !m_pWndEdit->IsWindowVisible ())
	{
		CRect rectEdit = m_rectCommand;
		rectEdit.DeflateRect (m_szMargin.cx, m_szMargin.cy, 0, m_szMargin.cy);
		rectEdit.DeflateRect(0, m_sizePadding.cy / 2);

		if (m_bSearchMode)
		{
			rectEdit.right -= m_rect.Height();
		}

		m_pWndEdit->SetWindowPos (NULL, 
			rectEdit.left, rectEdit.top,
			rectEdit.Width (), rectEdit.Height (),
			SWP_NOZORDER | SWP_NOACTIVATE);

		m_pWndEdit->ShowWindow (SW_SHOWNOACTIVATE);

		if (m_bSearchMode && m_pBtnClear->GetSafeHwnd () != NULL)
		{
			m_pBtnClear->SetWindowPos (NULL, 
				m_rectMenu.left - m_rect.Height() + 2, m_rect.top + 1,
				m_rect.Height () - 2, m_rect.Height () - 2,
				SWP_NOZORDER | SWP_NOACTIVATE);
			m_pBtnClear->ShowWindow (m_strEdit.IsEmpty() ? SW_HIDE : SW_SHOWNOACTIVATE);
		}
	}
}