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.ScrollableT; 26 27 public import glib.MemorySlice; 28 public import gobject.ObjectG; 29 public import gtk.Adjustment; 30 public import gtk.Border; 31 public import gtk.c.functions; 32 public import gtk.c.types; 33 public import gtkc.gtktypes; 34 35 36 /** 37 * #GtkScrollable is an interface that is implemented by widgets with native 38 * scrolling ability. 39 * 40 * To implement this interface you should override the 41 * #GtkScrollable:hadjustment and #GtkScrollable:vadjustment properties. 42 * 43 * ## Creating a scrollable widget 44 * 45 * All scrollable widgets should do the following. 46 * 47 * - When a parent widget sets the scrollable child widget’s adjustments, 48 * the widget should populate the adjustments’ 49 * #GtkAdjustment:lower, #GtkAdjustment:upper, 50 * #GtkAdjustment:step-increment, #GtkAdjustment:page-increment and 51 * #GtkAdjustment:page-size properties and connect to the 52 * #GtkAdjustment::value-changed signal. 53 * 54 * - Because its preferred size is the size for a fully expanded widget, 55 * the scrollable widget must be able to cope with underallocations. 56 * This means that it must accept any value passed to its 57 * #GtkWidgetClass.size_allocate() function. 58 * 59 * - When the parent allocates space to the scrollable child widget, 60 * the widget should update the adjustments’ properties with new values. 61 * 62 * - When any of the adjustments emits the #GtkAdjustment::value-changed signal, 63 * the scrollable widget should scroll its contents. 64 */ 65 public template ScrollableT(TStruct) 66 { 67 /** Get the main Gtk struct */ 68 public GtkScrollable* getScrollableStruct(bool transferOwnership = false) 69 { 70 if (transferOwnership) 71 ownedRef = false; 72 return cast(GtkScrollable*)getStruct(); 73 } 74 75 76 /** 77 * Returns the size of a non-scrolling border around the 78 * outside of the scrollable. An example for this would 79 * be treeview headers. GTK+ can use this information to 80 * display overlayed graphics, like the overshoot indication, 81 * at the right position. 82 * 83 * Params: 84 * border = return location for the results 85 * 86 * Returns: %TRUE if @border has been set 87 * 88 * Since: 3.16 89 */ 90 public bool getBorder(out Border border) 91 { 92 GtkBorder* outborder = sliceNew!GtkBorder(); 93 94 auto p = gtk_scrollable_get_border(getScrollableStruct(), outborder) != 0; 95 96 border = ObjectG.getDObject!(Border)(outborder, true); 97 98 return p; 99 } 100 101 /** 102 * Retrieves the #GtkAdjustment used for horizontal scrolling. 103 * 104 * Returns: horizontal #GtkAdjustment. 105 * 106 * Since: 3.0 107 */ 108 public Adjustment getHadjustment() 109 { 110 auto p = gtk_scrollable_get_hadjustment(getScrollableStruct()); 111 112 if(p is null) 113 { 114 return null; 115 } 116 117 return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p); 118 } 119 120 /** 121 * Gets the horizontal #GtkScrollablePolicy. 122 * 123 * Returns: The horizontal #GtkScrollablePolicy. 124 * 125 * Since: 3.0 126 */ 127 public GtkScrollablePolicy getHscrollPolicy() 128 { 129 return gtk_scrollable_get_hscroll_policy(getScrollableStruct()); 130 } 131 132 /** 133 * Retrieves the #GtkAdjustment used for vertical scrolling. 134 * 135 * Returns: vertical #GtkAdjustment. 136 * 137 * Since: 3.0 138 */ 139 public Adjustment getVadjustment() 140 { 141 auto p = gtk_scrollable_get_vadjustment(getScrollableStruct()); 142 143 if(p is null) 144 { 145 return null; 146 } 147 148 return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p); 149 } 150 151 /** 152 * Gets the vertical #GtkScrollablePolicy. 153 * 154 * Returns: The vertical #GtkScrollablePolicy. 155 * 156 * Since: 3.0 157 */ 158 public GtkScrollablePolicy getVscrollPolicy() 159 { 160 return gtk_scrollable_get_vscroll_policy(getScrollableStruct()); 161 } 162 163 /** 164 * Sets the horizontal adjustment of the #GtkScrollable. 165 * 166 * Params: 167 * hadjustment = a #GtkAdjustment 168 * 169 * Since: 3.0 170 */ 171 public void setHadjustment(Adjustment hadjustment) 172 { 173 gtk_scrollable_set_hadjustment(getScrollableStruct(), (hadjustment is null) ? null : hadjustment.getAdjustmentStruct()); 174 } 175 176 /** 177 * Sets the #GtkScrollablePolicy to determine whether 178 * horizontal scrolling should start below the minimum width or 179 * below the natural width. 180 * 181 * Params: 182 * policy = the horizontal #GtkScrollablePolicy 183 * 184 * Since: 3.0 185 */ 186 public void setHscrollPolicy(GtkScrollablePolicy policy) 187 { 188 gtk_scrollable_set_hscroll_policy(getScrollableStruct(), policy); 189 } 190 191 /** 192 * Sets the vertical adjustment of the #GtkScrollable. 193 * 194 * Params: 195 * vadjustment = a #GtkAdjustment 196 * 197 * Since: 3.0 198 */ 199 public void setVadjustment(Adjustment vadjustment) 200 { 201 gtk_scrollable_set_vadjustment(getScrollableStruct(), (vadjustment is null) ? null : vadjustment.getAdjustmentStruct()); 202 } 203 204 /** 205 * Sets the #GtkScrollablePolicy to determine whether 206 * vertical scrolling should start below the minimum height or 207 * below the natural height. 208 * 209 * Params: 210 * policy = the vertical #GtkScrollablePolicy 211 * 212 * Since: 3.0 213 */ 214 public void setVscrollPolicy(GtkScrollablePolicy policy) 215 { 216 gtk_scrollable_set_vscroll_policy(getScrollableStruct(), policy); 217 } 218 }