/*add a command into menu*/ int AddCommand(tMenu *pMenu, char* pCommand, char* pDesc, int (*pOpt)()) { if(pMenu == NULL || pCommand == NULL || pDesc == NULL) { return FAILURE; } AddLinkNode(pMenu->pMenuHead, (tLinkNode *)CreateCmdNode(pCommand, pDesc, pOpt)); return SUCCESS; }
void CIFHyperLink::SetText( char *str ) { int texIdx; int tx1, tx2, ty1, ty2; int rx = 0, ry = 0; bool bLinkStart = false; linkNode_t node; wchar_t uniCode; unsigned char aniCode[3]; char buffer[4]; bool bDoubleByte = false; int xs = m_info.sizeX; int ys = m_info.sizeY; strcpy( m_str, str ); ClearAllLinkNode(); m_startLine = 0; m_maxLineCount = 0; m_viewLineCount = 0; if ( *str == NULL ) return; m_maxLineCount = 1; while( *str ) { memset( aniCode, 0, sizeof( aniCode ) ); memset( buffer, 0, sizeof( buffer ) ); aniCode[0] = *str; tx1 = ty1 = tx2 = ty2 = 0; texIdx = -1; if( aniCode[0] == '&' ) { aniCode[1] = * ++str; if ( aniCode[1] == 's' ) { memset( &node, 0, sizeof(node) ); node.linkNumber = -1; node.left = rx; node.top = ry; bLinkStart = true; } else if ( aniCode[1] == 'e' ) { node.right = rx; node.bottom = ry + 13; if( bLinkStart && node.linkNumber != -1 ) { bLinkStart = false; AddLinkNode( &node ); } memset( &node, 0, sizeof(node) ); node.linkNumber = -1; } else if ( aniCode[1] == 'l' ) { buffer[0] = * ++str; buffer[1] = * ++str; buffer[2] = * ++str; buffer[3] = 0; if( bLinkStart ) { node.linkNumber = atoi( buffer ); } } else if( aniCode[1] == 'n' ) { if (bLinkStart) { node.right = xs; node.bottom = ry + 13; AddLinkNode( &node ); bLinkStart = false; } m_maxLineCount++; ry += 13; rx = 0; } } else if( aniCode[0] == ' ' ) { tx1 = 0; tx2 = 6; } else { if( IsDBCSLeadByte( (BYTE)aniCode[0] ) ) { aniCode[1] = * ++str; aniCode[2] = 0; bDoubleByte = true; } else { aniCode[1] = 0; } MultiByteToWideChar( CP_ACP, MB_COMPOSITE, (char*)aniCode, -1, &uniCode, 1 ); texIdx = g_chatManager->FindTexIdx( uniCode ); } if( texIdx >= 0 ) { tx1 = g_chatManager->GetHanTexCoord(texIdx)->tx1; ty1 = g_chatManager->GetHanTexCoord(texIdx)->ty1; tx2 = g_chatManager->GetHanTexCoord(texIdx)->tx2; ty2 = g_chatManager->GetHanTexCoord(texIdx)->ty2; } str ++; rx += tx2 - tx1; if( rx > xs ) { if (bLinkStart) { node.right = xs; node.bottom = ry + 13; AddLinkNode( &node ); bLinkStart = false; } if (bDoubleByte) str -= 2; else str --; m_maxLineCount++; rx = 0; ry += 13; } if( ry <= ys ) { m_viewLineCount = m_maxLineCount; } } }