コード例 #1
0
BOOL CBCGPTagManager::ParseColor (const CString& strItem, CBCGPColor& value)
{
	CBCGPTagManager tm (strItem);

	CStringArray sa;

	CString strA, strR, strG, strB;

	tm.ExcludeTag (s_A, strA);
	strA.TrimLeft ();
	strA.TrimRight ();
	tm.ExcludeTag (s_R, strR);
	strR.TrimLeft ();
	strR.TrimRight ();
	tm.ExcludeTag (s_G, strG);
	strG.TrimLeft ();
	strG.TrimRight ();
	tm.ExcludeTag (s_B, strB);
	strB.TrimLeft ();
	strB.TrimRight ();

	if (strR.IsEmpty () || strG.IsEmpty () || strB.IsEmpty ())
	{
		if (!ParseString (strItem, _T(","), sa, TRUE, FALSE))
		{
			strR = tm.GetBuffer ();
			strR.TrimLeft ();
			strR.TrimRight ();

			sa.Add (strR);
		}
	}
	else
	{
		sa.Add (strR);
		sa.Add (strG);
		sa.Add (strB);

		if (!strA.IsEmpty ())
		{
			sa.Add (strA);
		}
	}

	if (sa.GetSize () > 0)
	{
		const int count = (int) sa.GetSize ();
		if (count >= 3)
		{
			value.r = bcg_clamp((double)_ttol(sa[0]) / 255.0, 0.0, 1.0);
			value.g = bcg_clamp((double)_ttol(sa[1]) / 255.0, 0.0, 1.0);
			value.b = bcg_clamp((double)_ttol(sa[2]) / 255.0, 0.0, 1.0);
			value.a = count == 4 ? bcg_clamp((double)_ttol(sa[3]) / 255.0, 0.0, 1.0) : 1.0;

			return TRUE;
		}
	}

	return FALSE;
}
コード例 #2
0
BOOL CBCGPTagManager::ParsePoint (const CString& strItem, CPoint& value)
{
	CBCGPTagManager tm (strItem);

	CStringArray sa;

	CString strX, strY;

	tm.ExcludeTag (s_X, strX);
	strX.TrimLeft ();
	strX.TrimRight ();
	tm.ExcludeTag (s_Y, strY);
	strY.TrimLeft ();
	strY.TrimRight ();

	if (strX.IsEmpty () || strY.IsEmpty ())
	{
		if (!ParseString (tm.GetBuffer (), _T(","), sa, TRUE, FALSE))
		{
			return FALSE;
		}
	}
	else
	{
		sa.Add (strX);
		sa.Add (strY);
	}

	if (sa.GetSize () == 2)
	{
		value.x = _ttol(sa[0]);
		value.y = _ttol(sa[1]);
		return TRUE;
	}

	return FALSE;
}
コード例 #3
0
BOOL CBCGPTagManager::ParseSize (const CString& strItem, CSize& value)
{
	CBCGPTagManager tm (strItem);
	CStringArray sa;

	CString strW, strH;

	tm.ExcludeTag (s_Width, strW);
	strW.TrimLeft ();
	strW.TrimRight ();
	tm.ExcludeTag (s_Height, strH);
	strH.TrimLeft ();
	strH.TrimRight ();

	if (strW.IsEmpty () || strH.IsEmpty ())
	{
		if (!ParseString (tm.GetBuffer (), _T(","), sa, TRUE, FALSE))
		{
			return FALSE;
		}
	}
	else
	{
		sa.Add (strW);
		sa.Add (strH);
	}

	if (sa.GetSize () == 2)
	{
		value.cx = _ttol(sa[0]);
		value.cy = _ttol(sa[1]);
		return TRUE;
	}

	return FALSE;
}
コード例 #4
0
BOOL CBCGPTagManager::ParseBrush (const CString& strItem, CBCGPBrush& value)
{
	CBCGPTagManager tm (strItem);

	int type = CBCGPBrush::BCGP_NO_GRADIENT;
	tm.ReadInt(s_BrushType, type);
	type = bcg_clamp(type, CBCGPBrush::BCGP_NO_GRADIENT, CBCGPBrush::BCGP_GRADIENT_RADIAL_BOTTOM_RIGHT);
	int opacity = 255;
	tm.ReadInt (s_Opacity, opacity);

	if (type == CBCGPBrush::BCGP_NO_GRADIENT)
	{
		CBCGPColor clr;
		tm.ReadColor (s_BrushColor, clr);

		value.SetColor (clr, bcg_clamp((double)opacity / 255.0, 0.0, 1.0));
	}
	else
	{
		CString strColors;

		if (tm.ExcludeTag (s_BrushColors, strColors))
		{
			CBCGPTagManager tmColors(strColors);

			CBCGPColor clr1;
			tmColors.ReadColor (s_BrushColor, clr1);
			CBCGPColor clr2;
			tmColors.ReadColor (s_BrushColor, clr2);

			value.SetColors (clr1, clr2, (CBCGPBrush::BCGP_GRADIENT_TYPE)type, bcg_clamp((double)opacity / 255.0, 0.0, 1.0));
		}
	}

	return TRUE;
}
コード例 #5
0
ファイル: SetPageBase.cpp プロジェクト: 20400992/CoolFormat
void CSetPageBase::InitPropList()
{
	CBCGPTagManager tm;
	CString strRes(_T("IDR_SETCONFIG_XML_") + m_strConfigName.MakeUpper());
	if (!tm.LoadFromResource(strRes, _T("XML")))
	{
		return;
	}

	CString strStyle;
	if (!tm.ExcludeTag(_T("SETCONFIG"), strStyle))
	{
		return;
	}
	tm.SetBuffer(strStyle);

	int nVersion;
	tm.ReadInt(_T("VERSION"), nVersion);
	if (nVersion != 1)
	{
		return;
	}

	CString strPropertys;
	if (tm.ExcludeTag(_T("PROPERTYS"), strPropertys))
	{
		CBCGPTagManager tmPropertys(strPropertys);

		CMyBCGPProp* pPropGroup = NULL;
		CString strProperty;
		while (tmPropertys.ExcludeTag(_T("PROPERTY"), strProperty))
		{
			CBCGPTagManager tmProperty(strProperty);
			CString strName = _T("NO NAME");
			tmProperty.ReadString(_T("NAME"), strName);

			BOOL bGroup = FALSE;
			if (tmProperty.ReadBool(_T("GROUP"), bGroup) && bGroup)
			{
				if (pPropGroup)
				{
					m_wndPropList.AddProperty(pPropGroup, FALSE, FALSE);
					pPropGroup = NULL;
				}

				pPropGroup = new CMyBCGPProp(strName);
			} 
			else if (pPropGroup)
			{
				CString strType = _T("Combo");
				tmProperty.ReadString(_T("TYPE"), strType);

				if (strType.CompareNoCase(_T("Combo")) == 0)
				{
					CString strValue;
					tmProperty.ReadString(_T("VALUE"), strValue);

					CMyBCGPProp* pProp = new CMyBCGPProp(strName, (_variant_t)strValue);
					
					CString strItem;
					while (tmProperty.ExcludeTag(_T("ITEM"), strItem))
					{
						CBCGPTagManager tmItem(strItem);
						tmItem.ReadString(_T("VALUE"), strValue);

						CString strShort, strPreview;
						tmItem.ReadString(_T("SHORT"), strShort);
						tmItem.ReadString(_T("PREVIEW"), strPreview);
						Entity_Backward(strPreview, s_EntityText);
						EntityToSymbol(strPreview);

						pProp->AddComboOption(strValue, strShort, strPreview);
					}

					pPropGroup->AddSubItem(pProp);
				} 
				else if (strType.CompareNoCase(_T("Number")) == 0)
				{
					int nValue;
					tmProperty.ReadInt(_T("VALUE"), nValue);

					CMyBCGPProp* pProp = new CMyBCGPProp(strName, (_variant_t)nValue);

					CSize range;
					tmProperty.ReadSize(_T("RANGE"), range);

					BOOL bBuddy = FALSE;
					tmProperty.ReadBool(_T("BUDDY"), bBuddy);
					CMyBCGPProp* pPropBuddy = NULL;
					if (bBuddy)
					{
						pPropBuddy = DYNAMIC_DOWNCAST(CMyBCGPProp, pPropGroup->GetSubItem(pPropGroup->GetSubItemsCount() - 1));
					}

					CString strShort, strPreview;
					tmProperty.ReadString(_T("SHORT"), strShort);
					tmProperty.ReadString(_T("PREVIEW"), strPreview);
					Entity_Backward(strPreview, s_EntityText);
					EntityToSymbol(strPreview);

					pProp->SetNumberSpin(range.cx, range.cy, strShort, strPreview, pPropBuddy);
					pPropGroup->AddSubItem(pProp);
				}
				else if (strType.CompareNoCase(_T("Text")) == 0)
				{
					CString strValue;
					tmProperty.ReadString(_T("VALUE"), strValue);

					CMyBCGPProp* pProp = new CMyBCGPProp(strName, (_variant_t)strValue);

					CString strShort, strPreview;
					tmProperty.ReadString(_T("SHORT"), strShort);
					tmProperty.ReadString(_T("PREVIEW"), strPreview);
					Entity_Backward(strPreview, s_EntityText);
					EntityToSymbol(strPreview);

					pProp->SetEditText(strShort, strPreview);
					pPropGroup->AddSubItem(pProp);
				}
			}
		}

		if (pPropGroup)
		{
			m_wndPropList.AddProperty(pPropGroup, FALSE, FALSE);
			pPropGroup = NULL;
		}
	}
}
コード例 #6
0
BOOL CBCGPTagManager::ParseFont (const CString& strItem, LOGFONT& value)
{
	CBCGPTagManager tm (strItem);

	CString strFontItem;

	if (tm.ExcludeTag (s_FaceName, strFontItem))
	{
		ASSERT(!strFontItem.IsEmpty ());

		if (!strFontItem.IsEmpty ())
		{
			memcpy (value.lfFaceName, (LPCTSTR)strFontItem, min(strFontItem.GetLength (), LF_FACESIZE) * sizeof(TCHAR));
		}
	}
	
	int val = 0;
	if (tm.ReadInt (s_Height, val))
	{
		value.lfHeight = val;
	}

	if (value.lfHeight > 0)
	{
		if (tm.ReadInt (s_Width, val))
		{
			value.lfWidth = val;
		}
	}

	if (tm.ExcludeTag (s_Weight, strFontItem))
	{
		struct WEIGHT_FONT_TYPE
		{
			LPCTSTR name;
			LONG    weight;
		};

		const WEIGHT_FONT_TYPE WEIGHT_FONT_TYPES[] = 
		{
			{_T("DONTCARE")  , FW_DONTCARE  },
			{_T("THIN")      , FW_THIN      },
			{_T("EXTRALIGHT"), FW_EXTRALIGHT},
			{_T("LIGHT")     , FW_LIGHT     },
			{_T("NORMAL")    , FW_NORMAL    },
			{_T("MEDIUM")    , FW_MEDIUM    },
			{_T("SEMIBOLD")  , FW_SEMIBOLD  },
			{_T("BOLD")      , FW_BOLD      },
			{_T("EXTRABOLD") , FW_EXTRABOLD },
			{_T("HEAVY")     , FW_HEAVY     },
			{_T("ULTRALIGHT"), FW_ULTRALIGHT},
			{_T("REGULAR")   , FW_REGULAR   },
			{_T("DEMIBOLD")  , FW_DEMIBOLD  },
			{_T("ULTRABOLD") , FW_ULTRABOLD },
			{_T("BLACK")     , FW_BLACK     }
		};

		for(long i = 0; i < sizeof(WEIGHT_FONT_TYPES) / sizeof(WEIGHT_FONT_TYPE); i++)
		{
			if(strFontItem.CompareNoCase (WEIGHT_FONT_TYPES[i].name) == 0)
			{
				value.lfWeight = WEIGHT_FONT_TYPES[i].weight;
				break;
			}
		}
	}

	if(tm.ExcludeTag (s_Quality, strFontItem))
	{
		struct QUALITY_FONT_TYPE
		{
			LPCTSTR name;
			BYTE    quality;
		};

		const QUALITY_FONT_TYPE QUALITY_FONT_TYPES[] = 
		{
			{_T("DEFAULT")          , DEFAULT_QUALITY          },
			{_T("DRAFT")            , DRAFT_QUALITY            },
			{_T("PROOF")            , PROOF_QUALITY            },
			{_T("NONANTIALIASED")   , NONANTIALIASED_QUALITY   },
			{_T("ANTIALIASED")      , ANTIALIASED_QUALITY      },
			{_T("CLEARTYPE")        , 5},//CLEARTYPE_QUALITY        
			{_T("CLEARTYPE_NATURAL"), 6} //CLEARTYPE_NATURAL_QUALITY
		};

		for(long i = 0; i < sizeof(QUALITY_FONT_TYPES) / sizeof(QUALITY_FONT_TYPE); i++)
		{
			if(strFontItem.CompareNoCase (QUALITY_FONT_TYPES[i].name) == 0)
			{
				if (QUALITY_FONT_TYPES[i].quality <= ANTIALIASED_QUALITY)
				{
					value.lfQuality = QUALITY_FONT_TYPES[i].quality;
				}
				else
				{
					OSVERSIONINFO osvi;
					osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
					::GetVersionEx (&osvi);

					if(osvi.dwPlatformId == VER_PLATFORM_WIN32_NT &&
					   osvi.dwMajorVersion >= 5)
					{
						value.lfQuality = QUALITY_FONT_TYPES[i].quality;
					}
				}
				break;
			}
		}
	}

	return TRUE;
}
コード例 #7
0
BOOL CBCGPTagManager::ParseRect (const CString& strItem, CRect& value)
{
	CBCGPTagManager tm (strItem);

	CString str1;
	CString str2;

	tm.ExcludeTag (s_Offset, str1);
	str1.TrimLeft ();
	str1.TrimRight ();
	tm.ExcludeTag (s_Size, str2);
	str2.TrimLeft ();
	str2.TrimRight ();

	CPoint pt (0, 0);
	CSize  sz (0, 0);

	if (ParsePoint (str1, pt) && ParseSize (str2, sz))
	{
		value = CRect (pt, sz);
		return TRUE;
	}

	tm.SetBuffer (strItem);
	tm.ExcludeTag (s_LT, str1);
	str1.TrimLeft ();
	str1.TrimRight ();
	tm.ExcludeTag (s_RB, str2);
	str2.TrimLeft ();
	str2.TrimRight ();

	CPoint pt2 (0, 0);
	if (ParsePoint (str1, pt) && ParsePoint (str2, pt2))
	{
		value = CRect (pt, pt2);
		return TRUE;
	}

	CStringArray sa;

	CString strL, strT, strR, strB;

	tm.SetBuffer (strItem);

	tm.ExcludeTag (s_Left, strL);
	strL.TrimLeft ();
	strL.TrimRight ();
	tm.ExcludeTag (s_Top, strT);
	strT.TrimLeft ();
	strT.TrimRight ();
	tm.ExcludeTag (s_Right, strR);
	strR.TrimLeft ();
	strR.TrimRight ();
	tm.ExcludeTag (s_Bottom, strB);
	strB.TrimLeft ();
	strB.TrimRight ();

	if (strL.IsEmpty () || strT.IsEmpty () || strR.IsEmpty () || strB.IsEmpty ())
	{
		if (!ParseString (tm.GetBuffer (), _T(","), sa, TRUE, FALSE))
		{
			return FALSE;
		}
	}
	else
	{
		sa.Add (strL);
		sa.Add (strT);
		sa.Add (strR);
		sa.Add (strB);
	}

	if (sa.GetSize () == 4)
	{
		value.left   = _ttol(sa[0]);
		value.top    = _ttol(sa[1]);
		value.right  = _ttol(sa[2]);
		value.bottom = _ttol(sa[3]);
		return TRUE;
	}

	return FALSE;
}
コード例 #8
0
BOOL CBCGPTagManager::ParseColor (const CString& strItem, COLORREF& value)
{
	CBCGPTagManager tm (strItem);

	CStringArray sa;

	CString strA, strR, strG, strB;

	tm.ExcludeTag (s_A, strA);
	strA.TrimLeft ();
	strA.TrimRight ();
	tm.ExcludeTag (s_R, strR);
	strR.TrimLeft ();
	strR.TrimRight ();
	tm.ExcludeTag (s_G, strG);
	strG.TrimLeft ();
	strG.TrimRight ();
	tm.ExcludeTag (s_B, strB);
	strB.TrimLeft ();
	strB.TrimRight ();

	if (strR.IsEmpty () || strG.IsEmpty () || strB.IsEmpty ())
	{
		if (!ParseString (strItem, _T(","), sa, TRUE, FALSE))
		{
			strR = tm.GetBuffer ();
			strR.TrimLeft ();
			strR.TrimRight ();

			sa.Add (strR);
		}
	}
	else
	{
		sa.Add (strR);
		sa.Add (strG);
		sa.Add (strB);

		if (!strA.IsEmpty ())
		{
			sa.Add (strA);
		}
	}

	if (sa.GetSize () > 0)
	{
		const int count = (int) sa.GetSize ();
		if (count == 3)
		{
			value = AddaptColor (RGB((BYTE)_ttol(sa[0]), (BYTE)_ttol(sa[1]), (BYTE)_ttol(sa[2])),
				m_clrBase, m_clrTarget);
			return TRUE;
		}
		else if (count == 4)
		{
			value = RGB((BYTE)_ttol(sa[0]), (BYTE)_ttol(sa[1]), (BYTE)_ttol(sa[2])) | (((DWORD)(BYTE)(_ttol(sa[3]))) << 24);
			return TRUE;
		}
		else if (count == 1)
		{
			value = (COLORREF)_ttol(sa[0]);
			return TRUE;
		}
	}

	return FALSE;
}