IWPAttrInterface Interface

[Top]  [Chapter]  [Previous]  [Next]

This important interface is used to update the character attributes and paragraph attributes.

 

The interface is published by property CurrAttr. This instance of the interface changes either the selected text (if text is selected) or the current writing mode. You can use to create your own toolbar, in case you do not want to use the inbuilt toolbar to change the attributes of the text. You can also use it to implement hotkeys, for example toggle 'bold' when pressing Ctrl+B.

 

The instance "AttrHelper" can be used to calculate CharAttrIndex values to be used with TextCursor.InputString.

 

A different instance is published as property CurrParAttr (Memo.CurrParAttr or RTFDataBlock.CurrParAttr). Here any change will affect all characters in this paragraph. Please note that it will not change the properties stored by the paragraph itself, but the properties used by the individual characters - in the attribute cache. If you need to change the character attributes stored in the paragraph object you can use the method ParASet.

StyleInheritance2

 

CurrStyleAttr is used to change the character attributes defined by a style. You can use SelectStyle to create a new paragraph style or select an existing style to be modified. To apply a style a style to a paragraph, you can use the property StyleName.

 

The interface IWPAttrInterface has several methods to read and write properties, i.e. AttrGet and AttrSet. These methods expect the property ID (WPAT...) - Please see the list of the available WPAT codes. If the AttrGet function returns the value false, the value has not been defined. This means the inherited or the default value will be used for this property.

 

The property CharAttrIndex represents the writing mode as index into the attribute cache. The value can be used with TextCursor.InputText("some text", x). You can store it into an integer variable if you need to temporarily change the writing mode. When you are done simply assign the value and you can use the previous writing mode. Please note that clearing the text makes the index values invalid!

 

Methods


Methods

[****]

IWPAttrInterface Example

 

UnderlineModes

This C# example code creates text to show the possible underline modes.

 string[] cnames =  new string[]

[OBJECT]

{ "WPUND_Standard"

[OBJECT]

, "WPUND_Dotted"

, "WPUND_Dashed"

, "WPUND_Dashdotted"

, "WPUND_Dashdotdotted"

, "WPUND_Double"

, "WPUND_Heavywave"

, "WPUND_Longdashed"

, "WPUND_Thick"

, "WPUND_Thickdotted"

, "WPUND_Thickdashed"

, "WPUND_Thickdashdotted"

, "WPUND_Thickdashdotdotted"

, "WPUND_Thicklongdashed"

, "WPUND_Doublewave"

, "WPUND_WordUnderline"

, "WPUND_wave"

, "WPUND_curlyunderline" };

IWPMemo Memo = WPDLLInt1.Memo;

IWPAttrInterface CurrAttr = Memo.CurrAttr;

IWPTextCursor TextCursor = Memo.TextCursor;

Memo.Clear(false,false);

CurrAttr.Clear();

CurrAttr.SetFontface("Verdana");

//150% Line Height

CurrAttr.AttrSET((int)WPAT.LineHeight, 150);

int m = 1;

foreach (string s in cnames)

{

TextCursor.InputParagraph(0, "");

CurrAttr.SetUnderlineMode(m);

CurrAttr.SetUnderlineColor(WPDLLInt1.ToRGB(Color.Red));

TextCursor.InputText(m.ToString());

TextCursor.InputText(" = ");

TextCursor.InputText(s);

m++;

}

Memo.Reformat();


[idh_interface_iwpattrinterface.htm]    Copyright © 2007 by WPCubed GmbH