Example #1
0
UINT32 CNameBrushDlg::IsValid(const StringBase& strName)
{
	UINT32 NumChars = strName.Length();
	if (NumChars > 20)
		return _R(IDS_BRUSHNAME_TOOLONG);
	// get the brush component from the document
	Document* pDoc = Document::GetCurrent();
	ERROR2IF(pDoc == NULL, FALSE, "Wheres the document?");
	BrushComponent* pBrushComp = (BrushComponent*)pDoc->GetDocComponent(CC_RUNTIME_CLASS(BrushComponent));
	ERROR2IF(pBrushComp == NULL, FALSE, "No brush component");
	
	if (pBrushComp->NameIsUnique(strName))
		return 0;

	return _R(IDS_BRUSHNAME_INVALID);
}
Example #2
0
StringBase* CNameBrushDlg::GetSuggestion(StringBase* pstrSuggest)
{
	ERROR2IF(pstrSuggest == NULL, FALSE, "Null input pointer to CNameBrushDlg::GetSuggestion");

	// get the brush component from the document
	Document* pDoc = Document::GetCurrent();
	ERROR2IF(pDoc == NULL, FALSE, "Wheres the document?");
	BrushComponent* pBrushComp = (BrushComponent*)pDoc->GetDocComponent(CC_RUNTIME_CLASS(BrushComponent));
	ERROR2IF(pBrushComp == NULL, FALSE, "No brush component");
	
	if (!pstrSuggest->IsEmpty())
		*pstrSuggest = pBrushComp->GetUniqueName((String_32*)pstrSuggest);
	else
		*pstrSuggest = pBrushComp->GetUniqueName(NULL);

	return pstrSuggest;
}