BOOL CBCGPTagManager::ParseTextFormat (const CString& strItem, CBCGPTextFormat& value)
{
	CBCGPTagManager tm (strItem);

	CString family;
	tm.ReadString (s_TextFormatFamily, family);
	if (family.IsEmpty ())
	{
		return FALSE;
	}

	double size = 0.0;
	tm.ReadDouble (s_TextFormatSize, size);
	if (size == 0.0)
	{
		return FALSE;
	}

	int nValue = 0;
	tm.ReadInt (s_TextFormatWeight, nValue);
	long weight = (long)bcg_clamp(nValue, FW_THIN, FW_HEAVY);

	nValue = (int)CBCGPTextFormat::BCGP_FONT_STYLE_NORMAL;
	tm.ReadInt (s_TextFormatStyle, nValue);
	CBCGPTextFormat::BCGP_FONT_STYLE style = (CBCGPTextFormat::BCGP_FONT_STYLE)
		bcg_clamp(nValue, (int)CBCGPTextFormat::BCGP_FONT_STYLE_NORMAL, (int)CBCGPTextFormat::BCGP_FONT_STYLE_ITALIC);

	CString locale;
	tm.ReadString (s_TextFormatLocale, locale);

	CBCGPTextFormat format(family, (float)size, weight, style, locale);

	nValue = (int)CBCGPTextFormat::BCGP_TEXT_ALIGNMENT_LEADING;
	tm.ReadInt (s_TextFormatAlignHorz, nValue);
	format.SetTextAlignment ((CBCGPTextFormat::BCGP_TEXT_ALIGNMENT)
		bcg_clamp(nValue, (int)CBCGPTextFormat::BCGP_TEXT_ALIGNMENT_LEADING, (int)CBCGPTextFormat::BCGP_TEXT_ALIGNMENT_CENTER));

	nValue = (int)CBCGPTextFormat::BCGP_TEXT_ALIGNMENT_LEADING;
	tm.ReadInt (s_TextFormatAlignVert, nValue);
	format.SetTextVerticalAlignment ((CBCGPTextFormat::BCGP_TEXT_ALIGNMENT)
		bcg_clamp(nValue, (int)CBCGPTextFormat::BCGP_TEXT_ALIGNMENT_LEADING, (int)CBCGPTextFormat::BCGP_TEXT_ALIGNMENT_CENTER));

	BOOL bValue = FALSE;
	tm.ReadBool (s_TextFormatWordWrap, bValue);
	format.SetWordWrap (bValue);

	bValue = FALSE;
	tm.ReadBool (s_TextFormatClipping, bValue);
	format.SetClipText (bValue);

	double dValue = 0.0;
	tm.ReadDouble (s_TextFormatAngle, dValue);
	format.SetDrawingAngle (dValue);

	value = format;

	return TRUE;
}
BOOL CBCGPTagManager::ParseToolTipParams (const CString& strItem, CBCGPToolTipParams& value)
{
	CBCGPTagManager tm (strItem);

	CBCGPToolTipParams params;

#ifndef _BCGSUITE_
	tm.ReadBool  (s_TTP_BallonTooltip   , params.m_bBallonTooltip);
#else
	tm.ReadBool  (s_TTP_BallonTooltip   , params.m_bBalloonTooltip);
#endif

	tm.ReadBool  (s_TTP_DrawIcon        , params.m_bDrawIcon);
	tm.ReadBool  (s_TTP_DrawDescription , params.m_bDrawDescription);
	tm.ReadInt   (s_TTP_MaxDescrWidth   , params.m_nMaxDescrWidth);
	tm.ReadBool  (s_TTP_RoundedCorners  , params.m_bRoundedCorners);
	tm.ReadBool  (s_TTP_BoldLabel       , params.m_bBoldLabel);
	tm.ReadColor (s_ColorFill           , params.m_clrFill);
	tm.ReadColor (s_ColorFillGradient   , params.m_clrFillGradient);
	tm.ReadInt   (s_GradientAngle       , params.m_nGradientAngle);
	tm.ReadColor (s_ColorText           , params.m_clrText);
	tm.ReadColor (s_ColorBorder         , params.m_clrBorder);
	tm.ReadBool  (s_TTP_DrawSeparator   , params.m_bDrawSeparator);

	value = params;

	return TRUE;
}
BOOL CBCGPTagManager::ParseToolBarImages (const CString& strItem, CBCGPToolBarImages& value, LPCTSTR lpszID)
{
	CBCGPTagManager tm (strItem);

	CSize size (value.GetImageSize ());

	value.Clear ();
	value.SetTransparentColor ((COLORREF)(-1));

	tm.ReadSize (s_Size, size);

	BOOL bPreMultiplyCheck = TRUE;
	tm.ReadBool (s_PreMltCheck, bPreMultiplyCheck);

	value.SetPreMultiplyAutoCheck (bPreMultiplyCheck);

	if (size != CSize (0, 0))
	{
		value.SetImageSize (size);
	}

	value.LoadStr (lpszID);

	if (size == CSize (0, 0))
	{
		value.SetSingleImage ();
	}

	COLORREF clrTransparent = CLR_DEFAULT;
	if (tm.ReadColor (s_Transparent, clrTransparent))
	{
		value.SetTransparentColor (clrTransparent);
	}

#ifndef _BCGSUITE_
	if (m_clrBase != (COLORREF)-1 &&
		m_clrTarget != (COLORREF)-1)
	{
		value.AddaptColors (m_clrBase, m_clrTarget);
	}
#endif

    if (CBCGPToolBarImages::IsRTL () && value.GetImageWell () != NULL &&
		clrTransparent == CLR_DEFAULT)
    {
		BITMAP bmp;
		if (::GetObject (value.GetImageWell (), sizeof (BITMAP), &bmp) != 0)
		{
			if (bmp.bmBitsPixel == 32)
			{
				value.Mirror ();
			}
		}
	}

	return TRUE;
}
BOOL CBCGPTagManager::ParseControlRendererParams (const CString& strItem, CBCGPControlRendererParams& value)
{
	CBCGPTagManager tm (strItem);

	CBCGPControlRendererParams params;
	params.SetResourceID (value.GetResourceID ());

#ifndef _BCGSUITE_
	params.SetBaseColor (m_clrBase, m_clrTarget);
#endif

	if (!tm.ReadRect (s_Rect, params.m_rectImage))
	{
		CSize size;

		if (tm.ReadSize (s_Size, size))
		{
			params.m_rectImage = CRect (CPoint (0, 0), size);
		}
	}

	if (params.m_rectImage.IsRectEmpty ())
	{
		return FALSE;
	}

	tm.ReadRect  (s_Corners, params.m_rectCorners);
	tm.ReadRect  (s_Sides, params.m_rectSides);
	tm.ReadRect  (s_Interior, params.m_rectInter);
	tm.ReadColor (s_Transparent, params.m_clrTransparent);
	tm.ReadBool  (s_PreMltCheck, params.m_bPreMultiplyCheck);

	value = params;

	return TRUE;
}