Implementation of nsIAccessibleValue

bug=150606 r=kyle.yuan@sun.com sr=jag patch=gilbert.fang@sun.com
This commit is contained in:
pete.zha%sun.com 2002-07-15 02:23:23 +00:00
Родитель b8851070cb
Коммит 655223904d
2 изменённых файлов: 56 добавлений и 1 удалений

Просмотреть файл

@ -434,6 +434,7 @@ NS_IMETHODIMP nsXULGroupboxAccessible::GetAccName(nsAString& _retval)
/**
* progressmeter
*/
NS_IMPL_ISUPPORTS_INHERITED1(nsXULProgressMeterAccessible, nsFormControlAccessible, nsIAccessibleValue)
nsXULProgressMeterAccessible::nsXULProgressMeterAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
nsFormControlAccessible(aNode, aShell)
@ -465,6 +466,55 @@ NS_IMETHODIMP nsXULProgressMeterAccessible::GetAccValue(nsAString& _retval)
return NS_OK;
}
/* readonly attribute double maximumValue; */
NS_IMETHODIMP nsXULProgressMeterAccessible::GetMaximumValue(double *aMaximumValue)
{
*aMaximumValue = 1; // 100% = 1;
return NS_OK;
}
/* readonly attribute double minimumValue; */
NS_IMETHODIMP nsXULProgressMeterAccessible::GetMinimumValue(double *aMinimumValue)
{
*aMinimumValue = 0;
return NS_OK;
}
/* readonly attribute double currentValue; */
NS_IMETHODIMP nsXULProgressMeterAccessible::GetCurrentValue(double *aCurrentValue)
{
nsAutoString currentValue;
GetAccValue(currentValue);
PRInt32 error;
*aCurrentValue = currentValue.ToFloat(&error) / 100;
return NS_OK;
}
/* boolean setCurrentValue (in double value); */
NS_IMETHODIMP nsXULProgressMeterAccessible::SetCurrentValue(double aValue, PRBool *_retval)
{
//Here I do not suppose the min/max are 0/1.00 because I want
// these part of code to be more extensible.
*_retval = PR_FALSE;
double min, max;
GetMinimumValue(&min);
GetMaximumValue(&max);
if (aValue > max || aValue < min)
return NS_ERROR_INVALID_ARG;
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(mDOMNode));
NS_ASSERTION(element, "No element for DOM node!");
PRUint32 value = PRUint32(aValue * 100.0 + 0.5);
nsAutoString valueString;
valueString.AppendInt(value);
valueString.Append(NS_LITERAL_STRING("%"));
if (NS_SUCCEEDED(element->SetAttribute(NS_LITERAL_STRING("value"), valueString))) {
*_retval = PR_TRUE;
return NS_OK;
}
return NS_ERROR_INVALID_ARG;
}
/**
* XUL Radio Button
*/

Просмотреть файл

@ -44,6 +44,7 @@
#include "nsBaseWidgetAccessible.h"
#include "nsFormControlAccessible.h"
#include "nsHTMLFormControlAccessible.h"
#include "nsIAccessibleValue.h"
class nsXULButtonAccessible : public nsAccessible
// Don't inherit from nsFormControlAccessible - it doesn't allow children and a button can have a dropmarker child
@ -95,8 +96,12 @@ public:
NS_IMETHOD GetAccName(nsAString& _retval);
};
class nsXULProgressMeterAccessible : public nsFormControlAccessible
class nsXULProgressMeterAccessible : public nsFormControlAccessible,
public nsIAccessibleValue
{
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLEVALUE
public:
nsXULProgressMeterAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
NS_IMETHOD GetAccRole(PRUint32 *_retval);