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