home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / jfc.bin / Caret.java < prev    next >
Text File  |  1998-02-26  |  5KB  |  185 lines

  1. /*
  2.  * @(#)Caret.java    1.20 98/01/27
  3.  * 
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  */
  20. package com.sun.java.swing.text;
  21.  
  22. import java.awt.Graphics;
  23. import java.awt.Point;
  24. import com.sun.java.swing.Action;
  25. import com.sun.java.swing.event.ChangeListener;
  26.  
  27. /**
  28.  * A place within a document view that represents where
  29.  * things can be inserted into the document model.  It gives a 
  30.  * way to navigate through the document view while abstracting
  31.  * away the details of how the view is arranged.  This can
  32.  * be useful because some views may filter out portions of
  33.  * the associated model, and some views may not allow navigation
  34.  * in certain areas such as read-only areas.
  35.  *
  36.  * @author  Timothy Prinzing
  37.  * @version 1.20 01/27/98
  38.  */
  39. public interface Caret {
  40.  
  41.     /**
  42.      * Called when the UI is being installed into the
  43.      * interface of a JTextComponent.  This can be used
  44.      * to gain access to the model that is being navigated
  45.      * by the implementation of this interface. 
  46.      *
  47.      * @param c the JTextComponent
  48.      */
  49.     public void install(JTextComponent c);
  50.  
  51.     /**
  52.      * Called when the UI is being removed from the
  53.      * interface of a JTextComponent.  This is used to 
  54.      * unregister any listeners that were attached.
  55.      *
  56.      * @param c the JTextComponent
  57.      */
  58.     public void deinstall(JTextComponent c);
  59.  
  60.     /**
  61.      * Renders the caret.
  62.      *
  63.      * @param g the graphics context
  64.      */
  65.     public void paint(Graphics g);
  66.  
  67.     /**
  68.      * Adds a listener to track whenever the caret position
  69.      * has been changed.
  70.      *
  71.      * @param l the change listener
  72.      */
  73.     public void addChangeListener(ChangeListener l);
  74.  
  75.     /**
  76.      * Removes a listener that was tracking caret position changes.
  77.      *
  78.      * @param l the change listener
  79.      */
  80.     public void removeChangeListener(ChangeListener l);
  81.  
  82.     /**
  83.      * Determines if the caret is currently visible.
  84.      *
  85.      * @return true if the caret is visible else false
  86.      */
  87.     public boolean isVisible();
  88.  
  89.     /**
  90.      * Sets the visibility of the caret.
  91.      *
  92.      * @param v  true if the caret should be shown,
  93.      *  and false if the caret should be hidden
  94.      */
  95.     public void setVisible(boolean v);
  96.  
  97.     /**
  98.      * Determines if the selection is currently visible.
  99.      *
  100.      * @return true if the caret is visible else false
  101.      */
  102.     public boolean isSelectionVisible();
  103.  
  104.     /**
  105.      * Sets the visibility of the selection
  106.      *
  107.      * @param v  true if the caret should be shown,
  108.      *  and false if the caret should be hidden
  109.      */
  110.     public void setSelectionVisible(boolean v);
  111.  
  112.     /**
  113.      * Saves the current caret position.  This is used when 
  114.      * caret up or down actions occur, moving between lines
  115.      * that have uneven end positions.
  116.      *
  117.      * @param p  the Point to use for the saved position
  118.      */
  119.     public void setMagicCaretPosition(Point p);
  120.  
  121.     /**
  122.      * Gets the current caret position. 
  123.      *
  124.      * @return the position
  125.      * @see #setMagicCaretPosition
  126.      */
  127.     public Point getMagicCaretPosition();
  128.  
  129.     /**
  130.      * Sets the blink rate of the caret.  This determines if
  131.      * and how fast the caret blinks, commonly used as one
  132.      * way to attract attention to the caret.
  133.      *
  134.      * @param rate  the delay in milliseconds.  If this is
  135.      *  zero the caret will not blink.
  136.      */
  137.     public void setBlinkRate(int rate);
  138.  
  139.     /**
  140.      * Gets the blink rate of the caret.  This determines if
  141.      * and how fast the caret blinks, commonly used as one
  142.      * way to attract attention to the caret.
  143.      *
  144.      * @returns the delay in milliseconds.  If this is
  145.      *  zero the caret will not blink.
  146.      */
  147.     public int getBlinkRate();
  148.  
  149.     /**
  150.      * Fetches the current position of the caret.
  151.      *
  152.      * @return the position
  153.      */
  154.     public int getDot();
  155.  
  156.     /**
  157.      * Fetches the current position of the mark.  If there
  158.      * is a selection, the mark will not be the same as
  159.      * the dot.
  160.      *
  161.      * @return the position
  162.      */
  163.     public int getMark();
  164.  
  165.     /**
  166.      * Sets the caret position to some position.  This
  167.      * causes the mark to become the same as the dot,
  168.      * effectively setting the selection range to zero.
  169.      *
  170.      * @param dot  the new position to set the caret to
  171.      */
  172.     public void setDot(int dot);
  173.  
  174.     /**
  175.      * Moves the caret position to some other position,
  176.      * leaving behind the mark.  This is useful for
  177.      * making selections.
  178.      *
  179.      * @param dot  the new position to move the caret to
  180.      */
  181.     public void moveDot(int dot);
  182.  
  183. };
  184.     
  185.