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