1 /* 2 * This file is part of d-dazzle. 3 * 4 * d-dazzle 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-dazzle 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-dazzle; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 module dazzle.MultiPaned; 20 21 private import dazzle.c.functions; 22 public import dazzle.c.types; 23 private import glib.ConstructionException; 24 private import gobject.ObjectG; 25 private import gobject.Signals; 26 private import gtk.BuildableIF; 27 private import gtk.BuildableT; 28 private import gtk.Container; 29 private import gtk.OrientableIF; 30 private import gtk.OrientableT; 31 private import gtk.Widget; 32 private import std.algorithm; 33 34 35 /** 36 * This widget is similar to #GtkPaned except that it allows adding more than 37 * two children to the widget. For each additional child added to the 38 * #DzlMultiPaned, an additional resize grip is added. 39 */ 40 public class MultiPaned : Container, OrientableIF 41 { 42 /** the main Gtk struct */ 43 protected DzlMultiPaned* dzlMultiPaned; 44 45 /** Get the main Gtk struct */ 46 public DzlMultiPaned* getMultiPanedStruct(bool transferOwnership = false) 47 { 48 if (transferOwnership) 49 ownedRef = false; 50 return dzlMultiPaned; 51 } 52 53 /** the main Gtk struct as a void* */ 54 protected override void* getStruct() 55 { 56 return cast(void*)dzlMultiPaned; 57 } 58 59 /** 60 * Sets our main struct and passes it to the parent class. 61 */ 62 public this (DzlMultiPaned* dzlMultiPaned, bool ownedRef = false) 63 { 64 this.dzlMultiPaned = dzlMultiPaned; 65 super(cast(GtkContainer*)dzlMultiPaned, ownedRef); 66 } 67 68 // add the Orientable capabilities 69 mixin OrientableT!(DzlMultiPaned); 70 71 72 /** */ 73 public static GType getType() 74 { 75 return dzl_multi_paned_get_type(); 76 } 77 78 /** */ 79 public this() 80 { 81 auto p = dzl_multi_paned_new(); 82 83 if(p is null) 84 { 85 throw new ConstructionException("null returned by new"); 86 } 87 88 this(cast(DzlMultiPaned*) p); 89 } 90 91 /** 92 * Locates the widget at position x,y within widget. 93 * 94 * @x and @y should be relative to @self. 95 * 96 * Params: 97 * x = x coordinate 98 * y = y coordinate 99 * 100 * Returns: a #GtkWidget or %NULL 101 * 102 * Since: 3.28 103 */ 104 public Widget getAtPoint(int x, int y) 105 { 106 auto p = dzl_multi_paned_get_at_point(dzlMultiPaned, x, y); 107 108 if(p is null) 109 { 110 return null; 111 } 112 113 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 114 } 115 116 /** */ 117 public uint getNChildren() 118 { 119 return dzl_multi_paned_get_n_children(dzlMultiPaned); 120 } 121 122 /** 123 * Gets the @nth child of the #DzlMultiPaned. 124 * 125 * It is an error to call this function with a value >= the result of 126 * dzl_multi_paned_get_nth_child(). 127 * 128 * The index starts from 0. 129 * 130 * Returns: A #GtkWidget 131 */ 132 public Widget getNthChild(uint nth) 133 { 134 auto p = dzl_multi_paned_get_nth_child(dzlMultiPaned, nth); 135 136 if(p is null) 137 { 138 return null; 139 } 140 141 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 142 } 143 144 /** */ 145 gulong addOnResizeDragBegin(void delegate(Widget, MultiPaned) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 146 { 147 return Signals.connect(this, "resize-drag-begin", dlg, connectFlags ^ ConnectFlags.SWAPPED); 148 } 149 150 /** */ 151 gulong addOnResizeDragEnd(void delegate(Widget, MultiPaned) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 152 { 153 return Signals.connect(this, "resize-drag-end", dlg, connectFlags ^ ConnectFlags.SWAPPED); 154 } 155 }