alternative to assert
[gtkD.git] / gtkD / src / gtk / ScrolledWindow.d
blob361139d239d695413536c7fa66617536553690b0
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GtkScrolledWindow.html
26 * outPack = gtk
27 * outFile = ScrolledWindow
28 * strct = GtkScrolledWindow
29 * realStrct=
30 * ctorStrct=
31 * clss = ScrolledWindow
32 * interf =
33 * class Code: Yes
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gtk_scrolled_window_
40 * - gtk_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * - gtk_scrolled_window_new
45 * imports:
46 * - gtk.Widget
47 * - gtk.Adjustment
48 * structWrap:
49 * - GtkAdjustment* -> Adjustment
50 * - GtkWidget* -> Widget
51 * module aliases:
52 * local aliases:
55 module gtk.ScrolledWindow;
57 version(noAssert)
59 version(Tango)
61 import tango.io.Stdout; // use the tango loging?
65 private import gtkc.gtktypes;
67 private import gtkc.gtk;
70 private import gtk.Widget;
71 private import gtk.Adjustment;
76 /**
77 * Description
78 * GtkScrolledWindow is a GtkBin subclass: it's a container
79 * the accepts a single child widget. GtkScrolledWindow adds scrollbars
80 * to the child widget and optionally draws a beveled frame around the
81 * child widget.
82 * The scrolled window can work in two ways. Some widgets have native
83 * scrolling support; these widgets have "slots" for GtkAdjustment
84 * objects.
85 * [5]
86 * Widgets with native scroll support include GtkTreeView, GtkTextView,
87 * and GtkLayout.
88 * For widgets that lack native scrolling support, the GtkViewport
89 * widget acts as an adaptor class, implementing scrollability for child
90 * widgets that lack their own scrolling capabilities. Use GtkViewport
91 * to scroll child widgets such as GtkTable, GtkBox, and so on.
92 * If a widget has native scrolling abilities, it can be added to the
93 * GtkScrolledWindow with gtk_container_add(). If a widget does not, you
94 * must first add the widget to a GtkViewport, then add the GtkViewport
95 * to the scrolled window. The convenience function
96 * gtk_scrolled_window_add_with_viewport() does exactly this, so you can
97 * ignore the presence of the viewport.
98 * The position of the scrollbars is controlled by the scroll
99 * adjustments. See GtkAdjustment for the fields in an adjustment - for
100 * GtkScrollbar, used by GtkScrolledWindow, the "value" field
101 * represents the position of the scrollbar, which must be between the
102 * "lower" field and "upper - page_size." The "page_size" field
103 * represents the size of the visible scrollable area. The
104 * "step_increment" and "page_increment" fields are used when the user
105 * asks to step down (using the small stepper arrows) or page down (using
106 * for example the PageDown key).
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 GtkTable.
111 private import gtk.Bin;
112 public class ScrolledWindow : Bin
115 /** the main Gtk struct */
116 protected GtkScrolledWindow* gtkScrolledWindow;
119 public GtkScrolledWindow* getScrolledWindowStruct()
121 return gtkScrolledWindow;
125 /** the main Gtk struct as a void* */
126 protected void* getStruct()
128 return cast(void*)gtkScrolledWindow;
132 * Sets our main struct and passes it to the parent class
134 public this (GtkScrolledWindow* gtkScrolledWindow)
136 version(noAssert)
138 if ( gtkScrolledWindow is null )
140 int zero = 0;
141 version(Tango)
143 Stdout("struct gtkScrolledWindow is null on constructor").newline;
145 else
147 printf("struct gtkScrolledWindow is null on constructor");
149 zero = zero / zero;
152 else
154 assert(gtkScrolledWindow !is null, "struct gtkScrolledWindow is null on constructor");
156 super(cast(GtkBin*)gtkScrolledWindow);
157 this.gtkScrolledWindow = gtkScrolledWindow;
160 public this()
162 this(null, null);
165 public this(Widget widget)
167 this();
168 addWithViewport(widget);
172 * Creates a new scrolled window. The two arguments are the scrolled
173 * window's adjustments; these will be shared with the scrollbars and the
174 * child widget to keep the bars in sync with the child. Usually you want
175 * to pass NULL for the adjustments, which will cause the scrolled window
176 * to create them for you.
177 * hadjustment:
178 * Horizontal adjustment.
179 * vadjustment:
180 * Vertical adjustment.
181 * Returns:
182 * New scrolled window.
184 public this (Adjustment hadjustment, Adjustment vadjustment)
186 // GtkWidget* gtk_scrolled_window_new (GtkAdjustment *hadjustment, GtkAdjustment *vadjustment);
187 this(cast(GtkScrolledWindow*)gtk_scrolled_window_new(
188 hadjustment is null ? null : hadjustment.getAdjustmentStruct(),
189 vadjustment is null ? null : vadjustment.getAdjustmentStruct())
194 * Creates a new Scrolled window and set the policy type
195 * @param hPolicy the horizontal policy
196 * @param vPolicy the vertical policy
198 this(PolicyType hPolicy, PolicyType vPolicy)
200 this();
201 setPolicy(hPolicy, vPolicy);
207 // imports for the signal processing
208 private import gobject.Signals;
209 private import gtkc.gdktypes;
210 int[char[]] connectedSignals;
212 void delegate(GtkDirectionType, ScrolledWindow)[] onMoveFocusOutListeners;
213 void addOnMoveFocusOut(void delegate(GtkDirectionType, ScrolledWindow) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
215 if ( !("move-focus-out" in connectedSignals) )
217 Signals.connectData(
218 getStruct(),
219 "move-focus-out",
220 cast(GCallback)&callBackMoveFocusOut,
221 cast(void*)this,
222 null,
223 connectFlags);
224 connectedSignals["move-focus-out"] = 1;
226 onMoveFocusOutListeners ~= dlg;
228 extern(C) static void callBackMoveFocusOut(GtkScrolledWindow* scrolledwindowStruct, GtkDirectionType arg1, ScrolledWindow scrolledWindow)
230 bool consumed = false;
232 foreach ( void delegate(GtkDirectionType, ScrolledWindow) dlg ; scrolledWindow.onMoveFocusOutListeners )
234 dlg(arg1, scrolledWindow);
237 return consumed;
240 gboolean delegate(GtkScrollType, gboolean, ScrolledWindow)[] onScrollChildListeners;
241 void addOnScrollChild(gboolean delegate(GtkScrollType, gboolean, ScrolledWindow) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
243 if ( !("scroll-child" in connectedSignals) )
245 Signals.connectData(
246 getStruct(),
247 "scroll-child",
248 cast(GCallback)&callBackScrollChild,
249 cast(void*)this,
250 null,
251 connectFlags);
252 connectedSignals["scroll-child"] = 1;
254 onScrollChildListeners ~= dlg;
256 extern(C) static void callBackScrollChild(GtkScrolledWindow* scrolledwindowStruct, GtkScrollType arg1, gboolean arg2, ScrolledWindow scrolledWindow)
258 bool consumed = false;
260 foreach ( gboolean delegate(GtkScrollType, gboolean, ScrolledWindow) dlg ; scrolledWindow.onScrollChildListeners )
262 dlg(arg1, arg2, scrolledWindow);
265 return consumed;
272 * Returns the horizontal scrollbar's adjustment, used to connect the
273 * horizontal scrollbar to the child widget's horizontal scroll
274 * functionality.
275 * scrolled_window:
276 * A GtkScrolledWindow.
277 * Returns:
278 * The horizontal GtkAdjustment.
280 public Adjustment getHadjustment()
282 // GtkAdjustment* gtk_scrolled_window_get_hadjustment (GtkScrolledWindow *scrolled_window);
283 return new Adjustment( gtk_scrolled_window_get_hadjustment(gtkScrolledWindow) );
287 * Returns the vertical scrollbar's adjustment, used to connect the
288 * vertical scrollbar to the child widget's vertical scroll
289 * functionality.
290 * scrolled_window:
291 * A GtkScrolledWindow.
292 * Returns:
293 * The vertical GtkAdjustment.
295 public Adjustment getVadjustment()
297 // GtkAdjustment* gtk_scrolled_window_get_vadjustment (GtkScrolledWindow *scrolled_window);
298 return new Adjustment( gtk_scrolled_window_get_vadjustment(gtkScrolledWindow) );
302 * Returns the horizontal scrollbar of scrolled_window.
303 * scrolled_window:
304 * a GtkScrolledWindow
305 * Returns:
306 * the horizontal scrollbar of the scrolled window, or
307 * NULL if it does not have one.
308 * Since 2.8
310 public Widget getHscrollbar()
312 // GtkWidget* gtk_scrolled_window_get_hscrollbar (GtkScrolledWindow *scrolled_window);
313 return new Widget( gtk_scrolled_window_get_hscrollbar(gtkScrolledWindow) );
317 * Returns the vertical scrollbar of scrolled_window.
318 * scrolled_window:
319 * a GtkScrolledWindow
320 * Returns:
321 * the vertical scrollbar of the scrolled window, or
322 * NULL if it does not have one.
323 * Since 2.8
325 public Widget getVscrollbar()
327 // GtkWidget* gtk_scrolled_window_get_vscrollbar (GtkScrolledWindow *scrolled_window);
328 return new Widget( gtk_scrolled_window_get_vscrollbar(gtkScrolledWindow) );
332 * Sets the scrollbar policy for the horizontal and vertical scrollbars.
333 * The policy determines when the scrollbar should appear; it is a value
334 * from the GtkPolicyType enumeration. If GTK_POLICY_ALWAYS, the
335 * scrollbar is always present; if GTK_POLICY_NEVER, the scrollbar is
336 * never present; if GTK_POLICY_AUTOMATIC, the scrollbar is present only
337 * if needed (that is, if the slider part of the bar would be smaller
338 * than the trough - the display is larger than the page size).
339 * scrolled_window:
340 * A GtkScrolledWindow.
341 * hscrollbar_policy:
342 * Policy for horizontal bar.
343 * vscrollbar_policy:
344 * Policy for vertical bar.
346 public void setPolicy(GtkPolicyType hscrollbarPolicy, GtkPolicyType vscrollbarPolicy)
348 // void gtk_scrolled_window_set_policy (GtkScrolledWindow *scrolled_window, GtkPolicyType hscrollbar_policy, GtkPolicyType vscrollbar_policy);
349 gtk_scrolled_window_set_policy(gtkScrolledWindow, hscrollbarPolicy, vscrollbarPolicy);
353 * Used to add children without native scrolling capabilities. This is
354 * simply a convenience function; it is equivalent to adding the
355 * unscrollable child to a viewport, then adding the viewport to the
356 * scrolled window. If a child has native scrolling, use
357 * gtk_container_add() instead of this function.
358 * The viewport scrolls the child by moving its GdkWindow, and takes the
359 * size of the child to be the size of its toplevel GdkWindow. This will
360 * be very wrong for most widgets that support native scrolling; for
361 * example, if you add a widget such as GtkTreeView with a viewport, the
362 * whole widget will scroll, including the column headings. Thus, widgets
363 * with native scrolling support should not be used with the GtkViewport proxy.
364 * A widget supports scrolling natively if the
365 * set_scroll_adjustments_signal field in GtkWidgetClass is non-zero,
366 * i.e. has been filled in with a valid signal identifier.
367 * scrolled_window:
368 * A GtkScrolledWindow.
369 * child:
370 * Widget you want to scroll.
372 public void addWithViewport(Widget child)
374 // void gtk_scrolled_window_add_with_viewport (GtkScrolledWindow *scrolled_window, GtkWidget *child);
375 gtk_scrolled_window_add_with_viewport(gtkScrolledWindow, (child is null) ? null : child.getWidgetStruct());
379 * Sets the placement of the contents with respect to the scrollbars
380 * for the scrolled window.
381 * See also gtk_scrolled_window_get_placement() and
382 * gtk_scrolled_window_unset_placement().
383 * Determines the location of the child widget with respect to the
384 * scrollbars. The default is GTK_CORNER_TOP_LEFT, meaning the child is
385 * in the top left, with the scrollbars underneath and to the right.
386 * Other values in GtkCornerType are GTK_CORNER_TOP_RIGHT,
387 * GTK_CORNER_BOTTOM_LEFT, and GTK_CORNER_BOTTOM_RIGHT.
388 * scrolled_window:
389 * a GtkScrolledWindow
390 * window_placement:
391 * Position of the child window.
393 public void setPlacement(GtkCornerType windowPlacement)
395 // void gtk_scrolled_window_set_placement (GtkScrolledWindow *scrolled_window, GtkCornerType window_placement);
396 gtk_scrolled_window_set_placement(gtkScrolledWindow, windowPlacement);
400 * Unsets the placement of the contents with respect to the scrollbars
401 * for the scrolled window. If no window placement is set for a scrolled
402 * window, it obeys the "gtk-scrolled-window-placement" XSETTING.
403 * See also gtk_scrolled_window_set_placement() and
404 * gtk_scrolled_window_get_placement().
405 * scrolled_window:
406 * a GtkScrolledWindow
407 * Since 2.10
409 public void unsetPlacement()
411 // void gtk_scrolled_window_unset_placement (GtkScrolledWindow *scrolled_window);
412 gtk_scrolled_window_unset_placement(gtkScrolledWindow);
416 * Changes the type of shadow drawn around the contents of
417 * scrolled_window.
418 * scrolled_window:
419 * a GtkScrolledWindow
420 * type:
421 * kind of shadow to draw around scrolled window contents
423 public void setShadowType(GtkShadowType type)
425 // void gtk_scrolled_window_set_shadow_type (GtkScrolledWindow *scrolled_window, GtkShadowType type);
426 gtk_scrolled_window_set_shadow_type(gtkScrolledWindow, type);
430 * Sets the GtkAdjustment for the horizontal scrollbar.
431 * scrolled_window:
432 * A GtkScrolledWindow.
433 * hadjustment:
434 * Horizontal scroll adjustment.
436 public void setHadjustment(Adjustment hadjustment)
438 // void gtk_scrolled_window_set_hadjustment (GtkScrolledWindow *scrolled_window, GtkAdjustment *hadjustment);
439 gtk_scrolled_window_set_hadjustment(gtkScrolledWindow, (hadjustment is null) ? null : hadjustment.getAdjustmentStruct());
443 * Sets the GtkAdjustment for the vertical scrollbar.
444 * scrolled_window:
445 * A GtkScrolledWindow.
446 * vadjustment:
447 * Vertical scroll adjustment.
449 public void setVadjustment(Adjustment vadjustment)
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());
456 * Gets the placement of the contents with respect to the scrollbars
457 * for the scrolled window. See gtk_scrolled_window_set_placement().
458 * scrolled_window:
459 * a GtkScrolledWindow
460 * Returns:
461 * the current placement value.
462 * See also gtk_scrolled_window_set_placement() and
463 * gtk_scrolled_window_unset_placement().
465 public GtkCornerType getPlacement()
467 // GtkCornerType gtk_scrolled_window_get_placement (GtkScrolledWindow *scrolled_window);
468 return gtk_scrolled_window_get_placement(gtkScrolledWindow);
472 * Retrieves the current policy values for the horizontal and vertical
473 * scrollbars. See gtk_scrolled_window_set_policy().
474 * scrolled_window:
475 * a GtkScrolledWindow
476 * hscrollbar_policy:
477 * location to store the policy for the horizontal scrollbar, or NULL.
478 * vscrollbar_policy:
479 * location to store the policy for the horizontal scrollbar, or NULL.
481 public void getPolicy(GtkPolicyType* hscrollbarPolicy, GtkPolicyType* vscrollbarPolicy)
483 // void gtk_scrolled_window_get_policy (GtkScrolledWindow *scrolled_window, GtkPolicyType *hscrollbar_policy, GtkPolicyType *vscrollbar_policy);
484 gtk_scrolled_window_get_policy(gtkScrolledWindow, hscrollbarPolicy, vscrollbarPolicy);
488 * Gets the shadow type of the scrolled window. See
489 * gtk_scrolled_window_set_shadow_type().
490 * scrolled_window:
491 * a GtkScrolledWindow
492 * Returns:
493 * the current shadow type
494 * Property Details
495 * The "hadjustment" property
496 * "hadjustment" GtkAdjustment : Read / Write / Construct
497 * The GtkAdjustment for the horizontal position.
499 public GtkShadowType getShadowType()
501 // GtkShadowType gtk_scrolled_window_get_shadow_type (GtkScrolledWindow *scrolled_window);
502 return gtk_scrolled_window_get_shadow_type(gtkScrolledWindow);