Package com.ms.fx |
![]() Previous |
![]() Contents |
![]() Index |
![]() Next |
public class FxFormattedText extends FxText implements IFxTextConstants, IFxGraphicsConstants { // Fields protected int flags; protected Font font; protected FontMetrics fm; protected IFxTextCallback callMe; protected IFxShape outline; // Constructors public FxFormattedText(); public FxFormattedText(String newBuff); public FxFormattedText(char newBuff[]); public FxFormattedText(char newBuff[], int offset, int length); // Methods public FxFormattedText dropTail(int iStart); public void setCallback(IFxTextCallback c); public Font getFont(); protected void updateFontInfo(Graphics g); public void ensureNotDirty( Graphics g ); public void setFont(Font f); public int getWordWrap(); public void setWordWrap(int ww); public int getWidth(); public int getHeight(); public String getText(); public void setText(char newBuff[], int offset, int len); public void setText(char newBuff[]); public void setText(String s); public void setStartPoint(int x, int y); public void setStartPoint(Point p); public Point getStartPoint(); public void setStartPointAtOrigin(); public Rectangle getBounding(); public Rectangle shrinkBound(boolean reset); public void setBounding(Rectangle r, boolean bRetainCurrPoint); public void setTextDirection(int dir); public int getTextDirection(); public void setHorizAlign(int h); public void setVertAlign(int v); public int getHorizAlign(); public int getVertAlign(); public void setOutline(IFxShape outline); public IFxShape getOutline(); public void paint(FxGraphics g, int startPos, int length, int opaquing); public void paint(Graphics g); public Point getNextStartPoint(); public void setKerning(boolean useKerning); public boolean getKerning(); public boolean isDirty(); public void insert(char key, int iPos); public void insert(char key[], int iPos); public void insert(char key[], int offs, int len, int iPos); public void remove(int iPos, int numberToRemove); public int getOffsetFromPos(int scrnX, int scrnY, int flags); public boolean isBodyLocationDetermined(); public Point getScrnLocation(int index); public Point getClosestOffset(int scrnX, int scrnY); public int getLocale(); public void setPasswordChar(char c); public boolean getMnemonicDrawing(); public void setMnemonicDrawing(boolean mnem); public void setLocale(int locale); }
This class is an improved version of DrawText(). It is designed for use with any language and will be superclassed for the basis of an edit class. Alignment, text direction, and others are completely specifiable.
public FxFormattedText();Creates an empty sentence.
public FxFormattedText(String newBuff);Creates a new sentence based on a string.
Parameter Description newBuff The string that the new sentence will be based on.
public FxFormattedText(char newBuff[]);Creates a new sentence based on an array of characters.
Parameter Description newBuff The array of characters that the new sentence will be based on.
public FxFormattedText(char newBuff[], int offset, int length);Creates a new sentence based on an array of characters.
Parameter Description newBuff The array of characters to base the new sentence will be based on. offset The offset to use. length The length of the array used.
public FxFormattedText dropTail(int iStart);Forms a clone of this class that contains all the text that is in this class, from iStart onward. The new block will have all the same attribs as this one. Then, remove the text from iStart onward from this block and return the new one.
Parameter Description iStart The starting point of the text that should be removed.
public void setCallback(IFxTextCallback c);Sets the callback.
Return Value:
No return value.
Parameter Description c The callback to set. Remarks:
This method is used to allow applications to make final modifications to the layout after all script processing has been done.
public Font getFont();Retrieves the font being used.
Return Value:
Returns the font being used.
protected void updateFontInfo(Graphics g);Updates the font being used.
Return Value:
No return value.
Parameter Description g The graphics object to update the font.
public void ensureNotDirty(Graphics g);Updates the text block formatting for the specified graphics context.
Return Value:
No return value.
Parameter Description g The graphics object. Remarks:
This method must be called before widths, heights, and other parameters can be retrieved.
public void setFont(Font f);Sets the font of the sentence.
Return Value:
No return value.
Parameter Description f The font to set the sentence to.
public int getWordWrap();Retrieves the word-wrapping functionality.
Return Value:
Returns the word-wrapping functionality.
public void setWordWrap(int ww);Sets the word-wrapping functionality.
Return Value:
No return value.
Parameter Description ww The value to set.
public int getWidth();Retrieves the width of the entire buffer if it was one long string.
Return Value:
Returns the buffer width.
public int getHeight();Retrieves the height of the current font.
Return Value:
Returns the height of the current font.
public String getText();Retrieves the current text in the sentence.
Return Value:
Returns a string that contains the current text in the sentence.
public void setText(String s);Replaces the text in the sentence.
Return Value:
No return value.
Parameter Description s The string to replace the sentence with.
public void setText(char newBuff[], int offset, int len);Replaces the text in the sentence with that of a character array, starting at a specified offset.
Return Value:
No return value.
Parameter Description newBuff[] A character array. offset The specified offset. len The length of the character array.
public void setText(char newBuff[]);Replaces the text in the sentence with that of a character array.
Return Value:
No return value.
Parameter Description newBuff[] A character array.
public void setStartPoint(int x, int y);Sets the start point of the text.
Return Value:
No return value.
Parameter Description x The x coordinate of the start point. y The y coordinate of the start point. Remarks:
If there is no bounding box, this is the (x,y) position, and the text will be drawn relative to it via the alignment flags. If there is a bounding box, then the xy position is used to set the start point within the bounding box and the box is used for limiting the text. It is legal to set the xy point outside the bounding box, this means that the start of the text will be missing (not drawn).
public void setStartPoint(Point p);Sets the start point for the text.
Return Value:
No return value.
Parameter Description p The starting point for the text.
public Point getStartPoint();Retrieves the start point for drawing the text.
Return Value:
Returns the point where the text starts.
public void setStartPointAtOrigin();Resets the text start position to be the origin based on what the script requires.
Return Value:
No return value.
public Rectangle getBounding();Retrieves the current bounding box.
Return Value:
Returns the rectangle that is being used as the bounding box.
public Rectangle shrinkBound(boolean reset);Shrinks the bounding rectangle to be as small as possible and still contain all the text. This method is the same as DrawRect(DT_CALCRECT).
Return Value:
Returns the new bounding rectangle if reset is true.
Parameter Description reset If true, the bounding rectangle of the object will reflect the change; otherwise, the result will be returned but the bounding rectangle will not be updated. Remarks:
The direction of shrinkage will depend on the text direction (for example, the upper left corner is not guaranteed to remain at (0,0)).
public void setBounding(Rectangle r, boolean bRetainCurrPoint);Sets the bounding box. If there isn't a bounding box, the text is drawn in the same way as DrawText(DT_SINGLELINE).
Return Value:
No return value.
Parameter Description r The rectangle to set as the bounding box. bRetainCurrPoint If bRetainCurrPoint is false, the alignment is processed as in DrawText() and the currPoint is lost. If the alignments are set to scriptDefault, RTOL/TOB/, and so on, will be picked up. Remarks:
See the rules for setCurrPoint.
public void setTextDirection(int dir);Sets the text flow direction. The direction can either be one of the tdXXX values specified in textConstants or a value of 0.360 is an angle where 0 is "east."
Return Value:
No return value.
Parameter Description dir The direction that the text should flow.
public int getTextDirection();Retrieves the current text direction.
Return Value:
Returns the current text direction.
public void setHorizAlign(int h);Sets the horizontal alignment for the text.
Return Value:
No return value.
Parameter Description h The horizontal alignment.
public void setVertAlign(int v);Sets the vertical alignment for the text.
Return Value:
No return value.
Parameter Description v The vertical alignment.
public int getHorizAlign();Retrieves the horizontal alignment for the text.
Return Value:
Returns the horizontal alignment.
public int getVertAlign();Retrieves the vertical alignment for the text.
Return Value:
Returns the vertical alignment.
public void setOutline(IFxShape outline);Sets the outline for which the text will wrap around.
Return Value:
No return value.
Parameter Description outline The shape to use as the outline. Remarks:
When a shape is used, the parameters of the block change their meanings. The horizontal alignment is used as the reference of how to sit on the shape (left, center, and so on). The vertical alignment is whether the text sits above, on, or below the shape. Opaquing has no effect when a shape is in use. As a result, as it cannot be determined.
public IFxShape getOutline();Retrieves the outline.
Return Value:
Returns the shape that is used as the outline.
public void paint(FxGraphics g, int startPos, int length, int opaquing);Paints the selected characters in the text block.
Return Value:
No return value.
Parameter Description g The graphics object to use. startPos The starting position. length The length. opaquing Used only if the graphics object has a text background color set and the text has a bounding box. Can be a combination of the following values:
0 Don't opaque. 1 Opaque everything prior to the starting position. 2 Clean everything between StartPos and NextPos (that is, fill out the lines painted). 3 Opaque everything after NextPos.
public void paint(Graphics g);Paints the sentence.
Return Value:
No return value.
Parameter Description g The graphics object to use.
public Point getNextStartPoint();Retrieves the next position to draw after the text.
Return Value:
Returns the point that is the next position to draw after the text.
Remarks:
This method is useful for tying multiple sentences together and is used by the textParagraph class. Be aware that if the text ends on a CR, xyNext must point to the next line.
public boolean getKerning();Determines whether kerning is in use.
Return Value:
Returns true if kerning is used.
public void setKerning(boolean useKerning);Sets whether the text should use kerning when formatting.
Return Value:
No return value.
public boolean isDirty();Determines whether the text needs reformatting before anything can be done with it.
Return Value:
Returns true if there is a pending update for the text.
public void insert(char key, int iPos);Inserts a character into the buffer.
Return Value:
No return value.
Parameter Description key The character to insert. iPos The position in the buffer where the character is to be inserted.
public void insert(char key[], int iPos);Inserts a character into the buffer.
Return Value:
No return value.
Parameter Description key The array of characters to insert. iPos The position where the characters are to be inserted.
public void insert(char key[], int offs, int len, int iPos);Inserts an array of characters into the buffer.
Return Value:
No return value.
Parameter Description key The array of characters to insert. offs The specified offset. len The length of the character array. iPos The position in the buffer where the characters are to be inserted.
public void remove(int iPos, int numberToRemove);Deletes a character.
Return Value:
No return value.
Parameter Description iPos The starting position of the characters to remove. numberToRemove The number of characters to remove.
public int getOffsetFromPos(int scrnX, int scrnY, int flags);Retrieves the offset of the character nearest to the point requested.
Return Value:
Returns offset if successful; otherwise, returns -1.
Parameter Description scrnX The x coordinate of the location to check. scrnY The y coordinate of the location to check. flags The flags controlling the method. Remarks:
Used by the Edit class to find what character is nearest the caret. The flags are the same as those for opaquing drawing. If there are dy arrays, this will fail. A failure is signified by returning -1. If a failure occurs, use getClosesetOffset.
public boolean isBodyLocationDetermined();Checks if there definable start, body, and end screen positions.
Return Value:
Returns true if there is a definable start, body, and end screen positions.
Remarks:
This method will be false of dy is defined anywhere, and so can we find exactly which character is nearest the caret.
public Point getScrnLocation(int index);Finds the location of a particular character.
Return Value:
Returns the point where the character is located.
Parameter Description index The character to look for.
public Point getClosestOffset(int scrnX, int scrnY);Finds the closest character to the screen location.
Return Value:
Returns the point where the closest character was found.
Parameter Description scrnX The x coordinate of the screen location. scrnY The y coordinate of the screen location. Remarks:
The point returned contains x = offset idx into the buffer. y = match param (x-x1)2 + (y-y1)2 (this is returned so all formats in a UIEDIT get the chance to pick the character position).
public int getLocale();Retrieves the locale that the text is based on.
Return Value:
Returns the locale.
public void setPasswordChar(char c);Sets the character echoed when password text is entered.
Return Value:
No return value.
Parameter Description c The character to use.
public boolean getMnemonicDrawing();Determine whether text is using underlines for hot key tracking.
Return Value:
Returns true if underlines are being set.
public void setMnemonicDrawing(boolean mnem);Sets whether the text displays underlines for hot key tracking.
Return Value:
No return value.
Parameter Description mnem Set to true to enable mnemonic drawing.
public void setLocale(int locale);Sets the locale for the text.
Return Value:
No return value.
Parameter Description locale The locale. Remarks:
This method determines which locale handler is used for formatting, word-breaking, and other operations.
© 1997 Microsoft Corporation. All rights reserved. Legal Notices.