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.Layout; 26 27 private import gdk.Window; 28 private import glib.ConstructionException; 29 private import gobject.ObjectG; 30 private import gtk.Adjustment; 31 private import gtk.Container; 32 private import gtk.ScrollableIF; 33 private import gtk.ScrollableT; 34 private import gtk.Widget; 35 private import gtkc.gtk; 36 public import gtkc.gtktypes; 37 38 39 /** 40 * #GtkLayout is similar to #GtkDrawingArea in that it’s a “blank slate” 41 * and doesn’t do anything but paint a blank background by default. It's 42 * different in that it supports scrolling natively (you can add it to a 43 * #GtkScrolledWindow), and it can contain child widgets, since it’s a 44 * #GtkContainer. However if you’re just going to draw, a #GtkDrawingArea 45 * is a better choice since it has lower overhead. 46 * 47 * When handling expose events on a #GtkLayout, you must draw to 48 * GTK_LAYOUT (layout)->bin_window, rather than to 49 * GTK_WIDGET (layout)->window, as you would for a drawing 50 * area. 51 */ 52 public class Layout : Container, ScrollableIF 53 { 54 /** the main Gtk struct */ 55 protected GtkLayout* gtkLayout; 56 57 /** Get the main Gtk struct */ 58 public GtkLayout* getLayoutStruct() 59 { 60 return gtkLayout; 61 } 62 63 /** the main Gtk struct as a void* */ 64 protected override void* getStruct() 65 { 66 return cast(void*)gtkLayout; 67 } 68 69 protected override void setStruct(GObject* obj) 70 { 71 gtkLayout = cast(GtkLayout*)obj; 72 super.setStruct(obj); 73 } 74 75 /** 76 * Sets our main struct and passes it to the parent class. 77 */ 78 public this (GtkLayout* gtkLayout, bool ownedRef = false) 79 { 80 this.gtkLayout = gtkLayout; 81 super(cast(GtkContainer*)gtkLayout, ownedRef); 82 } 83 84 // add the Scrollable capabilities 85 mixin ScrollableT!(GtkLayout); 86 87 /** 88 */ 89 90 public static GType getType() 91 { 92 return gtk_layout_get_type(); 93 } 94 95 /** 96 * Creates a new #GtkLayout. Unless you have a specific adjustment 97 * you’d like the layout to use for scrolling, pass %NULL for 98 * @hadjustment and @vadjustment. 99 * 100 * Params: 101 * hadjustment = horizontal scroll adjustment, or %NULL 102 * vadjustment = vertical scroll adjustment, or %NULL 103 * 104 * Return: a new #GtkLayout 105 * 106 * Throws: ConstructionException GTK+ fails to create the object. 107 */ 108 public this(Adjustment hadjustment, Adjustment vadjustment) 109 { 110 auto p = gtk_layout_new((hadjustment is null) ? null : hadjustment.getAdjustmentStruct(), (vadjustment is null) ? null : vadjustment.getAdjustmentStruct()); 111 112 if(p is null) 113 { 114 throw new ConstructionException("null returned by new"); 115 } 116 117 this(cast(GtkLayout*) p); 118 } 119 120 /** 121 * Retrieve the bin window of the layout used for drawing operations. 122 * 123 * Return: a #GdkWindow 124 * 125 * Since: 2.14 126 */ 127 public Window getBinWindow() 128 { 129 auto p = gtk_layout_get_bin_window(gtkLayout); 130 131 if(p is null) 132 { 133 return null; 134 } 135 136 return ObjectG.getDObject!(Window)(cast(GdkWindow*) p); 137 } 138 139 /** 140 * This function should only be called after the layout has been 141 * placed in a #GtkScrolledWindow or otherwise configured for 142 * scrolling. It returns the #GtkAdjustment used for communication 143 * between the horizontal scrollbar and @layout. 144 * 145 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details. 146 * 147 * Deprecated: Use gtk_scrollable_get_hadjustment() 148 * 149 * Return: horizontal scroll adjustment 150 */ 151 public Adjustment getHadjustment() 152 { 153 auto p = gtk_layout_get_hadjustment(gtkLayout); 154 155 if(p is null) 156 { 157 return null; 158 } 159 160 return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p); 161 } 162 163 /** 164 * Gets the size that has been set on the layout, and that determines 165 * the total extents of the layout’s scrollbar area. See 166 * gtk_layout_set_size (). 167 * 168 * Params: 169 * width = location to store the width set on 170 * @layout, or %NULL 171 * height = location to store the height set on 172 * @layout, or %NULL 173 */ 174 public void getSize(out uint width, out uint height) 175 { 176 gtk_layout_get_size(gtkLayout, &width, &height); 177 } 178 179 /** 180 * This function should only be called after the layout has been 181 * placed in a #GtkScrolledWindow or otherwise configured for 182 * scrolling. It returns the #GtkAdjustment used for communication 183 * between the vertical scrollbar and @layout. 184 * 185 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details. 186 * 187 * Deprecated: Use gtk_scrollable_get_vadjustment() 188 * 189 * Return: vertical scroll adjustment 190 */ 191 public Adjustment getVadjustment() 192 { 193 auto p = gtk_layout_get_vadjustment(gtkLayout); 194 195 if(p is null) 196 { 197 return null; 198 } 199 200 return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p); 201 } 202 203 /** 204 * Moves a current child of @layout to a new position. 205 * 206 * Params: 207 * childWidget = a current child of @layout 208 * x = X position to move to 209 * y = Y position to move to 210 */ 211 public void move(Widget childWidget, int x, int y) 212 { 213 gtk_layout_move(gtkLayout, (childWidget is null) ? null : childWidget.getWidgetStruct(), x, y); 214 } 215 216 /** 217 * Adds @child_widget to @layout, at position (@x,@y). 218 * @layout becomes the new parent container of @child_widget. 219 * 220 * Params: 221 * childWidget = child widget 222 * x = X position of child widget 223 * y = Y position of child widget 224 */ 225 public void put(Widget childWidget, int x, int y) 226 { 227 gtk_layout_put(gtkLayout, (childWidget is null) ? null : childWidget.getWidgetStruct(), x, y); 228 } 229 230 /** 231 * Sets the horizontal scroll adjustment for the layout. 232 * 233 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details. 234 * 235 * Deprecated: Use gtk_scrollable_set_hadjustment() 236 * 237 * Params: 238 * adjustment = new scroll adjustment 239 */ 240 public void setHadjustment(Adjustment adjustment) 241 { 242 gtk_layout_set_hadjustment(gtkLayout, (adjustment is null) ? null : adjustment.getAdjustmentStruct()); 243 } 244 245 /** 246 * Sets the size of the scrollable area of the layout. 247 * 248 * Params: 249 * width = width of entire scrollable area 250 * height = height of entire scrollable area 251 */ 252 public void setSize(uint width, uint height) 253 { 254 gtk_layout_set_size(gtkLayout, width, height); 255 } 256 257 /** 258 * Sets the vertical scroll adjustment for the layout. 259 * 260 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details. 261 * 262 * Deprecated: Use gtk_scrollable_set_vadjustment() 263 * 264 * Params: 265 * adjustment = new scroll adjustment 266 */ 267 public void setVadjustment(Adjustment adjustment) 268 { 269 gtk_layout_set_vadjustment(gtkLayout, (adjustment is null) ? null : adjustment.getAdjustmentStruct()); 270 } 271 }