1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* vim:expandtab:shiftwidth=4:tabstop=4:
4
/* ***** BEGIN LICENSE BLOCK *****
5
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
8
* The contents of this file are subject to the Mozilla Public
9
* License Version 1.1 (the "License"); you may not use this file
10
* except in compliance with the License. You may obtain a copy of
11
* the License at http://www.mozilla.org/MPL/
13
* Software distributed under the License is distributed on an "AS
14
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
15
* implied. See the License for the specific language governing
16
* rights and limitations under the License.
18
* The Original Code is mozilla.org code.
20
* The Initial Developer of the Original Code is Sun Microsystems, Inc.
21
* Portions created by Sun Microsystems are Copyright (C) 2002 Sun
22
* Microsystems, Inc. All Rights Reserved.
24
* Original Author: Silvia Zhao (silvia.zhao@sun.com)
28
* Alternatively, the contents of this file may be used under the terms of
29
* either the GNU General Public License Version 2 or later (the "GPL"), or
30
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
31
* in which case the provisions of the GPL or the LGPL are applicable instead
32
* of those above. If you wish to allow use of your version of this file only
33
* under the terms of either the GPL or the LGPL, and not to allow others to
34
* use your version of this file under the terms of the NPL, indicate your
35
* decision by deleting the provisions above and replace them with the notice
36
* and other provisions required by the GPL or the LGPL. If you do not delete
37
* the provisions above, a recipient may use your version of this file under
38
* the terms of any one of the NPL, the GPL or the LGPL.
40
* ***** END LICENSE BLOCK ***** */
42
#include "nsMaiInterfaceValue.h"
46
/*value interface callbacks*/
48
static void interfaceInitCB(AtkValueIface *aIface);
49
static void getCurrentValueCB(AtkValue *obj,
51
static void getMaximumValueCB(AtkValue *obj,
53
static void getMinimumValueCB(AtkValue *obj,
55
static gboolean setCurrentValueCB(AtkValue *obj,
59
MaiInterfaceValue::MaiInterfaceValue(nsAccessibleWrap *aAccWrap):
60
MaiInterface(aAccWrap)
64
MaiInterfaceValue::~MaiInterfaceValue()
69
MaiInterfaceValue::GetType()
71
return MAI_INTERFACE_VALUE;
74
const GInterfaceInfo *
75
MaiInterfaceValue::GetInterfaceInfo()
77
static const GInterfaceInfo atk_if_value_info = {
78
(GInterfaceInitFunc) interfaceInitCB,
79
(GInterfaceFinalizeFunc) NULL,
82
return &atk_if_value_info;
85
/* static functions */
88
interfaceInitCB(AtkValueIface *aIface)
90
NS_ASSERTION(aIface, "Invalid aIface");
94
aIface->get_current_value = getCurrentValueCB;
95
aIface->get_maximum_value = getMaximumValueCB;
96
aIface->get_minimum_value = getMinimumValueCB;
97
aIface->set_current_value = setCurrentValueCB;
101
getCurrentValueCB(AtkValue *obj, GValue *value)
103
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
107
nsCOMPtr<nsIAccessibleValue> accValue;
108
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
109
getter_AddRefs(accValue));
113
memset (value, 0, sizeof (GValue));
115
if (NS_FAILED(accValue->GetCurrentValue(&accDouble)))
117
g_value_init (value, G_TYPE_DOUBLE);
118
g_value_set_double (value, accDouble);
122
getMaximumValueCB(AtkValue *obj, GValue *value)
124
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
128
nsCOMPtr<nsIAccessibleValue> accValue;
129
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
130
getter_AddRefs(accValue));
134
memset (value, 0, sizeof (GValue));
136
if (NS_FAILED(accValue->GetMaximumValue(&accDouble)))
138
g_value_init (value, G_TYPE_DOUBLE);
139
g_value_set_double (value, accDouble);
143
getMinimumValueCB(AtkValue *obj, GValue *value)
145
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
149
nsCOMPtr<nsIAccessibleValue> accValue;
150
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
151
getter_AddRefs(accValue));
155
memset (value, 0, sizeof (GValue));
157
if (NS_FAILED(accValue->GetMinimumValue(&accDouble)))
159
g_value_init (value, G_TYPE_DOUBLE);
160
g_value_set_double (value, accDouble);
164
setCurrentValueCB(AtkValue *obj, const GValue *value)
166
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
167
NS_ENSURE_TRUE(accWrap, FALSE);
169
nsCOMPtr<nsIAccessibleValue> accValue;
170
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
171
getter_AddRefs(accValue));
172
NS_ENSURE_TRUE(accValue, FALSE);
176
accDouble = g_value_get_double (value);
177
accValue->SetCurrentValue(accDouble, &aBool);