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.ObjectAtk; 26 27 private import atk.RelationSet; 28 private import atk.StateSet; 29 private import glib.Str; 30 private import gobject.ObjectG; 31 private import gobject.Signals; 32 private import gtkc.atk; 33 public import gtkc.atktypes; 34 public import gtkc.gdktypes; 35 36 37 /** 38 * This class is the primary class for accessibility support via the 39 * Accessibility ToolKit (ATK). Objects which are instances of 40 * #AtkObject (or instances of AtkObject-derived types) are queried 41 * for properties which relate basic (and generic) properties of a UI 42 * component such as name and description. Instances of #AtkObject 43 * may also be queried as to whether they implement other ATK 44 * interfaces (e.g. #AtkAction, #AtkComponent, etc.), as appropriate 45 * to the role which a given UI component plays in a user interface. 46 * 47 * All UI components in an application which provide useful 48 * information or services to the user must provide corresponding 49 * #AtkObject instances on request (in GTK+, for instance, usually on 50 * a call to #gtk_widget_get_accessible ()), either via ATK support 51 * built into the toolkit for the widget class or ancestor class, or 52 * in the case of custom widgets, if the inherited #AtkObject 53 * implementation is insufficient, via instances of a new #AtkObject 54 * subclass. 55 * 56 * See also: #AtkObjectFactory, #AtkRegistry. (GTK+ users see also 57 * #GtkAccessible). 58 */ 59 public class ObjectAtk : ObjectG 60 { 61 /** the main Gtk struct */ 62 protected AtkObject* atkObject; 63 64 /** Get the main Gtk struct */ 65 public AtkObject* getObjectAtkStruct() 66 { 67 return atkObject; 68 } 69 70 /** the main Gtk struct as a void* */ 71 protected override void* getStruct() 72 { 73 return cast(void*)atkObject; 74 } 75 76 protected override void setStruct(GObject* obj) 77 { 78 atkObject = cast(AtkObject*)obj; 79 super.setStruct(obj); 80 } 81 82 /** 83 * Sets our main struct and passes it to the parent class. 84 */ 85 public this (AtkObject* atkObject, bool ownedRef = false) 86 { 87 this.atkObject = atkObject; 88 super(cast(GObject*)atkObject, ownedRef); 89 } 90 91 /** 92 */ 93 94 public static GType getType() 95 { 96 return atk_object_get_type(); 97 } 98 99 /** 100 * Adds a relationship of the specified type with the specified target. 101 * 102 * Params: 103 * relationship = The #AtkRelationType of the relation 104 * target = The #AtkObject which is to be the target of the relation. 105 * 106 * Return: TRUE if the relationship is added. 107 */ 108 public bool addRelationship(AtkRelationType relationship, ObjectAtk target) 109 { 110 return atk_object_add_relationship(atkObject, relationship, (target is null) ? null : target.getObjectAtkStruct()) != 0; 111 } 112 113 /** 114 * 115 * 116 * Deprecated: Since 2.12. Connect directly to property-change or 117 * notify signals. 118 * 119 * Params: 120 * handler = a function to be called when a property changes its value 121 * 122 * Return: a #guint which is the handler id used in 123 * atk_object_remove_property_change_handler() 124 */ 125 public uint connectPropertyChangeHandler(AtkPropertyChangeHandler* handler) 126 { 127 return atk_object_connect_property_change_handler(atkObject, handler); 128 } 129 130 /** 131 * Get a list of properties applied to this object as a whole, as an #AtkAttributeSet consisting of 132 * name-value pairs. As such these attributes may be considered weakly-typed properties or annotations, 133 * as distinct from strongly-typed object data available via other get/set methods. 134 * Not all objects have explicit "name-value pair" #AtkAttributeSet properties. 135 * 136 * Return: an #AtkAttributeSet consisting of all 137 * explicit properties/annotations applied to the object, or an empty 138 * set if the object has no name-value pair attributes assigned to 139 * it. This #atkattributeset should be freed by a call to 140 * atk_attribute_set_free(). 141 * 142 * Since: 1.12 143 */ 144 public AtkAttributeSet* getAttributes() 145 { 146 return atk_object_get_attributes(atkObject); 147 } 148 149 /** 150 * Gets the accessible description of the accessible. 151 * 152 * Return: a character string representing the accessible description 153 * of the accessible. 154 */ 155 public string getDescription() 156 { 157 return Str.toString(atk_object_get_description(atkObject)); 158 } 159 160 /** 161 * Gets the 0-based index of this accessible in its parent; returns -1 if the 162 * accessible does not have an accessible parent. 163 * 164 * Return: an integer which is the index of the accessible in its parent 165 */ 166 public int getIndexInParent() 167 { 168 return atk_object_get_index_in_parent(atkObject); 169 } 170 171 /** 172 * Gets the layer of the accessible. 173 * 174 * Deprecated: Use atk_component_get_layer instead. 175 * 176 * Return: an #AtkLayer which is the layer of the accessible 177 */ 178 public AtkLayer getLayer() 179 { 180 return atk_object_get_layer(atkObject); 181 } 182 183 /** 184 * Gets the zorder of the accessible. The value G_MININT will be returned 185 * if the layer of the accessible is not ATK_LAYER_MDI. 186 * 187 * Deprecated: Use atk_component_get_mdi_zorder instead. 188 * 189 * Return: a gint which is the zorder of the accessible, i.e. the depth at 190 * which the component is shown in relation to other components in the same 191 * container. 192 */ 193 public int getMdiZorder() 194 { 195 return atk_object_get_mdi_zorder(atkObject); 196 } 197 198 /** 199 * Gets the number of accessible children of the accessible. 200 * 201 * Return: an integer representing the number of accessible children 202 * of the accessible. 203 */ 204 public int getNAccessibleChildren() 205 { 206 return atk_object_get_n_accessible_children(atkObject); 207 } 208 209 /** 210 * Gets the accessible name of the accessible. 211 * 212 * Return: a character string representing the accessible name of the object. 213 */ 214 public string getName() 215 { 216 return Str.toString(atk_object_get_name(atkObject)); 217 } 218 219 /** 220 * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale 221 * of @accessible. 222 * 223 * Return: a UTF-8 string indicating the POSIX-style LC_MESSAGES 224 * locale of @accessible. 225 * 226 * Since: 2.8 227 */ 228 public string getObjectLocale() 229 { 230 return Str.toString(atk_object_get_object_locale(atkObject)); 231 } 232 233 /** 234 * Gets the accessible parent of the accessible. By default this is 235 * the one assigned with atk_object_set_parent(), but it is assumed 236 * that ATK implementors have ways to get the parent of the object 237 * without the need of assigning it manually with 238 * atk_object_set_parent(), and will return it with this method. 239 * 240 * If you are only interested on the parent assigned with 241 * atk_object_set_parent(), use atk_object_peek_parent(). 242 * 243 * Return: an #AtkObject representing the accessible 244 * parent of the accessible 245 */ 246 public ObjectAtk getParent() 247 { 248 auto p = atk_object_get_parent(atkObject); 249 250 if(p is null) 251 { 252 return null; 253 } 254 255 return ObjectG.getDObject!(ObjectAtk)(cast(AtkObject*) p); 256 } 257 258 /** 259 * Gets the role of the accessible. 260 * 261 * Return: an #AtkRole which is the role of the accessible 262 */ 263 public AtkRole getRole() 264 { 265 return atk_object_get_role(atkObject); 266 } 267 268 /** 269 * This function is called when implementing subclasses of #AtkObject. 270 * It does initialization required for the new object. It is intended 271 * that this function should called only in the ..._new() functions used 272 * to create an instance of a subclass of #AtkObject 273 * 274 * Params: 275 * data = a #gpointer which identifies the object for which the AtkObject was created. 276 */ 277 public void initialize(void* data) 278 { 279 atk_object_initialize(atkObject, data); 280 } 281 282 /** 283 * Emits a state-change signal for the specified state. 284 * 285 * Params: 286 * state = an #AtkState whose state is changed 287 * value = a gboolean which indicates whether the state is being set on or off 288 */ 289 public void notifyStateChange(AtkState state, bool value) 290 { 291 atk_object_notify_state_change(atkObject, state, value); 292 } 293 294 /** 295 * Gets the accessible parent of the accessible, if it has been 296 * manually assigned with atk_object_set_parent. Otherwise, this 297 * function returns %NULL. 298 * 299 * This method is intended as an utility for ATK implementors, and not 300 * to be exposed to accessible tools. See atk_object_get_parent() for 301 * further reference. 302 * 303 * Return: an #AtkObject representing the accessible 304 * parent of the accessible if assigned 305 */ 306 public ObjectAtk peekParent() 307 { 308 auto p = atk_object_peek_parent(atkObject); 309 310 if(p is null) 311 { 312 return null; 313 } 314 315 return ObjectG.getDObject!(ObjectAtk)(cast(AtkObject*) p); 316 } 317 318 /** 319 * Gets a reference to the specified accessible child of the object. 320 * The accessible children are 0-based so the first accessible child is 321 * at index 0, the second at index 1 and so on. 322 * 323 * Params: 324 * i = a gint representing the position of the child, starting from 0 325 * 326 * Return: an #AtkObject representing the specified 327 * accessible child of the accessible. 328 */ 329 public ObjectAtk refAccessibleChild(int i) 330 { 331 auto p = atk_object_ref_accessible_child(atkObject, i); 332 333 if(p is null) 334 { 335 return null; 336 } 337 338 return ObjectG.getDObject!(ObjectAtk)(cast(AtkObject*) p, true); 339 } 340 341 /** 342 * Gets the #AtkRelationSet associated with the object. 343 * 344 * Return: an #AtkRelationSet representing the relation set 345 * of the object. 346 */ 347 public RelationSet refRelationSet() 348 { 349 auto p = atk_object_ref_relation_set(atkObject); 350 351 if(p is null) 352 { 353 return null; 354 } 355 356 return ObjectG.getDObject!(RelationSet)(cast(AtkRelationSet*) p, true); 357 } 358 359 /** 360 * Gets a reference to the state set of the accessible; the caller must 361 * unreference it when it is no longer needed. 362 * 363 * Return: a reference to an #AtkStateSet which is the state 364 * set of the accessible 365 */ 366 public StateSet refStateSet() 367 { 368 auto p = atk_object_ref_state_set(atkObject); 369 370 if(p is null) 371 { 372 return null; 373 } 374 375 return ObjectG.getDObject!(StateSet)(cast(AtkStateSet*) p, true); 376 } 377 378 /** 379 * 380 * 381 * Deprecated: Since 2.12. 382 * 383 * Removes a property change handler. 384 * 385 * Params: 386 * handlerId = a guint which identifies the handler to be removed. 387 */ 388 public void removePropertyChangeHandler(uint handlerId) 389 { 390 atk_object_remove_property_change_handler(atkObject, handlerId); 391 } 392 393 /** 394 * Removes a relationship of the specified type with the specified target. 395 * 396 * Params: 397 * relationship = The #AtkRelationType of the relation 398 * target = The #AtkObject which is the target of the relation to be removed. 399 * 400 * Return: TRUE if the relationship is removed. 401 */ 402 public bool removeRelationship(AtkRelationType relationship, ObjectAtk target) 403 { 404 return atk_object_remove_relationship(atkObject, relationship, (target is null) ? null : target.getObjectAtkStruct()) != 0; 405 } 406 407 /** 408 * Sets the accessible description of the accessible. You can't set 409 * the description to NULL. This is reserved for the initial value. In 410 * this aspect NULL is similar to ATK_ROLE_UNKNOWN. If you want to set 411 * the name to a empty value you can use "". 412 * 413 * Params: 414 * description = a character string to be set as the accessible description 415 */ 416 public void setDescription(string description) 417 { 418 atk_object_set_description(atkObject, Str.toStringz(description)); 419 } 420 421 /** 422 * Sets the accessible name of the accessible. You can't set the name 423 * to NULL. This is reserved for the initial value. In this aspect 424 * NULL is similar to ATK_ROLE_UNKNOWN. If you want to set the name to 425 * a empty value you can use "". 426 * 427 * Params: 428 * name = a character string to be set as the accessible name 429 */ 430 public void setName(string name) 431 { 432 atk_object_set_name(atkObject, Str.toStringz(name)); 433 } 434 435 /** 436 * Sets the accessible parent of the accessible. @parent can be NULL. 437 * 438 * Params: 439 * parent = an #AtkObject to be set as the accessible parent 440 */ 441 public void setParent(ObjectAtk parent) 442 { 443 atk_object_set_parent(atkObject, (parent is null) ? null : parent.getObjectAtkStruct()); 444 } 445 446 /** 447 * Sets the role of the accessible. 448 * 449 * Params: 450 * role = an #AtkRole to be set as the role 451 */ 452 public void setRole(AtkRole role) 453 { 454 atk_object_set_role(atkObject, role); 455 } 456 457 int[string] connectedSignals; 458 459 void delegate(void*, ObjectAtk)[] onActiveDescendantChangedListeners; 460 /** 461 * The "active-descendant-changed" signal is emitted by an object 462 * which has the state ATK_STATE_MANAGES_DESCENDANTS when the focus 463 * object in the object changes. For instance, a table will emit the 464 * signal when the cell in the table which has focus changes. 465 * 466 * Params: 467 * arg1 = the newly focused object. 468 */ 469 void addOnActiveDescendantChanged(void delegate(void*, ObjectAtk) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 470 { 471 if ( "active-descendant-changed" !in connectedSignals ) 472 { 473 Signals.connectData( 474 this, 475 "active-descendant-changed", 476 cast(GCallback)&callBackActiveDescendantChanged, 477 cast(void*)this, 478 null, 479 connectFlags); 480 connectedSignals["active-descendant-changed"] = 1; 481 } 482 onActiveDescendantChangedListeners ~= dlg; 483 } 484 extern(C) static void callBackActiveDescendantChanged(AtkObject* objectatkStruct, void* arg1, ObjectAtk _objectatk) 485 { 486 foreach ( void delegate(void*, ObjectAtk) dlg; _objectatk.onActiveDescendantChangedListeners ) 487 { 488 dlg(arg1, _objectatk); 489 } 490 } 491 492 void delegate(uint, void*, ObjectAtk)[] onChildrenChangedListeners; 493 /** 494 * The signal "children-changed" is emitted when a child is added or 495 * removed form an object. It supports two details: "add" and 496 * "remove" 497 * 498 * Params: 499 * arg1 = The index of the added or removed child. The value can be 500 * -1. This is used if the value is not known by the implementor 501 * when the child is added/removed or irrelevant. 502 * arg2 = A gpointer to the child AtkObject which was added or 503 * removed. If the child was removed, it is possible that it is not 504 * available for the implementor. In that case this pointer can be 505 * NULL. 506 */ 507 void addOnChildrenChanged(void delegate(uint, void*, ObjectAtk) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 508 { 509 if ( "children-changed" !in connectedSignals ) 510 { 511 Signals.connectData( 512 this, 513 "children-changed", 514 cast(GCallback)&callBackChildrenChanged, 515 cast(void*)this, 516 null, 517 connectFlags); 518 connectedSignals["children-changed"] = 1; 519 } 520 onChildrenChangedListeners ~= dlg; 521 } 522 extern(C) static void callBackChildrenChanged(AtkObject* objectatkStruct, uint arg1, void* arg2, ObjectAtk _objectatk) 523 { 524 foreach ( void delegate(uint, void*, ObjectAtk) dlg; _objectatk.onChildrenChangedListeners ) 525 { 526 dlg(arg1, arg2, _objectatk); 527 } 528 } 529 530 void delegate(bool, ObjectAtk)[] onFocusListeners; 531 /** 532 * The signal "focus-event" is emitted when an object gained or lost 533 * focus. 534 * 535 * Deprecated: Since 2.9.4. Use #AtkObject::state-change signal instead. 536 * 537 * Params: 538 * arg1 = a boolean value which indicates whether the object gained 539 * or lost focus. 540 */ 541 void addOnFocus(void delegate(bool, ObjectAtk) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 542 { 543 if ( "focus-event" !in connectedSignals ) 544 { 545 Signals.connectData( 546 this, 547 "focus-event", 548 cast(GCallback)&callBackFocus, 549 cast(void*)this, 550 null, 551 connectFlags); 552 connectedSignals["focus-event"] = 1; 553 } 554 onFocusListeners ~= dlg; 555 } 556 extern(C) static void callBackFocus(AtkObject* objectatkStruct, bool arg1, ObjectAtk _objectatk) 557 { 558 foreach ( void delegate(bool, ObjectAtk) dlg; _objectatk.onFocusListeners ) 559 { 560 dlg(arg1, _objectatk); 561 } 562 } 563 564 void delegate(void*, ObjectAtk)[] onPropertyChangeListeners; 565 /** 566 * The signal "property-change" is emitted when an object's property 567 * value changes. @arg1 contains an #AtkPropertyValues with the name 568 * and the new value of the property whose value has changed. Note 569 * that, as with GObject notify, getting this signal does not 570 * guarantee that the value of the property has actually changed; it 571 * may also be emitted when the setter of the property is called to 572 * reinstate the previous value. 573 * 574 * Toolkit implementor note: ATK implementors should use 575 * g_object_notify() to emit property-changed 576 * notifications. #AtkObject::property-changed is needed by the 577 * implementation of atk_add_global_event_listener() because GObject 578 * notify doesn't support emission hooks. 579 * 580 * Params: 581 * arg1 = an #AtkPropertyValues containing the new value of the 582 * property which changed. 583 */ 584 void addOnPropertyChange(void delegate(void*, ObjectAtk) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 585 { 586 if ( "property-change" !in connectedSignals ) 587 { 588 Signals.connectData( 589 this, 590 "property-change", 591 cast(GCallback)&callBackPropertyChange, 592 cast(void*)this, 593 null, 594 connectFlags); 595 connectedSignals["property-change"] = 1; 596 } 597 onPropertyChangeListeners ~= dlg; 598 } 599 extern(C) static void callBackPropertyChange(AtkObject* objectatkStruct, void* arg1, ObjectAtk _objectatk) 600 { 601 foreach ( void delegate(void*, ObjectAtk) dlg; _objectatk.onPropertyChangeListeners ) 602 { 603 dlg(arg1, _objectatk); 604 } 605 } 606 607 void delegate(string, bool, ObjectAtk)[] onStateChangeListeners; 608 /** 609 * The "state-change" signal is emitted when an object's state 610 * changes. The detail value identifies the state type which has 611 * changed. 612 * 613 * Params: 614 * arg1 = The name of the state which has changed 615 * arg2 = A boolean which indicates whether the state has been set or unset. 616 */ 617 void addOnStateChange(void delegate(string, bool, ObjectAtk) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 618 { 619 if ( "state-change" !in connectedSignals ) 620 { 621 Signals.connectData( 622 this, 623 "state-change", 624 cast(GCallback)&callBackStateChange, 625 cast(void*)this, 626 null, 627 connectFlags); 628 connectedSignals["state-change"] = 1; 629 } 630 onStateChangeListeners ~= dlg; 631 } 632 extern(C) static void callBackStateChange(AtkObject* objectatkStruct, char* arg1, bool arg2, ObjectAtk _objectatk) 633 { 634 foreach ( void delegate(string, bool, ObjectAtk) dlg; _objectatk.onStateChangeListeners ) 635 { 636 dlg(Str.toString(arg1), arg2, _objectatk); 637 } 638 } 639 640 void delegate(ObjectAtk)[] onVisibleDataChangedListeners; 641 /** 642 * The "visible-data-changed" signal is emitted when the visual 643 * appearance of the object changed. 644 */ 645 void addOnVisibleDataChanged(void delegate(ObjectAtk) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 646 { 647 if ( "visible-data-changed" !in connectedSignals ) 648 { 649 Signals.connectData( 650 this, 651 "visible-data-changed", 652 cast(GCallback)&callBackVisibleDataChanged, 653 cast(void*)this, 654 null, 655 connectFlags); 656 connectedSignals["visible-data-changed"] = 1; 657 } 658 onVisibleDataChangedListeners ~= dlg; 659 } 660 extern(C) static void callBackVisibleDataChanged(AtkObject* objectatkStruct, ObjectAtk _objectatk) 661 { 662 foreach ( void delegate(ObjectAtk) dlg; _objectatk.onVisibleDataChangedListeners ) 663 { 664 dlg(_objectatk); 665 } 666 } 667 668 /** 669 * Get the #AtkRole type corresponding to a rolew name. 670 * 671 * Params: 672 * name = a string which is the (non-localized) name of an ATK role. 673 * 674 * Return: the #AtkRole enumerated type corresponding to the specified name, 675 * or #ATK_ROLE_INVALID if no matching role is found. 676 */ 677 public static AtkRole roleForName(string name) 678 { 679 return atk_role_for_name(Str.toStringz(name)); 680 } 681 682 /** 683 * Gets the localized description string describing the #AtkRole @role. 684 * 685 * Params: 686 * role = The #AtkRole whose localized name is required 687 * 688 * Return: the localized string describing the AtkRole 689 */ 690 public static string roleGetLocalizedName(AtkRole role) 691 { 692 return Str.toString(atk_role_get_localized_name(role)); 693 } 694 695 /** 696 * Gets the description string describing the #AtkRole @role. 697 * 698 * Params: 699 * role = The #AtkRole whose name is required 700 * 701 * Return: the string describing the AtkRole 702 */ 703 public static string roleGetName(AtkRole role) 704 { 705 return Str.toString(atk_role_get_name(role)); 706 } 707 708 /** 709 * Registers the role specified by @name. @name must be a meaningful 710 * name. So it should not be empty, or consisting on whitespaces. 711 * 712 * Deprecated: Since 2.12. If your application/toolkit doesn't find a 713 * suitable role for a specific object defined at #AtkRole, please 714 * submit a bug in order to add a new role to the specification. 715 * 716 * Params: 717 * name = a character string describing the new role. 718 * 719 * Return: an #AtkRole for the new role if added 720 * properly. ATK_ROLE_INVALID in case of error. 721 */ 722 public static AtkRole roleRegister(string name) 723 { 724 return atk_role_register(Str.toStringz(name)); 725 } 726 }