Back to index

lightning-sunbird  0.9+nobinonly
nsXULTreeAccessible.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Author: Kyle Yuan (kyle.yuan@sun.com)
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 #ifndef __nsXULTreeAccessible_h__
00039 #define __nsXULTreeAccessible_h__
00040 
00041 #include "nsBaseWidgetAccessible.h"
00042 #include "nsITreeBoxObject.h"
00043 #include "nsITreeView.h"
00044 #include "nsITreeColumns.h"
00045 #include "nsXULSelectAccessible.h"
00046 #include "nsIAccessibleTreeCache.h"
00047 
00048 
00049 /*
00050  * A class the represents the XUL Tree widget.
00051  */
00052 const PRUint32 kDefaultTreeCacheSize = 256;
00053 
00054 class nsXULTreeAccessible : public nsXULSelectableAccessible,
00055                             public nsIAccessibleTreeCache
00056 {
00057 public:
00058   NS_DECL_ISUPPORTS_INHERITED
00059   NS_DECL_NSIACCESSIBLESELECTABLE
00060   NS_DECL_NSIACCESSIBLETREECACHE
00061 
00062   nsXULTreeAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
00063   virtual ~nsXULTreeAccessible() {};
00064 
00065   /* ----- nsIAccessible ----- */
00066   NS_IMETHOD Shutdown();
00067   NS_IMETHOD GetRole(PRUint32 *_retval);
00068   NS_IMETHOD GetState(PRUint32 *_retval);
00069   NS_IMETHOD GetValue(nsAString& _retval);
00070 
00071   NS_IMETHOD GetFirstChild(nsIAccessible **_retval);
00072   NS_IMETHOD GetLastChild(nsIAccessible **_retval);
00073   NS_IMETHOD GetChildCount(PRInt32 *_retval);
00074   NS_IMETHOD GetFocusedChild(nsIAccessible **aFocusedChild);
00075 
00076   static void GetTreeBoxObject(nsIDOMNode* aDOMNode, nsITreeBoxObject** aBoxObject);
00077   static nsresult GetColumnCount(nsITreeBoxObject* aBoxObject, PRInt32 *aCount);
00078 
00079 protected:
00080   nsCOMPtr<nsITreeBoxObject> mTree;
00081   nsCOMPtr<nsITreeView> mTreeView;
00082   nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode> *mAccessNodeCache;
00083 
00084   NS_IMETHOD ChangeSelection(PRInt32 aIndex, PRUint8 aMethod, PRBool *aSelState);
00085 };
00086 
00090 class nsXULTreeitemAccessible : public nsLeafAccessible
00091 {
00092 public:
00093   NS_DECL_ISUPPORTS_INHERITED
00094 
00095   nsXULTreeitemAccessible(nsIAccessible *aParent, nsIDOMNode *aDOMNode, nsIWeakReference *aShell, PRInt32 aRow, nsITreeColumn* aColumn = nsnull);
00096   virtual ~nsXULTreeitemAccessible() {}
00097 
00098   NS_IMETHOD Shutdown();
00099 
00100   /* ----- nsIAccessible ----- */
00101   NS_IMETHOD GetName(nsAString& _retval);
00102   NS_IMETHOD GetRole(PRUint32 *_retval);
00103   NS_IMETHOD GetState(PRUint32 *_retval);
00104   NS_IMETHOD GetNumActions(PRUint8 *_retval);
00105   NS_IMETHOD GetActionName(PRUint8 index, nsAString& _retval);
00106 
00107   NS_IMETHOD GetParent(nsIAccessible **_retval);
00108   NS_IMETHOD GetNextSibling(nsIAccessible **_retval);
00109   NS_IMETHOD GetPreviousSibling(nsIAccessible **_retval);
00110 
00111   NS_IMETHOD DoAction(PRUint8 index);
00112   NS_IMETHOD GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height);
00113   NS_IMETHOD RemoveSelection(void); 
00114   NS_IMETHOD TakeSelection(void); 
00115   NS_IMETHOD TakeFocus(void); 
00116 
00117   NS_IMETHOD GetAccessibleRelated(PRUint32 aRelationType, nsIAccessible **aRelated);
00118   /* ------ nsIAccessNode ----- */
00119   NS_IMETHOD GetUniqueID(void **aUniqueID);
00120 
00121 protected:
00122   nsCOMPtr<nsITreeBoxObject> mTree;
00123   nsCOMPtr<nsITreeView> mTreeView;
00124   PRInt32 mRow;
00125   nsCOMPtr<nsITreeColumn> mColumn;
00126 };
00127 
00128 class nsXULTreeColumnsAccessible : public nsAccessibleWrap
00129 {
00130 public:
00131   NS_DECL_ISUPPORTS_INHERITED
00132 
00133   nsXULTreeColumnsAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
00134   virtual ~nsXULTreeColumnsAccessible() {}
00135 
00136   /* ----- nsIAccessible ----- */
00137   NS_IMETHOD GetRole(PRUint32 *_retval);
00138   NS_IMETHOD GetState(PRUint32 *_retval);
00139   NS_IMETHOD GetNumActions(PRUint8 *_retval);
00140   NS_IMETHOD GetActionName(PRUint8 index, nsAString& _retval);
00141 
00142   NS_IMETHOD GetNextSibling(nsIAccessible **_retval); 
00143   NS_IMETHOD GetPreviousSibling(nsIAccessible **_retval); 
00144 
00145   NS_IMETHOD DoAction(PRUint8 index);
00146 };
00147 
00148 class nsXULTreeColumnitemAccessible : public nsLeafAccessible
00149 {
00150 public:
00151   NS_DECL_ISUPPORTS_INHERITED
00152 
00153   nsXULTreeColumnitemAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
00154   virtual ~nsXULTreeColumnitemAccessible() {}
00155 
00156   /* ----- nsIAccessible ----- */
00157   NS_IMETHOD GetName(nsAString& _retval);
00158   NS_IMETHOD GetRole(PRUint32 *_retval);
00159   NS_IMETHOD GetState(PRUint32 *_retval);
00160   NS_IMETHOD GetNumActions(PRUint8 *_retval);
00161   NS_IMETHOD GetActionName(PRUint8 index, nsAString& _retval);
00162 
00163   NS_IMETHOD DoAction(PRUint8 index);
00164 };
00165 
00166 #endif