/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Mozilla 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/MPL/
 *
 * 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) 2003
 * the Initial Developer. All Rights Reserved.
 *
 * Original Author: Eric D Vaughan (evaughan@netscape.com)
 * Contributor(s): Aaron Leventhal (aaronl@netscape.com)
 *                 John Gaunt (jgaunt@netscape.com)
 *                 Kyle Yuan (kyle.yuan@sun.com)
 *                 Håkan Waara (hwaara@gmail.com)
 *
 * 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 MPL, 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 MPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */

#include "nsISupports.idl"
#include "nsIArray.idl"

interface nsIPersistentProperties;

/**
 * A cross-platform interface that supports platform-specific 
 * accessibility APIs like MSAA and ATK. Contains the sum of what's needed
 * to support IAccessible as well as ATK's generic accessibility objects.
 * Can also be used by in-process accessibility clients to get information
 * about objects in the accessible tree. The accessible tree is a subset of 
 * nodes in the DOM tree -- such as documents, focusable elements and text.
 * Mozilla creates the implementations of nsIAccessible on demand.
 * See http://www.mozilla.org/projects/ui/accessibility for more information.
 *
 * @status UNDER_REVIEW
 */
[scriptable, uuid(1b9596e8-d7bf-4b99-b032-53a1bf9be1c3)]
interface nsIAccessible : nsISupports
{
  /**
   * Parent node in accessible tree.
   */
  readonly attribute nsIAccessible parent;

  /**
   * Next sibling in accessible tree
   */
  readonly attribute nsIAccessible nextSibling;

  /**
   * Previous sibling in accessible tree
   */
  readonly attribute nsIAccessible previousSibling;

  /**
   * First child in accessible tree
   */
  readonly attribute nsIAccessible firstChild;

  /**
   * Last child in accessible tree
   */
  readonly attribute nsIAccessible lastChild;
  
  /**
   * Array of all this element's children.
   */
  readonly attribute nsIArray children;

  /**
   * Number of accessible children
   */
  readonly attribute long childCount;

  /**
   * The 0-based index of this accessible in its parent's list of children,
   * or -1 if this accessible does not have a parent.
   */
  readonly attribute long indexInParent;

  /**
   * Accessible name -- the main text equivalent for this node
   */
  attribute AString name;

  /**
   * Accessible value -- a number or a secondary text equivalent for this node
   * Widgets that use role attribute can force a value using the valuenow attribute
   */
  readonly attribute AString value;

  /**
   * Accessible description -- long text associated with this node
   */
  readonly attribute AString description;

  /**
   * Provides localized string of accesskey name, such as Alt+D.
   * The modifier may be affected by user and platform preferences.
   * Usually alt+letter, or just the letter alone for menu items. 
   */
  readonly attribute AString keyboardShortcut;

  /**
   * Provides localized string of global keyboard accelerator, such
   * as Ctrl+O for Open file
   */
  readonly attribute AString keyBinding;

  /**
   * Natural enumerated accessible role for the associated element.
   * The values depend on platform because of variations.
   * See the ROLE_* constants defined later in this file.
   * This does not take into account role attribute as the finalRole does.
   */
  readonly attribute unsigned long role;

  /**
   * Enumerated accessible role. The values depend on platform because of variations.
   * See the ROLE_* constants defined later in this file.
   * Widgets can use role attribute to force the final role
   */
  readonly attribute unsigned long finalRole;

  /**
   * Accessible states -- bit field which describes boolean properties of node. 
   * See the STATE_* constants defined later in this file.
   * Many states are only valid given a certain role attribute that supports them
   */
  readonly attribute unsigned long finalState;

  /**
   * Extended accessible states -- second bit field describing node
   */
  readonly attribute unsigned long extState;

  /**
   * True if this element is live in an editor.
   * False if the content is being displayed but not edited. 
   */
  readonly attribute boolean isEditable;

  /**
   * Help text associated with node
   */
  readonly attribute AString help;

  /**
   * Focused accessible child of node
   */
  readonly attribute nsIAccessible focusedChild;

  /**
   * Attributes of accessible
   */
  readonly attribute nsIPersistentProperties attributes;

  /**
   * Accessible child which contains the coordinate at (x, y) in screen pixels.
   */
  nsIAccessible getChildAtPoint(in long x, in long y);

  /**
   * Nth accessible child using zero-based index or last child if index less than zero
   */
  nsIAccessible getChildAt(in long aChildIndex);

  /**
   * Accessible node geometrically to the right of this one
   */
  nsIAccessible getAccessibleToRight();

  /**
   * Accessible node geometrically to the left of this one
   */
  nsIAccessible getAccessibleToLeft();

  /**
   * Accessible node geometrically above this one
   */
  nsIAccessible getAccessibleAbove();

  /**
   * Accessible node geometrically below this one
   */
  nsIAccessible getAccessibleBelow();

  /**
   * Accessible node related to this one 
   */
  nsIAccessible getAccessibleRelated(in unsigned long aRelationType);

  void getBounds(out long x, 
                    out long y, 
                    out long width, 
                    out long height);

  /**
   * Add or remove this accessible to the current selection
   */
  void setSelected(in boolean isSelected);

  /**
   * Extend the current selection from its current accessible anchor node
   * to this accessible
   */
  void extendSelection();

  /**
   * Select this accessible node only
   */
  void takeSelection();

  /**
   * Focus this accessible node,
   * The state STATE_FOCUSABLE indicates whether this node is normally focusable.
   * It is the callers responsibility to determine whether this node is focusable.
   * accTakeFocus on a node that is not normally focusable (such as a table),
   * will still set focus on that node, although normally that will not be visually 
   * indicated in most style sheets.
   */
  void takeFocus();

  /**
   * The number of accessible actions associated with this accessible
   */
  readonly attribute PRUint8 numActions;

  /**
   * The name of the accessible action at the given zero-based index
   */
  AString getActionName(in PRUint8 index);

  /**
   * Perform the accessible action at the given zero-based index
   * Action number 0 is the default action
   */
  void doAction(in PRUint8 index);   

  /**
   * Get a pointer to accessibility interface for this node, which is specific 
   * to the OS/accessibility toolkit we're running on.
   */
  [noscript] void getNativeInterface(out voidPtr aOutAccessible);

  /**
   * MSAA State flags - used for bitfield. More than 1 allowed.
   */
  const unsigned long  STATE_UNAVAILABLE        = 0x00000001;  // Disabled, maps to opposite of Java ENABLED, Gnome/ATK SENSITIVE?
  const unsigned long  STATE_SELECTED           = 0x00000002;
  const unsigned long  STATE_FOCUSED            = 0x00000004;
  const unsigned long  STATE_PRESSED            = 0x00000008;
  const unsigned long  STATE_CHECKED            = 0x00000010;
  const unsigned long  STATE_MIXED              = 0x00000020; // 3-state checkbox or toolbar button
  const unsigned long  STATE_READONLY           = 0x00000040; // Maps to opposite of Java/Gnome/ATK EDITABLE state
  const unsigned long  STATE_HOTTRACKED         = 0x00000080;
  const unsigned long  STATE_DEFAULT            = 0x00000100;
  const unsigned long  STATE_EXPANDED           = 0x00000200;
  const unsigned long  STATE_COLLAPSED          = 0x00000400;
  const unsigned long  STATE_BUSY               = 0x00000800;
  const unsigned long  STATE_FLOATING           = 0x00001000;  // Children "owned" not "contained" by parent
  const unsigned long  STATE_MARQUEED           = 0x00002000;
  const unsigned long  STATE_ANIMATED           = 0x00004000;
  const unsigned long  STATE_INVISIBLE          = 0x00008000;
  const unsigned long  STATE_OFFSCREEN          = 0x00010000;
  const unsigned long  STATE_SIZEABLE           = 0x00020000;
  const unsigned long  STATE_MOVEABLE           = 0x00040000;
  const unsigned long  STATE_SELFVOICING        = 0x00080000;
  const unsigned long  STATE_FOCUSABLE          = 0x00100000;
  const unsigned long  STATE_SELECTABLE         = 0x00200000;
  const unsigned long  STATE_LINKED             = 0x00400000;
  const unsigned long  STATE_TRAVERSED          = 0x00800000;
  const unsigned long  STATE_MULTISELECTABLE    = 0x01000000;  // Supports multiple selection
  const unsigned long  STATE_EXTSELECTABLE      = 0x02000000;  // Supports extended selection
  const unsigned long  STATE_ALERT_LOW          = 0x04000000;  // This information is of low priority
  const unsigned long  STATE_ALERT_MEDIUM       = 0x08000000;  // This information is of medium priority
  const unsigned long  STATE_ALERT_HIGH         = 0x10000000;  // This information is of high priority
  const unsigned long  STATE_PROTECTED          = 0x20000000;  // Maps to Gnome's *Role* ATK_ROLE_PASSWD_TEXT, nothing for Java?
  const unsigned long  STATE_HASPOPUP           = 0x40000000;  // New in MSAA 2.0

  // Mapping important states that we don't have to unused alert states on MSAA
  // as per discussions with AT vendors. On ATK there will be legitimate states for
  // STATE_REQUIRED AND STATE_INVALID
  const unsigned long  STATE_REQUIRED           = STATE_ALERT_LOW;
  const unsigned long  STATE_IMPORTANT          = STATE_ALERT_MEDIUM;
  const unsigned long  STATE_INVALID            = STATE_ALERT_HIGH;
  const unsigned long  STATE_CHECKABLE          = STATE_MARQUEED;

/**
 * Extended state flags (for now non-MSAA, for Java and Gnome/ATK support)
 * "Extended state flags" has separate value space from "MSAA State flags".
 */
  const unsigned long  EXT_STATE_DEFUNCT        = 0x00080000;  // Object no longer exists
  const unsigned long  EXT_STATE_SELECTABLE_TEXT= 0x00100000;  // For text which is selectable, object must implement nsIAccessibleText
  const unsigned long  EXT_STATE_EDITABLE       = 0x00200000;  // Used for XUL/HTML input (type = text,password) element
  const unsigned long  EXT_STATE_ACTIVE         = 0x00400000;  // This window is currently the active window    
  const unsigned long  EXT_STATE_EXPANDABLE     = 0x00800000;  // An item that can be expanded, such as a tree item with children    
  const unsigned long  EXT_STATE_MODAL          = 0x01000000;  // Must do something with control before leaving it    
  const unsigned long  EXT_STATE_MULTI_LINE     = 0x02000000;  // Edit control that can take multiple lines    
  const unsigned long  EXT_STATE_SENSITIVE      = 0x04000000;  // No explanation given    
  const unsigned long  EXT_STATE_SHOWING        = 0x10000000;  // This object and all of it's ancestors are visible    
  const unsigned long  EXT_STATE_SINGLE_LINE    = 0x20000000;  // This text object can only contain 1 line of text    
  const unsigned long  EXT_STATE_TRANSIENT      = 0x40000000;  // Tells accessibility aid "Don't add event listener - this object doesn't generate any". For example, could be used with higher level containers.    
  const unsigned long  EXT_STATE_VERTICAL       = 0x80000000;  // Especially used for sliders and scrollbars  

/**
 * Relation Types -- most of these come from ATK's atkrelationtype.h
 * When adding support for relations, make sure to add them to appropriate
 * places in nsAccessibleWrap implementations
 * RELATION_NULL:
 * RELATION_CONTROLLED_BY:    Controlled by one or more target objects.
 * RELATION_CONTROLLER_FOR:   Controller for one or more target objects.
 * RELATION_LABEL_FOR:        Label for one or more target objects.
 * RELATION_LABELLED_BY:      Labelled by one or more target objects.
 * RELATION_MEMBER_OF:        Member of a group of one or more target objects.
 * RELATION_NODE_CHILD_OF:    Cell in a treetable which is displayed because a
 *                            cell in the same col is expanded & identifies it.
 * RELATION_FLOWS_TO:         Has content that flows logically to another
 *                            object in a sequential way, e.g. text flow.
 * RELATION_FLOWS_FROM:       Has content that flows logically from another
 *                            object in a sequential way, e.g. text flow.
 * RELATION_SUBWINDOW_OF:     Subwindow attached to a component but otherwise 
 *                            not connected in the UI hierarchy to that component.
 * RELATION_EMBEDS:           Visually embeds another object's content, i.e.
 *                            this object's content flows around another's content.
 * RELATION_EMBEDDED_BY:      Inverse of RELATION_EMBEDS; this object's content
 *                            is visually embedded in another object.
 * RELATION_POPUP_FOR:        Popup for another object.
 * RELATION_PARENT_WINDOW_OF: Parent window of another object.
 * RELATION_DEFAULT_BUTTON:   Part of a form/dialog with a related default button.
 * RELATION_DESCRIBED_BY:     Described by one or more target objects.
 * RELATION_DESCRIPTION_FOR:  Description for one or more target objects.
 */

  const unsigned long RELATION_NUL = 0x00;               // ATK_RELATION_NUL
  const unsigned long RELATION_CONTROLLED_BY = 0x01;     // ATK_RELATION_CONTROLLED_BY
  const unsigned long RELATION_CONTROLLER_FOR = 0x02;    // ATK_RELATION_CONTROLLER_FOR
  const unsigned long RELATION_LABEL_FOR = 0x03;         // ATK_RELATION_LABEL_FOR
  const unsigned long RELATION_LABELLED_BY = 0x04;       // ATK_RELATION_LABELLED_BY
  const unsigned long RELATION_MEMBER_OF = 0x05;         // ATK_RELATION_MEMBER_OF
  const unsigned long RELATION_NODE_CHILD_OF = 0x06;     // ATK_RELATION_NODE_CHILD_OF
  const unsigned long RELATION_FLOWS_TO = 0x07;          // ATK_RELATION_FLOWS_TO
  const unsigned long RELATION_FLOWS_FROM = 0x08;        // ATK_RELATION_FLOWS_FROM
  const unsigned long RELATION_SUBWINDOW_OF = 0x09;      // ATK_RELATION_SUBWINDOW_OF
  const unsigned long RELATION_EMBEDS = 0x0a;            // ATK_RELATION_EMBEDS
  const unsigned long RELATION_EMBEDDED_BY = 0x0b;       // ATK_RELATION_EMBEDDED_BY
  const unsigned long RELATION_POPUP_FOR = 0x0c;         // ATK_RELATION_POPUP_FOR
  const unsigned long RELATION_PARENT_WINDOW_OF = 0x0d;  // ATK_RELATION_PARENT_WINDOW_OF
  const unsigned long RELATION_DESCRIBED_BY = 0x0e;      // ATK_RELATION_DESCRIBED_BY
  const unsigned long RELATION_DESCRIPTION_FOR = 0x0f;   // ATK_RELATION_DESCRIPTION_FOR
  const unsigned long RELATION_DEFAULT_BUTTON = 0x4000;  // MSAA only, no ATK relation

  // Cross Platform Roles
  // When adding a new role, be sure to also add it to nsRoleMap.h for each platform
  const unsigned long ROLE_NOTHING = 0;
  const unsigned long ROLE_TITLEBAR = 1;
  const unsigned long ROLE_MENUBAR = 2;
  const unsigned long ROLE_SCROLLBAR = 3;
  const unsigned long ROLE_GRIP = 4;
  const unsigned long ROLE_SOUND = 5;
  const unsigned long ROLE_CURSOR = 6;
  const unsigned long ROLE_CARET = 7;
  const unsigned long ROLE_ALERT = 8;
  const unsigned long ROLE_WINDOW = 9;
  const unsigned long ROLE_CLIENT = 10;
  const unsigned long ROLE_MENUPOPUP = 11;
  const unsigned long ROLE_MENUITEM = 12;
  const unsigned long ROLE_TOOLTIP = 13;
  const unsigned long ROLE_APPLICATION = 14; // See also ROLE_APP_ROOT
  const unsigned long ROLE_DOCUMENT = 15;
  const unsigned long ROLE_PANE = 16;
  const unsigned long ROLE_CHART = 17;
  const unsigned long ROLE_DIALOG = 18;
  const unsigned long ROLE_BORDER = 19;
  const unsigned long ROLE_GROUPING = 20;
  const unsigned long ROLE_SEPARATOR = 21;
  const unsigned long ROLE_TOOLBAR = 22;
  const unsigned long ROLE_STATUSBAR = 23;
  const unsigned long ROLE_TABLE = 24;
  const unsigned long ROLE_COLUMNHEADER = 25;
  const unsigned long ROLE_ROWHEADER = 26;
  const unsigned long ROLE_COLUMN = 27;
  const unsigned long ROLE_ROW = 28;
  const unsigned long ROLE_CELL = 29;
  const unsigned long ROLE_LINK = 30;
  const unsigned long ROLE_HELPBALLOON = 31;
  const unsigned long ROLE_CHARACTER = 32;
  const unsigned long ROLE_LIST = 33;
  const unsigned long ROLE_LISTITEM = 34;
  const unsigned long ROLE_OUTLINE = 35;
  const unsigned long ROLE_OUTLINEITEM = 36;
  const unsigned long ROLE_PAGETAB = 37;
  const unsigned long ROLE_PROPERTYPAGE = 38;
  const unsigned long ROLE_INDICATOR = 39;
  const unsigned long ROLE_GRAPHIC = 40;
  const unsigned long ROLE_STATICTEXT = 41;
  const unsigned long ROLE_TEXT_LEAF = 42;
  const unsigned long ROLE_PUSHBUTTON = 43;
  const unsigned long ROLE_CHECKBUTTON = 44;
  const unsigned long ROLE_RADIOBUTTON = 45;
  const unsigned long ROLE_COMBOBOX = 46;
  const unsigned long ROLE_DROPLIST = 47;
  const unsigned long ROLE_PROGRESSBAR = 48;
  const unsigned long ROLE_DIAL = 49;
  const unsigned long ROLE_HOTKEYFIELD = 50;
  const unsigned long ROLE_SLIDER = 51;
  const unsigned long ROLE_SPINBUTTON = 52;
  const unsigned long ROLE_DIAGRAM = 53;
  const unsigned long ROLE_ANIMATION = 54;
  const unsigned long ROLE_EQUATION = 55;
  const unsigned long ROLE_BUTTONDROPDOWN = 56;
  const unsigned long ROLE_BUTTONMENU = 57;
  const unsigned long ROLE_BUTTONDROPDOWNGRID = 58;
  const unsigned long ROLE_WHITESPACE = 59;
  const unsigned long ROLE_PAGETABLIST = 60;
  const unsigned long ROLE_CLOCK = 61;
  const unsigned long ROLE_SPLITBUTTON = 62;
  const unsigned long ROLE_IPADDRESS = 63;
  const unsigned long ROLE_ACCEL_LABEL = 64;
  const unsigned long ROLE_ARROW  = 65;
  const unsigned long ROLE_CANVAS = 66;
  const unsigned long ROLE_CHECK_MENU_ITEM = 67;
  const unsigned long ROLE_COLOR_CHOOSER  = 68;
  const unsigned long ROLE_DATE_EDITOR = 69;
  const unsigned long ROLE_DESKTOP_ICON = 70;
  const unsigned long ROLE_DESKTOP_FRAME = 71;
  const unsigned long ROLE_DIRECTORY_PANE = 72;
  const unsigned long ROLE_FILE_CHOOSER = 73;
  const unsigned long ROLE_FONT_CHOOSER = 74;
  const unsigned long ROLE_CHROME_WINDOW = 75;
  const unsigned long ROLE_GLASS_PANE = 76;
  const unsigned long ROLE_HTML_CONTAINER = 77;
  const unsigned long ROLE_ICON = 78;
  const unsigned long ROLE_LABEL = 79;
  const unsigned long ROLE_LAYERED_PANE = 80;
  const unsigned long ROLE_OPTION_PANE = 81;
  const unsigned long ROLE_PASSWORD_TEXT = 82;
  const unsigned long ROLE_POPUP_MENU = 83;
  const unsigned long ROLE_RADIO_MENU_ITEM = 84;
  const unsigned long ROLE_ROOT_PANE = 85;
  const unsigned long ROLE_SCROLL_PANE = 86;
  const unsigned long ROLE_SPLIT_PANE = 87;
  const unsigned long ROLE_TABLE_COLUMN_HEADER = 88;
  const unsigned long ROLE_TABLE_ROW_HEADER = 89;
  const unsigned long ROLE_TEAR_OFF_MENU_ITEM = 90;
  const unsigned long ROLE_TERMINAL = 91;
  const unsigned long ROLE_TEXT_CONTAINER = 92;
  const unsigned long ROLE_TOGGLE_BUTTON = 93;
  const unsigned long ROLE_TREE_TABLE = 94;
  const unsigned long ROLE_VIEWPORT = 95;
  const unsigned long ROLE_HEADER = 96;
  const unsigned long ROLE_FOOTER = 97;
  const unsigned long ROLE_PARAGRAPH = 98;
  const unsigned long ROLE_RULER = 99;
  const unsigned long ROLE_AUTOCOMPLETE = 100;
  const unsigned long ROLE_EDITBAR = 101;
  const unsigned long ROLE_ENTRY = 102;
  const unsigned long ROLE_CAPTION = 103;
  const unsigned long ROLE_DOCUMENT_FRAME = 104;
  const unsigned long ROLE_HEADING = 105;
  const unsigned long ROLE_PAGE = 106;
  const unsigned long ROLE_SECTION = 107;
  const unsigned long ROLE_REDUNDANT_OBJECT = 108;
  const unsigned long ROLE_FORM = 109;
  const unsigned long ROLE_IME = 110;
  const unsigned long ROLE_APP_ROOT = 111;
  const unsigned long ROLE_PARENT_MENUITEM = 112;
  const unsigned long ROLE_LAST_ENTRY = 113; // Important -- helps ensure nsRoleMap's are synchronized

// MSAA relationship extensions to accNavigate
  const unsigned long NAVRELATION_CONTROLLED_BY = 0x1000;
  const unsigned long NAVRELATION_CONTROLLER_FOR = 0x1001;
  const unsigned long NAVRELATION_LABEL_FOR = 0x1002;
  const unsigned long NAVRELATION_LABELLED_BY = 0x1003;
  const unsigned long NAVRELATION_MEMBER_OF = 0x1004;
  const unsigned long NAVRELATION_NODE_CHILD_OF = 0x1005;
  const unsigned long NAVRELATION_FLOWS_TO = 0x1006;
  const unsigned long NAVRELATION_FLOWS_FROM = 0x1007;
  const unsigned long NAVRELATION_SUBWINDOW_OF = 0x1008;
  const unsigned long NAVRELATION_EMBEDS = 0x1009;
  const unsigned long NAVRELATION_EMBEDDED_BY = 0x100a;
  const unsigned long NAVRELATION_POPUP_FOR = 0x100b;
  const unsigned long NAVRELATION_PARENT_WINDOW_OF = 0x100c;
  const unsigned long NAVRELATION_DEFAULT_BUTTON = 0x100d;
  const unsigned long NAVRELATION_DESCRIBED_BY = 0x100e;
  const unsigned long NAVRELATION_DESCRIPTION_FOR = 0x100f;
};
