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