예제 #1
0
void CPianoCtrl::RemoveKeyColors()
{
	int	nKeys = GetKeyCount();
	for (int iKey = 0; iKey < nKeys; iKey++)	// for each key
		m_Key[iKey].m_Color = -1;	// restore default color scheme
	Invalidate();
}
예제 #2
0
void Blackboard::AddKey(BlackboardKeyType_Base* key)
{
    BlackboardKeyEntry* bbKeyEntry = new BlackboardKeyEntry();
    bbKeyEntry->SetUID(GetKeyCount());
    bbKeyEntry->SetKeyData(key);
    m_Keys.push_back(bbKeyEntry);
}
예제 #3
0
int CPianoCtrl::FindKey(CPoint pt) const
{
	int	nKeys = GetKeyCount();
	for (int iKey = 0; iKey < nKeys; iKey++) {	// for each key
		if (m_Key[iKey].m_Rgn.PtInRegion(pt))	// if point within key's region
			return(iKey);	// return key's index
	}
	return(-1);	// key not found
}
//keys is a utf-8 array
void KeyboardControler::SendMultiKey(char *utf8, int size)
{
	short* keys = GetKeyUnicodes(utf8, size);
	int count = GetKeyCount(utf8, size);

	for(int i=0;i<count;i++)
	{
		SendKey(keys[i]);
	}
}
예제 #5
0
void CPianoCtrl::ReleaseKeys(UINT KeySourceMask)
{
	int	nKeys = GetKeyCount();
	for (int iKey = 0; iKey < nKeys; iKey++) {	// for each key
		const CKey&	key = m_Key[iKey];
		UINT	KeyBit = key.m_IsExternal ? KS_EXTERNAL : KS_INTERNAL;
		// if key pressed and its source matches caller's mask
		if (key.m_IsPressed && (KeyBit & KeySourceMask))
			SetPressed(iKey, FALSE);	// reset key to avoid stuck notes
	}
}
예제 #6
0
TInt CConfigImpl::GenerateInternalKey(const TDesC8& aSection,TBuf8<15>& aKeyName)
	{
	TPtrC8 lastKey;
	TInt ret=GetKeyCount(aSection,lastKey);
	if (ret<0)
		{
		return ret;		
		}
	//either "mediaX" or "X"
	//TInt key=ret;

	if(aSection.Compare(KPrimaryFilterSection)== 0 ) 
	{
		TInt lastKeyValue=0;
		if(lastKey.Length())
			{
			TLex8 lex(lastKey);
			TInt err = lex.Val(lastKeyValue);
			if(err != KErrNone)
				return err;
			}
		aKeyName.Format(_L8("%03d"),++lastKeyValue);
	}
	else if(aSection.Compare(KSecondaryFilterSection) == 0)
	{
		TInt lastKeyValue=0;
		if(lastKey.Length())
			{
			TLex8 lex(lastKey);
			TInt err = lex.Val(lastKeyValue);
			if(err != KErrNone)
				return err;
			}
		aKeyName.Format(_L8("%04d"),++lastKeyValue);
	}
	else
	{
		TInt lastKeyValue=0;
		if(lastKey.Length())
			{
			TLex8 lex(lastKey);
			TInt err = lex.Val(lastKeyValue);
			if(err != KErrNone)
				return err;
			}
		aKeyName.Format(_L8("%d"),++lastKeyValue);
	}	
	return KErrNone;	
}
예제 #7
0
void FCDAnimationMultiCurve::SetKeyCount(size_t count, FUDaeInterpolation::Interpolation interpolation)
{
	size_t oldCount = GetKeyCount();
	if (oldCount < count)
	{
		keys.reserve(count);
		for (; oldCount < count; ++oldCount) AddKey(interpolation);
	}
	else if (count < oldCount)
	{
		for (FCDAnimationMKeyList::iterator it = keys.begin() + count; it != keys.end(); ++it) delete (*it);
		keys.resize(count);
	}
	SetDirtyFlag();
}
int main(int argc, char **argv)
{
    int rc = RTR3InitExe(argc, &argv, 0);
    if (RT_FAILURE(rc))
        return RTMsgInitFailure(rc);

    rc = ConnectToSmc();
    if (RT_SUCCESS(rc))
    {
        /*
         * Dump the keys.
         */
        uint32_t cKeys;
        rc = GetKeyCount(&cKeys);
        if (RT_SUCCESS(rc))
            RTPrintf("#Keys=%u\n", cKeys);
        for (uint32_t iKey = 0; iKey < cKeys; iKey++)
        {
            SMCPARAM Key;
            rc = GetKeyByIndex(iKey, &Key);
            if (RT_SUCCESS(rc))
            {
                RTPrintf("%#06x: ", iKey);
                DisplayKey(&Key);
            }
        }

        /*
         * Known keys that doesn't make it into the enumeration.
         */
        DisplayKeyByName('OSK0');
        DisplayKeyByName('OSK1');
        DisplayKeyByName('OSK2');

        /* Negative checks, sometimes maybe. */
        DisplayKeyByName('$Num');
        DisplayKeyByName('MSTf');
        DisplayKeyByName('MSDS');
        DisplayKeyByName('LSOF');
    }
    DisconnectFromSmc();

    if (RT_SUCCESS(rc))
        return RTEXITCODE_SUCCESS;
    return RTEXITCODE_FAILURE;
}
예제 #9
0
void CPianoCtrl::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	CRect	cb;
	dc.GetClipBox(cb);
//printf("OnPaint cb %d %d %d %d\n", cb.left, cb.top, cb.right, cb.bottom);
	HFONT	hFont;
	if (m_Font != NULL)	// if user specified font
		hFont = m_Font;
	else	// font not specified
		hFont = m_KeyLabelFont;	// use auto-scaled font
	HGDIOBJ	hPrevFont = dc.SelectObject(hFont);
	DWORD	dwStyle = GetStyle();
	bool	ShowPressed = (dwStyle & PS_HIGHLIGHT_PRESS) != 0;
	UINT	nAlign;
	if (dwStyle & PS_VERTICAL) {	// if vertical orientation
		nAlign = TA_RIGHT | TA_TOP;
	} else {	// horizontal orientation
		if (dwStyle & PS_ROTATE_LABELS)	// if rotated labels
			nAlign = TA_LEFT | TA_TOP;
		else	// normal labels
			nAlign = TA_CENTER | TA_BOTTOM;
	}
	dc.SetTextAlign(nAlign);
	TEXTMETRIC	TextMetric;
	dc.GetTextMetrics(&TextMetric);
	dc.SetBkMode(TRANSPARENT);
	int	nKeys = GetKeyCount();
	for (int iKey = 0; iKey < nKeys; iKey++) {	// for each key
		CKey&	key = m_Key[iKey];
		if (key.m_Rgn.RectInRegion(cb)) {	// if key's region intersects clip box
			// fill key's region with appropriate brush for key color and state
			bool	IsPressed = key.m_IsPressed & ShowPressed;
			if ((dwStyle & PS_PER_KEY_COLORS) && key.m_Color >= 0) {
				SetDCBrushColor(dc, key.m_Color);
				FillRgn(dc, key.m_Rgn, (HBRUSH)GetStockObject(DC_BRUSH));
			} else	// default color scheme
				dc.FillRgn(&key.m_Rgn, &m_KeyBrush[key.m_IsBlack][IsPressed]);
			// outline key's region; this flickers slightly because it overlaps fill
			dc.FrameRgn(&key.m_Rgn, &m_OutlineBrush, OUTLINE_WIDTH, OUTLINE_WIDTH);
			if (iKey < m_KeyLabel.GetSize() && !m_KeyLabel[iKey].IsEmpty()) {
				COLORREF	TextColor;
				if (dwStyle & PS_PER_KEY_COLORS) {	// if per-key colors
					COLORREF	BkColor;
					int	BkMode = TRANSPARENT;
					if (key.m_Color >= 0) {	// if key has custom color
						// compute lightness, compensating for our sensitivity to green
						int	lightness = GetRValue(key.m_Color) 
							+ GetGValue(key.m_Color) * 2 + GetBValue(key.m_Color);
						if (lightness < 255 * 2)	// if lightness below threshold
							TextColor = RGB(255, 255, 255);	// white text
						else	// key is light enough
							TextColor = RGB(0, 0, 0);	// black text
						if (dwStyle & PS_INVERT_LABELS) {	// if inverting labels
							if (key.m_IsPressed) {	// if key pressed
								BkColor = TextColor;	// set background to text color
								TextColor ^= 0xffffff;	// invert text color
								BkMode = OPAQUE;
							} else	// key not pressed
								BkColor = key.m_Color;	// make background same as key
						} else	// not highlighting pressed keys
							BkColor = key.m_Color;	// make background same as key
					} else {	// default color scheme
						TextColor = m_KeyColor[!key.m_IsBlack][0];
						BkColor = m_KeyColor[key.m_IsBlack][key.m_IsPressed];
					}
					dc.SetBkColor(BkColor);	// set background color
					dc.SetBkMode(BkMode);	// set background mode
				} else	// default color scheme
					TextColor = m_KeyColor[!key.m_IsBlack][0];
				dc.SetTextColor(TextColor);	// set text color
				CRect	rKey;
				key.m_Rgn.GetRgnBox(rKey);
				CPoint	pt;
				if (dwStyle & PS_VERTICAL) {	// if vertical orientation
					pt.x = rKey.right - TextMetric.tmDescent * 2;
					pt.y = rKey.top + (rKey.Height() - TextMetric.tmHeight) / 2;
				} else {	// horizontal orientation
					if (dwStyle & PS_ROTATE_LABELS) {	// if vertical labels
						pt.x = rKey.left + (rKey.Width() - TextMetric.tmHeight) / 2;
						pt.y = rKey.bottom - TextMetric.tmDescent * 2;
					} else {	// horizontal labels
						pt.x = rKey.left + rKey.Width() / 2;
						pt.y = rKey.bottom - TextMetric.tmDescent;
					}
				}
				dc.TextOut(pt.x, pt.y, m_KeyLabel[iKey]);
			}
		}
	}
	dc.SelectObject(hPrevFont);
}
예제 #10
0
void CPianoCtrl::Update(CSize Size)
{
	// compute number of white keys
	int	nWhites = 0;
	int	iKey;
	int	nKeys = m_Key.GetSize();	// get existing key count
	for (iKey = 0; iKey < nKeys; iKey++)	// for each key array element
		m_Key[iKey].m_Rgn.DeleteObject();	// delete key's polygonal area
	int	StartDelta = m_StartNote - m_PrevStartNote;
	if (StartDelta) {	// if start note changed
		if (StartDelta > 0)	// if start note increased
			m_Key.RemoveAt(0, min(StartDelta, nKeys));
		else {	// start note decreased
			CKey	key;
			m_Key.InsertAt(0, key, min(-StartDelta, nKeys));
		}
		m_PrevStartNote = m_StartNote;
	}
	nKeys = GetKeyCount();	// get new key count
	m_Key.SetSize(nKeys);	// resize key array, possibly reallocating it
	for (iKey = 0; iKey < nKeys; iKey++) {	// for each key
		int	iKeyInfo = (m_StartNote + iKey) % NOTES;	// account for start note
		if (!m_KeyInfo[iKeyInfo].BlackOffset)	// if key is black
			nWhites++;
	}
	// build array of key regions, one per key
	double	WhiteWidth;
	CSize	BlackSize;
	DWORD	dwStyle = GetStyle();
	bool	IsVertical = (dwStyle & PS_VERTICAL) != 0;
	if (IsVertical)	// if vertical orientation
		WhiteWidth = double(Size.cy) / nWhites;
	else	// horizontal orientation
		WhiteWidth = double(Size.cx) / nWhites;
	double	HScale = WhiteWidth / WHITE_WIDTH;
	double	BlackWidth = BLACK_WIDTH * HScale;
	if (IsVertical)	// if vertical orientation
		BlackSize = CSize(round(m_BlackHeightRatio * Size.cx), round(BlackWidth));
	else	// horizontal orientation
		BlackSize = CSize(round(BlackWidth), round(m_BlackHeightRatio * Size.cy));
	int	iStartWhite = m_KeyInfo[m_StartNote % NOTES].WhiteIndex;
	double	StartOffset = iStartWhite * WhiteWidth;
	int	iWhite = iStartWhite;
	int	PrevWhiteX = 0;
	int	PrevBlackOffset = 0;
	for (iKey = 0; iKey < nKeys; iKey++) {	// for each key
		CKey&	key = m_Key[iKey];
		int	iKeyInfo = (m_StartNote + iKey) % NOTES;	// account for start note
		int	BlackOffset = m_KeyInfo[iKeyInfo].BlackOffset;
		if (BlackOffset) {	// if black key
			double	OctaveOffset = (iWhite / WHITES) * WhiteWidth * WHITES;
			int	x = round(BlackOffset * HScale - StartOffset + OctaveOffset);
			CRect	rKey;
			if (IsVertical)	// if vertical orientation
				rKey = CRect(CPoint(0, Size.cy - x - BlackSize.cy), BlackSize);
			else	// horizontal orientation
				rKey = CRect(CPoint(x, 0), BlackSize);
			key.m_Rgn.CreateRectRgnIndirect(rKey);	// create black key region
			if (iKey) {	// if not first key
				// deduct this black key's region from previous white key's region
				CRgn&	PrevRgn = m_Key[iKey - 1].m_Rgn;
				PrevRgn.CombineRgn(&PrevRgn, &key.m_Rgn, RGN_DIFF);
			}
		} else {	// white key
			int	x = round((iWhite + 1) * WhiteWidth - StartOffset);
			CRect	rKey;
			if (IsVertical)	// if vertical orientation
				rKey = CRect(0, Size.cy - PrevWhiteX, Size.cx, Size.cy - x);
			else	// horizontal orientation
				rKey = CRect(PrevWhiteX, 0, x, Size.cy);
			key.m_Rgn.CreateRectRgnIndirect(rKey);	// create white key region
			if (PrevBlackOffset) {	// if previous key is black
				// deduct previous black key's region from this white key's region
				CRgn&	PrevRgn = m_Key[iKey - 1].m_Rgn;
				key.m_Rgn.CombineRgn(&key.m_Rgn, &PrevRgn, RGN_DIFF);
			}
			PrevWhiteX = x;
			iWhite++;
		}
		key.m_IsBlack = BlackOffset != 0;
		PrevBlackOffset = BlackOffset;
	}
	m_BlackKeySize = BlackSize;
	if (dwStyle & PS_SHOW_SHORTCUTS) {	// if showing shortcuts
		m_KeyLabel.RemoveAll();	// delete any existing labels
		m_KeyLabel.SetSize(nKeys);	// allocate labels
	}
	// if using or showing shortcuts
	if (dwStyle & (PS_SHOW_SHORTCUTS | PS_USE_SHORTCUTS)) {
		memset(m_ScanCodeToKey, -1, sizeof(m_ScanCodeToKey));
		int	iScanCode = 0;
		for (int iKey = 0; iKey < nKeys; iKey++) {	// for each key
			// if key is white, and first key or previous key is white
			if (!IsBlack(iKey) && (!iKey || !IsBlack(iKey - 1)))
				iScanCode++;	// advance one extra scan code
			if (iScanCode < _countof(m_ScanCode)) {	// if within scan code array
				int	ScanCode = m_ScanCode[iScanCode];
				ASSERT(ScanCode < _countof(m_ScanCodeToKey));
				m_ScanCodeToKey[ScanCode] = static_cast<char>(iKey);
				if (dwStyle & PS_SHOW_SHORTCUTS) {	// if showing shortcuts
					TCHAR	KeyName[2];	// buffer for shortcut key name
					if (GetKeyNameText(ScanCode << 16, KeyName, _countof(KeyName)))
						m_KeyLabel[iKey] = KeyName;
				}
			}
			iScanCode++;
		}
	}
	if (m_Font == NULL)	// if window font not specified
		UpdateKeyLabelFont(Size, dwStyle);	// update auto-scaled key label font
}
예제 #11
0
파일: vrml_api.cpp 프로젝트: nixz/covise
BOOL
CallbackTable::GetCallbackMethods(Interface *ip)
{
    int i;
    LPCTSTR lpSection = _T("Dlls");
    LPCTSTR lpKey = NULL;
    LPCTSTR lpDefault = _T("none");
    TCHAR lpBuf[MAX_PATH];
    DWORD nSize = sizeof(lpBuf);

    const TCHAR *maxPlugCfgPath = ip->GetDir(APP_PLUGCFG_DIR);
    TCHAR lpINIFileName[MAX_PATH];
    _stprintf(lpINIFileName, _T("%s\\%s"), maxPlugCfgPath, _T("vrmlexp.ini"));

    // see if the INI files exists.
    WIN32_FIND_DATA file;
    HANDLE findhandle = FindFirstFile(lpINIFileName, &file);
    FindClose(findhandle);
    if (findhandle == INVALID_HANDLE_VALUE)
    {
        /*  if the .ini file is missing assume they aren't using the API
        TSTR buf = "couldn't find INI file";
	    MessageBox(GetActiveWindow(), buf, " ", MB_OK|MB_TASKMODAL);
        */
        return FALSE;
    }

    // get dllKeys
    GetPrivateProfileString(lpSection, lpKey, lpDefault, (LPTSTR)lpBuf, nSize, (LPCTSTR)lpINIFileName);
    TCHAR *tmpPtr = lpBuf;
    while (tmpPtr[0] != '\0')
    {
        TCHAR *dllKey = (TCHAR *)malloc(_tcslen(tmpPtr) * sizeof(TCHAR));
        _tcscpy(dllKey, tmpPtr);
        AddKey(dllKey);
        tmpPtr = _tcschr(tmpPtr, '\0') + 1;
    }

    // check validity of INI file
    if (!lstrcmp(lpBuf, _T("none")))
    {
        TSTR buf = _T("couldn't find [dlls] section in INI file");
        MessageBox(GetActiveWindow(), buf, _T(" "), MB_OK | MB_TASKMODAL);
        return FALSE;
    }

    // get dlls
    for (i = 0; i < GetKeyCount(); i++)
    {
        GetPrivateProfileString(lpSection, GetKey(i), lpDefault, (LPTSTR)lpBuf, nSize, lpINIFileName);
        TCHAR *dllPtr = (TCHAR *)malloc(_tcslen(lpBuf) * sizeof(TCHAR));
        _tcscpy(dllPtr, lpBuf);
        AddDll(dllPtr);
    }

    // load the dlls
    for (i = GetDllCount(); i--;)
    {
        HINSTANCE libInst = (HINSTANCE)LoadLibraryEx(GetDll(i), NULL, 0);
        if (libInst)
        {
            AddDLLHandle(libInst);
            FARPROC lpCallbackType = NULL;
            FARPROC lpProc = NULL;
            TCHAR lpStr[64];
            __int64 CallbackType;

            lpCallbackType = GetProcAddress((HMODULE)libInst, (LPCSTR) "ExportLibSupport");
            if (lpCallbackType)
            {
                CallbackType = (*(lpCallbackType))();
            }

            // Export Lib support for pre-scene export
            if (PreSceneCallback & CallbackType)
            {
                _tcscpy(lpStr, _T("PreSceneExport"));
                DllPreScene lpProc = (DllPreScene)GetProcAddress((HMODULE)libInst, (LPCSTR)lpStr);
                if (!lpProc)
                {
                    TCHAR buf[256];
                    _stprintf(buf, _T("method %s not implimented"), lpStr);
                    MessageBox(GetActiveWindow(), buf, _T("Export Lib"), MB_OK | MB_TASKMODAL);
                }
                AddPreScene(lpProc);
            }

            // Export Lib support for post-scene export
            if (PostSceneCallback & CallbackType)
            {
                _tcscpy(lpStr, _T("PostSceneExport"));
                DllPostScene lpProc = (DllPostScene)GetProcAddress((HMODULE)libInst, (LPCSTR)lpStr);
                if (!lpProc)
                {
                    TCHAR buf[256];
                    _stprintf(buf, _T("method %s not implimented"), lpStr);
                    MessageBox(GetActiveWindow(), buf, _T("Export Lib"), MB_OK | MB_TASKMODAL);
                }
                AddPostScene(lpProc);
            }

            // Export Lib support for pre-node export
            if (PreNodeCallback & CallbackType)
            {
                _tcscpy(lpStr, _T("PreNodeExport"));
                DllPreNode lpProc = (DllPreNode)GetProcAddress((HMODULE)libInst, (LPCSTR)lpStr);
                if (!lpProc)
                {
                    TCHAR buf[256];
                    _stprintf(buf, _T("method %s not implimented"), lpStr);
                    MessageBox(GetActiveWindow(), buf, _T("Export Lib"), MB_OK | MB_TASKMODAL);
                }
                AddPreNode(lpProc);
            }

            // Export Lib support for post-node export
            if (PostNodeCallback & CallbackType)
            {
                _tcscpy(lpStr, _T("PostNodeExport"));
                DllPostNode lpProc = (DllPostNode)GetProcAddress((HMODULE)libInst, (LPCSTR)lpStr);
                if (!lpProc)
                {
                    TCHAR buf[256];
                    _stprintf(buf, _T("method %s not implimented"), lpStr);
                    MessageBox(GetActiveWindow(), buf, _T("Export Lib"), MB_OK | MB_TASKMODAL);
                }
                AddPostNode(lpProc);
            }
        }
        else
        {
            TCHAR buf[256];
            _stprintf(buf, _T("Lib [%s] Load Failed"), GetDll(i));
            MessageBox(GetActiveWindow(), buf, _T("Export Lib"), MB_OK | MB_TASKMODAL);
        }
    }

    return TRUE;
}