void CNativeRibbonApp::UpdateCmdUI(BOOL bDisableIfNoHandler)
{
	for (auto it = m_commandIds.begin(); it != m_commandIds.end(); ++it)
	{
		CRibbonCmdUI ui(*it);
		ui.DoUpdate(m_pFrame, bDisableIfNoHandler);
		if (ui.m_bEnableChanged)
		{
			PROPVARIANT val = { 0 };
			UIInitPropertyFromBoolean(UI_PKEY_Enabled, ui.m_bOn, &val);
			m_pFramework->SetUICommandProperty(*it, UI_PKEY_Enabled, val);
		}

		if (ui.m_bCheckChanged)
		{
			PROPVARIANT val = { 0 };
			UIInitPropertyFromBoolean(UI_PKEY_BooleanValue, ui.m_nCheck, &val);
			m_pFramework->SetUICommandProperty(*it, UI_PKEY_BooleanValue, val);
		}
	}

	for (auto it = m_collectionCommandIds.begin(); it != m_collectionCommandIds.end(); ++it)
	{
		PROPVARIANT currentValue = { 0 };
		PROPVARIANT newValue = { 0 };

		UpdateProperty(*it, UI_PKEY_SelectedItem, &currentValue, &newValue);
		m_pFramework->SetUICommandProperty(*it, UI_PKEY_SelectedItem, newValue);
	}
}
示例#2
0
STDMETHODIMP CMainFrame::UpdateProperty(UINT32 nCmdID, __in REFPROPERTYKEY key,  __in_opt  const PROPVARIANT *currentValue, __out PROPVARIANT *newValue) 
{   
	// This function is called when a ribbon button is updated. 
	// Refer to IUICommandHandler::UpdateProperty in the Windows 7 SDK documentation
	UNREFERENCED_PARAMETER(currentValue);

    HRESULT hr = E_NOTIMPL;
    if(UI_PKEY_Enabled == key)
    {
        return UIInitPropertyFromBoolean(UI_PKEY_Enabled, TRUE, newValue);
    }

	switch(nCmdID)
    {
    case IDC_MRULIST:
        // Set up the Most Recently Used (MRU) menu
		if (UI_PKEY_Label == key)
        {
            WCHAR label[MAX_PATH] = L"Recent Files";
            hr = UIInitPropertyFromString(UI_PKEY_Label, label, newValue);
        }
        else if (UI_PKEY_RecentItems == key)
        {
            hr = PopulateRibbonRecentItems(newValue);
        }
        break;

	case IDC_PEN_COLOR:
		// Set the initial pen color
		hr = UIInitPropertyFromUInt32(key, RGB(1, 1, 1), newValue);
		break;
	} 

	return hr;
}
示例#3
0
	// IUICommandhandler Implementation
	STDMETHODIMP CConfigDialogApplication::Execute(UINT nCmdID,												/*Control ID*/
						UI_EXECUTIONVERB verb,										/*Action or Event*/
						__in_opt const PROPERTYKEY* key,							/*Property Changing*/
						__in_opt const PROPVARIANT* ppropvarValue,					/*Value of the propery changing*/
						__in_opt IUISimplePropertySet* pCommandExecutionProperties)
	{
		UNREFERENCED_PARAMETER(pCommandExecutionProperties);
		m_hr = S_OK;
		
		switch (verb)//Action switch
		{
		case UI_EXECUTIONVERB_EXECUTE:
		case UI_EXECUTIONVERB_PREVIEW:
		case UI_EXECUTIONVERB_CANCELPREVIEW:
			{
			switch( nCmdID )//Control switch
			{
			case cmdVSync:
				{
					PROPVARIANT var, varNew;

					m_hr = pRibbonFramework->GetUICommandProperty(cmdVSync, UI_PKEY_BooleanValue, &var);
					if (FAILED(m_hr))
					   return m_hr;

					m_hr = PropVariantToBoolean(var, &m_VSyncEnable);
					if (FAILED(m_hr))
					   return m_hr;

					m_VSyncEnable = !m_VSyncEnable;
					m_hr = UIInitPropertyFromBoolean(UI_PKEY_Enabled, m_VSyncEnable, &varNew);
					if (FAILED(m_hr))
					   return m_hr;

					m_hr = pRibbonFramework->InvalidateUICommand(cmdVSync, UI_INVALIDATIONS_PROPERTY, &UI_PKEY_Label);
					if (FAILED(m_hr))
						return m_hr;
				}
				break;
			case cmdFTS:
				{
					m_FTSEnable = !m_FTSEnable;
					
					m_hr = pRibbonFramework->InvalidateUICommand(cmdFTS, UI_INVALIDATIONS_PROPERTY, &UI_PKEY_Label);
					m_hr = pRibbonFramework->InvalidateUICommand(cmdFT,  UI_INVALIDATIONS_PROPERTY, &UI_PKEY_Enabled);
					if (FAILED(m_hr))
						return m_hr;
				}
				break;

			}//End Control switch

			}
			break;

		}//End Action Switch

		return m_hr;
	}
示例#4
0
	STDMETHODIMP CConfigDialogApplication::UpdateProperty(UINT nCmdID,									 /*Control ID*/
								__in REFPROPERTYKEY key,						 /*Property Key Affected*/
								__in_opt const PROPVARIANT* ppropvarCurrentValue,/*Current Value*/
								__out PROPVARIANT* ppropvarNewValue)			 /*New Value*/
	{

		UNREFERENCED_PARAMETER(ppropvarCurrentValue);

		m_hr = E_FAIL;

		if( key == UI_PKEY_Label )
		{
			// Update the Label of FTS control, to show if it is enabled or not
			if (nCmdID == cmdFTS)
			{
				if (m_FTSEnable)
					m_hr = UIInitPropertyFromString(UI_PKEY_Label, L"FTS Enabled", ppropvarNewValue);
				else
					m_hr = UIInitPropertyFromString(UI_PKEY_Label, L"FTS Disabled", ppropvarNewValue);
			}

			// Update the Label of VSync control, to show if it is enabled or not
			if (nCmdID == cmdVSync)
			{
				if (m_VSyncEnable)
					m_hr = UIInitPropertyFromString(UI_PKEY_Label, L"VSync\nEnabled", ppropvarNewValue);
				else
					m_hr = UIInitPropertyFromString(UI_PKEY_Label, L"VSync\nDisabled", ppropvarNewValue);
			}
		}

		if( key == UI_PKEY_Enabled )
		{
			// Update the Enabability of FT depending on FTS
			if (nCmdID == cmdFT)
			{
				if(m_FTSEnable)
					m_hr = UIInitPropertyFromBoolean(UI_PKEY_Enabled, true, ppropvarNewValue);
				else
					m_hr = UIInitPropertyFromBoolean(UI_PKEY_Enabled, false, ppropvarNewValue);
			}
		}

		return m_hr;

	}
IFACEMETHODIMP touchmind::ribbon::handler::LineColorCommandHandler::UpdateProperty(
    UINT cmdID, REFPROPERTYKEY key, const PROPVARIANT *pPropvarCurrentValue, PROPVARIANT *pPropvarNewValue) {
  LOG_ENTER;

  UNREFERENCED_PARAMETER(cmdID);
  UNREFERENCED_PARAMETER(key);
  UNREFERENCED_PARAMETER(pPropvarCurrentValue);
  UNREFERENCED_PARAMETER(pPropvarNewValue);

  HRESULT hr = E_FAIL;
  if (key == UI_PKEY_Enabled) {
    BOOL enabled = m_pRibbonRequestDispatcher->UpdateProperty_IsLineColorChangeable() ? TRUE : FALSE;
    m_pRibbonFramework->GetFramework()->InvalidateUICommand(cmdLineColor, UI_INVALIDATIONS_PROPERTY,
                                                            &UI_PKEY_ColorType);
    m_pRibbonFramework->GetFramework()->InvalidateUICommand(cmdLineColor, UI_INVALIDATIONS_PROPERTY, &UI_PKEY_Color);
    m_pRibbonFramework->GetFramework()->InvalidateUICommand(cmdLineColor, UI_INVALIDATIONS_PROPERTY,
                                                            &UI_PKEY_LargeImage);
    hr = UIInitPropertyFromBoolean(UI_PKEY_BooleanValue, enabled, pPropvarNewValue);
  } else if (key == UI_PKEY_ColorType) {
    hr = UIInitPropertyFromUInt32(key, UI_SWATCHCOLORTYPE_RGB, pPropvarNewValue);
  } else if (key == UI_PKEY_Color) {
    if (pPropvarCurrentValue == nullptr) {
      hr = UIInitPropertyFromUInt32(key, RGB(0, 0, 0), pPropvarNewValue);
    } else {
      D2D1_COLOR_F colorF = m_pRibbonRequestDispatcher->UpdateProperty_GetLineColor();
      COLORREF colorref = touchmind::util::ColorUtil::ToColorref(colorF);
      hr = UIInitPropertyFromUInt32(key, colorref, pPropvarNewValue);
    }
  } else if (key == UI_PKEY_LargeImage) {
    if (pPropvarCurrentValue != nullptr) {
      CComPtr<IUIImage> uiImage = nullptr;
      D2D1_COLOR_F colorF = m_pRibbonRequestDispatcher->UpdateProperty_GetLineColor();
      hr = _CreateUIImage(colorF, &uiImage);
      CHK_RES(uiImage, S_OK);
      if (SUCCEEDED(hr)) {
        hr = UIInitPropertyFromImage(key, uiImage, pPropvarNewValue);
      }
    }
  }
  LOG_LEAVE;
  return hr;
}
STDMETHODIMP CNativeRibbonApp::UpdateProperty(UINT32 commandId, REFPROPERTYKEY key, const PROPVARIANT* /*currentValue*/, PROPVARIANT* newValue)
{
	if (key == UI_PKEY_TooltipTitle)
	{
		CString str;
		if (!str.LoadString(commandId))
			return S_FALSE;

		int nIndex = str.Find(L'\n');
		if (nIndex <= 0)
			return S_FALSE;

		str = str.Mid(nIndex + 1);

		CString strLabel;

		if (m_pFrame != NULL && (CKeyboardManager::FindDefaultAccelerator(commandId, strLabel, m_pFrame, TRUE) ||
			CKeyboardManager::FindDefaultAccelerator(commandId, strLabel, m_pFrame->GetActiveFrame(), FALSE)))
		{
			str += _T(" (");
			str += strLabel;
			str += _T(')');
		}

		return UIInitPropertyFromString(UI_PKEY_TooltipTitle, str, newValue);
	}
	else if (key == UI_PKEY_TooltipDescription)
	{
		CString str;
		if (!str.LoadString(commandId))
			return S_FALSE;

		int nIndex = str.Find(L'\n');
		if (nIndex <= 0)
			return S_FALSE;

		str = str.Left(nIndex);

		return UIInitPropertyFromString(UI_PKEY_TooltipDescription, str, newValue);
	}
	else if (key == UI_PKEY_Enabled)
	{
		CRibbonCmdUI ui(commandId);
		ui.DoUpdate(m_pFrame, TRUE);

		return UIInitPropertyFromBoolean(UI_PKEY_Enabled, ui.m_bOn, newValue);
	}
	else if (key == UI_PKEY_BooleanValue)
	{
		CRibbonCmdUI ui(commandId);
		ui.DoUpdate(m_pFrame, TRUE);

		return UIInitPropertyFromBoolean(UI_PKEY_BooleanValue, ui.m_nCheck, newValue);
	}
	else if (key == UI_PKEY_SelectedItem)
	{
		CComPtr<IUICollection> items = GetUICommandItemsSource(commandId);
		if (!items)
			return E_FAIL;

		UINT32 count;
		items->GetCount(&count);
		for (UINT32 idx = 0; idx < count; idx++)
		{
			CComPtr<IUnknown> item;
			items->GetItem(idx, &item);

			CComQIPtr<IUISimplePropertySet> simplePropertySet(item);
			if (simplePropertySet)
			{
				PROPVARIANT var = { 0 };
				UINT32 uiVal;
				simplePropertySet->GetValue(UI_PKEY_CommandId, &var);
				UIPropertyToUInt32(UI_PKEY_CommandId, var, &uiVal);

				CRibbonCmdUI ui(uiVal);
				ui.DoUpdate(m_pFrame, TRUE);

				if (ui.m_nCheck)
				{
					UIInitPropertyFromUInt32(UI_PKEY_SelectedItem, idx, newValue);
					return S_OK;
				}
			}
		}

		// No selected item.
		UIInitPropertyFromUInt32(UI_PKEY_SelectedItem, static_cast<UINT>(-1), newValue);

		return S_OK;
	}

	return E_NOTIMPL;
}