예제 #1
0
BOOL CConfigShortcuts::OnApply()
{
	CAccelerator *pAccel = theApp.GetAccelerator();

	std::unordered_map<int, int> m;		// // // check for conflicts
	for (int i = 0; i < CAccelerator::ACCEL_COUNT; ++i) {
		int KeyVal = (m_iKeys[i] & 0xFF) | (m_iMods[i] << 8);
		if (!KeyVal) continue;
		auto it = m.find(KeyVal);
		if (it == m.end())
			m[KeyVal] = i;
		else {
			AfxMessageBox(FormattedW(L"These two commands are assigned to the same shortcut (%s):\n- %s\n- %s",
				(LPCWSTR)AssembleKeyString(m_iMods[i], m_iKeys[i]),
				CAccelerator::DEFAULT_TABLE[it->second].name,
				CAccelerator::DEFAULT_TABLE[i].name), MB_ICONERROR);
			return FALSE;
		}
	}

	// Store keys
	for (int i = 0; i < CAccelerator::ACCEL_COUNT; ++i)
		pAccel->StoreShortcut(i, m_iKeys[i], m_iMods[i]);

	pAccel->Setup();

	theApp.UpdateMenuShortcuts();		// // //

	return CPropertyPage::OnApply();
}
예제 #2
0
void CConfigShortcuts::OnBnClickedDefault()
{
	CAccelerator *pAccel = theApp.GetAccelerator();

	int Key = pAccel->GetDefaultKey(m_iSelectedItem);
	int Mod = pAccel->GetDefaultMod(m_iSelectedItem);

	StoreKey(m_iSelectedItem, Key, Mod);

	CStringW KeyString = AssembleKeyString(Mod, Key);
	SetDlgItemTextW(IDC_KEY, KeyString);

	SetModified();
}
예제 #3
0
void CConfigShortcuts::StoreKey(int Item, int Key, int Mod)
{
	// Store in temp. list
	CAccelerator *pAccel = theApp.GetAccelerator();
	CStringW KeyName = pAccel->GetVKeyName(Key);

	// Save to list
	CListCtrl *pListView = static_cast<CListCtrl*>(GetDlgItem(IDC_SHORTCUTS));

	pListView->SetItemText(m_iSelectedItem, 1, CAccelerator::MOD_NAMES[Mod]);
	pListView->SetItemText(m_iSelectedItem, 2, KeyName);

	m_iKeys[Item] = Key;
	m_iMods[Item] = Mod;
}
예제 #4
0
void CConfigShortcuts::OnBnClickedDefault()
{
	CListCtrl *pListView = (CListCtrl*)GetDlgItem(IDC_SHORTCUTS);
	CAccelerator *pAccel = theApp.GetAccelerator();
	
	int Key = pAccel->GetDefaultKey(m_iSelectedItem);
	int Mod = pAccel->GetDefaultMod(m_iSelectedItem);

	StoreKey(m_iSelectedItem, Key, Mod);

	CString KeyString = AssembleKeyString(Mod, Key);
	SetDlgItemText(IDC_KEY, KeyString);

	SetModified();
}
예제 #5
0
BOOL CConfigShortcuts::OnApply()
{
	CAccelerator *pAccel = theApp.GetAccelerator();
	CListCtrl *pListView = (CListCtrl*)GetDlgItem(IDC_SHORTCUTS);

	// Store keys
	for (int i = 0; i < CAccelerator::ACCEL_COUNT; ++i)
		pAccel->StoreShortcut(i, m_iKeys[i], m_iMods[i]);

	pAccel->Setup();

	CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();
	pMainFrame->UpdateMenus();

	return CPropertyPage::OnApply();
}
예제 #6
0
BOOL CConfigShortcuts::OnInitDialog()
{
	CPropertyPage::OnInitDialog();

	CAccelerator *pAccel = theApp.GetAccelerator();
	CListCtrl *pListView = static_cast<CListCtrl*>(GetDlgItem(IDC_SHORTCUTS));

	CRect r;		// // //
	pListView->GetClientRect(&r);
	int w = r.Width() - ::GetSystemMetrics(SM_CXHSCROLL);
	pListView->DeleteAllItems();
	pListView->InsertColumn(0, L"Action", LVCFMT_LEFT, static_cast<int>(.52 * w));
	pListView->InsertColumn(1, L"Modifier", LVCFMT_LEFT, static_cast<int>(.23 * w));
	pListView->InsertColumn(2, L"Key", LVCFMT_LEFT, static_cast<int>(.25 * w));

	// Build shortcut list
	for (int i = 0; i < CAccelerator::ACCEL_COUNT; ++i) {
		pListView->InsertItem(i, pAccel->GetItemName(i), 0);
		pListView->SetItemText(i, 1, pAccel->GetItemModName(i));
		pListView->SetItemText(i, 2, pAccel->GetItemKeyName(i));

		m_iKeys[i] = pAccel->GetItemKey(i);
		m_iMods[i] = pAccel->GetItemMod(i);
	}

	pListView->SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
	pListView->SetSelectionMark(0);

	m_iSelectedItem = 0;

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
예제 #7
0
BOOL CConfigShortcuts::OnInitDialog()
{
	CPropertyPage::OnInitDialog();

	CAccelerator *pAccel = theApp.GetAccelerator();
	CListCtrl *pListView = (CListCtrl*)GetDlgItem(IDC_SHORTCUTS);

	pListView->DeleteAllItems();
	pListView->InsertColumn(0, _T("Action"), LVCFMT_LEFT, 170);
	pListView->InsertColumn(1, _T("Modifier"), LVCFMT_LEFT, 90);
	pListView->InsertColumn(2, _T("Key"), LVCFMT_LEFT, 110);

	// Build shortcut list
	for (int i = 0; i < CAccelerator::ACCEL_COUNT; ++i) {
		pListView->InsertItem(i, pAccel->GetItemName(i), 0);
		pListView->SetItemText(i, 1, pAccel->GetItemModName(i));
		pListView->SetItemText(i, 2, pAccel->GetItemKeyName(i));

		m_iKeys[i] = pAccel->GetItemKey(i);
		m_iMods[i] = pAccel->GetItemMod(i);
	}
	
	pListView->SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
	pListView->SetSelectionMark(0);

	m_iSelectedItem = 0;

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
예제 #8
0
CStringW CConfigShortcuts::AssembleKeyString(int Mod, int Key)
{
	CAccelerator *pAccel = theApp.GetAccelerator();
	CStringW KeyStr;

	if (Mod & MOD_SHIFT) {
		KeyStr.Append(pAccel->GetVKeyName(VK_SHIFT));
		KeyStr.Append(L" + ");
	}

	if (Mod & MOD_CONTROL) {
		KeyStr.Append(pAccel->GetVKeyName(VK_CONTROL));
		KeyStr.Append(L" + ");
	}

	if (Mod & MOD_ALT) {
		KeyStr.Append(pAccel->GetVKeyName(VK_MENU));
		KeyStr.Append(L" + ");
	}

	KeyStr.Append(pAccel->GetVKeyName(Key));

	return KeyStr;
}