/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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) 1998
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *
 *
 * 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"

interface nsIContent;
interface nsIDOMHTMLOptionElement;
interface nsIPresContext;
interface nsIPresState;

/** 
 * This interface is used to notify a SELECT when OPTION
 * elements are added and removed from its subtree.
 * Note that the nsIDOMHTMLSelectElement and nsIContent 
 * interfaces are the ones to use to access and enumerate
 * OPTIONs within a SELECT element.
 */

[scriptable, uuid(a6cf90f6-15b3-11d2-932e-00805f8add32)]
interface nsISelectElement : nsISupports
{

  /**
   * To be called when stuff is added under a child of
   * the select--but *before* they are actually added.
   */
  [noscript] void willAddOptions(in nsIContent aOptions,
                                 in nsIContent aParent,
                                 in long aContentIndex);

  /**
   * To be called when stuff is removed under a child of
   * the select--but *before* they are actually removed.
   */
  [noscript] void willRemoveOptions(in nsIContent aParent,
                                    in long aContentIndex);

  /**
   * An OPTION element has been added to the SELECT's
   * subtree.
   */
  [noscript] void addOption(in nsIContent aContent);

  /**
   * An OPTION element has been deleted from the SELECT's
   * subtree.
   */
  [noscript] void removeOption(in nsIContent aContent);

  /**
   * Called when the parser is done adding child content
   * to the select during document loading.
   */
  void doneAddingChildren();

  /**
   * Returns whether the parser is done adding child content
   * to the select during document loading.
   *
   * @return whether the parser is done adding children
   */
  boolean isDoneAddingChildren();

  /**
   * Returns whether we're the option is selected
   */
  boolean isOptionSelected(in nsIDOMHTMLOptionElement aOption);

  /**
   * Sets an option selected or delselected
   */
  void setOptionSelected(in nsIDOMHTMLOptionElement aOption,
                         in boolean aIsSelected);

  /**
   * Checks whether an option is disabled (even if it's part of an optgroup)
   */
  boolean isOptionDisabled(in long aIndex);

  /**
   * Sets multiple options (or just sets startIndex if select is single)
   */
  boolean setOptionsSelectedByIndex(in long aStartIndex,
                                    in long aEndIndex,
                                    in boolean aIsSelected,
                                    in boolean aClearAll,
                                    in boolean aSetDisabled,
                                    in boolean aNotify);

  /**
   * Called when an option is disabled
   */
  void onOptionDisabled(in nsIDOMHTMLOptionElement aOption);

  /**
   * Called to save/restore to/from pres. state
   */
  [noscript] void saveState();
  [noscript] void restoreState(in nsIPresState aState);
};
