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.ObjectFactory;
26 
27 private import atk.ObjectAtk;
28 private import atk.c.functions;
29 public  import atk.c.types;
30 private import gobject.ObjectG;
31 public  import gtkc.atktypes;
32 
33 
34 /**
35  * This class is the base object class for a factory used to create an
36  * accessible object for a specific GType. The function
37  * atk_registry_set_factory_type() is normally called to store in the
38  * registry the factory type to be used to create an accessible of a
39  * particular GType.
40  */
41 public class ObjectFactory : ObjectG
42 {
43 	/** the main Gtk struct */
44 	protected AtkObjectFactory* atkObjectFactory;
45 
46 	/** Get the main Gtk struct */
47 	public AtkObjectFactory* getObjectFactoryStruct(bool transferOwnership = false)
48 	{
49 		if (transferOwnership)
50 			ownedRef = false;
51 		return atkObjectFactory;
52 	}
53 
54 	/** the main Gtk struct as a void* */
55 	protected override void* getStruct()
56 	{
57 		return cast(void*)atkObjectFactory;
58 	}
59 
60 	protected override void setStruct(GObject* obj)
61 	{
62 		atkObjectFactory = cast(AtkObjectFactory*)obj;
63 		super.setStruct(obj);
64 	}
65 
66 	/**
67 	 * Sets our main struct and passes it to the parent class.
68 	 */
69 	public this (AtkObjectFactory* atkObjectFactory, bool ownedRef = false)
70 	{
71 		this.atkObjectFactory = atkObjectFactory;
72 		super(cast(GObject*)atkObjectFactory, ownedRef);
73 	}
74 
75 
76 	/** */
77 	public static GType getType()
78 	{
79 		return atk_object_factory_get_type();
80 	}
81 
82 	/**
83 	 * Provides an #AtkObject that implements an accessibility interface
84 	 * on behalf of @obj
85 	 *
86 	 * Params:
87 	 *     obj = a #GObject
88 	 *
89 	 * Returns: an #AtkObject that implements an accessibility
90 	 *     interface on behalf of @obj
91 	 */
92 	public ObjectAtk createAccessible(ObjectG obj)
93 	{
94 		auto p = atk_object_factory_create_accessible(atkObjectFactory, (obj is null) ? null : obj.getObjectGStruct());
95 
96 		if(p is null)
97 		{
98 			return null;
99 		}
100 
101 		return ObjectG.getDObject!(ObjectAtk)(cast(AtkObject*) p, true);
102 	}
103 
104 	/**
105 	 * Gets the GType of the accessible which is created by the factory.
106 	 *
107 	 * Returns: the type of the accessible which is created by the @factory.
108 	 *     The value G_TYPE_INVALID is returned if no type if found.
109 	 */
110 	public GType getAccessibleType()
111 	{
112 		return atk_object_factory_get_accessible_type(atkObjectFactory);
113 	}
114 
115 	/**
116 	 * Inform @factory that it is no longer being used to create
117 	 * accessibles. When called, @factory may need to inform
118 	 * #AtkObjects which it has created that they need to be re-instantiated.
119 	 * Note: primarily used for runtime replacement of #AtkObjectFactorys
120 	 * in object registries.
121 	 */
122 	public void invalidate()
123 	{
124 		atk_object_factory_invalidate(atkObjectFactory);
125 	}
126 }