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 = GtkScrolledWindow.html 27 * outPack = gtk 28 * outFile = ScrolledWindow 29 * strct = GtkScrolledWindow 30 * realStrct= 31 * ctorStrct= 32 * clss = ScrolledWindow 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_scrolled_window_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - gtk.Adjustment 47 * - gtk.Widget 48 * structWrap: 49 * - GtkAdjustment* -> Adjustment 50 * - GtkWidget* -> Widget 51 * module aliases: 52 * local aliases: 53 * overrides: 54 */ 55 56 module gtk.ScrolledWindow; 57 58 public import gtkc.gtktypes; 59 60 private import gtkc.gtk; 61 private import glib.ConstructionException; 62 private import gobject.ObjectG; 63 64 private import gobject.Signals; 65 public import gtkc.gdktypes; 66 67 private import gtk.Adjustment; 68 private import gtk.Widget; 69 70 71 72 private import gtk.Bin; 73 74 /** 75 * GtkScrolledWindow is a GtkBin subclass: it's a container 76 * the accepts a single child widget. GtkScrolledWindow adds scrollbars 77 * to the child widget and optionally draws a beveled frame around the 78 * child widget. 79 * 80 * The scrolled window can work in two ways. Some widgets have native 81 * scrolling support; these widgets implement the GtkScrollable interface. 82 * Widgets with native scroll support include GtkTreeView, GtkTextView, 83 * and GtkLayout. 84 * 85 * For widgets that lack native scrolling support, the GtkViewport 86 * widget acts as an adaptor class, implementing scrollability for child 87 * widgets that lack their own scrolling capabilities. Use GtkViewport 88 * to scroll child widgets such as GtkGrid, GtkBox, and so on. 89 * 90 * If a widget has native scrolling abilities, it can be added to the 91 * GtkScrolledWindow with gtk_container_add(). If a widget does not, you 92 * must first add the widget to a GtkViewport, then add the GtkViewport 93 * to the scrolled window. gtk_container_add() will do this for you for 94 * widgets that don't implement GtkScrollable natively, so you can 95 * ignore the presence of the viewport. 96 * 97 * The position of the scrollbars is controlled by the scroll 98 * adjustments. See GtkAdjustment for the fields in an adjustment - for 99 * GtkScrollbar, used by GtkScrolledWindow, the "value" field 100 * represents the position of the scrollbar, which must be between the 101 * "lower" field and "upper - page_size." The "page_size" field 102 * represents the size of the visible scrollable area. The 103 * "step_increment" and "page_increment" fields are used when the user 104 * asks to step down (using the small stepper arrows) or page down (using 105 * for example the PageDown key). 106 * 107 * If a GtkScrolledWindow doesn't behave quite as you would like, or 108 * doesn't have exactly the right layout, it's very possible to set up 109 * your own scrolling with GtkScrollbar and for example a GtkGrid. 110 */ 111 public class ScrolledWindow : Bin 112 { 113 114 /** the main Gtk struct */ 115 protected GtkScrolledWindow* gtkScrolledWindow; 116 117 118 public GtkScrolledWindow* getScrolledWindowStruct() 119 { 120 return gtkScrolledWindow; 121 } 122 123 124 /** the main Gtk struct as a void* */ 125 protected override void* getStruct() 126 { 127 return cast(void*)gtkScrolledWindow; 128 } 129 130 /** 131 * Sets our main struct and passes it to the parent class 132 */ 133 public this (GtkScrolledWindow* gtkScrolledWindow) 134 { 135 super(cast(GtkBin*)gtkScrolledWindow); 136 this.gtkScrolledWindow = gtkScrolledWindow; 137 } 138 139 protected override void setStruct(GObject* obj) 140 { 141 super.setStruct(obj); 142 gtkScrolledWindow = cast(GtkScrolledWindow*)obj; 143 } 144 145 /** */ 146 public this() 147 { 148 this(null, null); 149 } 150 151 /** */ 152 public this(Widget widget) 153 { 154 this(); 155 add(widget); 156 } 157 158 /** 159 * Creates a new Scrolled window and set the policy type 160 * Params: 161 * hPolicy = the horizontal policy 162 * vPolicy = the vertical policy 163 */ 164 this(PolicyType hPolicy, PolicyType vPolicy) 165 { 166 this(); 167 setPolicy(hPolicy, vPolicy); 168 } 169 170 /** 171 */ 172 int[string] connectedSignals; 173 174 void delegate(GtkDirectionType, ScrolledWindow)[] onMoveFocusOutListeners; 175 /** 176 * The ::move-focus-out signal is a 177 * keybinding signal 178 * which gets emitted when focus is moved away from the scrolled 179 * window by a keybinding. 180 * The "move-focus" signal is emitted with direction_type 181 * on this scrolled windows toplevel parent in the container hierarchy. 182 * The default bindings for this signal are 183 * Tab+Ctrl 184 * and 185 * Tab+Ctrl+Shift. 186 */ 187 void addOnMoveFocusOut(void delegate(GtkDirectionType, ScrolledWindow) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 188 { 189 if ( !("move-focus-out" in connectedSignals) ) 190 { 191 Signals.connectData( 192 getStruct(), 193 "move-focus-out", 194 cast(GCallback)&callBackMoveFocusOut, 195 cast(void*)this, 196 null, 197 connectFlags); 198 connectedSignals["move-focus-out"] = 1; 199 } 200 onMoveFocusOutListeners ~= dlg; 201 } 202 extern(C) static void callBackMoveFocusOut(GtkScrolledWindow* scrolledWindowStruct, GtkDirectionType directionType, ScrolledWindow _scrolledWindow) 203 { 204 foreach ( void delegate(GtkDirectionType, ScrolledWindow) dlg ; _scrolledWindow.onMoveFocusOutListeners ) 205 { 206 dlg(directionType, _scrolledWindow); 207 } 208 } 209 210 bool delegate(GtkScrollType, gboolean, ScrolledWindow)[] onScrollChildListeners; 211 /** 212 * The ::scroll-child signal is a 213 * keybinding signal 214 * which gets emitted when a keybinding that scrolls is pressed. 215 * The horizontal or vertical adjustment is updated which triggers a 216 * signal that the scrolled windows child may listen to and scroll itself. 217 * See Also 218 * GtkScrollable, GtkViewport, GtkAdjustment 219 */ 220 void addOnScrollChild(bool delegate(GtkScrollType, gboolean, ScrolledWindow) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 221 { 222 if ( !("scroll-child" in connectedSignals) ) 223 { 224 Signals.connectData( 225 getStruct(), 226 "scroll-child", 227 cast(GCallback)&callBackScrollChild, 228 cast(void*)this, 229 null, 230 connectFlags); 231 connectedSignals["scroll-child"] = 1; 232 } 233 onScrollChildListeners ~= dlg; 234 } 235 extern(C) static gboolean callBackScrollChild(GtkScrolledWindow* scrolledWindowStruct, GtkScrollType scroll, gboolean horizontal, ScrolledWindow _scrolledWindow) 236 { 237 foreach ( bool delegate(GtkScrollType, gboolean, ScrolledWindow) dlg ; _scrolledWindow.onScrollChildListeners ) 238 { 239 if ( dlg(scroll, horizontal, _scrolledWindow) ) 240 { 241 return 1; 242 } 243 } 244 245 return 0; 246 } 247 248 249 /** 250 * Creates a new scrolled window. 251 * The two arguments are the scrolled window's adjustments; these will be 252 * shared with the scrollbars and the child widget to keep the bars in sync 253 * with the child. Usually you want to pass NULL for the adjustments, which 254 * will cause the scrolled window to create them for you. 255 * Params: 256 * hadjustment = horizontal adjustment. [allow-none] 257 * vadjustment = vertical adjustment. [allow-none] 258 * Throws: ConstructionException GTK+ fails to create the object. 259 */ 260 public this (Adjustment hadjustment, Adjustment vadjustment) 261 { 262 // GtkWidget * gtk_scrolled_window_new (GtkAdjustment *hadjustment, GtkAdjustment *vadjustment); 263 auto p = gtk_scrolled_window_new((hadjustment is null) ? null : hadjustment.getAdjustmentStruct(), (vadjustment is null) ? null : vadjustment.getAdjustmentStruct()); 264 if(p is null) 265 { 266 throw new ConstructionException("null returned by gtk_scrolled_window_new((hadjustment is null) ? null : hadjustment.getAdjustmentStruct(), (vadjustment is null) ? null : vadjustment.getAdjustmentStruct())"); 267 } 268 this(cast(GtkScrolledWindow*) p); 269 } 270 271 /** 272 * Returns the horizontal scrollbar's adjustment, used to connect the 273 * horizontal scrollbar to the child widget's horizontal scroll 274 * functionality. 275 * Returns: the horizontal GtkAdjustment. [transfer none] 276 */ 277 public Adjustment getHadjustment() 278 { 279 // GtkAdjustment * gtk_scrolled_window_get_hadjustment (GtkScrolledWindow *scrolled_window); 280 auto p = gtk_scrolled_window_get_hadjustment(gtkScrolledWindow); 281 282 if(p is null) 283 { 284 return null; 285 } 286 287 return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p); 288 } 289 290 /** 291 * Returns the vertical scrollbar's adjustment, used to connect the 292 * vertical scrollbar to the child widget's vertical scroll functionality. 293 * Returns: the vertical GtkAdjustment. [transfer none] 294 */ 295 public Adjustment getVadjustment() 296 { 297 // GtkAdjustment * gtk_scrolled_window_get_vadjustment (GtkScrolledWindow *scrolled_window); 298 auto p = gtk_scrolled_window_get_vadjustment(gtkScrolledWindow); 299 300 if(p is null) 301 { 302 return null; 303 } 304 305 return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p); 306 } 307 308 /** 309 * Returns the horizontal scrollbar of scrolled_window. 310 * Since 2.8 311 * Returns: the horizontal scrollbar of the scrolled window, or NULL if it does not have one. [transfer none] 312 */ 313 public Widget getHscrollbar() 314 { 315 // GtkWidget * gtk_scrolled_window_get_hscrollbar (GtkScrolledWindow *scrolled_window); 316 auto p = gtk_scrolled_window_get_hscrollbar(gtkScrolledWindow); 317 318 if(p is null) 319 { 320 return null; 321 } 322 323 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 324 } 325 326 /** 327 * Returns the vertical scrollbar of scrolled_window. 328 * Since 2.8 329 * Returns: the vertical scrollbar of the scrolled window, or NULL if it does not have one. [transfer none] 330 */ 331 public Widget getVscrollbar() 332 { 333 // GtkWidget * gtk_scrolled_window_get_vscrollbar (GtkScrolledWindow *scrolled_window); 334 auto p = gtk_scrolled_window_get_vscrollbar(gtkScrolledWindow); 335 336 if(p is null) 337 { 338 return null; 339 } 340 341 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 342 } 343 344 /** 345 * Sets the scrollbar policy for the horizontal and vertical scrollbars. 346 * The policy determines when the scrollbar should appear; it is a value 347 * from the GtkPolicyType enumeration. If GTK_POLICY_ALWAYS, the 348 * scrollbar is always present; if GTK_POLICY_NEVER, the scrollbar is 349 * never present; if GTK_POLICY_AUTOMATIC, the scrollbar is present only 350 * if needed (that is, if the slider part of the bar would be smaller 351 * than the trough - the display is larger than the page size). 352 * Params: 353 * hscrollbarPolicy = policy for horizontal bar 354 * vscrollbarPolicy = policy for vertical bar 355 */ 356 public void setPolicy(GtkPolicyType hscrollbarPolicy, GtkPolicyType vscrollbarPolicy) 357 { 358 // void gtk_scrolled_window_set_policy (GtkScrolledWindow *scrolled_window, GtkPolicyType hscrollbar_policy, GtkPolicyType vscrollbar_policy); 359 gtk_scrolled_window_set_policy(gtkScrolledWindow, hscrollbarPolicy, vscrollbarPolicy); 360 } 361 362 /** 363 * Warning 364 * gtk_scrolled_window_add_with_viewport has been deprecated since version 3.8 and should not be used in newly-written code. gtk_container_add() will now automatically add 365 * a GtkViewport if the child doesn't implement GtkScrollable. 366 * Used to add children without native scrolling capabilities. This 367 * is simply a convenience function; it is equivalent to adding the 368 * unscrollable child to a viewport, then adding the viewport to the 369 * scrolled window. If a child has native scrolling, use 370 * gtk_container_add() instead of this function. 371 * The viewport scrolls the child by moving its GdkWindow, and takes 372 * the size of the child to be the size of its toplevel GdkWindow. 373 * This will be very wrong for most widgets that support native scrolling; 374 * for example, if you add a widget such as GtkTreeView with a viewport, 375 * the whole widget will scroll, including the column headings. Thus, 376 * widgets with native scrolling support should not be used with the 377 * GtkViewport proxy. 378 * A widget supports scrolling natively if it implements the 379 * GtkScrollable interface. 380 * Params: 381 * child = the widget you want to scroll 382 */ 383 public void addWithViewport(Widget child) 384 { 385 // void gtk_scrolled_window_add_with_viewport (GtkScrolledWindow *scrolled_window, GtkWidget *child); 386 gtk_scrolled_window_add_with_viewport(gtkScrolledWindow, (child is null) ? null : child.getWidgetStruct()); 387 } 388 389 /** 390 * Sets the placement of the contents with respect to the scrollbars 391 * for the scrolled window. 392 * The default is GTK_CORNER_TOP_LEFT, meaning the child is 393 * in the top left, with the scrollbars underneath and to the right. 394 * Other values in GtkCornerType are GTK_CORNER_TOP_RIGHT, 395 * GTK_CORNER_BOTTOM_LEFT, and GTK_CORNER_BOTTOM_RIGHT. 396 * See also gtk_scrolled_window_get_placement() and 397 * gtk_scrolled_window_unset_placement(). 398 * Params: 399 * windowPlacement = position of the child window 400 */ 401 public void setPlacement(GtkCornerType windowPlacement) 402 { 403 // void gtk_scrolled_window_set_placement (GtkScrolledWindow *scrolled_window, GtkCornerType window_placement); 404 gtk_scrolled_window_set_placement(gtkScrolledWindow, windowPlacement); 405 } 406 407 /** 408 * Unsets the placement of the contents with respect to the scrollbars 409 * for the scrolled window. If no window placement is set for a scrolled 410 * window, it defaults to GTK_CORNER_TOP_LEFT. 411 * See also gtk_scrolled_window_set_placement() and 412 * gtk_scrolled_window_get_placement(). 413 * Since 2.10 414 */ 415 public void unsetPlacement() 416 { 417 // void gtk_scrolled_window_unset_placement (GtkScrolledWindow *scrolled_window); 418 gtk_scrolled_window_unset_placement(gtkScrolledWindow); 419 } 420 421 /** 422 * Changes the type of shadow drawn around the contents of 423 * scrolled_window. 424 * Params: 425 * type = kind of shadow to draw around scrolled window contents 426 */ 427 public void setShadowType(GtkShadowType type) 428 { 429 // void gtk_scrolled_window_set_shadow_type (GtkScrolledWindow *scrolled_window, GtkShadowType type); 430 gtk_scrolled_window_set_shadow_type(gtkScrolledWindow, type); 431 } 432 433 /** 434 * Sets the GtkAdjustment for the horizontal scrollbar. 435 * Params: 436 * hadjustment = horizontal scroll adjustment 437 */ 438 public void setHadjustment(Adjustment hadjustment) 439 { 440 // void gtk_scrolled_window_set_hadjustment (GtkScrolledWindow *scrolled_window, GtkAdjustment *hadjustment); 441 gtk_scrolled_window_set_hadjustment(gtkScrolledWindow, (hadjustment is null) ? null : hadjustment.getAdjustmentStruct()); 442 } 443 444 /** 445 * Sets the GtkAdjustment for the vertical scrollbar. 446 * Params: 447 * vadjustment = vertical scroll adjustment 448 */ 449 public void setVadjustment(Adjustment vadjustment) 450 { 451 // void gtk_scrolled_window_set_vadjustment (GtkScrolledWindow *scrolled_window, GtkAdjustment *vadjustment); 452 gtk_scrolled_window_set_vadjustment(gtkScrolledWindow, (vadjustment is null) ? null : vadjustment.getAdjustmentStruct()); 453 } 454 455 /** 456 * Gets the placement of the contents with respect to the scrollbars 457 * for the scrolled window. See gtk_scrolled_window_set_placement(). 458 * Returns: the current placement value. See also gtk_scrolled_window_set_placement() and gtk_scrolled_window_unset_placement(). 459 */ 460 public GtkCornerType getPlacement() 461 { 462 // GtkCornerType gtk_scrolled_window_get_placement (GtkScrolledWindow *scrolled_window); 463 return gtk_scrolled_window_get_placement(gtkScrolledWindow); 464 } 465 466 /** 467 * Retrieves the current policy values for the horizontal and vertical 468 * scrollbars. See gtk_scrolled_window_set_policy(). 469 * Params: 470 * hscrollbarPolicy = location to store the policy 471 * for the horizontal scrollbar, or NULL. [out][allow-none] 472 * vscrollbarPolicy = location to store the policy 473 * for the vertical scrollbar, or NULL. [out][allow-none] 474 */ 475 public void getPolicy(out GtkPolicyType hscrollbarPolicy, out GtkPolicyType vscrollbarPolicy) 476 { 477 // void gtk_scrolled_window_get_policy (GtkScrolledWindow *scrolled_window, GtkPolicyType *hscrollbar_policy, GtkPolicyType *vscrollbar_policy); 478 gtk_scrolled_window_get_policy(gtkScrolledWindow, &hscrollbarPolicy, &vscrollbarPolicy); 479 } 480 481 /** 482 * Gets the shadow type of the scrolled window. See 483 * gtk_scrolled_window_set_shadow_type(). 484 * Returns: the current shadow type 485 */ 486 public GtkShadowType getShadowType() 487 { 488 // GtkShadowType gtk_scrolled_window_get_shadow_type (GtkScrolledWindow *scrolled_window); 489 return gtk_scrolled_window_get_shadow_type(gtkScrolledWindow); 490 } 491 492 /** 493 * Gets the minimum content width of scrolled_window, or -1 if not set. 494 * Returns: the minimum content width Since 3.0 495 */ 496 public int getMinContentWidth() 497 { 498 // gint gtk_scrolled_window_get_min_content_width (GtkScrolledWindow *scrolled_window); 499 return gtk_scrolled_window_get_min_content_width(gtkScrolledWindow); 500 } 501 502 /** 503 * Sets the minimum width that scrolled_window should keep visible. 504 * Note that this can and (usually will) be smaller than the minimum 505 * size of the content. 506 * Params: 507 * width = the minimal content width 508 * Since 3.0 509 */ 510 public void setMinContentWidth(int width) 511 { 512 // void gtk_scrolled_window_set_min_content_width (GtkScrolledWindow *scrolled_window, gint width); 513 gtk_scrolled_window_set_min_content_width(gtkScrolledWindow, width); 514 } 515 516 /** 517 * Gets the minimal content height of scrolled_window, or -1 if not set. 518 * Returns: the minimal content height Since 3.0 519 */ 520 public int getMinContentHeight() 521 { 522 // gint gtk_scrolled_window_get_min_content_height (GtkScrolledWindow *scrolled_window); 523 return gtk_scrolled_window_get_min_content_height(gtkScrolledWindow); 524 } 525 526 /** 527 * Sets the minimum height that scrolled_window should keep visible. 528 * Note that this can and (usually will) be smaller than the minimum 529 * size of the content. 530 * Params: 531 * height = the minimal content height 532 * Since 3.0 533 */ 534 public void setMinContentHeight(int height) 535 { 536 // void gtk_scrolled_window_set_min_content_height (GtkScrolledWindow *scrolled_window, gint height); 537 gtk_scrolled_window_set_min_content_height(gtkScrolledWindow, height); 538 } 539 540 /** 541 * Turns kinetic scrolling on or off. 542 * Kinetic scrolling only applies to devices with source 543 * GDK_SOURCE_TOUCHSCREEN. 544 * Params: 545 * kineticScrolling = TRUE to enable kinetic scrolling 546 * Since 3.4 547 */ 548 public void setKineticScrolling(int kineticScrolling) 549 { 550 // void gtk_scrolled_window_set_kinetic_scrolling (GtkScrolledWindow *scrolled_window, gboolean kinetic_scrolling); 551 gtk_scrolled_window_set_kinetic_scrolling(gtkScrolledWindow, kineticScrolling); 552 } 553 554 /** 555 * Returns the specified kinetic scrolling behavior. 556 * Returns: the scrolling behavior flags. Since 3.4 557 */ 558 public int getKineticScrolling() 559 { 560 // gboolean gtk_scrolled_window_get_kinetic_scrolling (GtkScrolledWindow *scrolled_window); 561 return gtk_scrolled_window_get_kinetic_scrolling(gtkScrolledWindow); 562 } 563 564 /** 565 * Changes the behaviour of scrolled_window wrt. to the initial 566 * event that possibly starts kinetic scrolling. When capture_button_press 567 * is set to TRUE, the event is captured by the scrolled window, and 568 * then later replayed if it is meant to go to the child widget. 569 * This should be enabled if any child widgets perform non-reversible 570 * actions on "button-press-event". If they don't, and handle 571 * additionally handle "grab-broken-event", it might be better 572 * to set capture_button_press to FALSE. 573 * This setting only has an effect if kinetic scrolling is enabled. 574 * Params: 575 * captureButtonPress = TRUE to capture button presses 576 * Since 3.4 577 */ 578 public void setCaptureButtonPress(int captureButtonPress) 579 { 580 // void gtk_scrolled_window_set_capture_button_press (GtkScrolledWindow *scrolled_window, gboolean capture_button_press); 581 gtk_scrolled_window_set_capture_button_press(gtkScrolledWindow, captureButtonPress); 582 } 583 584 /** 585 * Return whether button presses are captured during kinetic 586 * scrolling. See gtk_scrolled_window_set_capture_button_press(). 587 * Returns: TRUE if button presses are captured during kinetic scrolling Since 3.4 588 */ 589 public int getCaptureButtonPress() 590 { 591 // gboolean gtk_scrolled_window_get_capture_button_press (GtkScrolledWindow *scrolled_window); 592 return gtk_scrolled_window_get_capture_button_press(gtkScrolledWindow); 593 } 594 }