1 /* 2 * This file is part of d-handy. 3 * 4 * d-handy 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 * d-handy 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 d-handy; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 module handy.Clamp; 20 21 private import glib.ConstructionException; 22 private import gobject.ObjectG; 23 private import gtk.Bin; 24 private import gtk.BuildableIF; 25 private import gtk.BuildableT; 26 private import gtk.OrientableIF; 27 private import gtk.OrientableT; 28 private import gtk.Widget; 29 private import handy.c.functions; 30 public import handy.c.types; 31 32 33 /** */ 34 public class Clamp : Bin, OrientableIF 35 { 36 /** the main Gtk struct */ 37 protected HdyClamp* hdyClamp; 38 39 /** Get the main Gtk struct */ 40 public HdyClamp* getClampStruct(bool transferOwnership = false) 41 { 42 if (transferOwnership) 43 ownedRef = false; 44 return hdyClamp; 45 } 46 47 /** the main Gtk struct as a void* */ 48 protected override void* getStruct() 49 { 50 return cast(void*)hdyClamp; 51 } 52 53 /** 54 * Sets our main struct and passes it to the parent class. 55 */ 56 public this (HdyClamp* hdyClamp, bool ownedRef = false) 57 { 58 this.hdyClamp = hdyClamp; 59 super(cast(GtkBin*)hdyClamp, ownedRef); 60 } 61 62 // add the Orientable capabilities 63 mixin OrientableT!(HdyClamp); 64 65 66 /** */ 67 public static GType getType() 68 { 69 return hdy_clamp_get_type(); 70 } 71 72 /** 73 * Creates a new #HdyClamp. 74 * 75 * Returns: a new #HdyClamp 76 * 77 * Since: 1.0 78 * 79 * Throws: ConstructionException GTK+ fails to create the object. 80 */ 81 public this() 82 { 83 auto __p = hdy_clamp_new(); 84 85 if(__p is null) 86 { 87 throw new ConstructionException("null returned by new"); 88 } 89 90 this(cast(HdyClamp*) __p); 91 } 92 93 /** 94 * Gets the maximum size to allocate to the contained child. It is the width if 95 * @self is horizontal, or the height if it is vertical. 96 * 97 * Returns: the maximum width to allocate to the contained child. 98 * 99 * Since: 1.0 100 */ 101 public int getMaximumSize() 102 { 103 return hdy_clamp_get_maximum_size(hdyClamp); 104 } 105 106 /** 107 * Gets the size starting from which the clamp will tighten its grip on the 108 * child. 109 * 110 * Returns: the size starting from which the clamp will tighten its grip on the 111 * child. 112 * 113 * Since: 1.0 114 */ 115 public int getTighteningThreshold() 116 { 117 return hdy_clamp_get_tightening_threshold(hdyClamp); 118 } 119 120 /** 121 * Sets the maximum size to allocate to the contained child. It is the width if 122 * @self is horizontal, or the height if it is vertical. 123 * 124 * Params: 125 * maximumSize = the maximum size 126 * 127 * Since: 1.0 128 */ 129 public void setMaximumSize(int maximumSize) 130 { 131 hdy_clamp_set_maximum_size(hdyClamp, maximumSize); 132 } 133 134 /** 135 * Sets the size starting from which the clamp will tighten its grip on the 136 * child. 137 * 138 * Params: 139 * tighteningThreshold = the tightening threshold 140 * 141 * Since: 1.0 142 */ 143 public void setTighteningThreshold(int tighteningThreshold) 144 { 145 hdy_clamp_set_tightening_threshold(hdyClamp, tighteningThreshold); 146 } 147 }