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 gdk.PopupT;
26 
27 public  import gdk.PopupLayout;
28 public  import gdk.Surface;
29 public  import gdk.c.functions;
30 public  import gdk.c.types;
31 public  import gobject.ObjectG;
32 
33 
34 /**
35  * A `GdkPopup` is a surface that is attached to another surface.
36  * 
37  * The `GdkPopup` is positioned relative to its parent surface.
38  * 
39  * `GdkPopup`s are typically used to implement menus and similar popups.
40  * They can be modal, which is indicated by the [property@GdkPopup:autohide]
41  * property.
42  */
43 public template PopupT(TStruct)
44 {
45 	/** Get the main Gtk struct */
46 	public GdkPopup* getPopupStruct(bool transferOwnership = false)
47 	{
48 		if (transferOwnership)
49 			ownedRef = false;
50 		return cast(GdkPopup*)getStruct();
51 	}
52 
53 
54 	/**
55 	 * Returns whether this popup is set to hide on outside clicks.
56 	 *
57 	 * Returns: %TRUE if @popup will autohide
58 	 */
59 	public bool getAutohide()
60 	{
61 		return gdk_popup_get_autohide(getPopupStruct()) != 0;
62 	}
63 
64 	/**
65 	 * Returns the parent surface of a popup.
66 	 *
67 	 * Returns: the parent surface
68 	 */
69 	public Surface getParent()
70 	{
71 		auto __p = gdk_popup_get_parent(getPopupStruct());
72 
73 		if(__p is null)
74 		{
75 			return null;
76 		}
77 
78 		return ObjectG.getDObject!(Surface)(cast(GdkSurface*) __p);
79 	}
80 
81 	/**
82 	 * Obtains the position of the popup relative to its parent.
83 	 *
84 	 * Returns: the X coordinate of @popup position
85 	 */
86 	public int getPositionX()
87 	{
88 		return gdk_popup_get_position_x(getPopupStruct());
89 	}
90 
91 	/**
92 	 * Obtains the position of the popup relative to its parent.
93 	 *
94 	 * Returns: the Y coordinate of @popup position
95 	 */
96 	public int getPositionY()
97 	{
98 		return gdk_popup_get_position_y(getPopupStruct());
99 	}
100 
101 	/**
102 	 * Gets the current popup rectangle anchor.
103 	 *
104 	 * The value returned may change after calling [method@Gdk.Popup.present],
105 	 * or after the [signal@Gdk.Surface::layout] signal is emitted.
106 	 *
107 	 * Returns: the current rectangle anchor value of @popup
108 	 */
109 	public GdkGravity getRectAnchor()
110 	{
111 		return gdk_popup_get_rect_anchor(getPopupStruct());
112 	}
113 
114 	/**
115 	 * Gets the current popup surface anchor.
116 	 *
117 	 * The value returned may change after calling [method@Gdk.Popup.present],
118 	 * or after the [signal@Gdk.Surface::layout] signal is emitted.
119 	 *
120 	 * Returns: the current surface anchor value of @popup
121 	 */
122 	public GdkGravity getSurfaceAnchor()
123 	{
124 		return gdk_popup_get_surface_anchor(getPopupStruct());
125 	}
126 
127 	/**
128 	 * Present @popup after having processed the #GdkPopupLayout rules.
129 	 *
130 	 * If the popup was previously now showing, it will be showed,
131 	 * otherwise it will change position according to @layout.
132 	 *
133 	 * After calling this function, the result should be handled in response
134 	 * to the [signal@GdkSurface::layout] signal being emitted. The resulting
135 	 * popup position can be queried using [method@Gdk.Popup.get_position_x],
136 	 * [method@Gdk.Popup.get_position_y], and the resulting size will be sent as
137 	 * parameters in the layout signal. Use [method@Gdk.Popup.get_rect_anchor]
138 	 * and [method@Gdk.Popup.get_surface_anchor] to get the resulting anchors.
139 	 *
140 	 * Presenting may fail, for example if the @popup is set to autohide
141 	 * and is immediately hidden upon being presented. If presenting failed,
142 	 * the [signal@Gdk.Surface::layout] signal will not me emitted.
143 	 *
144 	 * Params:
145 	 *     width = the unconstrained popup width to layout
146 	 *     height = the unconstrained popup height to layout
147 	 *     layout = the `GdkPopupLayout` object used to layout
148 	 *
149 	 * Returns: %FALSE if it failed to be presented, otherwise %TRUE.
150 	 */
151 	public bool present(int width, int height, PopupLayout layout)
152 	{
153 		return gdk_popup_present(getPopupStruct(), width, height, (layout is null) ? null : layout.getPopupLayoutStruct()) != 0;
154 	}
155 }