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.Viewport; 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.Bin; 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 * The #GtkViewport widget acts as an adaptor class, implementing 41 * scrollability for child widgets that lack their own scrolling 42 * capabilities. Use #GtkViewport to scroll child widgets such as 43 * #GtkGrid, #GtkBox, and so on. 44 * 45 * If a widget has native scrolling abilities, such as #GtkTextView, 46 * #GtkTreeView or #GtkIconView, it can be added to a #GtkScrolledWindow 47 * with gtk_container_add(). If a widget does not, you must first add the 48 * widget to a #GtkViewport, then add the viewport to the scrolled window. 49 * gtk_container_add() does this automatically if a child that does not 50 * implement #GtkScrollable is added to a #GtkScrolledWindow, so you can 51 * ignore the presence of the viewport. 52 * 53 * The #GtkViewport will start scrolling content only if allocated less 54 * than the child widget’s minimum size in a given orientation. 55 */ 56 public class Viewport : Bin, ScrollableIF 57 { 58 /** the main Gtk struct */ 59 protected GtkViewport* gtkViewport; 60 61 /** Get the main Gtk struct */ 62 public GtkViewport* getViewportStruct() 63 { 64 return gtkViewport; 65 } 66 67 /** the main Gtk struct as a void* */ 68 protected override void* getStruct() 69 { 70 return cast(void*)gtkViewport; 71 } 72 73 protected override void setStruct(GObject* obj) 74 { 75 gtkViewport = cast(GtkViewport*)obj; 76 super.setStruct(obj); 77 } 78 79 /** 80 * Sets our main struct and passes it to the parent class. 81 */ 82 public this (GtkViewport* gtkViewport, bool ownedRef = false) 83 { 84 this.gtkViewport = gtkViewport; 85 super(cast(GtkBin*)gtkViewport, ownedRef); 86 } 87 88 // add the Scrollable capabilities 89 mixin ScrollableT!(GtkViewport); 90 91 /** 92 */ 93 94 public static GType getType() 95 { 96 return gtk_viewport_get_type(); 97 } 98 99 /** 100 * Creates a new #GtkViewport with the given adjustments, or with default 101 * adjustments if none are given. 102 * 103 * Params: 104 * hadjustment = horizontal adjustment 105 * vadjustment = vertical adjustment 106 * 107 * Return: a new #GtkViewport 108 * 109 * Throws: ConstructionException GTK+ fails to create the object. 110 */ 111 public this(Adjustment hadjustment, Adjustment vadjustment) 112 { 113 auto p = gtk_viewport_new((hadjustment is null) ? null : hadjustment.getAdjustmentStruct(), (vadjustment is null) ? null : vadjustment.getAdjustmentStruct()); 114 115 if(p is null) 116 { 117 throw new ConstructionException("null returned by new"); 118 } 119 120 this(cast(GtkViewport*) p); 121 } 122 123 /** 124 * Gets the bin window of the #GtkViewport. 125 * 126 * Return: a #GdkWindow 127 * 128 * Since: 2.20 129 */ 130 public Window getBinWindow() 131 { 132 auto p = gtk_viewport_get_bin_window(gtkViewport); 133 134 if(p is null) 135 { 136 return null; 137 } 138 139 return ObjectG.getDObject!(Window)(cast(GdkWindow*) p); 140 } 141 142 /** 143 * Returns the horizontal adjustment of the viewport. 144 * 145 * Deprecated: Use gtk_scrollable_get_hadjustment() 146 * 147 * Return: the horizontal adjustment of @viewport. 148 */ 149 public Adjustment getHadjustment() 150 { 151 auto p = gtk_viewport_get_hadjustment(gtkViewport); 152 153 if(p is null) 154 { 155 return null; 156 } 157 158 return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p); 159 } 160 161 /** 162 * Gets the shadow type of the #GtkViewport. See 163 * gtk_viewport_set_shadow_type(). 164 * 165 * Return: the shadow type 166 */ 167 public GtkShadowType getShadowType() 168 { 169 return gtk_viewport_get_shadow_type(gtkViewport); 170 } 171 172 /** 173 * Returns the vertical adjustment of the viewport. 174 * 175 * Deprecated: Use gtk_scrollable_get_vadjustment() 176 * 177 * Return: the vertical adjustment of @viewport. 178 */ 179 public Adjustment getVadjustment() 180 { 181 auto p = gtk_viewport_get_vadjustment(gtkViewport); 182 183 if(p is null) 184 { 185 return null; 186 } 187 188 return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p); 189 } 190 191 /** 192 * Gets the view window of the #GtkViewport. 193 * 194 * Return: a #GdkWindow 195 * 196 * Since: 2.22 197 */ 198 public Window getViewWindow() 199 { 200 auto p = gtk_viewport_get_view_window(gtkViewport); 201 202 if(p is null) 203 { 204 return null; 205 } 206 207 return ObjectG.getDObject!(Window)(cast(GdkWindow*) p); 208 } 209 210 /** 211 * Sets the horizontal adjustment of the viewport. 212 * 213 * Deprecated: Use gtk_scrollable_set_hadjustment() 214 * 215 * Params: 216 * adjustment = a #GtkAdjustment. 217 */ 218 public void setHadjustment(Adjustment adjustment) 219 { 220 gtk_viewport_set_hadjustment(gtkViewport, (adjustment is null) ? null : adjustment.getAdjustmentStruct()); 221 } 222 223 /** 224 * Sets the shadow type of the viewport. 225 * 226 * Params: 227 * type = the new shadow type. 228 */ 229 public void setShadowType(GtkShadowType type) 230 { 231 gtk_viewport_set_shadow_type(gtkViewport, type); 232 } 233 234 /** 235 * Sets the vertical adjustment of the viewport. 236 * 237 * Deprecated: Use gtk_scrollable_set_vadjustment() 238 * 239 * Params: 240 * adjustment = a #GtkAdjustment. 241 */ 242 public void setVadjustment(Adjustment adjustment) 243 { 244 gtk_viewport_set_vadjustment(gtkViewport, (adjustment is null) ? null : adjustment.getAdjustmentStruct()); 245 } 246 }