Package com.ms.ui Previous
Previous
Contents
Contents
Index
Index
Next
Next

Class UIDrawText

Constructors , Methods

public class UIDrawText extends UICanvas implements IFxTextConstants
{
  // Constructors
  public UIDrawText();
  public UIDrawText(String newBuff);
  public UIDrawText(char newBuff[]);

  // Methods
  public void createCaret();
  public void destroyCaret();
  public void hideCaret();
  public void moveCaret(int idx);
  public void showCaret();
  public void showCaret(int iPos);

  protected int eoln(int idx);
  public int length();
  public void selectAll();

  public boolean isAutoResizable();
  public boolean isBordered();
  public boolean isSingleLine();

  public Graphics getCachedGraphics();
  public int getCharFromScreen(int scrnX, int scrnY);
  public int getCharFromScreen(Point scrnPos);
  public Point getCharLocation(int iPos);
  public int getCurrIndex();
  public IFxShape getOutline();
  public char getPasswordChar();
  public String getSelectedText();
  public int getSelectionEnd();
  public int getSelectionStart();
  public Point getStartPoint();
  public String getText();
  protected int getWordEdge(int iPos, boolean pleaseMoveLeft, 
                            boolean givePrevious);
  public int getWordWrap();

  public void setAutoResize(boolean auto);
  public void setBackground(Color c);
  public void setBorder(boolean b);
  public void setCurrIndex(int idx, boolean showCaretNow);
  public void setFont(Font f);
  public void setFont(Font f, int min, int max);
  public void setForeground(Color c);
  public void setHorizAlign(int h);
  public void setOutline(IFxShape outline);
  public void setPasswordChar(char c);
  public void setRefresh(boolean r);
  public void setSelection(int selStart, int selEnd); 
  public void setSingleLine(boolean sl);
  public void setText(String s);
  public void setText(char newBuff[], int offset, int len);
  public void setVertAlign(int v);
  public void setWordWrap(int ww);

  public void ensureNotDirty(FxGraphics g);
  public boolean ensureVisible(int idx); 
  public boolean ensureVisible(Point p);
  public boolean ensureVisible(Rectangle r);
  public Dimension minimumSize();
  public Dimension preferredSize();
  public void paint(Graphics g);
  protected void paint(FxGraphics g, int startPos, int endPos);
  public void reshape(int x, int y, int width, int height);
  public void resize(int width, int height);

  public boolean gotFocus(Event  evt, Object  what);
  public boolean lostFocus(Event  evt, Object  what);
  public boolean keyDown(Event  evt, int  key);
  public boolean mouseDown(Event  evt, int  x, int  y);
  public boolean mouseDrag(Event  evt, int  x, int  y);

}

A class that manages the display of read-only text. Although the text cannot be changed through user interaction, it can be changed programmatically. Use UIEdit to allow the user to edit the control.


Constructors


UIDrawText

public UIDrawText();

Creates an empty read-only text control.


UIDrawText

public UIDrawText(String newBuff);

Creates a read-only text control based on the specified string.

ParameterDescription
newBuff The text for the control.


UIDrawText

public UIDrawText(char newBuff[]);

Creates a read-only text control based on the specified char buffer.

ParameterDescription
newBuff Contains the text for the control.


Methods


createCaret

public void createCaret();

Creates a caret for the control and displays it at the current position.

Return Value:

No return value.


destroyCaret

public void destroyCaret();

Destroys the caret.

Return Value:

No return value.


ensureNotDirty

public void ensureNotDirty(FxGraphics g);

Updates all text blocks.

Return Value:

No return value.

ParameterDescription
g A Graphics object to which the control will paint itself.


ensureVisible

public boolean ensureVisible(int idx);
   

Ensures that a character index is visible and scrolls the control, if necessary.

Return Value:

Returns true if the method was successful or false otherwise.

ParameterDescription
idx Index of the character that will be made visible.


ensureVisible

public boolean ensureVisible(Point p);   

Ensures that a position in the control is visible and scrolls the control, if necessary.

Return Value:

Returns true if the method was successful or false otherwise.

ParameterDescription
p Client coordinates that will be made visible.


ensureVisible

public boolean ensureVisible(Rectangle r);
   

Ensures that a specified rectangle is visible and resizes the control, if necessary.

Return Value:

Returns true if the method was successful or false otherwise.

ParameterDescription
r A Rectangle object that contains the desired rectangle.


eoln

protected int eoln(int idx);

Retrieves the end of line character index for a line.

Return Value:

Returns the character index of the end of line. This is where the caret would be placed if it were at the end of the line.

ParameterDescription
idx Index of a character on the line in question.


getCachedGraphics

public Graphics getCachedGraphics(); 
   

Retrieves the Graphics object for the control.

Return Value:

Returns the control's Graphics object.


getCharFromScreen

public int getCharFromScreen(int scrnX, int scrnY);

Retrieves the character at the specified position.

Return Value:

Returns the index of the character at the specified position. If there is no character at that position, the character returned will be the last one on the nearest line.

ParameterDescription
scrnX Specifies the x client coordinate, in pixels.
scrnY Specifies the y client coordinate, in pixels.


getCharFromScreen

public int getCharFromScreen(Point scrnPos);

Retrieves the character at the specified position.

Return Value:

Returns the index of the character at the specified position. If there is no character at that position, the character returned will be the last one on the nearest line.

ParameterDescription
scrnPos Specifies the client coordinates, in pixels.


getCharLocation

public Point getCharLocation(int iPos);

Retrieves the position that the character would be drawn at if drawn alone. This is typically used for placing the caret.

Return Value:

A point.

Return Value:

Returns a Point that contains the client coordinates of the character.

ParameterDescription
iPos Index of the character to query.


getCurrIndex

public int getCurrIndex();

Retrieves the current caret position.

Return Value:

Returns the character index where the caret is located.


getOutline

public IFxShape getOutline();

Retrieves the outline of the control.

Return Value:

Returns an IFxShape object that specifies the outline.


getPasswordChar

public char getPasswordChar();

Retrieves the character that the control displays for password characters.

Return Value:

Returns the character that the control displays for password characters.


getSelectedText

public String getSelectedText(); 
   

Retrieves the selected text in the control.

Return Value:

Returns a String object that contains the selected text of the control.


getSelectionEnd

public int getSelectionEnd(); 
   

Retrieves the ending point of the selection.

Return Value:

Returns the character index of the ending point of the selection.


getSelectionStart

public int getSelectionStart(); 
   

Retrieves the starting point of the selection.

Return Value:

Returns the character index of the starting point of the selection.


getStartPoint

public Point getStartPoint();

Retrieves the drawing start point of the control.

Return Value:

A Point object that specifies the drawing start point of the control.


getText

public String getText();

Retrieves the text in the control.

Return Value:

Returns a String object that contains the text of the control.


getWordEdge

protected int getWordEdge(int iPos, boolean pleaseMoveLeft, boolean givePrevious);

Searches for and retrieves the character index of the first or last character in a word.

Return Value:

Returns the index of the first or the last character of the word, depending upon givePrevious.

ParameterDescription
iPos Specifies the position where the search should start.
pleaseMoveLeft Specifies the direction of the search. If true, the search will be to the left of iPos. If false, the search will be to the right of iPos.
givePrevious Specifies if the index of the beginning or end of the word will be returned. If true, the index of the first character will be returned. If false, the index of the last character will be returned.


getWordWrap

public int getWordWrap();

Retrieves the word wrapping style.

Return Value:

Returns the word wrapping style. This is a combination of one or more of the ww values of the IFxTextConstants.


gotFocus

public boolean gotFocus(Event evt, Object what);

Called when the component receives the input focus.

ParameterDescription
evt An Event object that specifies the event.
what The Object that previously had the focus.


hideCaret

public void hideCaret();

Hides the caret.

Return Value:

No return value.


isAutoResizable

public boolean isAutoResizable();

Retrieves the control's auto resize attribute.

Return Value:

Returns true if the control is auto re-sizable or false otherwise.


isBordered

public boolean isBordered();

Retrieves the control's border attribute.

Return Value:

Returns true if the control is bordered or false if the control is not bordered.


isSingleLine

public boolean isSingleLine();

Retrieves the control's multi-line attribute.

Return Value:

Returns true if the control is multi-line or false if the control is single-line.


keyDown

public boolean keyDown(Event  evt, int  key);

Processes a key down event.

Return Value:

Returns true if the event was handled by the method; otherwise, returns false.

ParameterDescription
evt An Event object that specifies the event.
key Specifies the key that the event occurred for.


length

public int length();

Retrieves the length of the text in the control.

Return Value:

Returns the number of characters in the control.


lostFocus

public boolean lostFocus(Event  evt, Object  what);

Called when the component loses the input focus.

ParameterDescription
evt An Event object that specifies the event.
what The Object that is gaining the focus.


minimumSize

public Dimension minimumSize(); 
   

Retrieves the minimum size of the control.

Return Value:

Returns a Dimension object that contains the minimum size of the control.

See Also: preferredSize, LayoutManager


mouseDown

public boolean mouseDown(Event  evt, int  x, int  y);

Processes a mouse down event.

Return Value:

Returns true if the event was handled by the method or false otherwise.

ParameterDescription
evt An Event object that specifies the .
x Specifies the x coordinate where the mouse event occurred.
y Specifies the y coordinate where the mouse event occurred.


mouseDrag

public boolean mouseDrag(Event  evt, int  x, int  y);

Processes a mouse drag event.

Return Value:

Returns true if the event was handled by the method or false otherwise.

ParameterDescription
evt An Event object that specifies the event.
x Specifies the x coordinate where the mouse event occurred.
y Specifies the y coordinate where the mouse event occurred.


moveCaret

public void moveCaret(int idx);

Positions the caret at the specified character index.

Return Value:

No return value.

ParameterDescription
idx Character index where the caret should be placed.


paint

public void paint(Graphics g);

Causes the control to paint itself.

Return Value:

No return value.

ParameterDescription
g A Graphics object to which the control will paint itself.


paint

protected void paint(FxGraphics g, int startPos, int endPos);

Causes the control to paint a portion of text.

Return Value:

No return value.

ParameterDescription
g A Graphics object to which the control will paint itself.
startPos Specifies the starting character index.
endPos Specifies the ending character index.


preferredSize

public Dimension preferredSize(); 
   

Retrieves the preferred size of the control.

Return Value:

Returns a Dimension object that contains the preferred size of the control.

See Also: minimumSize, LayoutManager


reshape

public void reshape(int x, int y, int width, int height);

Moves and sizes the control.

Return Value:

No return value.

ParameterDescription
x Specifies the horizontal position of the control, in pixels, relative to its parent.
y Specifies the vertical position of the control, in pixels, relative to its parent.
width Specifies the width of the control, in pixels.
height Specifies the height of the control, in pixels.


resize

public void resize(int  width, int  height);

Sizes the control, but does not move it.

Return Value:

No return value.

ParameterDescription
width Specifies the width of the control, in pixels.
height Specifies the height of the control, in pixels.


selectAll

public void selectAll(); 
   

Selects all of the text in the control.

Return Value:

No return value.


setAutoResize

public void setAutoResize(boolean auto);

Sets the control's auto resize attribute.

Return Value:

No return value.

ParameterDescription
auto True if the control's bounding box will adjust to the size of the control if it is resized or reshaped or false otherwise.


setBackground

public void setBackground(Color c);

Sets the background color of the control.

Return Value:

No return value.

ParameterDescription
c A Color object that specifies the background color.


setBorder

public void setBorder(boolean b);

Sets the control's border attribute.

Return Value:

No return value.

ParameterDescription
b True if the control becomes bordered or false if the control becomes not bordered.


setCurrIndex

public void setCurrIndex(int idx, boolean showCaretNow);

Sets the current caret position and, optionally, shows it.

Return Value:

No return value.

ParameterDescription
idx Character index where the caret should be placed.
showCaretNow True if the caret should be shown or false if the caret should remain in its current display state.


setFont

public void setFont(Font f);

Sets the font for the current selection. If no selection is present, sets the font for all of the text.

Return Value:

No return value.

ParameterDescription
f A Font object that specifies the font.


setFont

public void setFont(Font f, int min, int max);

Sets the font for a block of text.

Return Value:

No return value.

ParameterDescription
f A Font object that specifies the font for the block.
min Specifies the starting index of the block. This must be greater than or equal to max.
max Specifies the ending index of the block. This must be less than or equal to min.


setForeground

public void setForeground(Color c);

Sets the text color of the control.

Return Value:

No return value.

ParameterDescription
c A Color object that specifies the text color.


setHorizAlign

public void setHorizAlign(int h);

Sets the horizontal alignment.

Return Value:

No return value.

ParameterDescription
h One of the hta values of the IFxTextConstants.


setOutline

public void setOutline(IFxShape outline);

Sets the outline of the control.

Return Value:

No return value.

ParameterDescription
outline An IFxShape object that specifies the outline.


setPasswordChar

public void setPasswordChar(char c);

Sets the character that the control displays for password characters.

Return Value:

No return value.

ParameterDescription
c Specifies the character that will be displayed in place of password characters. If this value is zero, the password character is cleared.


setRefresh

public void setRefresh(boolean r);

Sets the refresh flag.

Return Value:

No return value.

ParameterDescription
r If true, the control will update itself whenever a parameter is changed. If false, the control will not update itself.

Remarks:

Normally, when a parameter is changed an update will take place immediately. If you want to update multiple parameters, set the refresh to false, make all of the changes and then set it back to true.


setSelection

public void setSelection(int selStart, int selEnd); 
   

Sets the current selection to the specified start and end indexes.

Return Value:

No return value.

ParameterDescription
selStart The starting index of the selection.
selEnd The ending index of the selection.


setSingleLine

public void setSingleLine(boolean sl);

Changes the control's multi-line attribute.

Return Value:

No return value.

ParameterDescription
sl Specifies if the control is multi-line or not. If true, the control becomes multi-line. If false, the control becomes single-line.


setText

public void setText(String s);

Sets the text in the control.

Return Value:

No return value.

ParameterDescription
s A String object that specifies the new text.


setText

public void setText(char newBuff[], int offset, int len);

Replaces the text in the sentence.

Replace the text in the sentence based on an array of characters passed in.

ParameterDescription
newBuff The array of characters to base the new sentence on.
offset The offset to use.
length The length of the array used.


setVertAlign

public void setVertAlign(int v);

Sets the vertical alignment.

Return Value:

No return value.

ParameterDescription
v One of the vta values of the IFxTextConstants.


setWordWrap

public void setWordWrap(int ww);

Sets the word wrapping style.

Return Value:

No return value.

ParameterDescription
ww A combination of one or more of the ww values of the IFxTextConstants.


showCaret

public void showCaret();

Shows the caret at the current position.

Return Value:

No return value.


showCaret

public void showCaret(int iPos);

Positions the caret at the specified position and shows it.

Return Value:

No return value.

ParameterDescription
iPos Character index where the caret should be placed.



Top© 1997 Microsoft Corporation. All rights reserved. Legal Notices.