alternative to assert
[gtkD.git] / gtkD / src / atk / Component.d
blobcd65c352fc49b808428a9a5d9434b1ac9621f55c
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = AtkComponent.html
26 * outPack = atk
27 * outFile = Component
28 * strct = AtkComponent
29 * realStrct=
30 * ctorStrct=
31 * clss = Component
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - atk_component_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * structWrap:
45 * module aliases:
46 * local aliases:
49 module atk.Component;
51 version(noAssert)
53 version(Tango)
55 import tango.io.Stdout; // use the tango loging?
59 private import gtkc.atktypes;
61 private import gtkc.atk;
68 /**
69 * Description
70 * AtkComponent should be implemented by most if not all UI elements with
71 * an actual on-screen presence, i.e. components which can be said to have
72 * a screen-coordinate bounding box. Virtually all widgets will need to
73 * have AtkComponent implementations provided for their corresponding
74 * AtkObject class. In short, only UI elements which are *not* GUI
75 * elements will omit this ATK interface.
76 * A possible exception might be textual information with a transparent
77 * background, in which case text glyph bounding box information is
78 * provided by AtkText.
80 public class Component
83 /** the main Gtk struct */
84 protected AtkComponent* atkComponent;
87 public AtkComponent* getComponentStruct()
89 return atkComponent;
93 /** the main Gtk struct as a void* */
94 protected void* getStruct()
96 return cast(void*)atkComponent;
99 /**
100 * Sets our main struct and passes it to the parent class
102 public this (AtkComponent* atkComponent)
104 version(noAssert)
106 if ( atkComponent is null )
108 int zero = 0;
109 version(Tango)
111 Stdout("struct atkComponent is null on constructor").newline;
113 else
115 printf("struct atkComponent is null on constructor");
117 zero = zero / zero;
120 else
122 assert(atkComponent !is null, "struct atkComponent is null on constructor");
124 this.atkComponent = atkComponent;
130 // imports for the signal processing
131 private import gobject.Signals;
132 private import gtkc.gdktypes;
133 int[char[]] connectedSignals;
135 void delegate(AtkRectangle*, Component)[] onBoundsChangedListeners;
136 void addOnBoundsChanged(void delegate(AtkRectangle*, Component) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
138 if ( !("bounds-changed" in connectedSignals) )
140 Signals.connectData(
141 getStruct(),
142 "bounds-changed",
143 cast(GCallback)&callBackBoundsChanged,
144 cast(void*)this,
145 null,
146 connectFlags);
147 connectedSignals["bounds-changed"] = 1;
149 onBoundsChangedListeners ~= dlg;
151 extern(C) static void callBackBoundsChanged(AtkComponent* atkcomponentStruct, AtkRectangle* arg1, Component component)
153 bool consumed = false;
155 foreach ( void delegate(AtkRectangle*, Component) dlg ; component.onBoundsChangedListeners )
157 dlg(arg1, component);
160 return consumed;
166 * Add the specified handler to the set of functions to be called
167 * when this object receives focus events (in or out). If the handler is
168 * already added it is not added again
169 * component:
170 * The AtkComponent to attach the handler to
171 * handler:
172 * The AtkFocusHandler to be attached to component
173 * Returns:
174 * a handler id which can be used in atk_component_remove_focus_handler
175 * or zero if the handler was already added.
177 public uint addFocusHandler(AtkFocusHandler handler)
179 // guint atk_component_add_focus_handler (AtkComponent *component, AtkFocusHandler handler);
180 return atk_component_add_focus_handler(atkComponent, handler);
184 * Checks whether the specified point is within the extent of the component.
185 * component:
186 * the AtkComponent
187 * x:
188 * x coordinate
189 * y:
190 * y coordinate
191 * coord_type:
192 * specifies whether the coordinates are relative to the screen
193 * or to the components top level window
194 * Returns:
195 * TRUE or FALSE indicating whether the specified point is within
196 * the extent of the component or not
198 public int contains(int x, int y, AtkCoordType coordType)
200 // gboolean atk_component_contains (AtkComponent *component, gint x, gint y, AtkCoordType coord_type);
201 return atk_component_contains(atkComponent, x, y, coordType);
205 * Gets the rectangle which gives the extent of the component.
206 * component:
207 * an AtkComponent
208 * x:
209 * address of gint to put x coordinate
210 * y:
211 * address of gint to put y coordinate
212 * width:
213 * address of gint to put width
214 * height:
215 * address of gint to put height
216 * coord_type:
217 * specifies whether the coordinates are relative to the screen
218 * or to the components top level window
220 public void getExtents(int* x, int* y, int* width, int* height, AtkCoordType coordType)
222 // void atk_component_get_extents (AtkComponent *component, gint *x, gint *y, gint *width, gint *height, AtkCoordType coord_type);
223 atk_component_get_extents(atkComponent, x, y, width, height, coordType);
227 * Gets the layer of the component.
228 * component:
229 * an AtkComponent
230 * Returns:
231 * an AtkLayer which is the layer of the component
233 public AtkLayer getLayer()
235 // AtkLayer atk_component_get_layer (AtkComponent *component);
236 return atk_component_get_layer(atkComponent);
240 * Gets the zorder of the component. The value G_MININT will be returned
241 * if the layer of the component is not ATK_LAYER_MDI or ATK_LAYER_WINDOW.
242 * component:
243 * an AtkComponent
244 * Returns:
245 * a gint which is the zorder of the component, i.e. the depth at
246 * which the component is shown in relation to other components in the same
247 * container.
249 public int getMdiZorder()
251 // gint atk_component_get_mdi_zorder (AtkComponent *component);
252 return atk_component_get_mdi_zorder(atkComponent);
256 * Gets the position of component in the form of
257 * a point specifying component's top-left corner.
258 * component:
259 * an AtkComponent
260 * x:
261 * address of gint to put x coordinate position
262 * y:
263 * address of gint to put y coordinate position
264 * coord_type:
265 * specifies whether the coordinates are relative to the screen
266 * or to the components top level window
268 public void getPosition(int* x, int* y, AtkCoordType coordType)
270 // void atk_component_get_position (AtkComponent *component, gint *x, gint *y, AtkCoordType coord_type);
271 atk_component_get_position(atkComponent, x, y, coordType);
275 * Gets the size of the component in terms of width and height.
276 * component:
277 * an AtkComponent
278 * width:
279 * address of gint to put width of component
280 * height:
281 * address of gint to put height of component
283 public void getSize(int* width, int* height)
285 // void atk_component_get_size (AtkComponent *component, gint *width, gint *height);
286 atk_component_get_size(atkComponent, width, height);
290 * Grabs focus for this component.
291 * component:
292 * an AtkComponent
293 * Returns:
294 * TRUE if successful, FALSE otherwise.
296 public int grabFocus()
298 // gboolean atk_component_grab_focus (AtkComponent *component);
299 return atk_component_grab_focus(atkComponent);
303 * Gets a reference to the accessible child, if one exists, at the
304 * coordinate point specified by x and y.
305 * component:
306 * the AtkComponent
307 * x:
308 * x coordinate
309 * y:
310 * y coordinate
311 * coord_type:
312 * specifies whether the coordinates are relative to the screen
313 * or to the components top level window
314 * Returns:
315 * a reference to the accessible child, if one exists
317 public AtkObject* refAccessibleAtPoint(int x, int y, AtkCoordType coordType)
319 // AtkObject* atk_component_ref_accessible_at_point (AtkComponent *component, gint x, gint y, AtkCoordType coord_type);
320 return atk_component_ref_accessible_at_point(atkComponent, x, y, coordType);
324 * Remove the handler specified by handler_id from the list of
325 * functions to be executed when this object receives focus events
326 * (in or out).
327 * component:
328 * the AtkComponent to remove the focus handler from
329 * handler_id:
330 * the handler id of the focus handler to be removed
331 * from component
333 public void removeFocusHandler(uint handlerId)
335 // void atk_component_remove_focus_handler (AtkComponent *component, guint handler_id);
336 atk_component_remove_focus_handler(atkComponent, handlerId);
340 * Sets the extents of component.
341 * component:
342 * an AtkComponent
343 * x:
344 * x coordinate
345 * y:
346 * y coordinate
347 * width:
348 * width to set for component
349 * height:
350 * height to set for component
351 * coord_type:
352 * specifies whether the coordinates are relative to the screen
353 * or to the components top level window
354 * Returns:
355 * TRUE or FALSE whether the extents were set or not
357 public int setExtents(int x, int y, int width, int height, AtkCoordType coordType)
359 // gboolean atk_component_set_extents (AtkComponent *component, gint x, gint y, gint width, gint height, AtkCoordType coord_type);
360 return atk_component_set_extents(atkComponent, x, y, width, height, coordType);
364 * Sets the postition of component.
365 * component:
366 * an AtkComponent
367 * x:
368 * x coordinate
369 * y:
370 * y coordinate
371 * coord_type:
372 * specifies whether the coordinates are relative to the screen
373 * or to the components top level window
374 * Returns:
375 * TRUE or FALSE whether or not the position was set or not
377 public int setPosition(int x, int y, AtkCoordType coordType)
379 // gboolean atk_component_set_position (AtkComponent *component, gint x, gint y, AtkCoordType coord_type);
380 return atk_component_set_position(atkComponent, x, y, coordType);
384 * Set the size of the component in terms of width and height.
385 * component:
386 * an AtkComponent
387 * width:
388 * width to set for component
389 * height:
390 * height to set for component
391 * Returns:
392 * TRUE or FALSE whether the size was set or not
394 public int setSize(int width, int height)
396 // gboolean atk_component_set_size (AtkComponent *component, gint width, gint height);
397 return atk_component_set_size(atkComponent, width, height);
401 * Returns the alpha value (i.e. the opacity) for this
402 * component, on a scale from 0 (fully transparent) to 1.0
403 * (fully opaque).
404 * component:
405 * an AtkComponent
406 * Returns:
407 * An alpha value from 0 to 1.0, inclusive.
408 * Since ATK 1.12
409 * Signal Details
410 * The "bounds-changed" signal
411 * void user_function (AtkComponent *atkcomponent,
412 * AtkRectangle *arg1,
413 * gpointer user_data) : Run Last
414 * The 'bounds-changed" signal is emitted when the bposition or size of the
415 * a component changes.
416 * atkcomponent:
417 * the object which received the signal.
418 * arg1:
419 * The AtkRectangle giving the new position and size.
420 * user_data:
421 * user data set when the signal handler was connected.
423 public double getAlpha()
425 // gdouble atk_component_get_alpha (AtkComponent *component);
426 return atk_component_get_alpha(atkComponent);