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