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