001package org.vishia.gral.ifc;
002
003/**This is the interface to all widgets which represents a simple text.
004 * @author Hartmut Schorrig
005 *
006 */
007public interface GralTextField_ifc extends GralWidget_ifc
008{
009  
010  /**Version and history
011   * <ul>
012   * <li>2012-01-17 new {@link #setSelection(String)}. The possible values of the string parameter are not defined well yet.
013   *   The method is only used to show a text right aligned. 
014   * <li>2011-12-11 chg {@link #setText(CharSequence)} now uses CharSequence instead String. 
015   *   A CharSequence is more universal. Internally the contained String will be copied.
016   * <li>2011-12-01 new {@link #getCursorPos()}, to get parts of selected texts in a box.
017   *   It is used for commands in the output window for JavaCommander.
018   * <li>2011-09-00 created, universal access to textual kind fields.
019   * </ul>
020   * 
021   * 
022   * <b>Copyright/Copyleft</b>:<br>
023   * For this source the LGPL Lesser General Public License,
024   * published by the Free Software Foundation is valid.
025   * It means:
026   * <ol>
027   * <li> You can use this source without any restriction for any desired purpose.
028   * <li> You can redistribute copies of this source to everybody.
029   * <li> Every user of this source, also the user of redistribute copies
030   *    with or without payment, must accept this license for further using.
031   * <li> But the LPGL is not appropriate for a whole software product,
032   *    if this source is only a part of them. It means, the user
033   *    must publish this part of source,
034   *    but doesn't need to publish the whole source of the own product.
035   * <li> You can study and modify (improve) this source
036   *    for own using or for redistribution, but you have to license the
037   *    modified sources likewise under this LGPL Lesser General Public License.
038   *    You mustn't delete this Copyright/Copyleft inscription in this source file.
039   * </ol>
040   * If you intent to use this source without publishing its usage, you can get
041   * a second license subscribing a special contract with the author. 
042   * 
043   * @author Hartmut Schorrig = hartmut.schorrig@vishia.de
044   */
045  public static final int version = 20120303;
046
047  
048  /**Set the textual content of the widget. This method is able to call in any thread. 
049   * The text may be stored in a queue and applied to the widget in the graphical thread.
050   * @param text The content
051   */
052  void setText(CharSequence text);
053  
054  /**Sets the textual content and show it with the given caret position.
055   * It is adequate {@link #setText(CharSequence)} if caretPos = 0.
056   * @param text The text to show in the widget.
057   * @param caretPos 0 for left, -1 for right, 0 to Integer.MAXINT for a given position.
058   *   If the caret position is greater then the number of chars, it is set right.
059   *   That character which is left from the caret position is shown guaranteed in the text field.
060   *   Especially -1 can be given to show the text right-aligned.
061   */
062  void setText(CharSequence text, int caretPos);
063  
064  /**Returns the text of this field. Returns always a valid String object, "" if the text was never set. */
065  String getText();
066  
067  int getCursorPos();
068  
069  int setCursorPos(int pos);
070  
071  /**Sets the style of all new set and added texts. The content contained in the text field or box are not changed.
072   * @param color
073   * @param font
074   */
075  void setTextStyle(GralColor color, GralFont font);
076  
077  
078  
079  /**Sets the selection of the text.
080   * <ul>
081   * <li>|..< from left to rigth, right aligned
082   * <li>TODO
083   * </ul>
084   * @param how
085   */
086  //void setSelection(String how);
087  
088}