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 * Note that as a general rule when the state of an existing object changes, 286 * emitting a notification is expected. 287 * 288 * Params: 289 * state = an #AtkState whose state is changed 290 * value = a gboolean which indicates whether the state is being set on or off 291 */ 292 public void notifyStateChange(AtkState state, bool value) 293 { 294 atk_object_notify_state_change(atkObject, state, value); 295 } 296 297 /** 298 * Gets the accessible parent of the accessible, if it has been 299 * manually assigned with atk_object_set_parent. Otherwise, this 300 * function returns %NULL. 301 * 302 * This method is intended as an utility for ATK implementors, and not 303 * to be exposed to accessible tools. See atk_object_get_parent() for 304 * further reference. 305 * 306 * Return: an #AtkObject representing the accessible 307 * parent of the accessible if assigned 308 */ 309 public ObjectAtk peekParent() 310 { 311 auto p = atk_object_peek_parent(atkObject); 312 313 if(p is null) 314 { 315 return null; 316 } 317 318 return ObjectG.getDObject!(ObjectAtk)(cast(AtkObject*) p); 319 } 320 321 /** 322 * Gets a reference to the specified accessible child of the object. 323 * The accessible children are 0-based so the first accessible child is 324 * at index 0, the second at index 1 and so on. 325 * 326 * Params: 327 * i = a gint representing the position of the child, starting from 0 328 * 329 * Return: an #AtkObject representing the specified 330 * accessible child of the accessible. 331 */ 332 public ObjectAtk refAccessibleChild(int i) 333 { 334 auto p = atk_object_ref_accessible_child(atkObject, i); 335 336 if(p is null) 337 { 338 return null; 339 } 340 341 return ObjectG.getDObject!(ObjectAtk)(cast(AtkObject*) p, true); 342 } 343 344 /** 345 * Gets the #AtkRelationSet associated with the object. 346 * 347 * Return: an #AtkRelationSet representing the relation set 348 * of the object. 349 */ 350 public RelationSet refRelationSet() 351 { 352 auto p = atk_object_ref_relation_set(atkObject); 353 354 if(p is null) 355 { 356 return null; 357 } 358 359 return ObjectG.getDObject!(RelationSet)(cast(AtkRelationSet*) p, true); 360 } 361 362 /** 363 * Gets a reference to the state set of the accessible; the caller must 364 * unreference it when it is no longer needed. 365 * 366 * Return: a reference to an #AtkStateSet which is the state 367 * set of the accessible 368 */ 369 public StateSet refStateSet() 370 { 371 auto p = atk_object_ref_state_set(atkObject); 372 373 if(p is null) 374 { 375 return null; 376 } 377 378 return ObjectG.getDObject!(StateSet)(cast(AtkStateSet*) p, true); 379 } 380 381 /** 382 * 383 * 384 * Deprecated: Since 2.12. 385 * 386 * Removes a property change handler. 387 * 388 * Params: 389 * handlerId = a guint which identifies the handler to be removed. 390 */ 391 public void removePropertyChangeHandler(uint handlerId) 392 { 393 atk_object_remove_property_change_handler(atkObject, handlerId); 394 } 395 396 /** 397 * Removes a relationship of the specified type with the specified target. 398 * 399 * Params: 400 * relationship = The #AtkRelationType of the relation 401 * target = The #AtkObject which is the target of the relation to be removed. 402 * 403 * Return: TRUE if the relationship is removed. 404 */ 405 public bool removeRelationship(AtkRelationType relationship, ObjectAtk target) 406 { 407 return atk_object_remove_relationship(atkObject, relationship, (target is null) ? null : target.getObjectAtkStruct()) != 0; 408 } 409 410 /** 411 * Sets the accessible description of the accessible. You can't set 412 * the description to NULL. This is reserved for the initial value. In 413 * this aspect NULL is similar to ATK_ROLE_UNKNOWN. If you want to set 414 * the name to a empty value you can use "". 415 * 416 * Params: 417 * description = a character string to be set as the accessible description 418 */ 419 public void setDescription(string description) 420 { 421 atk_object_set_description(atkObject, Str.toStringz(description)); 422 } 423 424 /** 425 * Sets the accessible name of the accessible. You can't set the name 426 * to NULL. This is reserved for the initial value. In this aspect 427 * NULL is similar to ATK_ROLE_UNKNOWN. If you want to set the name to 428 * a empty value you can use "". 429 * 430 * Params: 431 * name = a character string to be set as the accessible name 432 */ 433 public void setName(string name) 434 { 435 atk_object_set_name(atkObject, Str.toStringz(name)); 436 } 437 438 /** 439 * Sets the accessible parent of the accessible. @parent can be NULL. 440 * 441 * Params: 442 * parent = an #AtkObject to be set as the accessible parent 443 */ 444 public void setParent(ObjectAtk parent) 445 { 446 atk_object_set_parent(atkObject, (parent is null) ? null : parent.getObjectAtkStruct()); 447 } 448 449 /** 450 * Sets the role of the accessible. 451 * 452 * Params: 453 * role = an #AtkRole to be set as the role 454 */ 455 public void setRole(AtkRole role) 456 { 457 atk_object_set_role(atkObject, role); 458 } 459 460 int[string] connectedSignals; 461 462 void delegate(void*, ObjectAtk)[] onActiveDescendantChangedListeners; 463 /** 464 * The "active-descendant-changed" signal is emitted by an object 465 * which has the state ATK_STATE_MANAGES_DESCENDANTS when the focus 466 * object in the object changes. For instance, a table will emit the 467 * signal when the cell in the table which has focus changes. 468 * 469 * Params: 470 * arg1 = the newly focused object. 471 */ 472 void addOnActiveDescendantChanged(void delegate(void*, ObjectAtk) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 473 { 474 if ( "active-descendant-changed" !in connectedSignals ) 475 { 476 Signals.connectData( 477 this, 478 "active-descendant-changed", 479 cast(GCallback)&callBackActiveDescendantChanged, 480 cast(void*)this, 481 null, 482 connectFlags); 483 connectedSignals["active-descendant-changed"] = 1; 484 } 485 onActiveDescendantChangedListeners ~= dlg; 486 } 487 extern(C) static void callBackActiveDescendantChanged(AtkObject* objectatkStruct, void* arg1, ObjectAtk _objectatk) 488 { 489 foreach ( void delegate(void*, ObjectAtk) dlg; _objectatk.onActiveDescendantChangedListeners ) 490 { 491 dlg(arg1, _objectatk); 492 } 493 } 494 495 void delegate(uint, void*, ObjectAtk)[] onChildrenChangedListeners; 496 /** 497 * The signal "children-changed" is emitted when a child is added or 498 * removed form an object. It supports two details: "add" and 499 * "remove" 500 * 501 * Params: 502 * arg1 = The index of the added or removed child. The value can be 503 * -1. This is used if the value is not known by the implementor 504 * when the child is added/removed or irrelevant. 505 * arg2 = A gpointer to the child AtkObject which was added or 506 * removed. If the child was removed, it is possible that it is not 507 * available for the implementor. In that case this pointer can be 508 * NULL. 509 */ 510 void addOnChildrenChanged(void delegate(uint, void*, ObjectAtk) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 511 { 512 if ( "children-changed" !in connectedSignals ) 513 { 514 Signals.connectData( 515 this, 516 "children-changed", 517 cast(GCallback)&callBackChildrenChanged, 518 cast(void*)this, 519 null, 520 connectFlags); 521 connectedSignals["children-changed"] = 1; 522 } 523 onChildrenChangedListeners ~= dlg; 524 } 525 extern(C) static void callBackChildrenChanged(AtkObject* objectatkStruct, uint arg1, void* arg2, ObjectAtk _objectatk) 526 { 527 foreach ( void delegate(uint, void*, ObjectAtk) dlg; _objectatk.onChildrenChangedListeners ) 528 { 529 dlg(arg1, arg2, _objectatk); 530 } 531 } 532 533 void delegate(bool, ObjectAtk)[] onFocusListeners; 534 /** 535 * The signal "focus-event" is emitted when an object gained or lost 536 * focus. 537 * 538 * Deprecated: Use #AtkObject::state-change signal instead. 539 * 540 * Params: 541 * arg1 = a boolean value which indicates whether the object gained 542 * or lost focus. 543 */ 544 void addOnFocus(void delegate(bool, ObjectAtk) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 545 { 546 if ( "focus-event" !in connectedSignals ) 547 { 548 Signals.connectData( 549 this, 550 "focus-event", 551 cast(GCallback)&callBackFocus, 552 cast(void*)this, 553 null, 554 connectFlags); 555 connectedSignals["focus-event"] = 1; 556 } 557 onFocusListeners ~= dlg; 558 } 559 extern(C) static void callBackFocus(AtkObject* objectatkStruct, bool arg1, ObjectAtk _objectatk) 560 { 561 foreach ( void delegate(bool, ObjectAtk) dlg; _objectatk.onFocusListeners ) 562 { 563 dlg(arg1, _objectatk); 564 } 565 } 566 567 void delegate(void*, ObjectAtk)[] onPropertyChangeListeners; 568 /** 569 * The signal "property-change" is emitted when an object's property 570 * value changes. @arg1 contains an #AtkPropertyValues with the name 571 * and the new value of the property whose value has changed. Note 572 * that, as with GObject notify, getting this signal does not 573 * guarantee that the value of the property has actually changed; it 574 * may also be emitted when the setter of the property is called to 575 * reinstate the previous value. 576 * 577 * Toolkit implementor note: ATK implementors should use 578 * g_object_notify() to emit property-changed 579 * notifications. #AtkObject::property-changed is needed by the 580 * implementation of atk_add_global_event_listener() because GObject 581 * notify doesn't support emission hooks. 582 * 583 * Params: 584 * arg1 = an #AtkPropertyValues containing the new value of the 585 * property which changed. 586 */ 587 void addOnPropertyChange(void delegate(void*, ObjectAtk) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 588 { 589 if ( "property-change" !in connectedSignals ) 590 { 591 Signals.connectData( 592 this, 593 "property-change", 594 cast(GCallback)&callBackPropertyChange, 595 cast(void*)this, 596 null, 597 connectFlags); 598 connectedSignals["property-change"] = 1; 599 } 600 onPropertyChangeListeners ~= dlg; 601 } 602 extern(C) static void callBackPropertyChange(AtkObject* objectatkStruct, void* arg1, ObjectAtk _objectatk) 603 { 604 foreach ( void delegate(void*, ObjectAtk) dlg; _objectatk.onPropertyChangeListeners ) 605 { 606 dlg(arg1, _objectatk); 607 } 608 } 609 610 void delegate(string, bool, ObjectAtk)[] onStateChangeListeners; 611 /** 612 * The "state-change" signal is emitted when an object's state 613 * changes. The detail value identifies the state type which has 614 * changed. 615 * 616 * Params: 617 * arg1 = The name of the state which has changed 618 * arg2 = A boolean which indicates whether the state has been set or unset. 619 */ 620 void addOnStateChange(void delegate(string, bool, ObjectAtk) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 621 { 622 if ( "state-change" !in connectedSignals ) 623 { 624 Signals.connectData( 625 this, 626 "state-change", 627 cast(GCallback)&callBackStateChange, 628 cast(void*)this, 629 null, 630 connectFlags); 631 connectedSignals["state-change"] = 1; 632 } 633 onStateChangeListeners ~= dlg; 634 } 635 extern(C) static void callBackStateChange(AtkObject* objectatkStruct, char* arg1, bool arg2, ObjectAtk _objectatk) 636 { 637 foreach ( void delegate(string, bool, ObjectAtk) dlg; _objectatk.onStateChangeListeners ) 638 { 639 dlg(Str.toString(arg1), arg2, _objectatk); 640 } 641 } 642 643 void delegate(ObjectAtk)[] onVisibleDataChangedListeners; 644 /** 645 * The "visible-data-changed" signal is emitted when the visual 646 * appearance of the object changed. 647 */ 648 void addOnVisibleDataChanged(void delegate(ObjectAtk) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 649 { 650 if ( "visible-data-changed" !in connectedSignals ) 651 { 652 Signals.connectData( 653 this, 654 "visible-data-changed", 655 cast(GCallback)&callBackVisibleDataChanged, 656 cast(void*)this, 657 null, 658 connectFlags); 659 connectedSignals["visible-data-changed"] = 1; 660 } 661 onVisibleDataChangedListeners ~= dlg; 662 } 663 extern(C) static void callBackVisibleDataChanged(AtkObject* objectatkStruct, ObjectAtk _objectatk) 664 { 665 foreach ( void delegate(ObjectAtk) dlg; _objectatk.onVisibleDataChangedListeners ) 666 { 667 dlg(_objectatk); 668 } 669 } 670 671 /** 672 * Get the #AtkRole type corresponding to a rolew name. 673 * 674 * Params: 675 * name = a string which is the (non-localized) name of an ATK role. 676 * 677 * Return: the #AtkRole enumerated type corresponding to the specified name, 678 * or #ATK_ROLE_INVALID if no matching role is found. 679 */ 680 public static AtkRole roleForName(string name) 681 { 682 return atk_role_for_name(Str.toStringz(name)); 683 } 684 685 /** 686 * Gets the localized description string describing the #AtkRole @role. 687 * 688 * Params: 689 * role = The #AtkRole whose localized name is required 690 * 691 * Return: the localized string describing the AtkRole 692 */ 693 public static string roleGetLocalizedName(AtkRole role) 694 { 695 return Str.toString(atk_role_get_localized_name(role)); 696 } 697 698 /** 699 * Gets the description string describing the #AtkRole @role. 700 * 701 * Params: 702 * role = The #AtkRole whose name is required 703 * 704 * Return: the string describing the AtkRole 705 */ 706 public static string roleGetName(AtkRole role) 707 { 708 return Str.toString(atk_role_get_name(role)); 709 } 710 711 /** 712 * Registers the role specified by @name. @name must be a meaningful 713 * name. So it should not be empty, or consisting on whitespaces. 714 * 715 * Deprecated: Since 2.12. If your application/toolkit doesn't find a 716 * suitable role for a specific object defined at #AtkRole, please 717 * submit a bug in order to add a new role to the specification. 718 * 719 * Params: 720 * name = a character string describing the new role. 721 * 722 * Return: an #AtkRole for the new role if added 723 * properly. ATK_ROLE_INVALID in case of error. 724 */ 725 public static AtkRole roleRegister(string name) 726 { 727 return atk_role_register(Str.toStringz(name)); 728 } 729 }