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.Bin; 31 private import gtk.Widget; 32 private import gtk.c.functions; 33 public import gtk.c.types; 34 public import gtkc.gtktypes; 35 private import std.algorithm; 36 37 38 /** 39 * GtkOverlay is a container which contains a single main child, on top 40 * of which it can place “overlay” widgets. The position of each overlay 41 * widget is determined by its #GtkWidget:halign and #GtkWidget:valign 42 * properties. E.g. a widget with both alignments set to %GTK_ALIGN_START 43 * will be placed at the top left corner of the GtkOverlay container, 44 * whereas an overlay with halign set to %GTK_ALIGN_CENTER and valign set 45 * to %GTK_ALIGN_END will be placed a the bottom edge of the GtkOverlay, 46 * horizontally centered. The position can be adjusted by setting the margin 47 * properties of the child to non-zero values. 48 * 49 * More complicated placement of overlays is possible by connecting 50 * to the #GtkOverlay::get-child-position signal. 51 * 52 * # GtkOverlay as GtkBuildable 53 * 54 * The GtkOverlay implementation of the GtkBuildable interface 55 * supports placing a child as an overlay by specifying “overlay” as 56 * the “type” attribute of a `<child>` element. 57 * 58 * # CSS nodes 59 * 60 * GtkOverlay has a single CSS node with the name “overlay”. Overlay children 61 * whose alignments cause them to be positioned at an edge get the style classes 62 * “.left”, “.right”, “.top”, and/or “.bottom” according to their position. 63 */ 64 public class Overlay : Bin 65 { 66 /** the main Gtk struct */ 67 protected GtkOverlay* gtkOverlay; 68 69 /** Get the main Gtk struct */ 70 public GtkOverlay* getOverlayStruct(bool transferOwnership = false) 71 { 72 if (transferOwnership) 73 ownedRef = false; 74 return gtkOverlay; 75 } 76 77 /** the main Gtk struct as a void* */ 78 protected override void* getStruct() 79 { 80 return cast(void*)gtkOverlay; 81 } 82 83 /** 84 * Sets our main struct and passes it to the parent class. 85 */ 86 public this (GtkOverlay* gtkOverlay, bool ownedRef = false) 87 { 88 this.gtkOverlay = gtkOverlay; 89 super(cast(GtkBin*)gtkOverlay, ownedRef); 90 } 91 92 93 /** */ 94 public static GType getType() 95 { 96 return gtk_overlay_get_type(); 97 } 98 99 /** 100 * Creates a new #GtkOverlay. 101 * 102 * Returns: a new #GtkOverlay object. 103 * 104 * Since: 3.2 105 * 106 * Throws: ConstructionException GTK+ fails to create the object. 107 */ 108 public this() 109 { 110 auto p = gtk_overlay_new(); 111 112 if(p is null) 113 { 114 throw new ConstructionException("null returned by new"); 115 } 116 117 this(cast(GtkOverlay*) p); 118 } 119 120 /** 121 * Adds @widget to @overlay. 122 * 123 * The widget will be stacked on top of the main widget 124 * added with gtk_container_add(). 125 * 126 * The position at which @widget is placed is determined 127 * from its #GtkWidget:halign and #GtkWidget:valign properties. 128 * 129 * Params: 130 * widget = a #GtkWidget to be added to the container 131 * 132 * Since: 3.2 133 */ 134 public void addOverlay(Widget widget) 135 { 136 gtk_overlay_add_overlay(gtkOverlay, (widget is null) ? null : widget.getWidgetStruct()); 137 } 138 139 /** 140 * Convenience function to get the value of the #GtkOverlay:pass-through 141 * child property for @widget. 142 * 143 * Params: 144 * widget = an overlay child of #GtkOverlay 145 * 146 * Returns: whether the widget is a pass through child. 147 * 148 * Since: 3.18 149 */ 150 public bool getOverlayPassThrough(Widget widget) 151 { 152 return gtk_overlay_get_overlay_pass_through(gtkOverlay, (widget is null) ? null : widget.getWidgetStruct()) != 0; 153 } 154 155 /** 156 * Moves @child to a new @index in the list of @overlay children. 157 * The list contains overlays in the order that these were 158 * added to @overlay. 159 * 160 * A widget’s index in the @overlay children list determines which order 161 * the children are drawn if they overlap. The first child is drawn at 162 * the bottom. It also affects the default focus chain order. 163 * 164 * Params: 165 * child = the overlaid #GtkWidget to move 166 * position = the new index for @child in the list of overlay children 167 * of @overlay, starting from 0. If negative, indicates the end of 168 * the list 169 * 170 * Since: 3.18 171 */ 172 public void reorderOverlay(Widget child, int position) 173 { 174 gtk_overlay_reorder_overlay(gtkOverlay, (child is null) ? null : child.getWidgetStruct(), position); 175 } 176 177 /** 178 * Convenience function to set the value of the #GtkOverlay:pass-through 179 * child property for @widget. 180 * 181 * Params: 182 * widget = an overlay child of #GtkOverlay 183 * passThrough = whether the child should pass the input through 184 * 185 * Since: 3.18 186 */ 187 public void setOverlayPassThrough(Widget widget, bool passThrough) 188 { 189 gtk_overlay_set_overlay_pass_through(gtkOverlay, (widget is null) ? null : widget.getWidgetStruct(), passThrough); 190 } 191 192 /** 193 * The ::get-child-position signal is emitted to determine 194 * the position and size of any overlay child widgets. A 195 * handler for this signal should fill @allocation with 196 * the desired position and size for @widget, relative to 197 * the 'main' child of @overlay. 198 * 199 * The default handler for this signal uses the @widget's 200 * halign and valign properties to determine the position 201 * and gives the widget its natural size (except that an 202 * alignment of %GTK_ALIGN_FILL will cause the overlay to 203 * be full-width/height). If the main child is a 204 * #GtkScrolledWindow, the overlays are placed relative 205 * to its contents. 206 * 207 * Params: 208 * widget = the child widget to position 209 * allocation = return 210 * location for the allocation 211 * 212 * Returns: %TRUE if the @allocation has been filled 213 */ 214 gulong addOnGetChildPosition(bool delegate(Widget, GdkRectangle*, Overlay) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 215 { 216 return Signals.connect(this, "get-child-position", dlg, connectFlags ^ ConnectFlags.SWAPPED); 217 } 218 }