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   cspi_return_val_if_fail (obj != NULL, FALSE);
59
60   return Accessibility_Component_contains (CSPI_OBJREF (obj),
61                                            (CORBA_long) x,
62                                            (CORBA_long) y,
63                                            ctype,
64                                            cspi_ev ());
65 }
66
67 /**
68  * AccessibleComponent_getAccessibleAtPoint:
69  * @obj: a pointer to the #AccessibleComponent to query.
70  * @x: a #long specifying the x coordinate of the point in question.
71  * @y: a #long specifying the y coordinate of the point in question.
72  * @ctype: the coordinate system of the point (@x, @y)
73  *         (e.g. CSPI_COORD_TYPE_WINDOW, CSPI_COORD_TYPE_SCREEN).
74  *
75  * Get the accessible child at a given coordinate within an #AccessibleComponent.
76  *
77  * Returns: a pointer to an #Accessible child of the specified component which
78  *          contains the point (@x, @y), or NULL of no child contains the point.
79  **/
80 Accessible *
81 AccessibleComponent_getAccessibleAtPoint (AccessibleComponent *obj,
82                                           long int x,
83                                           long int y,
84                                           AccessibleCoordType ctype)
85 {
86   Accessibility_Accessible child;
87
88   cspi_return_val_if_fail (obj != NULL, NULL);
89
90   child = Accessibility_Component_getAccessibleAtPoint (CSPI_OBJREF (obj),
91                                                         (CORBA_long) x,
92                                                         (CORBA_long) y,
93                                                         ctype,
94                                                         cspi_ev ());
95   return cspi_object_add (child);
96 }
97
98 /**
99  * AccessibleComponent_getExtents:
100  * @obj: a pointer to the #AccessibleComponent to query.
101  * @x: a pointer to a #long into which the minimum x coordinate will be returned.
102  * @y: a pointer to a #long into which the minimum y coordinate will be returned.
103  * @width: a pointer to a #long into which the x extents (width) will be returned.
104  * @height: a pointer to a #long into which the y extents (height) will be returned.
105  * @ctype: the desired coordinate system into which to return the results,
106  *         (e.g. CSPI_COORD_TYPE_WINDOW, CSPI_COORD_TYPE_SCREEN).
107  *
108  * Get the bounding box of the specified #AccessibleComponent.
109  *
110  **/
111 void
112 AccessibleComponent_getExtents (AccessibleComponent *obj,
113                                 long int *x,
114                                 long int *y,
115                                 long int *width,
116                                 long int *height,
117                                 AccessibleCoordType ctype)
118 {
119   Accessibility_BoundingBox bbox;
120
121   cspi_return_if_fail (obj != NULL);
122
123   bbox = Accessibility_Component_getExtents (CSPI_OBJREF (obj),
124                                              ctype,
125                                              cspi_ev ());
126   if (cspi_check_ev ("AccessibleComponent_getExtents"))
127     {
128       *x = *y = *width = *height = 0;    
129     }
130   else
131     {
132       *x = bbox.x;
133       *y = bbox.y;
134       *width = bbox.width;
135       *height = bbox.height;
136     }
137 }
138
139 /**
140  * AccessibleComponent_getPosition:
141  * @obj: a pointer to the #AccessibleComponent to query.
142  * @x: a pointer to a #long into which the minimum x coordinate will be returned.
143  * @y: a pointer to a #long into which the minimum y coordinate will be returned.
144  * @ctype: the desired coordinate system into which to return the results,
145  *         (e.g. CSPI_COORD_TYPE_WINDOW, CSPI_COORD_TYPE_SCREEN).
146  *
147  * Get the minimum x and y coordinates of the specified #AccessibleComponent.
148  *
149  **/
150 void
151 AccessibleComponent_getPosition (AccessibleComponent *obj,
152                                  long int *x,
153                                  long int *y,
154                                  AccessibleCoordType ctype)
155 {
156   Accessibility_Component_getPosition (CSPI_OBJREF (obj),
157                                        (CORBA_long *) x,
158                                        (CORBA_long *) y,
159                                        ctype,
160                                        cspi_ev ());
161 }
162
163 /**
164  * AccessibleComponent_getSize:
165  * @obj: a pointer to the #AccessibleComponent to query.
166  * @width: a pointer to a #long into which the x extents (width) will be returned.
167  * @height: a pointer to a #long into which the y extents (height) will be returned.
168  *
169  * Get the size of the specified #AccessibleComponent.
170  *
171  **/
172 void
173 AccessibleComponent_getSize (AccessibleComponent *obj,
174                              long int *width,
175                              long int *height)
176 {
177   Accessibility_Component_getSize (CSPI_OBJREF (obj),
178                                    (CORBA_long *) width,
179                                    (CORBA_long *) height,
180                                    cspi_ev ());
181 }
182
183 /**
184  * AccessibleComponent_getLayer:
185  * @obj: a pointer to the #AccessibleComponent to query.
186  *
187  * Query which layer the component is painted into, to help determine its 
188  *      visibility in terms of stacking order.
189  *
190  * Returns: the #AccessibleComponentLayer into which this component is painted.
191  **/
192 AccessibleComponentLayer
193 AccessibleComponent_getLayer (AccessibleComponent *obj)
194 {
195   Accessibility_ComponentLayer zlayer;
196   AccessibleComponentLayer retval;
197   
198   zlayer = Accessibility_Component_getLayer (CSPI_OBJREF (obj),
199                                              cspi_ev ());
200   switch (zlayer)
201     {
202     case Accessibility_LAYER_BACKGROUND:
203       retval = SPI_LAYER_BACKGROUND;
204       break;
205     case Accessibility_LAYER_CANVAS:      
206       retval = SPI_LAYER_CANVAS;
207       break;
208     case Accessibility_LAYER_WIDGET:      
209       retval = SPI_LAYER_WIDGET;
210       break;
211     case Accessibility_LAYER_MDI:         
212       retval = SPI_LAYER_MDI;
213       break;
214     case Accessibility_LAYER_POPUP:       
215       retval = SPI_LAYER_POPUP;
216       break;
217     case Accessibility_LAYER_OVERLAY:     
218       retval = SPI_LAYER_OVERLAY;
219       break;
220     default:
221       retval = SPI_LAYER_INVALID;
222       break;
223     }
224   return retval;
225 }
226
227 /**
228  * AccessibleComponent_getMDIZOrder:
229  * @obj: a pointer to the #AccessibleComponent to query.
230  *
231  * Query the z stacking order of a component which is in the MDI layer.
232  *       (Bigger z-order numbers mean nearer the top)
233  *
234  * Returns: a short integer indicating the stacking order of the component 
235  *       in the MDI layer, or -1 if the component is not in the MDI layer.
236  **/
237 short
238 AccessibleComponent_getMDIZOrder (AccessibleComponent *obj)
239 {
240   return (short) Accessibility_Component_getMDIZOrder (CSPI_OBJREF (obj),
241                                                        cspi_ev ());
242 }
243
244 /**
245  * AccessibleComponent_grabFocus:
246  * @obj: a pointer to the #AccessibleComponent on which to operate.
247  *
248  * Attempt to set the keyboard input focus to the specified
249  *         #AccessibleComponent.
250  *
251  **/
252 void
253 AccessibleComponent_grabFocus (AccessibleComponent *obj)
254 {
255   ;
256 }