/* 
 * AT-SPI - Assistive Technology Service Provider Interface 
 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
 *
 * Copyright 2001 Sun Microsystems, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

module Accessibility {

  enum TEXT_BOUNDARY_TYPE {
    TEXT_BOUNDARY_CHAR,
    TEXT_BOUNDARY_WORD_START,
    TEXT_BOUNDARY_WORD_END,
    TEXT_BOUNDARY_SENTENCE_START,
    TEXT_BOUNDARY_SENTENCE_END,
    TEXT_BOUNDARY_LINE_START,
    TEXT_BOUNDARY_LINE_END
  };

  /**
   * TEXT_CLIP_TYPE:
   * CLIP_MIN means text clipped by min coordinate is omitted,
   * CLIP_MAX clips text interescted by the max coord, and CLIP_BOTH
   * will retain only text falling fully within the min/max bounds.
   *
   **/
  enum TEXT_CLIP_TYPE {
    TEXT_CLIP_NONE,
    TEXT_CLIP_MIN,
    TEXT_CLIP_MAX,
    TEXT_CLIP_BOTH
  };

  interface Text : Bonobo::Unknown {

    struct Range {
      long startOffset;
      long endOffset; 
      string content;
      any  data;
    };
    
    typedef sequence<Range> RangeList;
    
    readonly attribute long characterCount;
    readonly attribute long caretOffset;
    string getText (in long startOffset, in long endOffset);
    boolean setCaretOffset (in long offset);
    string getTextBeforeOffset (in long offset, in TEXT_BOUNDARY_TYPE type,
				out long startOffset, out long endOffset);
    string getTextAtOffset (in long offset, in TEXT_BOUNDARY_TYPE type,
			    				out long startOffset, out long endOffset);
    string getTextAfterOffset (in long offset, in TEXT_BOUNDARY_TYPE type,
			       				out long startOffset, out long endOffset);
    unsigned long getCharacterAtOffset (in long offset);  /* long instead of wchar, 
							   * to allow unicode chars > 16 bits 
							   */
    string getAttributes (in long offset,
			  out long startOffset, out long endOffset);
    void getCharacterExtents (in long offset, out long x, out long y, out long width, out long height, in short coordType);
    long getOffsetAtPoint (in long x, in long y, in short coordType);
    long getNSelections ();
    void getSelection (in long selectionNum, out long startOffset, out long endOffset);
    boolean addSelection (in long startOffset, in long endOffset);
    boolean removeSelection (in long selectionNum);
    boolean setSelection (in long selectionNum, in long startOffset, in long endOffset);
    void    getRangeExtents (in long startOffset, in long endOffset, 
			     out long x, out long y, 
			     out long width, out long height, in short coordType);
    RangeList getBoundedRanges (in long x, in long y, 
				in long width, in long height, 
				in short coordType, 
				in TEXT_CLIP_TYPE xClipType, 
				in TEXT_CLIP_TYPE yClipType);
    /**
     * unImplemented:
     *
     * placeholders for future expansion.
     */
    void unImplemented ();
    void unImplemented2 ();
    void unImplemented3 ();
    void unImplemented4 ();
  };
};
