MLTEPane styles trouble

MLTEPane styles trouble

Post by jolielar » Wed, 12 Jan 2005 00:32:58


Hi,

I'm having trouble dealing with MLTEPane styles (using ::TXN* funcs).
When I set styles (bold, italic...) they are toggled.
Q1: Is there a simple way to set style normally i.e. if bold is
already set, setting it does nothing instead of (annoyingly) clearing
it?

In ATSUnicode.h there is a last ATSUAttributeTag enum field called:
kATSUMaxATSUITagValue = 65535L /* This is the maximum Apple ATSUI
reserved tag value. Client defined tags must be larger.*/

I defined larger values for my own tags:
enum
{
eMY_kATSUIMaxResTagValue = kATSUMaxATSUITagValue,
eMY_kATSUintIndex, // Type: int
eMY_kATSUstructSRECORD // Type: SRECORD
};
and setting them via
const ItemCount iAttrCount = 1;
TXNTypeAttributes iAttributes[iAttrCount + 1];

iAttributes[0].tag = eMY_kATSUintIndex;
iAttributes[0].size = sizeof(int);
iAttributes[0].data.dataValue = nIndex; // Any value (-1, 1, 2, 4...)
memset(&iAttributes[1], 0, sizeof(TXNTypeAttributes));
OSStatus osStatus = ::TXNSetTypeAttributes(mTXNObject, iAttrCount,
iAttributes, kTXNUseCurrentSelection, kTXNUseCurrentSelection);
returns 0 (i.e. OK).

Q2: How to retrieve these user defined types?
Using:
TXNContinuousFlags oContinuousFlags;
const ItemCount iAttrCount = 1;
TXNTypeAttributes ioTypeAttributes[] = {
{ eMY_kATSUintIndex, sizeof(int) },
{0} };
OSStatus osStatus = ::TXNGetContinuousTypeAttributes(mTXNObject,
&oContinuousFlags, iAttrCount, ioTypeAttributes);
int nIndex = ioTypeAttributes[0].data.dataValue;
returns 0 but nIndex is always 0! (Never -1 or 1 or 2 or 4...)

And this is for simple types such as int, not mentioning structures
like my onw SRECORD:
Setting:
TXNTypeAttributes iAttributes[] = {
{ eMY_kATSUstructSRECORD, sizeof(SRECORD) },
{0} };
iAttributes[0].data.dataPtr = &sRecord;
OSStatus osStatus = ::TXNSetTypeAttributes(mTXNObject, iAttrCount,
iAttributes, kTXNUseCurrentSelection, kTXNUseCurrentSelection);

Retrieving:
TXNTypeAttributes ioTypeAttributes[] = {
{ eMY_kATSUstructSRECORD, sizeof(SRECORD) },
{0} };
OSStatus osStatus = ::TXNGetContinuousTypeAttributes(mTXNObject,
&oContinuousFlags, iAttrCount, ioTypeAttributes);
SRECORD* pRecord = ioTypeAttributes[0].data.dataPtr;
(pRecord always null)

Thanks in advance for your help. :-)
Regards, MacPorter.