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 public static GType getType() 90 { 91 return gtk_layout_get_type(); 92 } 93 94 /** 95 * Creates a new #GtkLayout. Unless you have a specific adjustment 96 * you’d like the layout to use for scrolling, pass %NULL for 97 * @hadjustment and @vadjustment. 98 * 99 * Params: 100 * hadjustment = horizontal scroll adjustment, or %NULL 101 * vadjustment = vertical scroll adjustment, or %NULL 102 * 103 * Return: a new #GtkLayout 104 * 105 * Throws: ConstructionException GTK+ fails to create the object. 106 */ 107 public this(Adjustment hadjustment, Adjustment vadjustment) 108 { 109 auto p = gtk_layout_new((hadjustment is null) ? null : hadjustment.getAdjustmentStruct(), (vadjustment is null) ? null : vadjustment.getAdjustmentStruct()); 110 111 if(p is null) 112 { 113 throw new ConstructionException("null returned by new"); 114 } 115 116 this(cast(GtkLayout*) p); 117 } 118 119 /** 120 * Retrieve the bin window of the layout used for drawing operations. 121 * 122 * Return: a #GdkWindow 123 * 124 * Since: 2.14 125 */ 126 public Window getBinWindow() 127 { 128 auto p = gtk_layout_get_bin_window(gtkLayout); 129 130 if(p is null) 131 { 132 return null; 133 } 134 135 return ObjectG.getDObject!(Window)(cast(GdkWindow*) p); 136 } 137 138 /** 139 * This function should only be called after the layout has been 140 * placed in a #GtkScrolledWindow or otherwise configured for 141 * scrolling. It returns the #GtkAdjustment used for communication 142 * between the horizontal scrollbar and @layout. 143 * 144 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details. 145 * 146 * Deprecated: Use gtk_scrollable_get_hadjustment() 147 * 148 * Return: horizontal scroll adjustment 149 */ 150 public Adjustment getHadjustment() 151 { 152 auto p = gtk_layout_get_hadjustment(gtkLayout); 153 154 if(p is null) 155 { 156 return null; 157 } 158 159 return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p); 160 } 161 162 /** 163 * Gets the size that has been set on the layout, and that determines 164 * the total extents of the layout’s scrollbar area. See 165 * gtk_layout_set_size (). 166 * 167 * Params: 168 * width = location to store the width set on 169 * @layout, or %NULL 170 * height = location to store the height set on 171 * @layout, or %NULL 172 */ 173 public void getSize(out uint width, out uint height) 174 { 175 gtk_layout_get_size(gtkLayout, &width, &height); 176 } 177 178 /** 179 * This function should only be called after the layout has been 180 * placed in a #GtkScrolledWindow or otherwise configured for 181 * scrolling. It returns the #GtkAdjustment used for communication 182 * between the vertical scrollbar and @layout. 183 * 184 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details. 185 * 186 * Deprecated: Use gtk_scrollable_get_vadjustment() 187 * 188 * Return: vertical scroll adjustment 189 */ 190 public Adjustment getVadjustment() 191 { 192 auto p = gtk_layout_get_vadjustment(gtkLayout); 193 194 if(p is null) 195 { 196 return null; 197 } 198 199 return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p); 200 } 201 202 /** 203 * Moves a current child of @layout to a new position. 204 * 205 * Params: 206 * childWidget = a current child of @layout 207 * x = X position to move to 208 * y = Y position to move to 209 */ 210 public void move(Widget childWidget, int x, int y) 211 { 212 gtk_layout_move(gtkLayout, (childWidget is null) ? null : childWidget.getWidgetStruct(), x, y); 213 } 214 215 /** 216 * Adds @child_widget to @layout, at position (@x,@y). 217 * @layout becomes the new parent container of @child_widget. 218 * 219 * Params: 220 * childWidget = child widget 221 * x = X position of child widget 222 * y = Y position of child widget 223 */ 224 public void put(Widget childWidget, int x, int y) 225 { 226 gtk_layout_put(gtkLayout, (childWidget is null) ? null : childWidget.getWidgetStruct(), x, y); 227 } 228 229 /** 230 * Sets the horizontal scroll adjustment for the layout. 231 * 232 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details. 233 * 234 * Deprecated: Use gtk_scrollable_set_hadjustment() 235 * 236 * Params: 237 * adjustment = new scroll adjustment 238 */ 239 public void setHadjustment(Adjustment adjustment) 240 { 241 gtk_layout_set_hadjustment(gtkLayout, (adjustment is null) ? null : adjustment.getAdjustmentStruct()); 242 } 243 244 /** 245 * Sets the size of the scrollable area of the layout. 246 * 247 * Params: 248 * width = width of entire scrollable area 249 * height = height of entire scrollable area 250 */ 251 public void setSize(uint width, uint height) 252 { 253 gtk_layout_set_size(gtkLayout, width, height); 254 } 255 256 /** 257 * Sets the vertical scroll adjustment for the layout. 258 * 259 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details. 260 * 261 * Deprecated: Use gtk_scrollable_set_vadjustment() 262 * 263 * Params: 264 * adjustment = new scroll adjustment 265 */ 266 public void setVadjustment(Adjustment adjustment) 267 { 268 gtk_layout_set_vadjustment(gtkLayout, (adjustment is null) ? null : adjustment.getAdjustmentStruct()); 269 } 270 }