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.Overlay; 26 27 private import glib.ConstructionException; 28 private import gobject.ObjectG; 29 private import gobject.Signals; 30 private import gtk.Widget; 31 private import gtk.c.functions; 32 public import gtk.c.types; 33 private import std.algorithm; 34 35 36 /** 37 * `GtkOverlay` is a container which contains a single main child, on top 38 * of which it can place “overlay” widgets. 39 * 40 *  41 * 42 * The position of each overlay widget is determined by its 43 * [property@Gtk.Widget:halign] and [property@Gtk.Widget:valign] 44 * properties. E.g. a widget with both alignments set to %GTK_ALIGN_START 45 * will be placed at the top left corner of the `GtkOverlay` container, 46 * whereas an overlay with halign set to %GTK_ALIGN_CENTER and valign set 47 * to %GTK_ALIGN_END will be placed a the bottom edge of the `GtkOverlay`, 48 * horizontally centered. The position can be adjusted by setting the margin 49 * properties of the child to non-zero values. 50 * 51 * More complicated placement of overlays is possible by connecting 52 * to the [signal@Gtk.Overlay::get-child-position] signal. 53 * 54 * An overlay’s minimum and natural sizes are those of its main child. 55 * The sizes of overlay children are not considered when measuring these 56 * preferred sizes. 57 * 58 * # GtkOverlay as GtkBuildable 59 * 60 * The `GtkOverlay` implementation of the `GtkBuildable` interface 61 * supports placing a child as an overlay by specifying “overlay” as 62 * the “type” attribute of a `<child>` element. 63 * 64 * # CSS nodes 65 * 66 * `GtkOverlay` has a single CSS node with the name “overlay”. Overlay children 67 * whose alignments cause them to be positioned at an edge get the style classes 68 * “.left”, “.right”, “.top”, and/or “.bottom” according to their position. 69 */ 70 public class Overlay : Widget 71 { 72 /** the main Gtk struct */ 73 protected GtkOverlay* gtkOverlay; 74 75 /** Get the main Gtk struct */ 76 public GtkOverlay* getOverlayStruct(bool transferOwnership = false) 77 { 78 if (transferOwnership) 79 ownedRef = false; 80 return gtkOverlay; 81 } 82 83 /** the main Gtk struct as a void* */ 84 protected override void* getStruct() 85 { 86 return cast(void*)gtkOverlay; 87 } 88 89 /** 90 * Sets our main struct and passes it to the parent class. 91 */ 92 public this (GtkOverlay* gtkOverlay, bool ownedRef = false) 93 { 94 this.gtkOverlay = gtkOverlay; 95 super(cast(GtkWidget*)gtkOverlay, ownedRef); 96 } 97 98 99 /** */ 100 public static GType getType() 101 { 102 return gtk_overlay_get_type(); 103 } 104 105 /** 106 * Creates a new `GtkOverlay`. 107 * 108 * Returns: a new `GtkOverlay` object. 109 * 110 * Throws: ConstructionException GTK+ fails to create the object. 111 */ 112 public this() 113 { 114 auto __p = gtk_overlay_new(); 115 116 if(__p is null) 117 { 118 throw new ConstructionException("null returned by new"); 119 } 120 121 this(cast(GtkOverlay*) __p); 122 } 123 124 /** 125 * Adds @widget to @overlay. 126 * 127 * The widget will be stacked on top of the main widget 128 * added with [method@Gtk.Overlay.set_child]. 129 * 130 * The position at which @widget is placed is determined 131 * from its [property@Gtk.Widget:halign] and 132 * [property@Gtk.Widget:valign] properties. 133 * 134 * Params: 135 * widget = a `GtkWidget` to be added to the container 136 */ 137 public void addOverlay(Widget widget) 138 { 139 gtk_overlay_add_overlay(gtkOverlay, (widget is null) ? null : widget.getWidgetStruct()); 140 } 141 142 /** 143 * Gets the child widget of @overlay. 144 * 145 * Returns: the child widget of @overlay 146 */ 147 public Widget getChild() 148 { 149 auto __p = gtk_overlay_get_child(gtkOverlay); 150 151 if(__p is null) 152 { 153 return null; 154 } 155 156 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p); 157 } 158 159 /** 160 * Gets whether @widget should be clipped within the parent. 161 * 162 * Params: 163 * widget = an overlay child of `GtkOverlay` 164 * 165 * Returns: whether the widget is clipped within the parent. 166 */ 167 public bool getClipOverlay(Widget widget) 168 { 169 return gtk_overlay_get_clip_overlay(gtkOverlay, (widget is null) ? null : widget.getWidgetStruct()) != 0; 170 } 171 172 /** 173 * Gets whether @widget's size is included in the measurement of 174 * @overlay. 175 * 176 * Params: 177 * widget = an overlay child of `GtkOverlay` 178 * 179 * Returns: whether the widget is measured 180 */ 181 public bool getMeasureOverlay(Widget widget) 182 { 183 return gtk_overlay_get_measure_overlay(gtkOverlay, (widget is null) ? null : widget.getWidgetStruct()) != 0; 184 } 185 186 /** 187 * Removes an overlay that was added with gtk_overlay_add_overlay(). 188 * 189 * Params: 190 * widget = a `GtkWidget` to be removed 191 */ 192 public void removeOverlay(Widget widget) 193 { 194 gtk_overlay_remove_overlay(gtkOverlay, (widget is null) ? null : widget.getWidgetStruct()); 195 } 196 197 /** 198 * Sets the child widget of @overlay. 199 * 200 * Params: 201 * child = the child widget 202 */ 203 public void setChild(Widget child) 204 { 205 gtk_overlay_set_child(gtkOverlay, (child is null) ? null : child.getWidgetStruct()); 206 } 207 208 /** 209 * Sets whether @widget should be clipped within the parent. 210 * 211 * Params: 212 * widget = an overlay child of `GtkOverlay` 213 * clipOverlay = whether the child should be clipped 214 */ 215 public void setClipOverlay(Widget widget, bool clipOverlay) 216 { 217 gtk_overlay_set_clip_overlay(gtkOverlay, (widget is null) ? null : widget.getWidgetStruct(), clipOverlay); 218 } 219 220 /** 221 * Sets whether @widget is included in the measured size of @overlay. 222 * 223 * The overlay will request the size of the largest child that has 224 * this property set to %TRUE. Children who are not included may 225 * be drawn outside of @overlay's allocation if they are too large. 226 * 227 * Params: 228 * widget = an overlay child of `GtkOverlay` 229 * measure = whether the child should be measured 230 */ 231 public void setMeasureOverlay(Widget widget, bool measure) 232 { 233 gtk_overlay_set_measure_overlay(gtkOverlay, (widget is null) ? null : widget.getWidgetStruct(), measure); 234 } 235 236 /** 237 * Emitted to determine the position and size of any overlay 238 * child widgets. 239 * 240 * A handler for this signal should fill @allocation with 241 * the desired position and size for @widget, relative to 242 * the 'main' child of @overlay. 243 * 244 * The default handler for this signal uses the @widget's 245 * halign and valign properties to determine the position 246 * and gives the widget its natural size (except that an 247 * alignment of %GTK_ALIGN_FILL will cause the overlay to 248 * be full-width/height). If the main child is a 249 * `GtkScrolledWindow`, the overlays are placed relative 250 * to its contents. 251 * 252 * Params: 253 * widget = the child widget to position 254 * allocation = return 255 * location for the allocation 256 * 257 * Returns: %TRUE if the @allocation has been filled 258 */ 259 gulong addOnGetChildPosition(bool delegate(Widget, GdkRectangle*, Overlay) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 260 { 261 return Signals.connect(this, "get-child-position", dlg, connectFlags ^ ConnectFlags.SWAPPED); 262 } 263 }