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 public static GType getType() 94 { 95 return gtk_viewport_get_type(); 96 } 97 98 /** 99 * Creates a new #GtkViewport with the given adjustments, or with default 100 * adjustments if none are given. 101 * 102 * Params: 103 * hadjustment = horizontal adjustment 104 * vadjustment = vertical adjustment 105 * 106 * Return: a new #GtkViewport 107 * 108 * Throws: ConstructionException GTK+ fails to create the object. 109 */ 110 public this(Adjustment hadjustment, Adjustment vadjustment) 111 { 112 auto p = gtk_viewport_new((hadjustment is null) ? null : hadjustment.getAdjustmentStruct(), (vadjustment is null) ? null : vadjustment.getAdjustmentStruct()); 113 114 if(p is null) 115 { 116 throw new ConstructionException("null returned by new"); 117 } 118 119 this(cast(GtkViewport*) p); 120 } 121 122 /** 123 * Gets the bin window of the #GtkViewport. 124 * 125 * Return: a #GdkWindow 126 * 127 * Since: 2.20 128 */ 129 public Window getBinWindow() 130 { 131 auto p = gtk_viewport_get_bin_window(gtkViewport); 132 133 if(p is null) 134 { 135 return null; 136 } 137 138 return ObjectG.getDObject!(Window)(cast(GdkWindow*) p); 139 } 140 141 /** 142 * Returns the horizontal adjustment of the viewport. 143 * 144 * Deprecated: Use gtk_scrollable_get_hadjustment() 145 * 146 * Return: the horizontal adjustment of @viewport. 147 */ 148 public Adjustment getHadjustment() 149 { 150 auto p = gtk_viewport_get_hadjustment(gtkViewport); 151 152 if(p is null) 153 { 154 return null; 155 } 156 157 return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p); 158 } 159 160 /** 161 * Gets the shadow type of the #GtkViewport. See 162 * gtk_viewport_set_shadow_type(). 163 * 164 * Return: the shadow type 165 */ 166 public GtkShadowType getShadowType() 167 { 168 return gtk_viewport_get_shadow_type(gtkViewport); 169 } 170 171 /** 172 * Returns the vertical adjustment of the viewport. 173 * 174 * Deprecated: Use gtk_scrollable_get_vadjustment() 175 * 176 * Return: the vertical adjustment of @viewport. 177 */ 178 public Adjustment getVadjustment() 179 { 180 auto p = gtk_viewport_get_vadjustment(gtkViewport); 181 182 if(p is null) 183 { 184 return null; 185 } 186 187 return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p); 188 } 189 190 /** 191 * Gets the view window of the #GtkViewport. 192 * 193 * Return: a #GdkWindow 194 * 195 * Since: 2.22 196 */ 197 public Window getViewWindow() 198 { 199 auto p = gtk_viewport_get_view_window(gtkViewport); 200 201 if(p is null) 202 { 203 return null; 204 } 205 206 return ObjectG.getDObject!(Window)(cast(GdkWindow*) p); 207 } 208 209 /** 210 * Sets the horizontal adjustment of the viewport. 211 * 212 * Deprecated: Use gtk_scrollable_set_hadjustment() 213 * 214 * Params: 215 * adjustment = a #GtkAdjustment. 216 */ 217 public void setHadjustment(Adjustment adjustment) 218 { 219 gtk_viewport_set_hadjustment(gtkViewport, (adjustment is null) ? null : adjustment.getAdjustmentStruct()); 220 } 221 222 /** 223 * Sets the shadow type of the viewport. 224 * 225 * Params: 226 * type = the new shadow type. 227 */ 228 public void setShadowType(GtkShadowType type) 229 { 230 gtk_viewport_set_shadow_type(gtkViewport, type); 231 } 232 233 /** 234 * Sets the vertical adjustment of the viewport. 235 * 236 * Deprecated: Use gtk_scrollable_set_vadjustment() 237 * 238 * Params: 239 * adjustment = a #GtkAdjustment. 240 */ 241 public void setVadjustment(Adjustment adjustment) 242 { 243 gtk_viewport_set_vadjustment(gtkViewport, (adjustment is null) ? null : adjustment.getAdjustmentStruct()); 244 } 245 }