Fixed macro-name typos.
[platform/core/uifw/at-spi2-atk.git] / cspi / spi_component.c
1 /*
2  *
3  * AccessibleComponent function implementations
4  *
5  */
6
7 #include <cspi/spi-private.h>
8
9 /**
10  * AccessibleComponent_ref:
11  * @obj: a pointer to an object implementing #AccessibleComponent on which to operate.
12  *
13  * Increment the reference count for an #AccessibleComponent.
14  *
15  **/
16 void
17 AccessibleComponent_ref (AccessibleComponent *obj)
18 {
19   cspi_object_ref (obj);
20 }
21
22 /**
23  * AccessibleComponent_unref:
24  * @obj: a pointer to the object implementing #AccessibleComponent on which to operate.
25  *
26  * Decrement the reference count for an #AccessibleComponent.
27  *
28  **/
29 void
30 AccessibleComponent_unref (AccessibleComponent *obj)
31 {
32   cspi_object_unref (obj);
33 }
34
35 /**
36  * AccessibleComponent_contains:
37  * @obj: a pointer to the #AccessibleComponent to query.
38  * @x: a #long specifying the x coordinate in question.
39  * @y: a #long specifying the y coordinate in question.
40  * @ctype: the desired coordinate system of the point (@x, @y)
41  *         (e.g. CSPI_COORD_TYPE_WINDOW, CSPI_COORD_TYPE_SCREEN).
42  *
43  * Query whether a given #AccessibleComponent contains a particular point.
44  *
45  * Returns: a #TRUE if the specified component contains the point (@x, @y),
46  *          otherwise #FALSE.
47  **/
48 SPIBoolean
49 AccessibleComponent_contains (AccessibleComponent *obj,
50                               long int x,
51                               long int y,
52                               AccessibleCoordType ctype)
53 {
54   SPIBoolean retval;
55
56   cspi_return_val_if_fail (obj != NULL, FALSE);
57
58   retval = Accessibility_Component_contains (CSPI_OBJREF (obj),
59                                              (CORBA_long) x,
60                                              (CORBA_long) y,
61                                              ctype,
62                                              cspi_ev ());
63   cspi_return_val_if_ev ("contains", FALSE);
64
65   return retval;
66 }
67
68 /**
69  * AccessibleComponent_getAccessibleAtPoint:
70  * @obj: a pointer to the #AccessibleComponent to query.
71  * @x: a #long specifying the x coordinate of the point in question.
72  * @y: a #long specifying the y coordinate of the point in question.
73  * @ctype: the coordinate system of the point (@x, @y)
74  *         (e.g. CSPI_COORD_TYPE_WINDOW, CSPI_COORD_TYPE_SCREEN).
75  *
76  * Get the accessible child at a given coordinate within an #AccessibleComponent.
77  *
78  * Returns: a pointer to an #Accessible child of the specified component which
79  *          contains the point (@x, @y), or NULL of no child contains the point.
80  **/
81 Accessible *
82 AccessibleComponent_getAccessibleAtPoint (AccessibleComponent *obj,
83                                           long int x,
84                                           long int y,
85                                           AccessibleCoordType ctype)
86 {
87   Accessibility_Accessible child;
88
89   cspi_return_val_if_fail (obj != NULL, NULL);
90
91   child = Accessibility_Component_getAccessibleAtPoint (CSPI_OBJREF (obj),
92                                                         (CORBA_long) x,
93                                                         (CORBA_long) y,
94                                                         ctype,
95                                                         cspi_ev ());
96   return cspi_object_add (child);
97 }
98
99 /**
100  * AccessibleComponent_getExtents:
101  * @obj: a pointer to the #AccessibleComponent to query.
102  * @x: a pointer to a #long into which the minimum x coordinate will be returned.
103  * @y: a pointer to a #long into which the minimum y coordinate will be returned.
104  * @width: a pointer to a #long into which the x extents (width) will be returned.
105  * @height: a pointer to a #long into which the y extents (height) will be returned.
106  * @ctype: the desired coordinate system into which to return the results,
107  *         (e.g. CSPI_COORD_TYPE_WINDOW, CSPI_COORD_TYPE_SCREEN).
108  *
109  * Get the bounding box of the specified #AccessibleComponent.
110  *
111  **/
112 void
113 AccessibleComponent_getExtents (AccessibleComponent *obj,
114                                 long int *x,
115                                 long int *y,
116                                 long int *width,
117                                 long int *height,
118                                 AccessibleCoordType ctype)
119 {
120   Accessibility_BoundingBox bbox;
121
122   cspi_return_if_fail (obj != NULL);
123
124   bbox = Accessibility_Component_getExtents (CSPI_OBJREF (obj),
125                                              ctype,
126                                              cspi_ev ());
127   if (!cspi_check_ev ("AccessibleComponent_getExtents"))
128     {
129       *x = *y = *width = *height = 0;    
130     }
131   else
132     {
133       *x = bbox.x;
134       *y = bbox.y;
135       *width = bbox.width;
136       *height = bbox.height;
137     }
138 }
139
140 /**
141  * AccessibleComponent_getPosition:
142  * @obj: a pointer to the #AccessibleComponent to query.
143  * @x: a pointer to a #long into which the minimum x coordinate will be returned.
144  * @y: a pointer to a #long into which the minimum y coordinate will be returned.
145  * @ctype: the desired coordinate system into which to return the results,
146  *         (e.g. CSPI_COORD_TYPE_WINDOW, CSPI_COORD_TYPE_SCREEN).
147  *
148  * Get the minimum x and y coordinates of the specified #AccessibleComponent.
149  *
150  **/
151 void
152 AccessibleComponent_getPosition (AccessibleComponent *obj,
153                                  long int *x,
154                                  long int *y,
155                                  AccessibleCoordType ctype)
156 {
157   CORBA_long cx, cy;
158
159   cspi_return_if_fail (obj != NULL);
160
161   Accessibility_Component_getPosition (CSPI_OBJREF (obj),
162                                        &cx, &cy, ctype, cspi_ev ());
163
164   if (!cspi_check_ev ("getPosition"))
165     {
166       *x = *y = 0;
167     }
168   else
169     {
170       *x = cx;
171       *y = cy;
172     }
173 }
174
175 /**
176  * AccessibleComponent_getSize:
177  * @obj: a pointer to the #AccessibleComponent to query.
178  * @width: a pointer to a #long into which the x extents (width) will be returned.
179  * @height: a pointer to a #long into which the y extents (height) will be returned.
180  *
181  * Get the size of the specified #AccessibleComponent.
182  *
183  **/
184 void
185 AccessibleComponent_getSize (AccessibleComponent *obj,
186                              long int *width,
187                              long int *height)
188 {
189   cspi_return_if_fail (obj != NULL);
190
191   Accessibility_Component_getSize (CSPI_OBJREF (obj),
192                                    (CORBA_long *) width,
193                                    (CORBA_long *) height,
194                                    cspi_ev ());
195 }
196
197 /**
198  * AccessibleComponent_getLayer:
199  * @obj: a pointer to the #AccessibleComponent to query.
200  *
201  * Query which layer the component is painted into, to help determine its 
202  *      visibility in terms of stacking order.
203  *
204  * Returns: the #AccessibleComponentLayer into which this component is painted.
205  **/
206 AccessibleComponentLayer
207 AccessibleComponent_getLayer (AccessibleComponent *obj)
208 {
209   AccessibleComponentLayer     retval;
210   Accessibility_ComponentLayer zlayer;
211
212   cspi_return_val_if_fail (obj != NULL, FALSE);
213
214   zlayer = Accessibility_Component_getLayer (CSPI_OBJREF (obj),
215                                              cspi_ev ());
216
217   cspi_return_val_if_ev ("getLayer", SPI_LAYER_INVALID);
218
219   switch (zlayer)
220     {
221     case Accessibility_LAYER_BACKGROUND:
222       retval = SPI_LAYER_BACKGROUND;
223       break;
224     case Accessibility_LAYER_CANVAS:      
225       retval = SPI_LAYER_CANVAS;
226       break;
227     case Accessibility_LAYER_WIDGET:      
228       retval = SPI_LAYER_WIDGET;
229       break;
230     case Accessibility_LAYER_MDI:         
231       retval = SPI_LAYER_MDI;
232       break;
233     case Accessibility_LAYER_POPUP:       
234       retval = SPI_LAYER_POPUP;
235       break;
236     case Accessibility_LAYER_OVERLAY:     
237       retval = SPI_LAYER_OVERLAY;
238       break;
239     default:
240       retval = SPI_LAYER_INVALID;
241       break;
242     }
243
244   return retval;
245 }
246
247 /**
248  * AccessibleComponent_getMDIZOrder:
249  * @obj: a pointer to the #AccessibleComponent to query.
250  *
251  * Query the z stacking order of a component which is in the MDI layer.
252  *       (Bigger z-order numbers mean nearer the top)
253  *
254  * Returns: a short integer indicating the stacking order of the component 
255  *       in the MDI layer, or -1 if the component is not in the MDI layer.
256  **/
257 short
258 AccessibleComponent_getMDIZOrder (AccessibleComponent *obj)
259 {
260   short retval;
261
262   cspi_return_val_if_fail (obj != NULL, FALSE);
263
264   retval = Accessibility_Component_getMDIZOrder (CSPI_OBJREF (obj),
265                                                  cspi_ev ());
266
267   cspi_return_val_if_ev ("getMDIZOrder", FALSE);
268
269   return retval;
270 }
271
272 /**
273  * AccessibleComponent_grabFocus:
274  * @obj: a pointer to the #AccessibleComponent on which to operate.
275  *
276  * Attempt to set the keyboard input focus to the specified
277  *         #AccessibleComponent.
278  **/
279 void
280 AccessibleComponent_grabFocus (AccessibleComponent *obj)
281 {
282 }