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.Frame; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gtk.Bin; 31 private import gtk.Widget; 32 private import gtkc.gtk; 33 public import gtkc.gtktypes; 34 35 36 /** 37 * The frame widget is a bin that surrounds its child with a decorative 38 * frame and an optional label. If present, the label is drawn in a gap 39 * in the top side of the frame. The position of the label can be 40 * controlled with gtk_frame_set_label_align(). 41 * 42 * # GtkFrame as GtkBuildable 43 * 44 * The GtkFrame implementation of the GtkBuildable interface supports 45 * placing a child in the label position by specifying “label” as the 46 * “type” attribute of a <child> element. A normal content child can 47 * be specified without specifying a <child> type attribute. 48 * 49 * An example of a UI definition fragment with GtkFrame: 50 * |[ 51 * <object class="GtkFrame"> 52 * <child type="label"> 53 * <object class="GtkLabel" id="frame-label"/> 54 * </child> 55 * <child> 56 * <object class="GtkEntry" id="frame-content"/> 57 * </child> 58 * </object> 59 * ]| 60 * 61 * # CSS nodes 62 * 63 * |[<!-- language="plain" --> 64 * frame 65 * ├── border 66 * ├── <label widget> 67 * ╰── <child> 68 * ]| 69 * 70 * GtkFrame has a main CSS node with name frame and a subnode with 71 * name border. The border node is used to render the visible border. 72 * 73 * The border node can be given the style class .flat, which is used by themes 74 * to disable drawing of the border. To do this from code, call 75 * gtk_frame_set_shadow_type() with GTK_SHADOW_NONE to add the .flat class or 76 * any other shadow type to remove it. 77 */ 78 public class Frame : Bin 79 { 80 /** the main Gtk struct */ 81 protected GtkFrame* gtkFrame; 82 83 /** Get the main Gtk struct */ 84 public GtkFrame* getFrameStruct(bool transferOwnership = false) 85 { 86 if (transferOwnership) 87 ownedRef = false; 88 return gtkFrame; 89 } 90 91 /** the main Gtk struct as a void* */ 92 protected override void* getStruct() 93 { 94 return cast(void*)gtkFrame; 95 } 96 97 protected override void setStruct(GObject* obj) 98 { 99 gtkFrame = cast(GtkFrame*)obj; 100 super.setStruct(obj); 101 } 102 103 /** 104 * Sets our main struct and passes it to the parent class. 105 */ 106 public this (GtkFrame* gtkFrame, bool ownedRef = false) 107 { 108 this.gtkFrame = gtkFrame; 109 super(cast(GtkBin*)gtkFrame, ownedRef); 110 } 111 112 /** 113 * Creates frame with label and set it's child widget 114 */ 115 public this(Widget widget, string label) 116 { 117 this(label); 118 add(widget); 119 } 120 121 /** 122 */ 123 124 /** */ 125 public static GType getType() 126 { 127 return gtk_frame_get_type(); 128 } 129 130 /** 131 * Creates a new #GtkFrame, with optional label @label. 132 * If @label is %NULL, the label is omitted. 133 * 134 * Params: 135 * label = the text to use as the label of the frame 136 * 137 * Returns: a new #GtkFrame widget 138 * 139 * Throws: ConstructionException GTK+ fails to create the object. 140 */ 141 public this(string label) 142 { 143 auto p = gtk_frame_new(Str.toStringz(label)); 144 145 if(p is null) 146 { 147 throw new ConstructionException("null returned by new"); 148 } 149 150 this(cast(GtkFrame*) p); 151 } 152 153 /** 154 * If the frame’s label widget is a #GtkLabel, returns the 155 * text in the label widget. (The frame will have a #GtkLabel 156 * for the label widget if a non-%NULL argument was passed 157 * to gtk_frame_new().) 158 * 159 * Returns: the text in the label, or %NULL if there 160 * was no label widget or the lable widget was not 161 * a #GtkLabel. This string is owned by GTK+ and 162 * must not be modified or freed. 163 */ 164 public string getLabel() 165 { 166 return Str.toString(gtk_frame_get_label(gtkFrame)); 167 } 168 169 /** 170 * Retrieves the X and Y alignment of the frame’s label. See 171 * gtk_frame_set_label_align(). 172 * 173 * Params: 174 * xalign = location to store X alignment of 175 * frame’s label, or %NULL 176 * yalign = location to store X alignment of 177 * frame’s label, or %NULL 178 */ 179 public void getLabelAlign(out float xalign, out float yalign) 180 { 181 gtk_frame_get_label_align(gtkFrame, &xalign, &yalign); 182 } 183 184 /** 185 * Retrieves the label widget for the frame. See 186 * gtk_frame_set_label_widget(). 187 * 188 * Returns: the label widget, or %NULL if 189 * there is none. 190 */ 191 public Widget getLabelWidget() 192 { 193 auto p = gtk_frame_get_label_widget(gtkFrame); 194 195 if(p is null) 196 { 197 return null; 198 } 199 200 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 201 } 202 203 /** 204 * Retrieves the shadow type of the frame. See 205 * gtk_frame_set_shadow_type(). 206 * 207 * Returns: the current shadow type of the frame. 208 */ 209 public GtkShadowType getShadowType() 210 { 211 return gtk_frame_get_shadow_type(gtkFrame); 212 } 213 214 /** 215 * Removes the current #GtkFrame:label-widget. If @label is not %NULL, creates a 216 * new #GtkLabel with that text and adds it as the #GtkFrame:label-widget. 217 * 218 * Params: 219 * label = the text to use as the label of the frame 220 */ 221 public void setLabel(string label) 222 { 223 gtk_frame_set_label(gtkFrame, Str.toStringz(label)); 224 } 225 226 /** 227 * Sets the alignment of the frame widget’s label. The 228 * default values for a newly created frame are 0.0 and 0.5. 229 * 230 * Params: 231 * xalign = The position of the label along the top edge 232 * of the widget. A value of 0.0 represents left alignment; 233 * 1.0 represents right alignment. 234 * yalign = The y alignment of the label. A value of 0.0 aligns under 235 * the frame; 1.0 aligns above the frame. If the values are exactly 236 * 0.0 or 1.0 the gap in the frame won’t be painted because the label 237 * will be completely above or below the frame. 238 */ 239 public void setLabelAlign(float xalign, float yalign) 240 { 241 gtk_frame_set_label_align(gtkFrame, xalign, yalign); 242 } 243 244 /** 245 * Sets the #GtkFrame:label-widget for the frame. This is the widget that 246 * will appear embedded in the top edge of the frame as a title. 247 * 248 * Params: 249 * labelWidget = the new label widget 250 */ 251 public void setLabelWidget(Widget labelWidget) 252 { 253 gtk_frame_set_label_widget(gtkFrame, (labelWidget is null) ? null : labelWidget.getWidgetStruct()); 254 } 255 256 /** 257 * Sets the #GtkFrame:shadow-type for @frame, i.e. whether it is drawn without 258 * (GTK_SHADOW_NONE) or with (other values) a visible border. Values other than 259 * GTK_SHADOW_NONE are treated identically by #GtkFrame. The chosen type is 260 * applied by removing or adding the .flat class to the CSS node named border. 261 * 262 * Params: 263 * type = the new #GtkShadowType 264 */ 265 public void setShadowType(GtkShadowType type) 266 { 267 gtk_frame_set_shadow_type(gtkFrame, type); 268 } 269 }