Sorry, I've been sick for a few days, just got back. Hopefully this will still be useful to you (or someone else!).
First, I just want to mention that there's a suite for doing this kind of thing, the AIColorConversionSuite (AIColourConversion.h). I'd take a look at that; it might simply your conversion code.
As for setting the text colour in CS on, here's the code we use in our application for setting text's stroke colour:
------------- snip --------------
ASSERT(sATEPaint);
ASSERT(sAITextFrame);
TextRangeRef textRangeRef = 0;
// this code is inside an object that represents
// text art, so it has a member that has the art
// handle. This handle is retrieved using GetHandle()
// so just replace 'GetHandle()' with your AIArtHandle
// variable
AIErr error = sAITextFrame->GetATETextRange(GetHandle(), &textRangeRef);
THROW_EXCEP_IF(error);
ATE::ITextRange textRange(textRangeRef);
ATE::ICharFeatures charFeatures = textRange.GetUniqueLocalCharFeatures();
// colour is a pointer to our own colour object; its
// a pointer so that a 'null' stroke can be set
if (colour) {
ATE::ApplicationPaintRef paintRef = 0;
AIColor aiColour;
// this is the colour model of the document,
// which is either CMYK or RGB
EColourModel model = CDocumentList::GetCurrentDocument().GetColourModel();
// we have classes, CRGBColour & CCMYKColour that automatically do
// colour conversion for us -- they use the AIColorConversionSuite
if (eColourModelRGB == model) {
aiColour = (AIColor)(*colour);
} else if (eColourModelCMYK == model) {
aiColour = (AIColor)(CCMYKColour(*colour));
}
error = sATEPaint->CreateATEApplicationPaint(&aiColour, &paintRef);
THROW_EXCEP_IF(error);
ATE::IApplicationPaint paint(paintRef);
// obviously you'd use SetFillColor here if you wanted fill
charFeatures.SetStrokeColor(paint);
charFeatures.SetStroke(true);
} else {
charFeatures.SetStroke(false);
}
textRange.SetLocalCharFeatures(charFeatures);
------------- snip --------------
Note that THROW_EXCEP_IF is a macro of ours that throws an exception if error != kNoErr.
... View more