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