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.GesturePan;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gobject.Signals;
30 private import gtk.Gesture;
31 private import gtk.GestureDrag;
32 private import gtk.c.functions;
33 public  import gtk.c.types;
34 private import std.algorithm;
35 
36 
37 /**
38  * `GtkGesturePan` is a `GtkGesture` for pan gestures.
39  * 
40  * These are drags that are locked to happen along one axis. The axis
41  * that a `GtkGesturePan` handles is defined at construct time, and
42  * can be changed through [method@Gtk.GesturePan.set_orientation].
43  * 
44  * When the gesture starts to be recognized, `GtkGesturePan` will
45  * attempt to determine as early as possible whether the sequence
46  * is moving in the expected direction, and denying the sequence if
47  * this does not happen.
48  * 
49  * Once a panning gesture along the expected axis is recognized,
50  * the [signal@Gtk.GesturePan::pan] signal will be emitted as input
51  * events are received, containing the offset in the given axis.
52  */
53 public class GesturePan : GestureDrag
54 {
55 	/** the main Gtk struct */
56 	protected GtkGesturePan* gtkGesturePan;
57 
58 	/** Get the main Gtk struct */
59 	public GtkGesturePan* getGesturePanStruct(bool transferOwnership = false)
60 	{
61 		if (transferOwnership)
62 			ownedRef = false;
63 		return gtkGesturePan;
64 	}
65 
66 	/** the main Gtk struct as a void* */
67 	protected override void* getStruct()
68 	{
69 		return cast(void*)gtkGesturePan;
70 	}
71 
72 	/**
73 	 * Sets our main struct and passes it to the parent class.
74 	 */
75 	public this (GtkGesturePan* gtkGesturePan, bool ownedRef = false)
76 	{
77 		this.gtkGesturePan = gtkGesturePan;
78 		super(cast(GtkGestureDrag*)gtkGesturePan, ownedRef);
79 	}
80 
81 
82 	/** */
83 	public static GType getType()
84 	{
85 		return gtk_gesture_pan_get_type();
86 	}
87 
88 	/**
89 	 * Returns a newly created `GtkGesture` that recognizes pan gestures.
90 	 *
91 	 * Params:
92 	 *     orientation = expected orientation
93 	 *
94 	 * Returns: a newly created `GtkGesturePan`
95 	 *
96 	 * Throws: ConstructionException GTK+ fails to create the object.
97 	 */
98 	public this(GtkOrientation orientation)
99 	{
100 		auto __p = gtk_gesture_pan_new(orientation);
101 
102 		if(__p is null)
103 		{
104 			throw new ConstructionException("null returned by new");
105 		}
106 
107 		this(cast(GtkGesturePan*) __p, true);
108 	}
109 
110 	/**
111 	 * Returns the orientation of the pan gestures that this @gesture expects.
112 	 *
113 	 * Returns: the expected orientation for pan gestures
114 	 */
115 	public GtkOrientation getOrientation()
116 	{
117 		return gtk_gesture_pan_get_orientation(gtkGesturePan);
118 	}
119 
120 	/**
121 	 * Sets the orientation to be expected on pan gestures.
122 	 *
123 	 * Params:
124 	 *     orientation = expected orientation
125 	 */
126 	public void setOrientation(GtkOrientation orientation)
127 	{
128 		gtk_gesture_pan_set_orientation(gtkGesturePan, orientation);
129 	}
130 
131 	/**
132 	 * Emitted once a panning gesture along the expected axis is detected.
133 	 *
134 	 * Params:
135 	 *     direction = current direction of the pan gesture
136 	 *     offset = Offset along the gesture orientation
137 	 */
138 	gulong addOnPan(void delegate(GtkPanDirection, double, GesturePan) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
139 	{
140 		return Signals.connect(this, "pan", dlg, connectFlags ^ ConnectFlags.SWAPPED);
141 	}
142 }