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 gtk.WidgetPaintable;
26 
27 private import gdk.PaintableIF;
28 private import gdk.PaintableT;
29 private import glib.ConstructionException;
30 private import gobject.ObjectG;
31 private import gtk.Widget;
32 private import gtk.c.functions;
33 public  import gtk.c.types;
34 
35 
36 /**
37  * `GtkWidgetPaintable` is a `GdkPaintable` that displays the contents
38  * of a widget.
39  * 
40  * `GtkWidgetPaintable` will also take care of the widget not being in a
41  * state where it can be drawn (like when it isn't shown) and just draw
42  * nothing or where it does not have a size (like when it is hidden) and
43  * report no size in that case.
44  * 
45  * Of course, `GtkWidgetPaintable` allows you to monitor widgets for size
46  * changes by emitting the [signal@Gdk.Paintable::invalidate-size] signal
47  * whenever the size of the widget changes as well as for visual changes by
48  * emitting the [signal@Gdk.Paintable::invalidate-contents] signal whenever
49  * the widget changes.
50  * 
51  * You can use a `GtkWidgetPaintable` everywhere a `GdkPaintable` is allowed,
52  * including using it on a `GtkPicture` (or one of its parents) that it was
53  * set on itself via gtk_picture_set_paintable(). The paintable will take care
54  * of recursion when this happens. If you do this however, ensure that the
55  * [property@Gtk.Picture:can-shrink] property is set to %TRUE or you might
56  * end up with an infinitely growing widget.
57  */
58 public class WidgetPaintable : ObjectG, PaintableIF
59 {
60 	/** the main Gtk struct */
61 	protected GtkWidgetPaintable* gtkWidgetPaintable;
62 
63 	/** Get the main Gtk struct */
64 	public GtkWidgetPaintable* getWidgetPaintableStruct(bool transferOwnership = false)
65 	{
66 		if (transferOwnership)
67 			ownedRef = false;
68 		return gtkWidgetPaintable;
69 	}
70 
71 	/** the main Gtk struct as a void* */
72 	protected override void* getStruct()
73 	{
74 		return cast(void*)gtkWidgetPaintable;
75 	}
76 
77 	/**
78 	 * Sets our main struct and passes it to the parent class.
79 	 */
80 	public this (GtkWidgetPaintable* gtkWidgetPaintable, bool ownedRef = false)
81 	{
82 		this.gtkWidgetPaintable = gtkWidgetPaintable;
83 		super(cast(GObject*)gtkWidgetPaintable, ownedRef);
84 	}
85 
86 	// add the Paintable capabilities
87 	mixin PaintableT!(GtkWidgetPaintable);
88 
89 
90 	/** */
91 	public static GType getType()
92 	{
93 		return gtk_widget_paintable_get_type();
94 	}
95 
96 	/**
97 	 * Creates a new widget paintable observing the given widget.
98 	 *
99 	 * Params:
100 	 *     widget = a `GtkWidget` or %NULL
101 	 *
102 	 * Returns: a new `GtkWidgetPaintable`
103 	 *
104 	 * Throws: ConstructionException GTK+ fails to create the object.
105 	 */
106 	public this(Widget widget)
107 	{
108 		auto __p = gtk_widget_paintable_new((widget is null) ? null : widget.getWidgetStruct());
109 
110 		if(__p is null)
111 		{
112 			throw new ConstructionException("null returned by new");
113 		}
114 
115 		this(cast(GtkWidgetPaintable*) __p, true);
116 	}
117 
118 	/**
119 	 * Returns the widget that is observed or %NULL if none.
120 	 *
121 	 * Returns: the observed widget.
122 	 */
123 	public Widget getWidget()
124 	{
125 		auto __p = gtk_widget_paintable_get_widget(gtkWidgetPaintable);
126 
127 		if(__p is null)
128 		{
129 			return null;
130 		}
131 
132 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p);
133 	}
134 
135 	/**
136 	 * Sets the widget that should be observed.
137 	 *
138 	 * Params:
139 	 *     widget = the widget to observe or %NULL
140 	 */
141 	public void setWidget(Widget widget)
142 	{
143 		gtk_widget_paintable_set_widget(gtkWidgetPaintable, (widget is null) ? null : widget.getWidgetStruct());
144 	}
145 }