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.Fixed; 26 27 private import glib.ConstructionException; 28 private import gobject.ObjectG; 29 private import gsk.Transform; 30 private import gtk.Widget; 31 private import gtk.c.functions; 32 public import gtk.c.types; 33 34 35 /** 36 * `GtkFixed` places its child widgets at fixed positions and with fixed sizes. 37 * 38 * `GtkFixed` performs no automatic layout management. 39 * 40 * For most applications, you should not use this container! It keeps 41 * you from having to learn about the other GTK containers, but it 42 * results in broken applications. With `GtkFixed`, the following 43 * things will result in truncated text, overlapping widgets, and 44 * other display bugs: 45 * 46 * - Themes, which may change widget sizes. 47 * 48 * - Fonts other than the one you used to write the app will of course 49 * change the size of widgets containing text; keep in mind that 50 * users may use a larger font because of difficulty reading the 51 * default, or they may be using a different OS that provides different fonts. 52 * 53 * - Translation of text into other languages changes its size. Also, 54 * display of non-English text will use a different font in many 55 * cases. 56 * 57 * In addition, `GtkFixed` does not pay attention to text direction and 58 * thus may produce unwanted results if your app is run under right-to-left 59 * languages such as Hebrew or Arabic. That is: normally GTK will order 60 * containers appropriately for the text direction, e.g. to put labels to 61 * the right of the thing they label when using an RTL language, but it can’t 62 * do that with `GtkFixed`. So if you need to reorder widgets depending on 63 * the text direction, you would need to manually detect it and adjust child 64 * positions accordingly. 65 * 66 * Finally, fixed positioning makes it kind of annoying to add/remove 67 * UI elements, since you have to reposition all the other elements. This 68 * is a long-term maintenance problem for your application. 69 * 70 * If you know none of these things are an issue for your application, 71 * and prefer the simplicity of `GtkFixed`, by all means use the 72 * widget. But you should be aware of the tradeoffs. 73 */ 74 public class Fixed : Widget 75 { 76 /** the main Gtk struct */ 77 protected GtkFixed* gtkFixed; 78 79 /** Get the main Gtk struct */ 80 public GtkFixed* getFixedStruct(bool transferOwnership = false) 81 { 82 if (transferOwnership) 83 ownedRef = false; 84 return gtkFixed; 85 } 86 87 /** the main Gtk struct as a void* */ 88 protected override void* getStruct() 89 { 90 return cast(void*)gtkFixed; 91 } 92 93 /** 94 * Sets our main struct and passes it to the parent class. 95 */ 96 public this (GtkFixed* gtkFixed, bool ownedRef = false) 97 { 98 this.gtkFixed = gtkFixed; 99 super(cast(GtkWidget*)gtkFixed, ownedRef); 100 } 101 102 103 /** */ 104 public static GType getType() 105 { 106 return gtk_fixed_get_type(); 107 } 108 109 /** 110 * Creates a new `GtkFixed`. 111 * 112 * Returns: a new `GtkFixed`. 113 * 114 * Throws: ConstructionException GTK+ fails to create the object. 115 */ 116 public this() 117 { 118 auto __p = gtk_fixed_new(); 119 120 if(__p is null) 121 { 122 throw new ConstructionException("null returned by new"); 123 } 124 125 this(cast(GtkFixed*) __p); 126 } 127 128 /** 129 * Retrieves the translation transformation of the 130 * given child `GtkWidget` in the `GtkFixed`. 131 * 132 * See also: [method@Gtk.Fixed.get_child_transform]. 133 * 134 * Params: 135 * widget = a child of @fixed 136 * x = the horizontal position of the @widget 137 * y = the vertical position of the @widget 138 */ 139 public void getChildPosition(Widget widget, out double x, out double y) 140 { 141 gtk_fixed_get_child_position(gtkFixed, (widget is null) ? null : widget.getWidgetStruct(), &x, &y); 142 } 143 144 /** 145 * Retrieves the transformation for @widget set using 146 * gtk_fixed_set_child_transform(). 147 * 148 * Params: 149 * widget = a `GtkWidget`, child of @fixed 150 * 151 * Returns: a `GskTransform` or %NULL 152 * in case no transform has been set on @widget 153 */ 154 public Transform getChildTransform(Widget widget) 155 { 156 auto __p = gtk_fixed_get_child_transform(gtkFixed, (widget is null) ? null : widget.getWidgetStruct()); 157 158 if(__p is null) 159 { 160 return null; 161 } 162 163 return ObjectG.getDObject!(Transform)(cast(GskTransform*) __p); 164 } 165 166 /** 167 * Sets a translation transformation to the given @x and @y 168 * coordinates to the child @widget of the `GtkFixed`. 169 * 170 * Params: 171 * widget = the child widget 172 * x = the horizontal position to move the widget to 173 * y = the vertical position to move the widget to 174 */ 175 public void move(Widget widget, double x, double y) 176 { 177 gtk_fixed_move(gtkFixed, (widget is null) ? null : widget.getWidgetStruct(), x, y); 178 } 179 180 /** 181 * Adds a widget to a `GtkFixed` at the given position. 182 * 183 * Params: 184 * widget = the widget to add 185 * x = the horizontal position to place the widget at 186 * y = the vertical position to place the widget at 187 */ 188 public void put(Widget widget, double x, double y) 189 { 190 gtk_fixed_put(gtkFixed, (widget is null) ? null : widget.getWidgetStruct(), x, y); 191 } 192 193 /** 194 * Removes a child from @fixed. 195 * 196 * Params: 197 * widget = the child widget to remove 198 */ 199 public void remove(Widget widget) 200 { 201 gtk_fixed_remove(gtkFixed, (widget is null) ? null : widget.getWidgetStruct()); 202 } 203 204 /** 205 * Sets the transformation for @widget. 206 * 207 * This is a convenience function that retrieves the 208 * [class@Gtk.FixedLayoutChild] instance associated to 209 * @widget and calls [method@Gtk.FixedLayoutChild.set_transform]. 210 * 211 * Params: 212 * widget = a `GtkWidget`, child of @fixed 213 * transform = the transformation assigned to @widget or %NULL 214 * to reset @widget's transform 215 */ 216 public void setChildTransform(Widget widget, Transform transform) 217 { 218 gtk_fixed_set_child_transform(gtkFixed, (widget is null) ? null : widget.getWidgetStruct(), (transform is null) ? null : transform.getTransformStruct()); 219 } 220 }