bool BrowserComponentConfig::HandleInstruction(const std::string& theInstruction)
{
	if(theInstruction=="TRANSPARENT")
	{
		bool transparent = ReadBool();
		mBrowserComponent->GetHTMLView()->SetComponentFlags(ComponentFlag_GrabBG,transparent);
		if(transparent)
			mBrowserComponent->SetBackground(COLOR_INVALID);
		else
			mBrowserComponent->RemoveBackground();
	}
	else if(theInstruction=="BACKGROUND")
		mBrowserComponent->SetBackground(ReadBackground());
	else if(theInstruction=="SCROLLER")
		mBrowserComponent->SetScroller(SafeConfigGetComponent<Scroller*>(ReadComponent(),"Scroller"));
	else if(theInstruction=="FONTSIZE")
	{
		HTMLFontSize aSize;
		GUIString aSizeStr = ReadString();
		if(aSizeStr.compareNoCase("Smallest")==0) aSize = HTMLFontSize_Smallest;
		else if(aSizeStr.compareNoCase("Small")==0) aSize = HTMLFontSize_Small;
		else if(aSizeStr.compareNoCase("Medium")==0) aSize = HTMLFontSize_Medium;
		else if(aSizeStr.compareNoCase("Large")==0) aSize = HTMLFontSize_Large;
		else if(aSizeStr.compareNoCase("Largest")==0) aSize = HTMLFontSize_Largest;
		else
			throw ConfigObjectException("Invalid font size: " + (std::string)aSizeStr);

		mBrowserComponent->SetFontSize(aSize);
	}
	else
		return ContainerConfig::HandleInstruction(theInstruction);

	return true;
}
Пример #2
0
bool FontConfig::HandleInstruction(const std::string &theInstruction)
{
	if(theInstruction=="SRC")
		SetFont(ReadFont());
	else if(theInstruction=="SIZE")
	{
		mNeedRecalcFont = true;
		mDescriptor.mSize = ReadInt();
	}
	else if(theInstruction=="STYLE")
	{
		while(true)
		{
			mNeedRecalcFont = true;
			bool add = true;
			GUIString aStr = ReadFlag(&add);
			if(aStr.empty())
				break;

			int aStyle = 0;
			if(aStr.compareNoCase("Bold")==0)
				aStyle = FontStyle_Bold;
			else if(aStr.compareNoCase("Italic")==0)
				aStyle = FontStyle_Italic;
			else if(aStr.compareNoCase("Plain")==0)
				aStyle = FontStyle_Plain;
			else if(aStr.compareNoCase("Underline")==0)
				aStyle = FontStyle_Underline;
			else 
				throw ConfigObjectException("Unknown font style: " + (std::string)aStr);
			
			if(add)
				mDescriptor.mStyle |= aStyle;
			else
				mDescriptor.mStyle &= ~aStyle;
		}
	}
	else if(theInstruction=="SETDEFAULTFONT")
		WindowManager::GetDefaultWindowManager()->SetDefaultFont(ReadFont());
	else if(theInstruction=="SETNAMEDFONT")
	{
		GUIString aName = ReadString(); EnsureComma();
		FontPtr aFont = ReadFont();
		WindowManager::GetDefaultWindowManager()->SetNamedFont(aName,aFont);
	}
	else
		return false;

	return true;
}
bool ContainerConfig::HandleNoOverlapLayout()
{
	Component *target = ReadComponent();
	EnsureComma();

	int instructions = 0;
	while(true)
	{
		GUIString aStr = ReadString(true);
		if(aStr.empty())
			break;

		if(aStr.compareNoCase("Above")==0) instructions |= CLI_Above;
		else if(aStr.compareNoCase("Below")==0) instructions |= CLI_Below;
		else if(aStr.compareNoCase("Right")==0) instructions |= CLI_Right;
		else if(aStr.compareNoCase("Left")==0) instructions |= CLI_Left;
		else 
			throw ConfigObjectException("Unknown no overlap instruction: " + (std::string)aStr);
	}

	EnsureComma();
	Component *ref = ReadComponent(); EnsureComma();
	int horzPad, vertPad;
	horzPad = ReadInt(); EnsureComma();
	vertPad = ReadInt(); 

	NoOverlapLayoutPtr aLayout = new NoOverlapLayout(target,instructions,ref,horzPad,vertPad);
	while(!EndOfString())
	{
		EnsureComma();
		Component *aComponent = ReadComponent();
		aLayout->Add(aComponent);
	}

	mContainer->AddChildLayout(aLayout);

	return true;
}
Splitter::QuadrantPosition SplitterConfig::ReadQuadrant()
{
	GUIString aStr = ReadString();
	if(aStr.compareNoCase("Left")==0)
		return Splitter::Position_Left;
	else if(aStr.compareNoCase("Right")==0)
		return Splitter::Position_Right;
	else if(aStr.compareNoCase("Top")==0)
		return Splitter::Position_Top;
	else if(aStr.compareNoCase("Bottom")==0)
		return Splitter::Position_Bottom;
	else if(aStr.compareNoCase("TopLeft")==0)
		return Splitter::Position_TopLeft;
	else if(aStr.compareNoCase("TopRight")==0)
		return Splitter::Position_TopRight;
	else if(aStr.compareNoCase("BottomLeft")==0)
		return Splitter::Position_BottomLeft;
	else if(aStr.compareNoCase("BottomRight")==0)
		return Splitter::Position_BottomRight;
	else
		throw ConfigObjectException("Invalid quadrant: " + (std::string)aStr);
}
Splitter::SplitterType SplitterConfig::ReadSplitterType()
{
	GUIString aStr = ReadString();
	if(aStr.compareNoCase("LeftRight")==0)
		return Splitter::Splitter_LeftRight;
	else if(aStr.compareNoCase("UpDown")==0)
		return Splitter::Splitter_UpDown;
	else if(aStr.compareNoCase("LeftRight_Top")==0)
		return Splitter::Splitter_LeftRight_Top;
	else if(aStr.compareNoCase("LeftRight_Bottom")==0)
		return Splitter::Splitter_LeftRight_Bottom;
	else if(aStr.compareNoCase("UpDown_Left")==0)
		return Splitter::Splitter_UpDown_Left;
	else if(aStr.compareNoCase("UpDown_Right")==0)
		return Splitter::Splitter_UpDown_Right;
	else if(aStr.compareNoCase("Center")==0)
		return Splitter::Splitter_Center;
	else
		throw ConfigObjectException("Invalid splitter type: " + (std::string)aStr);
}
bool ContainerConfig::HandleLayout(bool chain, bool repeat)
{
	Component *target = ReadComponent(); 
	int instructions = 0;
	Component *ref;

	if(!chain && !repeat)
	{
		EnsureComma();
		while(true)
		{
			GUIString aStr = ReadString(true);
			if(aStr.empty())
				break;

			if(aStr.compareNoCase("SameWidth")==0) instructions |= CLI_SameWidth;
			else if(aStr.compareNoCase("SameHeight")==0) instructions |= CLI_SameHeight;
			else if(aStr.compareNoCase("Above")==0) instructions |= CLI_Above;
			else if(aStr.compareNoCase("Below")==0) instructions |= CLI_Below;
			else if(aStr.compareNoCase("Right")==0) instructions |= CLI_Right;
			else if(aStr.compareNoCase("Left")==0) instructions |= CLI_Left;
			else if(aStr.compareNoCase("SameLeft")==0) instructions |= CLI_SameLeft;
			else if(aStr.compareNoCase("SameRight")==0) instructions |= CLI_SameRight;
			else if(aStr.compareNoCase("SameTop")==0) instructions |= CLI_SameTop;
			else if(aStr.compareNoCase("SameBottom")==0) instructions |= CLI_SameBottom;
			else if(aStr.compareNoCase("GrowToRight")==0) instructions |= CLI_GrowToRight;
			else if(aStr.compareNoCase("GrowToLeft")==0) instructions |= CLI_GrowToLeft;
			else if(aStr.compareNoCase("GrowToTop")==0) instructions |= CLI_GrowToTop;
			else if(aStr.compareNoCase("GrowToBottom")==0) instructions |= CLI_GrowToBottom;
			else if(aStr.compareNoCase("SameSize")==0) instructions |= CLI_SameSize;	
			else 
				throw ConfigObjectException("Unknown layout instruction: " + (std::string)aStr);
		}
	}
	else
		instructions = mLayoutInstruction;

	if(chain || (repeat && EndOfString()))
	{
		if(mLayoutRef==NULL)
			throw ConfigObjectException("Invalid LayoutChain");

		ref = mLayoutRef;
	}
	else
	{
		EnsureComma();
		ref = ReadComponent();
	}

	if(!EndOfString())
		EnsureComma();

	for(int i=0; i<4; i++)
	{
		if(EndOfString())
			break;

		mLayoutParams[i] = ReadInt();
		if(!EndOfString())
			EnsureComma();
	}

	if((!chain && !repeat) || i!=0)
	{
		for(; i<4; i++)
			mLayoutParams[i] = 0;
	}

	mContainer->AddChildLayout(target,instructions,ref,mLayoutParams[0],mLayoutParams[1],
		mLayoutParams[2],mLayoutParams[3],mCurLayoutId);

	if(repeat)
		mLayoutRef = ref;
	else
		mLayoutRef = target;

	mLayoutInstruction = instructions;

	return true;
}