CLOSED TREE: TraceMonkey merge head. (a=blockers)
[mozilla-central.git] / accessible / src / xul / nsXULTreeGridAccessible.h
blob8572062d08bcbe89951e1d330b1f8c11e4fdcfff
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Mozilla Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 2009
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Alexander Surkov <surkov.alexander@gmail.com> (original author)
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #ifndef __nsXULTreeGridAccessible_h__
40 #define __nsXULTreeGridAccessible_h__
42 #include "nsIAccessibleTable.h"
44 #include "nsXULTreeAccessible.h"
46 /**
47 * Represents accessible for XUL tree in the case when it has multiple columns.
49 class nsXULTreeGridAccessible : public nsXULTreeAccessible,
50 public nsIAccessibleTable
52 public:
53 nsXULTreeGridAccessible(nsIContent *aContent, nsIWeakReference *aShell);
55 // nsISupports
56 NS_DECL_ISUPPORTS_INHERITED
58 // nsIAccessibleTable
59 NS_DECL_NSIACCESSIBLETABLE
61 // nsAccessible
62 virtual PRUint32 NativeRole();
64 protected:
66 // nsXULTreeAccessible
67 virtual already_AddRefed<nsAccessible> CreateTreeItemAccessible(PRInt32 aRow);
71 /**
72 * Represents accessible for XUL tree item in the case when XUL tree has
73 * multiple columns.
75 class nsXULTreeGridRowAccessible : public nsXULTreeItemAccessibleBase
77 public:
78 using nsAccessible::GetChildCount;
79 using nsAccessible::GetChildAt;
80 using nsAccessible::GetChildAtPoint;
82 nsXULTreeGridRowAccessible(nsIContent *aContent, nsIWeakReference *aShell,
83 nsAccessible *aParent, nsITreeBoxObject *aTree,
84 nsITreeView *aTreeView, PRInt32 aRow);
86 // nsISupports and cycle collection
87 NS_DECL_ISUPPORTS_INHERITED
88 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsXULTreeGridRowAccessible,
89 nsAccessible)
91 // nsAccessNode
92 virtual void Shutdown();
94 // nsAccessible
95 virtual PRUint32 NativeRole();
96 virtual nsresult GetChildAtPoint(PRInt32 aX, PRInt32 aY,
97 PRBool aDeepestChild,
98 nsIAccessible **aChild);
100 virtual nsAccessible* GetChildAt(PRUint32 aIndex);
101 virtual PRInt32 GetChildCount();
103 // nsXULTreeItemAccessibleBase
104 virtual nsAccessible* GetCellAccessible(nsITreeColumn *aColumn);
105 virtual void RowInvalidated(PRInt32 aStartColIdx, PRInt32 aEndColIdx);
107 protected:
109 // nsAccessible
110 virtual void CacheChildren();
112 // nsXULTreeItemAccessibleBase
113 nsAccessibleHashtable mAccessibleCache;
118 * Represents an accessible for XUL tree cell in the case when XUL tree has
119 * multiple columns.
122 #define NS_XULTREEGRIDCELLACCESSIBLE_IMPL_CID \
123 { /* 84588ad4-549c-4196-a932-4c5ca5de5dff */ \
124 0x84588ad4, \
125 0x549c, \
126 0x4196, \
127 { 0xa9, 0x32, 0x4c, 0x5c, 0xa5, 0xde, 0x5d, 0xff } \
130 class nsXULTreeGridCellAccessible : public nsLeafAccessible,
131 public nsIAccessibleTableCell
133 public:
134 using nsAccessible::GetParent;
136 nsXULTreeGridCellAccessible(nsIContent *aContent, nsIWeakReference *aShell,
137 nsXULTreeGridRowAccessible *aRowAcc,
138 nsITreeBoxObject *aTree, nsITreeView *aTreeView,
139 PRInt32 aRow, nsITreeColumn* aColumn);
141 // nsISupports
142 NS_DECL_ISUPPORTS_INHERITED
144 // nsIAccessible
145 NS_IMETHOD GetFocusedChild(nsIAccessible **aFocusedChild);
147 NS_IMETHOD GetName(nsAString& aName);
148 NS_IMETHOD GetBounds(PRInt32 *aX, PRInt32 *aY,
149 PRInt32 *aWidth, PRInt32 *aHeight);
151 NS_IMETHOD GetNumActions(PRUint8 *aCount);
152 NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
153 NS_IMETHOD DoAction(PRUint8 aIndex);
155 // nsIAccessibleTableCell
156 NS_DECL_NSIACCESSIBLETABLECELL
158 // nsAccessNode
159 virtual PRBool IsDefunct();
160 virtual PRBool Init();
161 virtual bool IsPrimaryForNode() const;
163 // nsAccessible
164 virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
165 virtual PRUint32 NativeRole();
166 virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
167 virtual PRInt32 GetIndexInParent() const;
169 // nsXULTreeGridCellAccessible
170 NS_DECLARE_STATIC_IID_ACCESSOR(NS_XULTREEGRIDCELLACCESSIBLE_IMPL_CID)
173 * Return index of the column.
175 PRInt32 GetColumnIndex() const;
178 * Fire name or state change event if the accessible text or value has been
179 * changed.
181 void CellInvalidated();
183 protected:
184 // nsAccessible
185 virtual nsAccessible* GetSiblingAtOffset(PRInt32 aOffset,
186 nsresult *aError = nsnull);
187 virtual void DispatchClickEvent(nsIContent *aContent, PRUint32 aActionIndex);
189 // nsXULTreeGridCellAccessible
192 * Return true if value of cell can be modified.
194 PRBool IsEditable() const;
196 enum { eAction_Click = 0 };
198 nsCOMPtr<nsITreeBoxObject> mTree;
199 nsCOMPtr<nsITreeView> mTreeView;
201 PRInt32 mRow;
202 nsCOMPtr<nsITreeColumn> mColumn;
204 nsString mCachedTextEquiv;
207 NS_DEFINE_STATIC_IID_ACCESSOR(nsXULTreeGridCellAccessible,
208 NS_XULTREEGRIDCELLACCESSIBLE_IMPL_CID)
210 #endif