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  = 
27  * outPack = gtk
28  * outFile = Requisition
29  * strct   = GtkRequisition
30  * realStrct=
31  * ctorStrct=
32  * clss    = Requisition
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_requisition_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * 	- accel-closures-changed
46  * 	- button-press-event
47  * 	- button-release-event
48  * 	- can-activate-accel
49  * 	- child-notify
50  * 	- composited-changed
51  * 	- configure-event
52  * 	- damage-event
53  * 	- delete-event
54  * 	- destroy
55  * 	- destroy-event
56  * 	- direction-changed
57  * 	- drag-begin
58  * 	- drag-data-delete
59  * 	- drag-data-get
60  * 	- drag-data-received
61  * 	- drag-drop
62  * 	- drag-end
63  * 	- drag-failed
64  * 	- drag-leave
65  * 	- drag-motion
66  * 	- draw
67  * 	- enter-notify-event
68  * 	- event
69  * 	- event-after
70  * 	- focus
71  * 	- focus-in-event
72  * 	- focus-out-event
73  * 	- grab-broken-event
74  * 	- grab-focus
75  * 	- grab-notify
76  * 	- hide
77  * 	- hierarchy-changed
78  * 	- key-press-event
79  * 	- key-release-event
80  * 	- keynav-failed
81  * 	- leave-notify-event
82  * 	- map
83  * 	- map-event
84  * 	- mnemonic-activate
85  * 	- motion-notify-event
86  * 	- move-focus
87  * 	- parent-set
88  * 	- popup-menu
89  * 	- property-notify-event
90  * 	- proximity-in-event
91  * 	- proximity-out-event
92  * 	- query-tooltip
93  * 	- realize
94  * 	- screen-changed
95  * 	- scroll-event
96  * 	- selection-clear-event
97  * 	- selection-get
98  * 	- selection-notify-event
99  * 	- selection-received
100  * 	- selection-request-event
101  * 	- show
102  * 	- show-help
103  * 	- size-allocate
104  * 	- state-changed
105  * 	- state-flags-changed
106  * 	- style-set
107  * 	- style-updated
108  * 	- unmap
109  * 	- unmap-event
110  * 	- unrealize
111  * 	- visibility-notify-event
112  * 	- window-state-event
113  * 	- touch-event
114  * imports:
115  * 	- gtkc.Loader
116  * 	- gtkc.paths
117  * structWrap:
118  * 	- GtkRequisition* -> Requisition
119  * module aliases:
120  * local aliases:
121  * overrides:
122  */
123 
124 module gtk.Requisition;
125 
126 public  import gtkc.gtktypes;
127 
128 private import gtkc.gtk;
129 private import glib.ConstructionException;
130 private import gobject.ObjectG;
131 
132 private import gobject.Signals;
133 public  import gtkc.gdktypes;
134 
135 private import gtkc.Loader;
136 private import gtkc.paths;
137 
138 
139 
140 
141 /**
142  * GtkWidget is the base class all widgets in GTK+ derive from. It manages the
143  * widget lifecycle, states and style.
144  *
145  * Height-for-width Geometry Management
146  *
147  * GTK+ uses a height-for-width (and width-for-height) geometry management
148  * system. Height-for-width means that a widget can change how much
149  * vertical space it needs, depending on the amount of horizontal space
150  * that it is given (and similar for width-for-height). The most common
151  * example is a label that reflows to fill up the available width, wraps
152  * to fewer lines, and therefore needs less height.
153  *
154  * Height-for-width geometry management is implemented in GTK+ by way
155  * of five virtual methods:
156  *
157  * GtkWidgetClass.get_request_mode()
158  * GtkWidgetClass.get_preferred_width()
159  * GtkWidgetClass.get_preferred_height()
160  * GtkWidgetClass.get_preferred_height_for_width()
161  * GtkWidgetClass.get_preferred_width_for_height()
162  * GtkWidgetClass.get_preferred_height_and_baseline_for_width()
163  *
164  * There are some important things to keep in mind when implementing
165  * height-for-width and when using it in container implementations.
166  *
167  * The geometry management system will query a widget hierarchy in
168  * only one orientation at a time. When widgets are initially queried
169  * for their minimum sizes it is generally done in two initial passes
170  * in the GtkSizeRequestMode chosen by the toplevel.
171  *
172  * For example, when queried in the normal
173  * GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH mode:
174  * First, the default minimum and natural width for each widget
175  * in the interface will be computed using gtk_widget_get_preferred_width().
176  * Because the preferred widths for each container depend on the preferred
177  * widths of their children, this information propagates up the hierarchy,
178  * and finally a minimum and natural width is determined for the entire
179  * toplevel. Next, the toplevel will use the minimum width to query for the
180  * minimum height contextual to that width using
181  * gtk_widget_get_preferred_height_for_width(), which will also be a highly
182  * recursive operation. The minimum height for the minimum width is normally
183  * used to set the minimum size constraint on the toplevel
184  * (unless gtk_window_set_geometry_hints() is explicitly used instead).
185  *
186  * After the toplevel window has initially requested its size in both
187  * dimensions it can go on to allocate itself a reasonable size (or a size
188  * previously specified with gtk_window_set_default_size()). During the
189  * recursive allocation process it's important to note that request cycles
190  * will be recursively executed while container widgets allocate their children.
191  * Each container widget, once allocated a size, will go on to first share the
192  * space in one orientation among its children and then request each child's
193  * height for its target allocated width or its width for allocated height,
194  * depending. In this way a GtkWidget will typically be requested its size
195  * a number of times before actually being allocated a size. The size a
196  * widget is finally allocated can of course differ from the size it has
197  * requested. For this reason, GtkWidget caches a small number of results
198  * to avoid re-querying for the same sizes in one allocation cycle.
199  *
200  * See GtkContainer's
201  * geometry management section
202  * to learn more about how height-for-width allocations are performed
203  * by container widgets.
204  *
205  * If a widget does move content around to intelligently use up the
206  * allocated size then it must support the request in both
207  * GtkSizeRequestModes even if the widget in question only
208  * trades sizes in a single orientation.
209  *
210  * For instance, a GtkLabel that does height-for-width word wrapping
211  * will not expect to have GtkWidgetClass.get_preferred_height() called
212  * because that call is specific to a width-for-height request. In this
213  * case the label must return the height required for its own minimum
214  * possible width. By following this rule any widget that handles
215  * height-for-width or width-for-height requests will always be allocated
216  * at least enough space to fit its own content.
217  *
218  * Here are some examples of how a GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH widget
219  * generally deals with width-for-height requests, for GtkWidgetClass.get_preferred_height()
220  * it will do:
221  *
222  * static void
223  * foo_widget_get_preferred_height (GtkWidget *widget, gint *min_height, gint *nat_height)
224  * {
225 	 *  if (i_am_in_height_for_width_mode)
226 	 *  {
227 		 *  gint min_width;
228 		 *
229 		 *  GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, min_width, NULL);
230 		 *  GTK_WIDGET_GET_CLASS (widget)->get_preferred_height_for_width (widget, min_width,
231 		 *  min_height, nat_height);
232 	 *  }
233 	 *  else
234 	 *  {
235 		 *  ... some widgets do both. For instance, if a GtkLabel is rotated to 90 degrees
236 		 *  it will return the minimum and natural height for the rotated label here.
237 	 *  }
238  * }
239  *
240  * And in GtkWidgetClass.get_preferred_width_for_height() it will simply return
241  * the minimum and natural width:
242  *
243  * static void
244  * foo_widget_get_preferred_width_for_height (GtkWidget *widget, gint for_height,
245  *  gint *min_width, gint *nat_width)
246  * {
247 	 *  if (i_am_in_height_for_width_mode)
248 	 *  {
249 		 *  GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, min_width, nat_width);
250 	 *  }
251 	 *  else
252 	 *  {
253 		 *  ... again if a widget is sometimes operating in width-for-height mode
254 		 *  (like a rotated GtkLabel) it can go ahead and do its real width for
255 		 *  height calculation here.
256 	 *  }
257  * }
258  *
259  * Often a widget needs to get its own request during size request or
260  * allocation. For example, when computing height it may need to also
261  * compute width. Or when deciding how to use an allocation, the widget
262  * may need to know its natural size. In these cases, the widget should
263  * be careful to call its virtual methods directly, like this:
264  *
265  * $(DDOC_COMMENT example)
266  *
267  * It will not work to use the wrapper functions, such as
268  * gtk_widget_get_preferred_width() inside your own size request
269  * implementation. These return a request adjusted by GtkSizeGroup
270  * and by the GtkWidgetClass.adjust_size_request() virtual method. If a
271  * widget used the wrappers inside its virtual method implementations,
272  * then the adjustments (such as widget margins) would be applied
273  * twice. GTK+ therefore does not allow this and will warn if you try
274  * to do it.
275  *
276  * Of course if you are getting the size request for
277  * another widget, such as a child of a
278  * container, you must use the wrapper APIs.
279  * Otherwise, you would not properly consider widget margins,
280  * GtkSizeGroup, and so forth.
281  *
282  * Since 3.10 Gtk+ also supports baseline vertical alignment of widgets. This
283  * means that widgets are positioned such that the typographical baseline of
284  * widgets in the same row are aligned. This happens if a widget supports baselines,
285  * has a vertical alignment of GTK_ALIGN_BASELINE, and is inside a container
286  * that supports baselines and has a natural "row" that it aligns to the baseline,
287  * or a baseline assigned to it by the grandparent.
288  *
289  * Baseline alignment support for a widget is done by the GtkWidgetClass.get_preferred_height_and_baseline_for_width()
290  * virtual function. It allows you to report a baseline in combination with the
291  * minimum and natural height. If there is no baseline you can return -1 to indicate
292  * this. The default implementation of this virtual function calls into the
293  * GtkWidgetClass.get_preferred_height() and GtkWidgetClass.get_preferred_height_for_width(),
294  * so if baselines are not supported it doesn't need to be implemented.
295  *
296  * If a widget ends up baseline aligned it will be allocated all the space in the parent
297  * as if it was GTK_ALIGN_FILL, but the selected baseline can be found via gtk_widget_get_allocated_baseline().
298  * If this has a value other than -1 you need to align the widget such that the baseline
299  * appears at the position.
300  *
301  * <hr>
302  *
303  * Style Properties
304  *
305  * GtkWidget introduces style
306  * properties - these are basically object properties that are stored
307  * not on the object, but in the style object associated to the widget. Style
308  * properties are set in resource files.
309  * This mechanism is used for configuring such things as the location of the
310  * scrollbar arrows through the theme, giving theme authors more control over the
311  * look of applications without the need to write a theme engine in C.
312  *
313  * Use gtk_widget_class_install_style_property() to install style properties for
314  * a widget class, gtk_widget_class_find_style_property() or
315  * gtk_widget_class_list_style_properties() to get information about existing
316  * style properties and gtk_widget_style_get_property(), gtk_widget_style_get() or
317  * gtk_widget_style_get_valist() to obtain the value of a style property.
318  *
319  * <hr>
320  *
321  * GtkWidget as GtkBuildable
322  *
323  * The GtkWidget implementation of the GtkBuildable interface supports a
324  * custom &lt;accelerator&gt; element, which has attributes named key,
325  * modifiers and signal and allows to specify accelerators.
326  *
327  * $(DDOC_COMMENT example)
328  *
329  * In addition to accelerators, GtkWidget also support a
330  * custom &lt;accessible&gt; element, which supports actions and relations.
331  * Properties on the accessible implementation of an object can be set by accessing the
332  * internal child "accessible" of a GtkWidget.
333  *
334  * $(DDOC_COMMENT example)
335  *
336  * Finally, GtkWidget allows style information such as style classes to
337  * be associated with widgets, using the custom &lt;style&gt; element:
338  *
339  * $(DDOC_COMMENT example)
340  *
341  * <hr>
342  *
343  * Building composite widgets from template XML
344  *
345  * GtkWidget exposes some facilities to automate the proceedure
346  * of creating composite widgets using GtkBuilder interface description
347  * language.
348  *
349  * To create composite widgets with GtkBuilder XML, one must associate
350  * the interface description with the widget class at class initialization
351  * time using gtk_widget_class_set_template().
352  *
353  * The interface description semantics expected in composite template descriptions
354  * is slightly different from regulare GtkBuilder XML.
355  *
356  * Unlike regular interface descriptions, gtk_widget_class_set_template() will expect a
357  * &lt;template&gt; tag as a direct child of the toplevel &lt;interface&gt;
358  * tag. The &lt;template&gt; tag must specify the "class" attribute which
359  * must be the type name of the widget. Optionally, the "parent" attribute
360  * may be specified to specify the direct parent type of the widget type, this
361  * is ignored by the GtkBuilder but required for Glade to introspect what kind
362  * of properties and internal children exist for a given type when the actual
363  * type does not exist.
364  *
365  * The XML which is contained inside the &lt;template&gt; tag behaves as if
366  * it were added to the &lt;object&gt; tag defining widget itself. You may set
367  * properties on widget by inserting &lt;property&gt; tags into the &lt;template&gt;
368  * tag, and also add &lt;child&gt; tags to add children and extend widget in the
369  * normal way you would with &lt;object&gt; tags.
370  *
371  * Additionally, &lt;object&gt; tags can also be added before and
372  * after the initial &lt;template&gt; tag in the normal way, allowing
373  * one to define auxilary objects which might be referenced by other
374  * widgets declared as children of the &lt;template&gt; tag.
375  *
376  * $(DDOC_COMMENT example)
377  */
378 public class Requisition
379 {
380 	
381 	/** the main Gtk struct */
382 	protected GtkRequisition* gtkRequisition;
383 	
384 	
385 	public GtkRequisition* getRequisitionStruct()
386 	{
387 		return gtkRequisition;
388 	}
389 	
390 	
391 	/** the main Gtk struct as a void* */
392 	protected void* getStruct()
393 	{
394 		return cast(void*)gtkRequisition;
395 	}
396 	
397 	/**
398 	 * Sets our main struct and passes it to the parent class
399 	 */
400 	public this (GtkRequisition* gtkRequisition)
401 	{
402 		this.gtkRequisition = gtkRequisition;
403 	}
404 	
405 	~this ()
406 	{
407 		if (  Linker.isLoaded(LIBRARY.GTK) && gtkRequisition !is null )
408 		{
409 			gtk_requisition_free(gtkRequisition);
410 		}
411 	}
412 	
413 	/**
414 	 */
415 	
416 	/**
417 	 * Allocates a new GtkRequisition structure and initializes its elements to zero.
418 	 * Throws: ConstructionException GTK+ fails to create the object.
419 	 */
420 	public this ()
421 	{
422 		// GtkRequisition * gtk_requisition_new (void);
423 		auto p = gtk_requisition_new();
424 		if(p is null)
425 		{
426 			throw new ConstructionException("null returned by gtk_requisition_new()");
427 		}
428 		this(cast(GtkRequisition*) p);
429 	}
430 	
431 	/**
432 	 * Copies a GtkRequisition.
433 	 * Returns: a copy of requisition
434 	 */
435 	public Requisition copy()
436 	{
437 		// GtkRequisition * gtk_requisition_copy (const GtkRequisition *requisition);
438 		auto p = gtk_requisition_copy(gtkRequisition);
439 		
440 		if(p is null)
441 		{
442 			return null;
443 		}
444 		
445 		return ObjectG.getDObject!(Requisition)(cast(GtkRequisition*) p);
446 	}
447 	
448 	/**
449 	 * Frees a GtkRequisition.
450 	 */
451 	public void free()
452 	{
453 		// void gtk_requisition_free (GtkRequisition *requisition);
454 		gtk_requisition_free(gtkRequisition);
455 	}
456 }