1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module atk.ComponentT; 26 27 public import atk.ObjectAtk; 28 public import atk.Rectangle; 29 public import atk.c.functions; 30 public import atk.c.types; 31 public import gobject.ObjectG; 32 public import gobject.Signals; 33 public import std.algorithm; 34 35 36 /** 37 * #AtkComponent should be implemented by most if not all UI elements 38 * with an actual on-screen presence, i.e. components which can be 39 * said to have a screen-coordinate bounding box. Virtually all 40 * widgets will need to have #AtkComponent implementations provided 41 * for their corresponding #AtkObject class. In short, only UI 42 * elements which are *not* GUI elements will omit this ATK interface. 43 * 44 * A possible exception might be textual information with a 45 * transparent background, in which case text glyph bounding box 46 * information is provided by #AtkText. 47 */ 48 public template ComponentT(TStruct) 49 { 50 /** Get the main Gtk struct */ 51 public AtkComponent* getComponentStruct(bool transferOwnership = false) 52 { 53 if (transferOwnership) 54 ownedRef = false; 55 return cast(AtkComponent*)getStruct(); 56 } 57 58 59 /** 60 * Add the specified handler to the set of functions to be called 61 * when this object receives focus events (in or out). If the handler is 62 * already added it is not added again 63 * 64 * Deprecated: If you need to track when an object gains or 65 * lose the focus, use the #AtkObject::state-change "focused" notification instead. 66 * 67 * Params: 68 * handler = The #AtkFocusHandler to be attached to @component 69 * 70 * Returns: a handler id which can be used in atk_component_remove_focus_handler() 71 * or zero if the handler was already added. 72 */ 73 public uint addFocusHandler(AtkFocusHandler handler) 74 { 75 return atk_component_add_focus_handler(getComponentStruct(), handler); 76 } 77 78 /** 79 * Checks whether the specified point is within the extent of the @component. 80 * 81 * Toolkit implementor note: ATK provides a default implementation for 82 * this virtual method. In general there are little reason to 83 * re-implement it. 84 * 85 * Params: 86 * x = x coordinate 87 * y = y coordinate 88 * coordType = specifies whether the coordinates are relative to the screen 89 * or to the components top level window 90 * 91 * Returns: %TRUE or %FALSE indicating whether the specified point is within 92 * the extent of the @component or not 93 */ 94 public bool contains(int x, int y, AtkCoordType coordType) 95 { 96 return atk_component_contains(getComponentStruct(), x, y, coordType) != 0; 97 } 98 99 /** 100 * Returns the alpha value (i.e. the opacity) for this 101 * @component, on a scale from 0 (fully transparent) to 1.0 102 * (fully opaque). 103 * 104 * Returns: An alpha value from 0 to 1.0, inclusive. 105 * 106 * Since: 1.12 107 */ 108 public double getAlpha() 109 { 110 return atk_component_get_alpha(getComponentStruct()); 111 } 112 113 /** 114 * Gets the rectangle which gives the extent of the @component. 115 * 116 * If the extent can not be obtained (e.g. a non-embedded plug or missing 117 * support), all of x, y, width, height are set to -1. 118 * 119 * Params: 120 * x = address of #gint to put x coordinate 121 * y = address of #gint to put y coordinate 122 * width = address of #gint to put width 123 * height = address of #gint to put height 124 * coordType = specifies whether the coordinates are relative to the screen 125 * or to the components top level window 126 */ 127 public void getExtents(out int x, out int y, out int width, out int height, AtkCoordType coordType) 128 { 129 atk_component_get_extents(getComponentStruct(), &x, &y, &width, &height, coordType); 130 } 131 132 /** 133 * Gets the layer of the component. 134 * 135 * Returns: an #AtkLayer which is the layer of the component 136 */ 137 public override AtkLayer getLayer() 138 { 139 return atk_component_get_layer(getComponentStruct()); 140 } 141 142 /** 143 * Gets the zorder of the component. The value G_MININT will be returned 144 * if the layer of the component is not ATK_LAYER_MDI or ATK_LAYER_WINDOW. 145 * 146 * Returns: a gint which is the zorder of the component, i.e. the depth at 147 * which the component is shown in relation to other components in the same 148 * container. 149 */ 150 public override int getMdiZorder() 151 { 152 return atk_component_get_mdi_zorder(getComponentStruct()); 153 } 154 155 /** 156 * Gets the position of @component in the form of 157 * a point specifying @component's top-left corner. 158 * 159 * If the position can not be obtained (e.g. a non-embedded plug or missing 160 * support), x and y are set to -1. 161 * 162 * Deprecated: Since 2.12. Use atk_component_get_extents() instead. 163 * 164 * Params: 165 * x = address of #gint to put x coordinate position 166 * y = address of #gint to put y coordinate position 167 * coordType = specifies whether the coordinates are relative to the screen 168 * or to the components top level window 169 */ 170 public void getPosition(out int x, out int y, AtkCoordType coordType) 171 { 172 atk_component_get_position(getComponentStruct(), &x, &y, coordType); 173 } 174 175 /** 176 * Gets the size of the @component in terms of width and height. 177 * 178 * If the size can not be obtained (e.g. a non-embedded plug or missing 179 * support), width and height are set to -1. 180 * 181 * Deprecated: Since 2.12. Use atk_component_get_extents() instead. 182 * 183 * Params: 184 * width = address of #gint to put width of @component 185 * height = address of #gint to put height of @component 186 */ 187 public void getSize(out int width, out int height) 188 { 189 atk_component_get_size(getComponentStruct(), &width, &height); 190 } 191 192 /** 193 * Grabs focus for this @component. 194 * 195 * Returns: %TRUE if successful, %FALSE otherwise. 196 */ 197 public bool grabFocus() 198 { 199 return atk_component_grab_focus(getComponentStruct()) != 0; 200 } 201 202 /** 203 * Gets a reference to the accessible child, if one exists, at the 204 * coordinate point specified by @x and @y. 205 * 206 * Params: 207 * x = x coordinate 208 * y = y coordinate 209 * coordType = specifies whether the coordinates are relative to the screen 210 * or to the components top level window 211 * 212 * Returns: a reference to the accessible 213 * child, if one exists 214 */ 215 public ObjectAtk refAccessibleAtPoint(int x, int y, AtkCoordType coordType) 216 { 217 auto __p = atk_component_ref_accessible_at_point(getComponentStruct(), x, y, coordType); 218 219 if(__p is null) 220 { 221 return null; 222 } 223 224 return ObjectG.getDObject!(ObjectAtk)(cast(AtkObject*) __p, true); 225 } 226 227 /** 228 * Remove the handler specified by @handler_id from the list of 229 * functions to be executed when this object receives focus events 230 * (in or out). 231 * 232 * Deprecated: If you need to track when an object gains or 233 * lose the focus, use the #AtkObject::state-change "focused" notification instead. 234 * 235 * Params: 236 * handlerId = the handler id of the focus handler to be removed 237 * from @component 238 */ 239 public void removeFocusHandler(uint handlerId) 240 { 241 atk_component_remove_focus_handler(getComponentStruct(), handlerId); 242 } 243 244 /** 245 * Makes @component visible on the screen by scrolling all necessary parents. 246 * 247 * Contrary to atk_component_set_position, this does not actually move 248 * @component in its parent, this only makes the parents scroll so that the 249 * object shows up on the screen, given its current position within the parents. 250 * 251 * Params: 252 * type = specify where the object should be made visible. 253 * 254 * Returns: whether scrolling was successful. 255 * 256 * Since: 2.30 257 */ 258 public bool scrollTo(AtkScrollType type) 259 { 260 return atk_component_scroll_to(getComponentStruct(), type) != 0; 261 } 262 263 /** 264 * Move the top-left of @component to a given position of the screen by 265 * scrolling all necessary parents. 266 * 267 * Params: 268 * coords = specify whether coordinates are relative to the screen or to the 269 * parent object. 270 * x = x-position where to scroll to 271 * y = y-position where to scroll to 272 * 273 * Returns: whether scrolling was successful. 274 * 275 * Since: 2.30 276 */ 277 public bool scrollToPoint(AtkCoordType coords, int x, int y) 278 { 279 return atk_component_scroll_to_point(getComponentStruct(), coords, x, y) != 0; 280 } 281 282 /** 283 * Sets the extents of @component. 284 * 285 * Params: 286 * x = x coordinate 287 * y = y coordinate 288 * width = width to set for @component 289 * height = height to set for @component 290 * coordType = specifies whether the coordinates are relative to the screen 291 * or to the components top level window 292 * 293 * Returns: %TRUE or %FALSE whether the extents were set or not 294 */ 295 public bool setExtents(int x, int y, int width, int height, AtkCoordType coordType) 296 { 297 return atk_component_set_extents(getComponentStruct(), x, y, width, height, coordType) != 0; 298 } 299 300 /** 301 * Sets the position of @component. 302 * 303 * Contrary to atk_component_scroll_to, this does not trigger any scrolling, 304 * this just moves @component in its parent. 305 * 306 * Params: 307 * x = x coordinate 308 * y = y coordinate 309 * coordType = specifies whether the coordinates are relative to the screen 310 * or to the component's top level window 311 * 312 * Returns: %TRUE or %FALSE whether or not the position was set or not 313 */ 314 public bool setPosition(int x, int y, AtkCoordType coordType) 315 { 316 return atk_component_set_position(getComponentStruct(), x, y, coordType) != 0; 317 } 318 319 /** 320 * Set the size of the @component in terms of width and height. 321 * 322 * Params: 323 * width = width to set for @component 324 * height = height to set for @component 325 * 326 * Returns: %TRUE or %FALSE whether the size was set or not 327 */ 328 public bool setSize(int width, int height) 329 { 330 return atk_component_set_size(getComponentStruct(), width, height) != 0; 331 } 332 333 /** 334 * The 'bounds-changed" signal is emitted when the bposition or 335 * size of the component changes. 336 * 337 * Params: 338 * arg1 = The AtkRectangle giving the new position and size. 339 */ 340 gulong addOnBoundsChanged(void delegate(Rectangle, ComponentIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 341 { 342 return Signals.connect(this, "bounds-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 343 } 344 }