当前位置: 首页>>代码示例>>C++>>正文


C++ Status::AddIcon方法代码示例

本文整理汇总了C++中Status::AddIcon方法的典型用法代码示例。如果您正苦于以下问题:C++ Status::AddIcon方法的具体用法?C++ Status::AddIcon怎么用?C++ Status::AddIcon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Status的用法示例。


在下文中一共展示了Status::AddIcon方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

std::map<std::string, Status*> Status::GetAllStatusses()
{
	if (s_allStatusses.size() == 0)
	{	
		IImageManager* imageManager = PlatformSpecific::GetImageManager();
		//otherwise open status XML file
		typedef vector<XMLNode*>::const_iterator SI;
		vector<XMLNode*> statusNodes = BmeClient::GetPreferences()->GetIconPrefs()->GetStatusNodes();
		
		for (SI s = statusNodes.begin(); s != statusNodes.end(); ++s)
		{
			XMLNode* statusNode = *s;
			if (statusNode->Name() == "status")
			{
				vector<XMLNode*> children = statusNode->Children();
				Status* status = new Status();
				for (SI c = children.begin(); c != children.end(); ++c)
				{
					
					XMLNode* statusChild = *c;
					if (statusChild->Name() == "icon")
					{						
						std::string iconPath = statusChild->StringValue();
						IPath* iconFullPath = PlatformSpecific::GetPathManager()->GetIconPrefsPath()->Append(iconPath);
						
						Image* statusIcon = imageManager->GetImageFromFile(iconFullPath->ToString());
						status->AddIcon(statusIcon);
						delete iconFullPath;
					}
					else if (statusChild->Name() == "message")
					{
						status->SetStatusName(statusChild->StringValue());
					}
					else if (statusChild->Name() == "protocol")
					{
						status->SetAbbreviation(statusChild->StringValue());
					}
					else if (statusChild->Name() == "visible")
					{
						bool userChoice = atoi(statusChild->StringValue().c_str());
						status->SetUserChoice(userChoice);
					}
					else if (statusChild->Name() == "color")
					{
					}
				}
				s_allStatusses[status->GetAbbreviation()] = (status);
			}
		}
		delete imageManager;
	}
	return s_allStatusses;
}
开发者ID:BackupTheBerlios,项目名称:bme-svn,代码行数:53,代码来源:Status.cpp

示例2: LoadStatusses

status_t LoadStatusses(BPath statFilePath)
{
	status_t error = B_OK;
	//open file
	BFile statFile(statFilePath.Path(), B_READ_ONLY);
	error = statFile.InitCheck();
	if (error != B_ERROR)
	{
		StringList *tokenList = new StringList();
		//read line
		off_t fileSize;
		if (statFile.GetSize(&fileSize) == B_OK)
		{			
			ssize_t bytesRead = 0;
			BString* token = new BString("");
			bool newToken = false;			
			do
			{
				char c[2];				
				bytesRead += statFile.Read(c,1);
				c[1] = '\0';				
				
				if (c[0] == '\t' || c[0] == '\n')
				{
					//clear token
					if (!newToken)
					{
						//add token to list
						tokenList->AddItem(token);						
						token = new BString("");				
						newToken = true;
					}
				}
				else 
				{
					token->Append(c);
					newToken = false;
				}
			}
			while (bytesRead < fileSize);
		}
		
		int32 startIndex = -1;
		int32 endIndex = -1;
		for (int32 i = 0; i < tokenList->CountItems(); i++)
		{
			if ((*tokenList)[i].ICompare("<status>") == 0)
				startIndex = i;
			else if ((*tokenList)[i].ICompare("</status>") == 0)
			{
				endIndex = i;
				break;
			}
		}
		
		if (startIndex != -1 && endIndex != -1)
		{
			//start past the <status> tag
			startIndex++;
			for (int32 i = startIndex; i < endIndex; i++)
			{
				int32 lastLineIndex = i + 4;

				if (lastLineIndex < endIndex)
				{
					//parse lines
					BString bitmapString = (*tokenList)[i];
					BString statusName = (*tokenList)[i+1];
					BString abbreviation = (*tokenList)[i+2];
					bool userChoice = atoi((*tokenList)[i+3].String());				
					BString colourString = (*tokenList)[i+4];
					i += 4;
					//construct bitmap path
					BPath bitmapPath;
					statFilePath.GetParent(&bitmapPath);
					bitmapPath.Append(bitmapString.String());
					BBitmap *icon = BTranslationUtils::GetBitmap(bitmapPath.Path());
					//construct status object
					Status *status = FindStatus(abbreviation);
					if (status != NULL)
					{
						status->AddIcon(icon);
					}
					else
					{
						//remove brackets from colourString
						colourString.RemoveAll("{");						
						colourString.RemoveAll("}");
						
						int32 colours[4];
						int32 startIndex = 0;						
						for (int i = 0; i < 4; i++)
						{
							int32 commaIndex = colourString.FindFirst(",",startIndex);							
							if (commaIndex != B_ERROR)
							{
								BString colourValue;
								colourString.CopyInto(colourValue,startIndex, commaIndex-startIndex);
								colours[i] = atoi(colourValue.String());
								startIndex = commaIndex + 1;
//.........这里部分代码省略.........
开发者ID:thinkpractice,项目名称:bme,代码行数:101,代码来源:Statusses.cpp


注:本文中的Status::AddIcon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。