Example #1
0
//******************************************************************
void CBCGPKeyboardPage::OnSelchangeCommandsList() 
{
	m_strDesrcription.Empty ();
	m_wndCurrentKeysList.ResetContent ();
	OnSelchangeCurrentKeysList ();

	int iIndex = m_wndCommandsList.GetCurSel ();
	if (iIndex == LB_ERR)
	{
		m_pSelButton = NULL;
		m_wndNewKey.EnableWindow (FALSE);

		UpdateData (FALSE);
		return;
	}

	//-------------------------
	// Set command description:
	//-------------------------
	m_pSelButton = (CBCGPToolbarButton*) m_wndCommandsList.GetItemData (iIndex);
	ASSERT_VALID (m_pSelButton);

	CFrameWnd* pParent = GetParentFrame ();
	if (pParent != NULL && pParent->GetSafeHwnd () != NULL && m_pSelButton->m_nID != 0)
	{
		pParent->GetMessageString (m_pSelButton->m_nID, m_strDesrcription);
	}

	//--------------------------------------------
	// Fill keys associated with selected command:
	//--------------------------------------------
	if (m_lpAccel != NULL)
	{
		for (int i = 0; i < m_nAccelSize; i ++)
		{
			if (m_pSelButton->m_nID == m_lpAccel [i].cmd)
			{
				AddKeyEntry (&m_lpAccel [i]);
			}
		}
	}

	m_wndNewKey.EnableWindow ();
	UpdateData (FALSE);
}
Example #2
0
bool CLangMngr::ReadINI_KeyValue(const char *key, const char *value, bool invalid_tokens, bool equal_token, bool quotes, unsigned int *curtok)
{
	bool colons_token = (key[strlen(key) - 1] == ':');

	if (!Data.multiLine)
	{
		Data.lastKey = key;

		if (colons_token || equal_token)
		{
			int iKey = GetKeyEntry(key);

			if (iKey == -1)
			{
				iKey = AddKeyEntry(key);
			}

			if (equal_token)
			{
				strncopy(Data.valueBuffer, value, sizeof(Data.valueBuffer));

				reparse_newlines_and_color(Data.valueBuffer);

				Data.entry.key = iKey;
				Data.entry.definition = new ke::AutoString;
				*Data.entry.definition = Data.valueBuffer;

				Data.defsQueue.append(Data.entry);
				Data.clearEntry();
			}
			else if (!value && colons_token)
			{
				Data.entry.key = iKey;
				Data.entry.definition = new ke::AutoString;

				Data.multiLine = true;
			}
		}
		else
		{
			AMXXLOG_Log("Invalid multi-lingual line (file \"%s\" key \"%s\" lang \"%s\")", Data.currentFile.chars(), Data.lastKey.chars(), Data.language);
		}
	}
	else
	{
		if (!value && colons_token)
		{
			strncopy(Data.valueBuffer, Data.entry.definition->ptr(), sizeof(Data.valueBuffer));
			reparse_newlines_and_color(Data.valueBuffer);

			*Data.entry.definition = Data.valueBuffer;

			Data.defsQueue.append(Data.entry);
			Data.clearEntry();

			Data.multiLine = false;
		}
		else
		{
			if (!Data.entry.definition)
			{
				Data.entry.definition = new ke::AutoString();
			}

			*Data.entry.definition = *Data.entry.definition + key;
		}
	}

	return true;
}
Example #3
0
int CLangMngr::AddKeyEntry(ke::AString &key)
{
	return AddKeyEntry(key.chars());
}
Example #4
0
//******************************************************************
void CBCGPKeyboardPage::OnAssign()
{
	ASSERT (m_lpAccel != NULL);
	ASSERT (m_pSelButton != NULL);

	//-----------------------------------------------------------
	// Obtain a new acceleration entry from the keyboard control:
	//-----------------------------------------------------------
	ASSERT (m_wndNewKey.IsKeyDefined ());

	ACCEL* pAccel = (ACCEL*) m_wndNewKey.GetAccel ();
	ASSERT (pAccel != NULL);

	pAccel->cmd = (USHORT) m_pSelButton->m_nID;

	CBCGPToolbarCustomize* pWndParent = DYNAMIC_DOWNCAST (CBCGPToolbarCustomize, GetParent ());
	ASSERT_VALID (pWndParent);

	if (!pWndParent->OnAssignKey (pAccel))
	{
		return;
	}

	if (m_bIsAlreadyDefined)
	{
		//---------------------
		// Replace current key:
		//---------------------
		for (int i = 0; i < m_nAccelSize; i ++)
		{
			const BYTE fRelFlags = FCONTROL | FALT | FSHIFT | FVIRTKEY;

			if (pAccel->key == m_lpAccel [i].key && (pAccel->fVirt & fRelFlags) == (m_lpAccel [i].fVirt & fRelFlags))
			{
				m_lpAccel [i].cmd = pAccel->cmd;
				AddKeyEntry (&m_lpAccel [i]);
				break;
			}
		}
	}
	else
	{
		//----------------------------
		// Create a new entries array:
		//----------------------------
		LPACCEL lpAccelOld = m_lpAccel;

		m_lpAccel = new ACCEL [m_nAccelSize + 1];
		ASSERT (m_lpAccel != NULL);

		memcpy (m_lpAccel, lpAccelOld, sizeof (ACCEL) * m_nAccelSize);

		int listcount = m_wndCurrentKeysList.GetCount();
		for (int i = 0; i < m_nAccelSize; i ++)
		{
			for (int idx=0; idx<listcount; idx++)
			{
				if ( m_wndCurrentKeysList.GetItemData(idx) == (DWORD_PTR) &lpAccelOld [i] )
				{
					m_wndCurrentKeysList.SetItemData(idx, (DWORD_PTR) &m_lpAccel [i]);
					break;
				}
			}
		}

		m_lpAccel [m_nAccelSize ++] = *pAccel;

		delete [] lpAccelOld;
	}

	g_pKeyboardManager->UpdateAcellTable(m_pSelTemplate, m_lpAccel, m_nAccelSize);

	if (!m_bIsAlreadyDefined)
	{
		AddKeyEntry (&m_lpAccel [m_nAccelSize - 1]);
	}

	m_wndNewKey.ResetKey ();
	OnUpdateNewShortcutKey ();

	m_wndCommandsList.SetFocus ();
	m_bIsAlreadyDefined = FALSE;
}