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