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 gobject.ObjectG; 29 public import gobject.Signals; 30 public import gtkc.atk; 31 public import gtkc.atktypes; 32 public import gtkc.gdktypes; 33 34 35 /** 36 * #AtkComponent should be implemented by most if not all UI elements 37 * with an actual on-screen presence, i.e. components which can be 38 * said to have a screen-coordinate bounding box. Virtually all 39 * widgets will need to have #AtkComponent implementations provided 40 * for their corresponding #AtkObject class. In short, only UI 41 * elements which are *not* GUI elements will omit this ATK interface. 42 * 43 * A possible exception might be textual information with a 44 * transparent background, in which case text glyph bounding box 45 * information is provided by #AtkText. 46 */ 47 public template ComponentT(TStruct) 48 { 49 /** Get the main Gtk struct */ 50 public AtkComponent* getComponentStruct() 51 { 52 return cast(AtkComponent*)getStruct(); 53 } 54 55 /** 56 */ 57 58 /** 59 * Add the specified handler to the set of functions to be called 60 * when this object receives focus events (in or out). If the handler is 61 * already added it is not added again 62 * 63 * Deprecated: This method is deprecated since ATK version 2.9.4. If 64 * you need to track when an object gains or lose the focus, use 65 * state-changed:focused notification instead. 66 * 67 * Params: 68 * handler = The #AtkFocusHandler to be attached to @component 69 * 70 * Return: 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 * Return: %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 * Return: 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 * Params: 117 * x = address of #gint to put x coordinate 118 * y = address of #gint to put y coordinate 119 * width = address of #gint to put width 120 * height = address of #gint to put height 121 * coordType = specifies whether the coordinates are relative to the screen 122 * or to the components top level window 123 */ 124 public void getExtents(int* x, int* y, int* width, int* height, AtkCoordType coordType) 125 { 126 atk_component_get_extents(getComponentStruct(), x, y, width, height, coordType); 127 } 128 129 /** 130 * Gets the layer of the component. 131 * 132 * Return: an #AtkLayer which is the layer of the component 133 */ 134 public override AtkLayer getLayer() 135 { 136 return atk_component_get_layer(getComponentStruct()); 137 } 138 139 /** 140 * Gets the zorder of the component. The value G_MININT will be returned 141 * if the layer of the component is not ATK_LAYER_MDI or ATK_LAYER_WINDOW. 142 * 143 * Return: a gint which is the zorder of the component, i.e. the depth at 144 * which the component is shown in relation to other components in the same 145 * container. 146 */ 147 public override int getMdiZorder() 148 { 149 return atk_component_get_mdi_zorder(getComponentStruct()); 150 } 151 152 /** 153 * Gets the position of @component in the form of 154 * a point specifying @component's top-left corner. 155 * 156 * Deprecated: Since 2.12. Use atk_component_get_extents() instead. 157 * 158 * Params: 159 * x = address of #gint to put x coordinate position 160 * y = address of #gint to put y coordinate position 161 * coordType = specifies whether the coordinates are relative to the screen 162 * or to the components top level window 163 */ 164 public void getPosition(int* x, int* y, AtkCoordType coordType) 165 { 166 atk_component_get_position(getComponentStruct(), x, y, coordType); 167 } 168 169 /** 170 * Gets the size of the @component in terms of width and height. 171 * 172 * Deprecated: Since 2.12. Use atk_component_get_extents() instead. 173 * 174 * Params: 175 * width = address of #gint to put width of @component 176 * height = address of #gint to put height of @component 177 */ 178 public void getSize(int* width, int* height) 179 { 180 atk_component_get_size(getComponentStruct(), width, height); 181 } 182 183 /** 184 * Grabs focus for this @component. 185 * 186 * Return: %TRUE if successful, %FALSE otherwise. 187 */ 188 public bool grabFocus() 189 { 190 return atk_component_grab_focus(getComponentStruct()) != 0; 191 } 192 193 /** 194 * Gets a reference to the accessible child, if one exists, at the 195 * coordinate point specified by @x and @y. 196 * 197 * Params: 198 * x = x coordinate 199 * y = y coordinate 200 * coordType = specifies whether the coordinates are relative to the screen 201 * or to the components top level window 202 * 203 * Return: a reference to the accessible 204 * child, if one exists 205 */ 206 public ObjectAtk refAccessibleAtPoint(int x, int y, AtkCoordType coordType) 207 { 208 auto p = atk_component_ref_accessible_at_point(getComponentStruct(), x, y, coordType); 209 210 if(p is null) 211 { 212 return null; 213 } 214 215 return ObjectG.getDObject!(ObjectAtk)(cast(AtkObject*) p, true); 216 } 217 218 /** 219 * Remove the handler specified by @handler_id from the list of 220 * functions to be executed when this object receives focus events 221 * (in or out). 222 * 223 * Deprecated: This method is deprecated since ATK version 2.9.4. If 224 * you need to track when an object gains or lose the focus, use 225 * state-changed:focused notification instead. 226 * 227 * Params: 228 * handlerId = the handler id of the focus handler to be removed 229 * from @component 230 */ 231 public void removeFocusHandler(uint handlerId) 232 { 233 atk_component_remove_focus_handler(getComponentStruct(), handlerId); 234 } 235 236 /** 237 * Sets the extents of @component. 238 * 239 * Params: 240 * x = x coordinate 241 * y = y coordinate 242 * width = width to set for @component 243 * height = height to set for @component 244 * coordType = specifies whether the coordinates are relative to the screen 245 * or to the components top level window 246 * 247 * Return: %TRUE or %FALSE whether the extents were set or not 248 */ 249 public bool setExtents(int x, int y, int width, int height, AtkCoordType coordType) 250 { 251 return atk_component_set_extents(getComponentStruct(), x, y, width, height, coordType) != 0; 252 } 253 254 /** 255 * Sets the postition of @component. 256 * 257 * Params: 258 * x = x coordinate 259 * y = y coordinate 260 * coordType = specifies whether the coordinates are relative to the screen 261 * or to the components top level window 262 * 263 * Return: %TRUE or %FALSE whether or not the position was set or not 264 */ 265 public bool setPosition(int x, int y, AtkCoordType coordType) 266 { 267 return atk_component_set_position(getComponentStruct(), x, y, coordType) != 0; 268 } 269 270 /** 271 * Set the size of the @component in terms of width and height. 272 * 273 * Params: 274 * width = width to set for @component 275 * height = height to set for @component 276 * 277 * Return: %TRUE or %FALSE whether the size was set or not 278 */ 279 public bool setSize(int width, int height) 280 { 281 return atk_component_set_size(getComponentStruct(), width, height) != 0; 282 } 283 284 int[string] connectedSignals; 285 286 void delegate(AtkRectangle*, ComponentIF)[] _onBoundsChangedListeners; 287 @property void delegate(AtkRectangle*, ComponentIF)[] onBoundsChangedListeners() 288 { 289 return _onBoundsChangedListeners; 290 } 291 /** 292 * The 'bounds-changed" signal is emitted when the bposition or 293 * size of the component changes. 294 * 295 * Params: 296 * arg1 = The AtkRectangle giving the new position and size. 297 */ 298 void addOnBoundsChanged(void delegate(AtkRectangle*, ComponentIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 299 { 300 if ( "bounds-changed" !in connectedSignals ) 301 { 302 Signals.connectData( 303 this, 304 "bounds-changed", 305 cast(GCallback)&callBackBoundsChanged, 306 cast(void*)cast(ComponentIF)this, 307 null, 308 connectFlags); 309 connectedSignals["bounds-changed"] = 1; 310 } 311 _onBoundsChangedListeners ~= dlg; 312 } 313 extern(C) static void callBackBoundsChanged(AtkComponent* componentStruct, AtkRectangle* arg1, ComponentIF _component) 314 { 315 foreach ( void delegate(AtkRectangle*, ComponentIF) dlg; _component.onBoundsChangedListeners ) 316 { 317 dlg(arg1, _component); 318 } 319 } 320 }