• Aucun résultat trouvé

Getting and SeNing Attributes

Dans le document PenPofnt GO (Page 27-30)

The messages that affect attributes (msg TextlnitAttrs, msg TextGetAttrs, msgTextChangeAttrs, and msgTextClearAttrs) require similar arguments.

We will describe the messages after describing the arguments that they use.

Text AHribute Arguments

All text attribute messages include a tag argument that specifies the type of attribute that is to change (character or paragraph). The tag argument uses an atom to specifY the different types of attributes. The atoms that apply to text attributes are atom Char, atomPara, atomParaTab, and atomEmbedded.

Most attribute messages require a first argument that indicates the position, or beginning of the position affected by the message. If first contains the symbol textDefaultAttrs, the message pertains to current defaults for that text data object.

Most attribute messages also require arguments that specifY new attributes and a mask. The mask specifies the attributes to change.

The mask is most useful when changing attributes on a range of characters or paragraphs. Any range of characters can contain many different formats. Without the mask, it would be necessary to enumerate all of the existing formats within the range, and carefully update each one with a separate call. With the mask, rather than worry about what attributes are set already, you identifY the range of characters you want to modifY and let clsText do the work. Similarly, the mask allows modification of a subset of the default attributes without having to first fetch the current values.

Character AHributes

When changing character attributes, applications use the tag atomChar. The mask for character attributes is defined in TA_ CHAR_MASK and the attributes are defined in TA_ CHAR_ATTRS. The symbols for the attributes and their corre-sponding mask bits are almost identical, the difference is that the mask defines additional symbols for the font (SYSDC_FONT_SPEC) structure.

Table 64-3 describes the symbols for the character attributes defined in TA_CHAR_ATTRS.

CHAPTER 64 / USING TEXT DATA OBJECTS 17 Getting and Setting Attributes

Attribute SIze

Ust:lge

Specifies the character size in Twips.

If true, characters are displayed in small capital letters.

If true, characters are displayed in all uppercase.

If true, characters have a line through them.

small Caps upperCase strikeout

underlines Specifies the underline style. The three possible styles are none (0), single underline 0), or double underline (2).

font Specifies the font characteristics structure. The font characteristics are defined by SYSDC_FONT _SPEC. These characteristics are described in Part 4: Windows and Graphics and in SYSFONT.H.

As mentioned above, the symbols for the mask defined in TA_CHA~MASK are similar to the symbols in TA_CHAR_ATTR, with the exception of the font attributes, which are defined by SYSDC_FONT _SPEC. Table 64-4 describes the mask symbols defined by TA_CHAR_MASK for the font attributes.

Mosk Mecming

id Enables use of font.id in the TA_ CHAR_ATTRS structure.

group weight aspect italic monospaced encoding

Enables use of font.group in the TA_ CHAR_ATTRS structure.

Enables use of font.weight in the TA_CHAR_ATTRS structure.

Enables use of font. aspect in the TA_CHAR_ATTRS structure.

Enables use offont.italic in the TA_ CHAR_ATTRS structure.

Enables use of font.monospaced in the TA_ CHA~ATTRS structure.

Enables use of font.encoding in the TA_ CHA~ATTRS structure.

Paragraph AHributes

When changing paragraph attributes, set tag to atomPara. The mask for para-graph attributes is defined in TA_PARA_MASK and the attributes are defined in TA_PARA_ATTRS. The symbols for the attributes and their corresponding mask bits are identical. Table 64-5 describes the symbols for the paragraph attributes and masks defined in TA_P ARA_ATTRS and TA_PARA_MASK.

64.9.1.2

Masks

18 PEN POINT ARCHITECTURAL REFERENCE Part 6 I Text

ribuh~~s

Attribwfe

alignment Specifies the alignment of the paragraph. The possible values are taParaLeft, taParaCenter, or taParaRight to indicate left, center and right alignment respectively.

If true, text should be justified. If false, text is ragged right.

justify

lineHeight Specifies the line height in Twips. This is usually the same as the character height.

The constant useMaxHeightOnLine indicates the the line height should be big enough to accomodate the tallest character in the line.

If a line contains any character or embedded object larger than the specified lineHeight, the larger value is used. Thus lineHeight is a minimum, not a maximum.

Specifies additional space between lines in Twips.

interLineHeight

beforeS pacing Specifies the amount of space before the paragraph in Twips. This space is considered to belong to the first line of the paragraph above the ink of the characters in the first line.

afterSpacing Specifies the amount of space after the paragraph in Twips. The before and after spacing are additive. This space is considered to belong to the last line of the paragraph below the ink of the characters in the last line.

firstLineOffset Specifies the horizontal offset for the first line in Twips. This is a signed value; a negative value will result in a hanging indent.

leftMargin rightMargin

Specifies the position of the left margin, relative to the left edge of the view, in Twips.

The position of the right margin, relative to the right edge, in Twips.

~,". Paragraph Tabs

The tab stops for a paragraph are set independently of the other paragraph attributes. The tag for tab stops is atomParaT abs; the mask is pN u11, and the value is specified by a TA_MANY_TABS structure, which contains:

count The number of tab stops in the paragraph.

repeatAtEnd Whether the last explicit stop acts as a prototype for an infinity of implicit stops.

tabs A fixed-length array ofTA_TAB_STOP descriptors. Only the first count number of descriptors are valid. Each TA_ TAB_STOP descriptor contains:

x The position of the tab stop, relative to the left edge of the paragraph.

type The alignment for the tab. The only valid alignment is taTabLeft.

lead The leader characters for the tab. The only valid leader character is space (taLeadSpace).

~pr GeHing AHributes

To get the character or paragraph attributes, send msgTextGetAttrs to the text object. msgTextGetAttrs can retrieve either local or default attributes. The message takes a pointer to a TEXT_GET_ATTRS structure, which specifies:

tag An atom that indicates the type of attribute to get.

first A text index to a location in the text data object. If you specify

textDefaultAttrs rather than a text index, the message returns the default

64.9.2

CHAPTER 64 / USING TEXT DATA OBJECTS Getting and Setting Attributes

attributes for the type of data specified in tag. If you specify a text index, the attributes are initialized to the tag attributes at that location (which allows you to copy attributes from one location in text to another).

length Reserved for future use. Must be zero.

pValues The address of the buffer to receive the attributes. Because pValues is of type P _UNKNOWN, you must use a cast to render the attributes in their correct type (p _TA_CHAR_ATTRS for character attributes,

P _TA_PARA_ATTRS for paragraph attributes, P_TA_MANY_TABS for tabs).

When the message returns, pValues contains the specified attributes.

Dans le document PenPofnt GO (Page 27-30)

Documents relatifs