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 	/**
98 	 * Sets our main struct and passes it to the parent class.
99 	 */
100 	public this (GtkFixed* gtkFixed, bool ownedRef = false)
101 	{
102 		this.gtkFixed = gtkFixed;
103 		super(cast(GtkContainer*)gtkFixed, ownedRef);
104 	}
105 
106 
107 	/** */
108 	public static GType getType()
109 	{
110 		return gtk_fixed_get_type();
111 	}
112 
113 	/**
114 	 * Creates a new #GtkFixed.
115 	 *
116 	 * Returns: a new #GtkFixed.
117 	 *
118 	 * Throws: ConstructionException GTK+ fails to create the object.
119 	 */
120 	public this()
121 	{
122 		auto p = gtk_fixed_new();
123 
124 		if(p is null)
125 		{
126 			throw new ConstructionException("null returned by new");
127 		}
128 
129 		this(cast(GtkFixed*) p);
130 	}
131 
132 	/**
133 	 * Moves a child of a #GtkFixed container to the given position.
134 	 *
135 	 * Params:
136 	 *     widget = the child widget.
137 	 *     x = the horizontal position to move the widget to.
138 	 *     y = the vertical position to move the widget to.
139 	 */
140 	public void move(Widget widget, int x, int y)
141 	{
142 		gtk_fixed_move(gtkFixed, (widget is null) ? null : widget.getWidgetStruct(), x, y);
143 	}
144 
145 	/**
146 	 * Adds a widget to a #GtkFixed container at the given position.
147 	 *
148 	 * Params:
149 	 *     widget = the widget to add.
150 	 *     x = the horizontal position to place the widget at.
151 	 *     y = the vertical position to place the widget at.
152 	 */
153 	public void put(Widget widget, int x, int y)
154 	{
155 		gtk_fixed_put(gtkFixed, (widget is null) ? null : widget.getWidgetStruct(), x, y);
156 	}
157 }