/* ***** BEGIN LICENSE BLOCK *****
 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Netscape Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/NPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is mozilla.org code.
 *
 * The Initial Developer of the Original Code is 
 * Netscape Communications Corporation.
 * Portions created by the Initial Developer are Copyright (C) 2001
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *   Joe Hewitt <hewitt@netscape.com> (Original Author)
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the NPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the NPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */

#include "nsISupports.idl"
#include "nsIAutoCompleteController.idl"

interface nsIAutoCompletePopup;

[scriptable, uuid(3B6E2742-B136-4588-A6DF-699B9585AF60)]
interface nsIAutoCompleteInput : nsISupports
{  
  /*
   * The result view that will be used to display results
   */
  readonly attribute nsIAutoCompletePopup popup;
  
  /*
   * The controller.
   */
  readonly attribute nsIAutoCompleteController controller;

  /* 
   * Indicates if the popup is currently open
   */
  attribute boolean popupOpen;

  /*
   * Option to disable autocomplete functionality
   */ 
  attribute boolean disableAutoComplete;
  
  /* 
   * If a search result has its defaultIndex set, this will optionally
   * try to complete the text in the textbox to the entire text of the
   * result at the default index as the user types
   */
  attribute boolean completeDefaultIndex;

  /* 
   * Option for completing to the default result whenever the user hits
   * enter or the textbox loses focus
   */
  attribute boolean forceComplete;
    
  /*
   * Option to open the popup only after a certain number of results are available
   */
  attribute unsigned long minResultsForPopup;
  
  /*
   * The maximum number of rows to show in the autocomplete popup.
   */
  attribute unsigned long maxRows;

  /*
   * Option to show a second column in the popup which contains
   * the comment for each autocomplete result
   */
  attribute unsigned long showCommentColumn;

  /* 
   * Number of milliseconds after a keystroke before a search begins
   */
  attribute unsigned long timeout;

  /*
   * An extra parameter to configure searches with.
   */
  attribute AString searchParam;

  /*
   * The number of autocomplete session to search
   */
  readonly attribute unsigned long searchCount;
  
  /*
   * Get the name of one of the autocomplete search session objects
   */
  ACString getSearchAt(in unsigned long index);

  /*
   * The value of text in the autocomplete textbox
   */
  attribute AString textValue;

  /*
   * Report the starting index of the cursor in the textbox
   */
  readonly attribute long selectionStart;

  /*
   * Report the ending index of the cursor in the textbox
   */
  readonly attribute long selectionEnd;

  /*
   * Select a range of text in the autocomplete textbox
   */
  void selectTextRange(in long startIndex, in long endIndex);

  /*
   * Notification that the search concluded successfully
   */
  void onSearchComplete();

  /*
   * Notification that the user selected and entered a result item
   *
   * @return True if the user wishes to prevent the enter
   */
  boolean onTextEntered();

  /*
   * Notification that the user cancelled the autocomplete session
   *
   * @return True if the user wishes to prevent the revert
   */
  boolean onTextReverted();
};
