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.HandleBox; 26 27 private import glib.ConstructionException; 28 private import gobject.ObjectG; 29 private import gobject.Signals; 30 private import gtk.Bin; 31 private import gtk.Widget; 32 private import gtkc.gtk; 33 public import gtkc.gtktypes; 34 private import std.algorithm; 35 36 37 /** 38 * The #GtkHandleBox widget allows a portion of a window to be "torn 39 * off". It is a bin widget which displays its child and a handle that 40 * the user can drag to tear off a separate window (the “float 41 * window”) containing the child widget. A thin 42 * “ghost” is drawn in the original location of the 43 * handlebox. By dragging the separate window back to its original 44 * location, it can be reattached. 45 * 46 * When reattaching, the ghost and float window, must be aligned 47 * along one of the edges, the “snap edge”. 48 * This either can be specified by the application programmer 49 * explicitly, or GTK+ will pick a reasonable default based 50 * on the handle position. 51 * 52 * To make detaching and reattaching the handlebox as minimally confusing 53 * as possible to the user, it is important to set the snap edge so that 54 * the snap edge does not move when the handlebox is deattached. For 55 * instance, if the handlebox is packed at the bottom of a VBox, then 56 * when the handlebox is detached, the bottom edge of the handlebox's 57 * allocation will remain fixed as the height of the handlebox shrinks, 58 * so the snap edge should be set to %GTK_POS_BOTTOM. 59 * 60 * > #GtkHandleBox has been deprecated. It is very specialized, lacks features 61 * > to make it useful and most importantly does not fit well into modern 62 * > application design. Do not use it. There is no replacement. 63 */ 64 public class HandleBox : Bin 65 { 66 /** the main Gtk struct */ 67 protected GtkHandleBox* gtkHandleBox; 68 69 /** Get the main Gtk struct */ 70 public GtkHandleBox* getHandleBoxStruct() 71 { 72 return gtkHandleBox; 73 } 74 75 /** the main Gtk struct as a void* */ 76 protected override void* getStruct() 77 { 78 return cast(void*)gtkHandleBox; 79 } 80 81 protected override void setStruct(GObject* obj) 82 { 83 gtkHandleBox = cast(GtkHandleBox*)obj; 84 super.setStruct(obj); 85 } 86 87 /** 88 * Sets our main struct and passes it to the parent class. 89 */ 90 public this (GtkHandleBox* gtkHandleBox, bool ownedRef = false) 91 { 92 this.gtkHandleBox = gtkHandleBox; 93 super(cast(GtkBin*)gtkHandleBox, ownedRef); 94 } 95 96 97 /** */ 98 public static GType getType() 99 { 100 return gtk_handle_box_get_type(); 101 } 102 103 /** 104 * Create a new handle box. 105 * 106 * Deprecated: #GtkHandleBox has been deprecated. 107 * 108 * Returns: a new #GtkHandleBox. 109 * 110 * Throws: ConstructionException GTK+ fails to create the object. 111 */ 112 public this() 113 { 114 auto p = gtk_handle_box_new(); 115 116 if(p is null) 117 { 118 throw new ConstructionException("null returned by new"); 119 } 120 121 this(cast(GtkHandleBox*) p); 122 } 123 124 /** 125 * Whether the handlebox’s child is currently detached. 126 * 127 * Deprecated: #GtkHandleBox has been deprecated. 128 * 129 * Returns: %TRUE if the child is currently detached, otherwise %FALSE 130 * 131 * Since: 2.14 132 */ 133 public bool getChildDetached() 134 { 135 return gtk_handle_box_get_child_detached(gtkHandleBox) != 0; 136 } 137 138 /** 139 * Gets the handle position of the handle box. See 140 * gtk_handle_box_set_handle_position(). 141 * 142 * Deprecated: #GtkHandleBox has been deprecated. 143 * 144 * Returns: the current handle position. 145 */ 146 public GtkPositionType getHandlePosition() 147 { 148 return gtk_handle_box_get_handle_position(gtkHandleBox); 149 } 150 151 /** 152 * Gets the type of shadow drawn around the handle box. See 153 * gtk_handle_box_set_shadow_type(). 154 * 155 * Deprecated: #GtkHandleBox has been deprecated. 156 * 157 * Returns: the type of shadow currently drawn around the handle box. 158 */ 159 public GtkShadowType getShadowType() 160 { 161 return gtk_handle_box_get_shadow_type(gtkHandleBox); 162 } 163 164 /** 165 * Gets the edge used for determining reattachment of the handle box. 166 * See gtk_handle_box_set_snap_edge(). 167 * 168 * Deprecated: #GtkHandleBox has been deprecated. 169 * 170 * Returns: the edge used for determining reattachment, or 171 * (GtkPositionType)-1 if this is determined (as per default) 172 * from the handle position. 173 */ 174 public GtkPositionType getSnapEdge() 175 { 176 return gtk_handle_box_get_snap_edge(gtkHandleBox); 177 } 178 179 /** 180 * Sets the side of the handlebox where the handle is drawn. 181 * 182 * Deprecated: #GtkHandleBox has been deprecated. 183 * 184 * Params: 185 * position = the side of the handlebox where the handle should be drawn. 186 */ 187 public void setHandlePosition(GtkPositionType position) 188 { 189 gtk_handle_box_set_handle_position(gtkHandleBox, position); 190 } 191 192 /** 193 * Sets the type of shadow to be drawn around the border 194 * of the handle box. 195 * 196 * Deprecated: #GtkHandleBox has been deprecated. 197 * 198 * Params: 199 * type = the shadow type. 200 */ 201 public void setShadowType(GtkShadowType type) 202 { 203 gtk_handle_box_set_shadow_type(gtkHandleBox, type); 204 } 205 206 /** 207 * Sets the snap edge of a handlebox. The snap edge is 208 * the edge of the detached child that must be aligned 209 * with the corresponding edge of the “ghost” left 210 * behind when the child was detached to reattach 211 * the torn-off window. Usually, the snap edge should 212 * be chosen so that it stays in the same place on 213 * the screen when the handlebox is torn off. 214 * 215 * If the snap edge is not set, then an appropriate value 216 * will be guessed from the handle position. If the 217 * handle position is %GTK_POS_RIGHT or %GTK_POS_LEFT, 218 * then the snap edge will be %GTK_POS_TOP, otherwise 219 * it will be %GTK_POS_LEFT. 220 * 221 * Deprecated: #GtkHandleBox has been deprecated. 222 * 223 * Params: 224 * edge = the snap edge, or -1 to unset the value; in which 225 * case GTK+ will try to guess an appropriate value 226 * in the future. 227 */ 228 public void setSnapEdge(GtkPositionType edge) 229 { 230 gtk_handle_box_set_snap_edge(gtkHandleBox, edge); 231 } 232 233 protected class OnChildAttachedDelegateWrapper 234 { 235 static OnChildAttachedDelegateWrapper[] listeners; 236 void delegate(Widget, HandleBox) dlg; 237 gulong handlerId; 238 239 this(void delegate(Widget, HandleBox) dlg) 240 { 241 this.dlg = dlg; 242 this.listeners ~= this; 243 } 244 245 void remove(OnChildAttachedDelegateWrapper source) 246 { 247 foreach(index, wrapper; listeners) 248 { 249 if (wrapper.handlerId == source.handlerId) 250 { 251 listeners[index] = null; 252 listeners = std.algorithm.remove(listeners, index); 253 break; 254 } 255 } 256 } 257 } 258 259 /** 260 * This signal is emitted when the contents of the 261 * handlebox are reattached to the main window. 262 * 263 * Deprecated: #GtkHandleBox has been deprecated. 264 * 265 * Params: 266 * widget = the child widget of the handlebox. 267 * (this argument provides no extra information 268 * and is here only for backwards-compatibility) 269 */ 270 gulong addOnChildAttached(void delegate(Widget, HandleBox) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 271 { 272 auto wrapper = new OnChildAttachedDelegateWrapper(dlg); 273 wrapper.handlerId = Signals.connectData( 274 this, 275 "child-attached", 276 cast(GCallback)&callBackChildAttached, 277 cast(void*)wrapper, 278 cast(GClosureNotify)&callBackChildAttachedDestroy, 279 connectFlags); 280 return wrapper.handlerId; 281 } 282 283 extern(C) static void callBackChildAttached(GtkHandleBox* handleboxStruct, GtkWidget* widget, OnChildAttachedDelegateWrapper wrapper) 284 { 285 wrapper.dlg(ObjectG.getDObject!(Widget)(widget), wrapper.outer); 286 } 287 288 extern(C) static void callBackChildAttachedDestroy(OnChildAttachedDelegateWrapper wrapper, GClosure* closure) 289 { 290 wrapper.remove(wrapper); 291 } 292 293 protected class OnChildDetachedDelegateWrapper 294 { 295 static OnChildDetachedDelegateWrapper[] listeners; 296 void delegate(Widget, HandleBox) dlg; 297 gulong handlerId; 298 299 this(void delegate(Widget, HandleBox) dlg) 300 { 301 this.dlg = dlg; 302 this.listeners ~= this; 303 } 304 305 void remove(OnChildDetachedDelegateWrapper source) 306 { 307 foreach(index, wrapper; listeners) 308 { 309 if (wrapper.handlerId == source.handlerId) 310 { 311 listeners[index] = null; 312 listeners = std.algorithm.remove(listeners, index); 313 break; 314 } 315 } 316 } 317 } 318 319 /** 320 * This signal is emitted when the contents of the 321 * handlebox are detached from the main window. 322 * 323 * Deprecated: #GtkHandleBox has been deprecated. 324 * 325 * Params: 326 * widget = the child widget of the handlebox. 327 * (this argument provides no extra information 328 * and is here only for backwards-compatibility) 329 */ 330 gulong addOnChildDetached(void delegate(Widget, HandleBox) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 331 { 332 auto wrapper = new OnChildDetachedDelegateWrapper(dlg); 333 wrapper.handlerId = Signals.connectData( 334 this, 335 "child-detached", 336 cast(GCallback)&callBackChildDetached, 337 cast(void*)wrapper, 338 cast(GClosureNotify)&callBackChildDetachedDestroy, 339 connectFlags); 340 return wrapper.handlerId; 341 } 342 343 extern(C) static void callBackChildDetached(GtkHandleBox* handleboxStruct, GtkWidget* widget, OnChildDetachedDelegateWrapper wrapper) 344 { 345 wrapper.dlg(ObjectG.getDObject!(Widget)(widget), wrapper.outer); 346 } 347 348 extern(C) static void callBackChildDetachedDestroy(OnChildDetachedDelegateWrapper wrapper, GClosure* closure) 349 { 350 wrapper.remove(wrapper); 351 } 352 }