home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 39 / IOPROG_39.ISO / SOFT / sdkjava40.exe / data1.cab / fg_Samples / Samples / afc11 / JNotepad / src / ITextOperationTargetExt.java < prev    next >
Encoding:
Java Source  |  2000-05-04  |  7.7 KB  |  291 lines

  1. //
  2. // (C) Copyright 1995 - 1999 Microsoft Corporation.  All rights reserved.
  3. //
  4. import com.ms.ui.event.*;
  5. import java.awt.*;
  6. import com.ms.fx.*;
  7.  
  8. /**
  9. *    Extends ITextOperationTarget to add some methods that are specific to
  10. *    objects which act like edit controls. Use this if you have a class which handles
  11. *    the generic text operations in ITextOperationTarget but also acts more
  12. *    like an edit control. Using this interface allows one to use edit controls
  13. *    without relying on a specific class -- one can plug in another class which uses
  14. *    this same interface, and things should work without a problem.
  15. *
  16. *    @see    ITextOperationTarget
  17. *
  18. *    @version    1.0, 7/15/97
  19. */
  20.  
  21. public interface ITextOperationTargetExt extends ITextOperationTarget
  22. {
  23.     /**
  24.     *    Sets the text in the object.
  25.     *
  26.     *    @param text    String containing the new text.
  27.     */
  28.     public void setText(String text);
  29.     
  30.     /**
  31.     *    Returns the text in the object.
  32.     *
  33.     *    @returns String    text contained in the object.
  34.     */
  35.     public String getText();
  36.     
  37.     /**
  38.     *    Inserts text at the given character offset from the beginning of 
  39.     *    the object's text.
  40.     *
  41.     *    @param    text    Text to insert
  42.     *    @param    iPos    Zero-based character offset (from the beginning of the
  43.     *                        object's text) to insert the text at.
  44.     */
  45.     public void insertText(String text, int iPos);
  46.     
  47.     /**
  48.     *    Appends text to the end of the object's text.
  49.     *
  50.     *    @param    text    String to append
  51.     */
  52.     public void appendText(String text);
  53.     
  54.     /**
  55.     *    Retrieves the font used in the object.
  56.     *
  57.     *    @returns    Font object used in the object's text field.
  58.     */
  59.     public Font getFont();
  60.     
  61.     /**
  62.     *    Sets the background color.
  63.     *    
  64.     *    @param    color    Color to set the background to.
  65.     */
  66.     public void setTextColor(FxColor color);
  67.     
  68.     /**
  69.     *    Sets the foreground color.
  70.     *    
  71.     *    @param    color    Color to set the foreground to.
  72.     */
  73.     public void setBackColor(FxColor color);    
  74.     
  75.     /**
  76.     *    Retrieves the foreground color.
  77.     *    
  78.     *    @returns    Color of the foreground.
  79.     */
  80.     public FxColor getTextColor();    
  81.     
  82.     /**
  83.     *    Retrieves the background color.
  84.     *    
  85.     *    @returns    Color of the background.
  86.     */
  87.     public FxColor getBackColor();
  88.     
  89.     /**
  90.     *    Pastes text from the clipboard at the current position in the object's
  91.     *    text field.
  92.     *
  93.     *    @param    text    String to paste into the object
  94.     */
  95.     public void paste(String text);
  96.     
  97.     
  98.     /**
  99.     *    Retrieves the character indexed position of the caret.
  100.     *
  101.     *    @returns    zero-based index into the object's text.
  102.     */
  103.     public int getCaretIndex();
  104.     
  105.     /**
  106.      *    Moves the caret.
  107.      *
  108.      *    @param    idx    Zero-based character index to move the caret to.
  109.      */
  110.     public void moveTheCaret(int idx);
  111.     
  112.     /**
  113.     *    Retrieves the beginning index of selected text.    
  114.     *
  115.     *    @returns    the zero-based index where selection begins. If there is no
  116.     *                    selected text, this value is equal to the that returned
  117.     *                    by getSelectionEnd()
  118.     */
  119.     public int getSelectionStart();
  120.     
  121.     /**
  122.     *    Retrieves the ending index of selected text.    
  123.     *
  124.     *    @returns    the zero-based index where selection ends. If there is no
  125.     *                    selected text, this value is equal to the that returned
  126.     *                    by getSelectionStart()
  127.     */    
  128.     public int getSelectionEnd();
  129.     
  130.     /**
  131.     *    Sets the selected text to the given range.
  132.     *
  133.     *    @param    selStart    the zero-based index which marks the beginning of the text to be selected
  134.     *    @param    selEnd        the zero-based index which marks the end of the text to be selected
  135.     */
  136.     public void setSelection(int selStart, int selEnd);
  137.     
  138.     /**
  139.     *    Retrieves the window coordinates of the character at the given position.
  140.     *
  141.     *    @param    iPos    The zero-based index of the character
  142.     *    @returns    The control-relative coordinates of the character.
  143.     */
  144.     public Point getCharLocation(int iPos);
  145.     
  146.     /**
  147.     *    Retrieves the character index closest to the given point.
  148.     *
  149.     *    @param    scrnPos    Point at which to find the character position
  150.     *    @returns    The index of the character at the given point.
  151.     */
  152.     public int getCharFromScreen(Point scrnPos);
  153.     
  154.     /**
  155.     *    Checks if the previous action can be undone.
  156.     *    
  157.     *    @returns    true if the previous action can be undone, false if not
  158.     */
  159.     public boolean isUndoable();
  160.     
  161.     /**
  162.     *    Checks if the previous undo can be redone.
  163.     *    
  164.     *    @returns    true if the previous undo can be redone, false if not
  165.     */
  166.     public boolean isRedoable();
  167.     
  168.     /**
  169.     *    Adds a Key listener object (one which implements IUIKeyListener)
  170.     *    to the ITextOperationTargetExt object.
  171.     *
  172.     *    @param    l    The object which will listen to key events from this object.
  173.     */
  174.     public void addKeyListener(IUIKeyListener l);
  175.     
  176.     /**
  177.     *    Removes the Key listener object from the ITextOperationTargetExt object.
  178.     *
  179.     *    @param    l    The object to remove a key listener from.
  180.     */
  181.     public void removeKeyListener(IUIKeyListener l);
  182.     
  183.     /**
  184.     *    Adds a Mouse listener object (one which implements IUIMouseListener)
  185.     *    to the ITextOperationTargetExt object.
  186.     *
  187.     *    @param    l    The object which will listen to Mouse events from this object.
  188.     */    
  189.     public void addMouseListener(IUIMouseListener l);
  190.     
  191.     /**
  192.     *    Removes the Mouse listener object from the ITextOperationTargetExt object.
  193.     *
  194.     *    @param    l    The object to remove a Mouse listener from.
  195.     */
  196.     public void removeMouseListener(IUIMouseListener l);
  197.     
  198.     /**
  199.     *    Adds a MouseMotion listener object (one which implements IUIMouseMotionListener)
  200.     *    to the ITextOperationTargetExt object.
  201.     *
  202.     *    @param    l    The object which will listen to MouseMotion events from this object.
  203.     */    
  204.     public void addMouseMotionListener(IUIMouseMotionListener l);
  205.     
  206.     /**
  207.     *    Removes the MouseMotion listener object from the ITextOperationTargetExt object.
  208.     *
  209.     *    @param    l    The object to remove a MouseMotion listener from.
  210.     */
  211.     public void removeMouseMotionListener(IUIMouseMotionListener l);
  212.     
  213.     /**
  214.     *    Adds a Action listener object (one which implements IUIActionListener)
  215.     *    to the ITextOperationTargetExt object.
  216.     *
  217.     *    @param    l    The object which will listen to Action events from this object.
  218.     */
  219.     public void addActionListener(IUIActionListener l);
  220.     
  221.     /**
  222.     *    Removes the Action listener object from the ITextOperationTargetExt object.
  223.     *
  224.     *    @param    l    The object to remove an Action listener from.
  225.     */
  226.     public void removeActionListener(IUIActionListener l);
  227.     
  228.     /**
  229.     *    Adds a Text listener object (one which implements IUITextListener)
  230.     *    to the ITextOperationTargetExt object.
  231.     *
  232.     *    @param    l    The object which will listen to Text events from this object.
  233.     */    
  234.     public void addTextListener(IUITextListener l);
  235.     
  236.     /**
  237.     *    Removes the Text listener object from the ITextOperationTargetExt object.
  238.     *
  239.     *    @param    l    The object to remove a Text listener from.
  240.     */    
  241.     public void removeTextListener(IUITextListener l);
  242.     
  243.     
  244.     /**
  245.     *    Sends an Event message to the object.
  246.     *
  247.     *    @param    evt    The Event object to send
  248.     *    @returns    if false, event is posted to object's parent.
  249.     */
  250.     public boolean postEvent(Event evt);
  251.     
  252.     /**
  253.     *    Sets the object to be read only
  254.     *
  255.     *    @param    ro    true if the file is to be set to read only, false if it is to be writable
  256.     */
  257.     public void setReadOnly(boolean ro);
  258.     
  259.     /**
  260.     *    Checks if the object is read only    
  261.     *    
  262.     *    @returns    true if the object is read only, false if not
  263.     */
  264.     public boolean isReadOnly();
  265.     
  266.     /**
  267.     *    Sets the ICommandFeedback object for this object. ICommandFeedback objects
  268.     *    are used to disable user commands.
  269.     *
  270.     *    @see    ICommandFeedback
  271.     *    @param    ICommandFeedback object to attach to this object
  272.     */
  273.     public void setFeedbackObject(ICommandFeedback compFeedback);
  274.     
  275.     /**
  276.     *    Sets the IComponentFeature object for this object. IComponentFeature objects
  277.     *    are used to handle user commands.
  278.     *
  279.     *    @see    IComponentFeature
  280.     *    @param    IComponentFeature object to attach to this object
  281.     */
  282.     public void setCommandObject(IComponentFeature compfeature);
  283.     
  284.     
  285.     /**
  286.     *    Redraws the object.
  287.     */
  288.     public void repaint();    
  289. }
  290.  
  291.