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