~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/accessible/src/atk/nsMaiInterfaceValue.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 
2
/* vim:expandtab:shiftwidth=4:tabstop=4:
 
3
 */
 
4
/* ***** BEGIN LICENSE BLOCK *****
 
5
 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
 
6
 *
 
7
 *
 
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/
 
12
 *
 
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.
 
17
 *
 
18
 * The Original Code is mozilla.org code.
 
19
 *
 
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.
 
23
 *
 
24
 * Original Author: Silvia Zhao (silvia.zhao@sun.com)
 
25
 *
 
26
 * Contributor(s):
 
27
 *
 
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.
 
39
 *
 
40
 * ***** END LICENSE BLOCK ***** */
 
41
 
 
42
#include "nsMaiInterfaceValue.h"
 
43
 
 
44
G_BEGIN_DECLS
 
45
    
 
46
/*value interface callbacks*/
 
47
 
 
48
static void interfaceInitCB(AtkValueIface *aIface);
 
49
static void getCurrentValueCB(AtkValue *obj,
 
50
                              GValue *value);
 
51
static void getMaximumValueCB(AtkValue *obj,
 
52
                              GValue *value);
 
53
static void getMinimumValueCB(AtkValue *obj,
 
54
                              GValue *value);
 
55
static gboolean setCurrentValueCB(AtkValue *obj,
 
56
                                  const GValue *value);
 
57
G_END_DECLS
 
58
 
 
59
MaiInterfaceValue::MaiInterfaceValue(nsAccessibleWrap *aAccWrap):
 
60
    MaiInterface(aAccWrap)
 
61
{
 
62
}
 
63
 
 
64
MaiInterfaceValue::~MaiInterfaceValue()
 
65
{
 
66
}
 
67
 
 
68
MaiInterfaceType
 
69
MaiInterfaceValue::GetType()
 
70
{
 
71
    return MAI_INTERFACE_VALUE;
 
72
}
 
73
 
 
74
const GInterfaceInfo *
 
75
MaiInterfaceValue::GetInterfaceInfo()
 
76
{
 
77
    static const GInterfaceInfo atk_if_value_info = {
 
78
        (GInterfaceInitFunc) interfaceInitCB,
 
79
        (GInterfaceFinalizeFunc) NULL,
 
80
        NULL
 
81
    };
 
82
    return &atk_if_value_info;
 
83
}
 
84
 
 
85
/* static functions */
 
86
 
 
87
void
 
88
interfaceInitCB(AtkValueIface *aIface)
 
89
{
 
90
    NS_ASSERTION(aIface, "Invalid aIface");
 
91
    if (!aIface)
 
92
        return;
 
93
 
 
94
    aIface->get_current_value = getCurrentValueCB;
 
95
    aIface->get_maximum_value = getMaximumValueCB;
 
96
    aIface->get_minimum_value = getMinimumValueCB;
 
97
    aIface->set_current_value = setCurrentValueCB;
 
98
}
 
99
 
 
100
void
 
101
getCurrentValueCB(AtkValue *obj, GValue *value)
 
102
{
 
103
    nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
 
104
    if (!accWrap)
 
105
        return;
 
106
 
 
107
    nsCOMPtr<nsIAccessibleValue> accValue;
 
108
    accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
 
109
                            getter_AddRefs(accValue));
 
110
    if (!accValue)
 
111
        return;
 
112
 
 
113
    memset (value,  0, sizeof (GValue));
 
114
    double accDouble;
 
115
    if (NS_FAILED(accValue->GetCurrentValue(&accDouble)))
 
116
        return;
 
117
    g_value_init (value, G_TYPE_DOUBLE);
 
118
    g_value_set_double (value, accDouble);
 
119
}
 
120
 
 
121
void
 
122
getMaximumValueCB(AtkValue *obj, GValue *value)
 
123
{
 
124
    nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
 
125
    if (!accWrap)
 
126
        return;
 
127
 
 
128
    nsCOMPtr<nsIAccessibleValue> accValue;
 
129
    accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
 
130
                            getter_AddRefs(accValue));
 
131
    if (!accValue)
 
132
        return;
 
133
 
 
134
    memset (value,  0, sizeof (GValue));
 
135
    double accDouble;
 
136
    if (NS_FAILED(accValue->GetMaximumValue(&accDouble)))
 
137
        return;
 
138
    g_value_init (value, G_TYPE_DOUBLE);
 
139
    g_value_set_double (value, accDouble);
 
140
}
 
141
 
 
142
void
 
143
getMinimumValueCB(AtkValue *obj, GValue *value)
 
144
{
 
145
    nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
 
146
    if (!accWrap)
 
147
        return;
 
148
 
 
149
    nsCOMPtr<nsIAccessibleValue> accValue;
 
150
    accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
 
151
                            getter_AddRefs(accValue));
 
152
    if (!accValue)
 
153
        return;
 
154
 
 
155
    memset (value,  0, sizeof (GValue));
 
156
    double accDouble;
 
157
    if (NS_FAILED(accValue->GetMinimumValue(&accDouble)))
 
158
        return;
 
159
    g_value_init (value, G_TYPE_DOUBLE);
 
160
    g_value_set_double (value, accDouble);
 
161
}
 
162
 
 
163
gboolean
 
164
setCurrentValueCB(AtkValue *obj, const GValue *value)
 
165
{
 
166
    nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
 
167
    NS_ENSURE_TRUE(accWrap, FALSE);
 
168
 
 
169
    nsCOMPtr<nsIAccessibleValue> accValue;
 
170
    accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
 
171
                            getter_AddRefs(accValue));
 
172
    NS_ENSURE_TRUE(accValue, FALSE);
 
173
 
 
174
    PRBool aBool;
 
175
    double accDouble;
 
176
    accDouble = g_value_get_double (value);
 
177
    accValue->SetCurrentValue(accDouble, &aBool);
 
178
    return aBool;
 
179
}