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 gtk.Container;
30 private import gtk.Widget;
31 private import gtk.c.functions;
32 public  import gtk.c.types;
33 public  import gtkc.gtktypes;
34 
35 
36 /**
37  * The #GtkFixed widget is a container which can place child widgets
38  * at fixed positions and with fixed sizes, given in pixels. #GtkFixed
39  * performs no automatic layout management.
40  * 
41  * For most applications, you should not use this container! It keeps
42  * you from having to learn about the other GTK+ containers, but it
43  * results in broken applications.  With #GtkFixed, the following
44  * things will result in truncated text, overlapping widgets, and
45  * other display bugs:
46  * 
47  * - Themes, which may change widget sizes.
48  * 
49  * - Fonts other than the one you used to write the app will of course
50  * change the size of widgets containing text; keep in mind that
51  * users may use a larger font because of difficulty reading the
52  * default, or they may be using a different OS that provides different fonts.
53  * 
54  * - Translation of text into other languages changes its size. Also,
55  * display of non-English text will use a different font in many
56  * cases.
57  * 
58  * In addition, #GtkFixed does not pay attention to text direction and thus may
59  * produce unwanted results if your app is run under right-to-left languages
60  * such as Hebrew or Arabic. That is: normally GTK+ will order containers
61  * appropriately for the text direction, e.g. to put labels to the right of the
62  * thing they label when using an RTL language, but it can’t do that with
63  * #GtkFixed. So if you need to reorder widgets depending on the text direction,
64  * you would need to manually detect it and adjust child positions accordingly.
65  * 
66  * Finally, fixed positioning makes it kind of annoying to add/remove
67  * GUI elements, since you have to reposition all the other
68  * elements. This is a long-term maintenance problem for your
69  * application.
70  * 
71  * If you know none of these things are an issue for your application,
72  * and prefer the simplicity of #GtkFixed, by all means use the
73  * widget. But you should be aware of the tradeoffs.
74  * 
75  * See also #GtkLayout, which shares the ability to perform fixed positioning
76  * of child widgets and additionally adds custom drawing and scrollability.
77  */
78 public class Fixed : Container
79 {
80 	/** the main Gtk struct */
81 	protected GtkFixed* gtkFixed;
82 
83 	/** Get the main Gtk struct */
84 	public GtkFixed* getFixedStruct(bool transferOwnership = false)
85 	{
86 		if (transferOwnership)
87 			ownedRef = false;
88 		return gtkFixed;
89 	}
90 
91 	/** the main Gtk struct as a void* */
92 	protected override void* getStruct()
93 	{
94 		return cast(void*)gtkFixed;
95 	}
96 
97 	protected override void setStruct(GObject* obj)
98 	{
99 		gtkFixed = cast(GtkFixed*)obj;
100 		super.setStruct(obj);
101 	}
102 
103 	/**
104 	 * Sets our main struct and passes it to the parent class.
105 	 */
106 	public this (GtkFixed* gtkFixed, bool ownedRef = false)
107 	{
108 		this.gtkFixed = gtkFixed;
109 		super(cast(GtkContainer*)gtkFixed, ownedRef);
110 	}
111 
112 
113 	/** */
114 	public static GType getType()
115 	{
116 		return gtk_fixed_get_type();
117 	}
118 
119 	/**
120 	 * Creates a new #GtkFixed.
121 	 *
122 	 * Returns: a new #GtkFixed.
123 	 *
124 	 * Throws: ConstructionException GTK+ fails to create the object.
125 	 */
126 	public this()
127 	{
128 		auto p = gtk_fixed_new();
129 
130 		if(p is null)
131 		{
132 			throw new ConstructionException("null returned by new");
133 		}
134 
135 		this(cast(GtkFixed*) p);
136 	}
137 
138 	/**
139 	 * Moves a child of a #GtkFixed container to the given position.
140 	 *
141 	 * Params:
142 	 *     widget = the child widget.
143 	 *     x = the horizontal position to move the widget to.
144 	 *     y = the vertical position to move the widget to.
145 	 */
146 	public void move(Widget widget, int x, int y)
147 	{
148 		gtk_fixed_move(gtkFixed, (widget is null) ? null : widget.getWidgetStruct(), x, y);
149 	}
150 
151 	/**
152 	 * Adds a widget to a #GtkFixed container at the given position.
153 	 *
154 	 * Params:
155 	 *     widget = the widget to add.
156 	 *     x = the horizontal position to place the widget at.
157 	 *     y = the vertical position to place the widget at.
158 	 */
159 	public void put(Widget widget, int x, int y)
160 	{
161 		gtk_fixed_put(gtkFixed, (widget is null) ? null : widget.getWidgetStruct(), x, y);
162 	}
163 }