Пример #1
0
/**
* Toggles the state of an item when the user clicks in the window.
*/
void ToggleListView::OnNMClick(NMHDR *pNMHDR, LRESULT *pResult) {
	CListCtrl& list = GetListCtrl();

	DWORD dwpos = GetMessagePos(); 

	LVHITTESTINFO info;
	info.pt.x = LOWORD(dwpos);
	info.pt.y = HIWORD(dwpos);		

	::MapWindowPoints(HWND_DESKTOP, pNMHDR->hwndFrom, &info.pt, 1);      

	int index = list.HitTest(&info);
	if ( index != -1 ) {
		int toggleState = GetToggleState(index);
		if(toggleState != TOGGLE_STATE_DISABLED) {

			RECT	rItem;
			list.GetItemRect(index, &rItem, LVIR_BOUNDS);

			if ( info.pt.x < TOGGLELIST_ITEMHEIGHT ) {
				if(toggleState == TOGGLE_STATE_ON) {
					SetToggleState(index, TOGGLE_STATE_OFF, true);
				} else {
					SetToggleState(index, TOGGLE_STATE_ON, true);
				}
			}												
		}
	}
	*pResult = 0;
}
/**
* Rebuilds the list of stages based on the currently selected material
*/
void StageView::RefreshStageList() {
	CListCtrl &list = GetListCtrl();
	POSITION pos = list.GetFirstSelectedItemPosition();
	int selectedItem = -1;
	if( pos ) {
		selectedItem = list.GetNextSelectedItem( pos );
	}
	list.DeleteAllItems();
	if( currentMaterial ) {
		//Always add the material item for the main material properties
		list.InsertItem( 0, "Material" );
		SetToggleState( 0, ToggleListView::TOGGLE_STATE_DISABLED );
		//Get the stage info
		int stageCount = currentMaterial->GetStageCount();
		for( int i = 0; i < stageCount; i++ ) {
			const char *name = currentMaterial->GetAttribute( i, "name" );
			int itemNum = list.InsertItem( list.GetItemCount(), name );
			if( currentMaterial->IsStageEnabled( i ) ) {
				SetToggleState( itemNum, ToggleListView::TOGGLE_STATE_ON );
			} else {
				SetToggleState( itemNum, ToggleListView::TOGGLE_STATE_OFF );
			}
		}
		if( selectedItem < 0 ) {
			//Select the material
			list.SetItemState( 0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED );
		} else {
			list.SetItemState( selectedItem, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED );
		}
	}
}
Пример #3
0
/**
* Called when a stage is added
* @param pMaterial The material that was affected.
* @param stageNum The index of the stage that was added
*/
void StageView::MV_OnMaterialStageAdd(MaterialDoc* pMaterial, int stageNum) {

	CListCtrl& list = GetListCtrl();

	idStr name = pMaterial->GetAttribute(stageNum, "name");

	int index = list.InsertItem(stageNum+1, name.c_str());
	SetToggleState(index, ToggleListView::TOGGLE_STATE_ON);
}
/**
* Called when the material changes have been saved.
* @param pMaterial The saved material.
*/
void StageView::MV_OnMaterialSaved( MaterialDoc *pMaterial ) {
	CListCtrl &list = GetListCtrl();
	//Saving a material reenables all of the stages
	if( pMaterial == currentMaterial ) {
		for( int i = 1; i < list.GetItemCount(); i++ ) {
			SetToggleState( i, ToggleListView::TOGGLE_STATE_ON );
		}
	}
}
Пример #5
0
void HS_SendKeys::SendRaw(const char *szSendKeys, HWND hWnd)
{
#ifdef _DEBUG
	Util_DebugMsg("==> HS_SendKeys::SendRaw : szSendKeys=%s, hWnd=%.x8)\n", szSendKeys, hWnd);
#endif
	char	ch;
	int		nPos = 0;
	bool	bCapsWasOn = false;

	// Store window (or NULL if not specified)
	m_hWnd = hWnd;

	// Attach to the window so that we can add things to the input queues
	WinAttach(m_hWnd, true);

	// First, store the state of capslock, then turn off
	if ( m_bStoreCapslockMode == true )
		bCapsWasOn = SetToggleState(VK_CAPITAL, false);

	// Send the keys, but watch out for the main script pausing/closing
	while ( (ch = szSendKeys[nPos]) != '\0' )
	{
		nPos++;									// Next key

		SendCh(ch, 1);
		m_nKeyMod &= RESETMOD;			// reset modifiers
	}


	// If required, restore caps lock state
		if ( m_bStoreCapslockMode == true )
			SetToggleState(VK_CAPITAL, bCapsWasOn);

	// Detach
	WinAttach(m_hWnd, false);

} // SendRaw()
Пример #6
0
void HS_SendKeys::Send(const char *szSendKeys, HWND hWnd)
{
#ifdef _DEBUG
	Util_DebugMsg("==> HS_SendKeys::Send : szSendKeys=%s)\n", szSendKeys);
#endif
	char	*szTemp;
	char	ch;
	int		nPos = 0;
	int		nPosTemp;
	bool	bCapsWasOn = false;

	// Store window (or NULL if not specified)
	m_hWnd = hWnd;

	// Attach to the window so that we can add things to the input queues
	WinAttach(m_hWnd, true);

	// Allocate some temporary memory for szTemp
	szTemp =  new char[strlen(szSendKeys)+1];

	// First, store the state of capslock, then turn off
	if ( m_bStoreCapslockMode == true )
		bCapsWasOn = SetToggleState(VK_CAPITAL, false);

	// Send the keys, but watch out for the main script pausing/closing
	while ( (ch = szSendKeys[nPos]) != '\0' )
	{
		nPos++;									// Next key

		// is it a special?
		switch (ch)
		{
			case '!':
				m_nKeyMod = m_nKeyMod | ALTMOD;
				break;
			case '^':
				m_nKeyMod = m_nKeyMod | CTRLMOD;
				break;
			case '+':
				m_nKeyMod = m_nKeyMod | SHIFTMOD;
				break;
			case '#':
				m_nKeyMod = m_nKeyMod | LWINMOD;
				break;

			case '{':
				nPosTemp = nPos;
				if ( ReadToChar('}', szSendKeys, szTemp, nPos) )
				{
					// NO CLOSE BRACKET!!?!
					nPos = nPosTemp;
					SendCh('{', 1);
					break;
				}
				else
				{
					SendSpecial(szTemp);
					m_nKeyMod &= RESETMOD;		// reset modifiers
					break;
				}

			default:
				SendCh(ch, 1);
				m_nKeyMod &= RESETMOD;			// reset modifiers
				break;

		} // End Switch

	} // End While


	// If required, restore caps lock state
	if ( m_bStoreCapslockMode == true )
		SetToggleState(VK_CAPITAL, bCapsWasOn);

	// Free temp string memory
	delete [] szTemp;


	// Detach
	WinAttach(m_hWnd, false);

} // Send()
Пример #7
0
void HS_SendKeys::SendSpecial(char *szTemp)
{
#ifdef _DEBUG
	Util_DebugMsg("==> HS_SendKeys::SendSpecial : szTemp=%s)\n", szTemp);
#endif
	int		nRep;
	int		nPos	= 0;
	int		n		= 0;
	bool	bUp		= false;
	bool	bDown	= false;
	bool	bOn		= false;
	bool	bOff	= false;

	char	*szCmd;
	char	*szRep;

	// Allocate temp memory
	szCmd = new char[strlen(szTemp)+1];
	szRep = new char[strlen(szTemp)+1];

	nRep = 1;									// Default number of repeats

	if ( !ReadToChar(' ', szTemp, szCmd, nPos) )
	{
		// Skip spaces to get to the number of repeats or "up", "down"
		while (szTemp[nPos] == ' ' || szTemp[nPos] == '\t')
			nPos++;

		ReadToChar('\0', szTemp, szRep, nPos);

		if (!stricmp(szRep, "up"))
			bUp = true;
		else if (!stricmp(szRep, "down"))
			bDown = true;
		else if (!stricmp(szRep, "on"))
			bOn = true;
		else if (!stricmp(szRep, "off"))
			bOff = true;
		else
		{
			nRep = atoi(szRep);
			if (nRep <= 0)
				nRep = 1;
		}
	}

	// Look up the index of the key
	while ( (n < NUMKEYS) && (stricmp(g_szKeyTable[n], szCmd)) )
		n++;

	// if unknown command, send the first letter
	if (n == NUMKEYS)
	{
		if (bDown)
			SimKeyDown(VkKeyScan(szCmd[0]) & 0xff);
		else if (bUp)
			SimKeyUp(VkKeyScan(szCmd[0]) & 0xff);
		else
			SendCh(szCmd[0], nRep);				// unknown command, send first char
	}
	else
	{
		// the command HAS been found if we are here...
		// n is the index
		// check if this is a simple lookup or a special function
		if (g_cKeyLookupType[n] == SK_LOOKUP)
		{
			if (bDown)
				SimKeyDown(g_nKeyCodes[n]);
			else if (bUp)
				SimKeyUp(g_nKeyCodes[n]);
			else if (bOn)
				SetToggleState(g_nKeyCodes[n], true);
			else if (bOff)
				SetToggleState(g_nKeyCodes[n], false);
			else
				SendVk(g_nKeyCodes[n], nRep);
		}
		else
		{
			// Special function
			switch ( g_nKeyCodes[n] )
			{
				case ALT:
					if ( !(m_nKeyMod & ALTPERMMOD) )
					{
						m_nKeyMod |= ALTMOD;// We have to use Mods to get the ALT SYSKEY in SendTo mode

						if (bDown)
							SimKeyDown(VK_MENU);
						else if (bUp)
							SimKeyUp(VK_MENU);
						else
							SimKeystroke(VK_MENU);
					}

					break;

				case NUMPADENTER:
					// This is the same as VK_RETURN but we set the extended key code
					// to indicate that it is on the numpad and not main keyboard
					if (bDown)
						SimKeyDown(VK_RETURN);
					else if (bUp)
						SimKeyUp(VK_RETURN);
					else
						SimKeystroke(VK_RETURN, true);
					break;

				case ALTDOWN:
					if ( !(m_nKeyMod & ALTPERMMOD) )
					{
						m_nKeyMod |= ALTMOD;// We have to use Mods to get the ALT SYSKEY in SendTo mode

						m_nKeyMod |= ALTPERMMOD;
						SimKeyDown(VK_MENU);
					}
					break;

				case ALTUP:
					if ( m_nKeyMod & ALTPERMMOD)
					{
						m_nKeyMod |= ALTMOD;// We have to use Mods to get the ALT SYSKEY in SendTo mode

						m_nKeyMod ^= ALTPERMMOD;
						SimKeyUp(VK_MENU);
					}
					break;

				case SHIFTDOWN:
					if ( !(m_nKeyMod & SHIFTPERMMOD) )
					{
						m_nKeyMod |= SHIFTPERMMOD;
						SimKeyDown(VK_SHIFT);
					}
					break;

				case SHIFTUP:
					if ( m_nKeyMod & SHIFTPERMMOD)
					{
						m_nKeyMod ^= SHIFTPERMMOD;
						SimKeyUp(VK_SHIFT);
					}
					break;

				case CTRLDOWN:
					if ( !(m_nKeyMod & CTRLPERMMOD) )
					{
						m_nKeyMod |= CTRLPERMMOD;
						SimKeyDown(VK_CONTROL);
					}
					break;

				case CTRLUP:
					if ( m_nKeyMod & CTRLPERMMOD)
					{
						m_nKeyMod ^= CTRLPERMMOD;
						SimKeyUp(VK_CONTROL);
					}
					break;

				case LWINDOWN:
					if ( !(m_nKeyMod & LWINPERMMOD) )
					{
						m_nKeyMod |= LWINPERMMOD;
						SimKeyDown(VK_LWIN);
					}
					break;

				case LWINUP:
					if ( m_nKeyMod & LWINPERMMOD)
					{
						m_nKeyMod ^= LWINPERMMOD;
						SimKeyUp(VK_LWIN);
					}
					break;

				case RWINDOWN:
					if ( !(m_nKeyMod & RWINPERMMOD) )
					{
						m_nKeyMod |= RWINPERMMOD;
						SimKeyDown(VK_RWIN);
					}
					break;

				case RWINUP:
					if ( m_nKeyMod & RWINPERMMOD)
					{
						m_nKeyMod ^= RWINPERMMOD;
						SimKeyUp(VK_RWIN);
					}
					break;


				case ASC:
					// convert nRep to text and send the chars with ALT held down
					// For this to work we need to use a keybd_event
					// keystroke for the ALT key

					// If in SendTo mode this will fail unless we have the controls parent window
					// active :( - Removed 3.0.103 - Probably not a useful thing to force
					//if (m_hWnd && GetForegroundWindow() != GetParent(m_hWnd) && GetParent(m_hWnd) != NULL)
					//{
						//MessageBox(NULL, "", "", MB_OK);
						//g_oSetForeWinEx.Activate(GetParent(m_hWnd));
						//::Sleep(250);
					//	break;
					//}

					if ( !(m_nKeyMod & ALTPERMMOD) )
					{
						keybd_event(VK_MENU, m_scanAlt, 0, 0);
						DoKeyDownDelay();
					}

					// ASCII 0 is 48, NUMPAD0 is 96, add on 48 to the ASCII
					n = 0;
					while (szRep[n] != '\0')
					{
						SimKeystroke(szRep[n]+48);	// Auto key delays
						n++;
					}

					if ( !(m_nKeyMod & ALTPERMMOD) )
					{
						keybd_event(VK_MENU, m_scanAlt, KEYEVENTF_KEYUP, 0);
						DoKeyDelay();
					}

					break;

				} // End Switch

			} // End If

	} // End If

	// Clean up temp memory
	delete []szCmd;
	delete []szRep;

} // SendSpecial()
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : state - 
//-----------------------------------------------------------------------------
// This is ONLY used by the node graph to test movement through a door
void CBaseDoor::InputSetToggleState( inputdata_t &inputdata )
{
	SetToggleState( inputdata.value.Int() );
}