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