| Top |
| CtkAdjustment * | hadjustment | Read / Write / Construct |
| CtkPolicyType | hscrollbar-policy | Read / Write |
| gboolean | kinetic-scrolling | Read / Write |
| int | max-content-height | Read / Write |
| int | max-content-width | Read / Write |
| int | min-content-height | Read / Write |
| int | min-content-width | Read / Write |
| gboolean | overlay-scrolling | Read / Write |
| gboolean | propagate-natural-height | Read / Write |
| gboolean | propagate-natural-width | Read / Write |
| CtkShadowType | shadow-type | Read / Write |
| CtkAdjustment * | vadjustment | Read / Write / Construct |
| CtkPolicyType | vscrollbar-policy | Read / Write |
| CtkCornerType | window-placement | Read / Write |
| gboolean | window-placement-set | Read / Write |
| void | edge-overshot | Run Last |
| void | edge-reached | Run Last |
| void | move-focus-out | Action |
| gboolean | scroll-child | Action |
| struct | CtkScrolledWindow |
| struct | CtkScrolledWindowClass |
| enum | CtkPolicyType |
| enum | CtkCornerType |
GObject
╰── GInitiallyUnowned
╰── CtkWidget
╰── CtkContainer
╰── CtkBin
╰── CtkScrolledWindow
╰── CtkPlacesSidebar
CtkScrolledWindow is a container that accepts a single child widget, makes that child scrollable using either internally added scrollbars or externally associated adjustments, and optionally draws a frame around the child.
Widgets with native scrolling support, i.e. those whose classes implement the
CtkScrollable interface, are added directly. For other types of widget, the
class CtkViewport acts as an adaptor, giving scrollability to other widgets.
CtkScrolledWindow’s implementation of ctk_container_add() intelligently
accounts for whether or not the added child is a CtkScrollable. If it isn’t,
CtkScrolledWindow wraps the child in a CtkViewport and adds that for you.
Therefore, you can just add any child widget and not worry about the details.
If ctk_container_add() has added a CtkViewport for you, you can remove
both your added child widget from the CtkViewport, and the CtkViewport
from the CtkScrolledWindow, like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
CtkWidget *scrolled_window = ctk_scrolled_window_new (NULL, NULL); CtkWidget *child_widget = ctk_button_new (); // CtkButton is not a CtkScrollable, so CtkScrolledWindow will automatically // add a CtkViewport. ctk_container_add (CTK_CONTAINER (scrolled_window), child_widget); // Either of these will result in child_widget being unparented: ctk_container_remove (CTK_CONTAINER (scrolled_window), child_widget); // or ctk_container_remove (CTK_CONTAINER (scrolled_window), ctk_bin_get_child (CTK_BIN (scrolled_window))); |
Unless “policy” is CTK_POLICY_NEVER or CTK_POLICY_EXTERNAL, CtkScrolledWindow adds internal CtkScrollbar widgets around its child. The scroll position of the child, and if applicable the scrollbars, is controlled by the “hadjustment” and “vadjustment” that are associated with the CtkScrolledWindow. See the docs on CtkScrollbar for the details, but note that the “step_increment” and “page_increment” fields are only effective if the policy causes scrollbars to be present.
If a CtkScrolledWindow doesn’t behave quite as you would like, or doesn’t have exactly the right layout, it’s very possible to set up your own scrolling with CtkScrollbar and for example a CtkGrid.
CtkScrolledWindow has built-in support for touch devices. When a touchscreen is used, swiping will move the scrolled window, and will expose 'kinetic' behavior. This can be turned off with the “kinetic-scrolling” property if it is undesired.
CtkScrolledWindow also displays visual 'overshoot' indication when the content is pulled beyond the end, and this situation can be captured with the “edge-overshot” signal.
If no mouse device is present, the scrollbars will overlayed as narrow, auto-hiding indicators over the content. If traditional scrollbars are desired although no mouse is present, this behaviour can be turned off with the “overlay-scrolling” property.
CtkScrolledWindow has a main CSS node with name scrolledwindow.
It uses subnodes with names overshoot and undershoot to draw the overflow and underflow indications. These nodes get the .left, .right, .top or .bottom style class added depending on where the indication is drawn.
CtkScrolledWindow also sets the positional style classes (.left, .right, .top, .bottom) and style classes related to overlay scrolling (.overlay-indicator, .dragging, .hovering) on its scrollbars.
If both scrollbars are visible, the area where they meet is drawn with a subnode named junction.
CtkWidget * ctk_scrolled_window_new (CtkAdjustment *hadjustment,CtkAdjustment *vadjustment);
Creates a new scrolled window.
The two arguments are the scrolled window’s adjustments; these will be
shared with the scrollbars and the child widget to keep the bars in sync
with the child. Usually you want to pass NULL for the adjustments, which
will cause the scrolled window to create them for you.
CtkAdjustment *
ctk_scrolled_window_get_hadjustment (CtkScrolledWindow *scrolled_window);
Returns the horizontal scrollbar’s adjustment, used to connect the horizontal scrollbar to the child widget’s horizontal scroll functionality.
void ctk_scrolled_window_set_hadjustment (CtkScrolledWindow *scrolled_window,CtkAdjustment *hadjustment);
Sets the CtkAdjustment for the horizontal scrollbar.
scrolled_window |
||
hadjustment |
the CtkAdjustment to use, or |
[nullable] |
CtkAdjustment *
ctk_scrolled_window_get_vadjustment (CtkScrolledWindow *scrolled_window);
Returns the vertical scrollbar’s adjustment, used to connect the vertical scrollbar to the child widget’s vertical scroll functionality.
void ctk_scrolled_window_set_vadjustment (CtkScrolledWindow *scrolled_window,CtkAdjustment *vadjustment);
Sets the CtkAdjustment for the vertical scrollbar.
scrolled_window |
||
vadjustment |
the CtkAdjustment to use, or |
[nullable] |
CtkWidget *
ctk_scrolled_window_get_hscrollbar (CtkScrolledWindow *scrolled_window);
Returns the horizontal scrollbar of scrolled_window
.
Since: 2.8
CtkWidget *
ctk_scrolled_window_get_vscrollbar (CtkScrolledWindow *scrolled_window);
Returns the vertical scrollbar of scrolled_window
.
Since: 2.8
void ctk_scrolled_window_get_policy (CtkScrolledWindow *scrolled_window,CtkPolicyType *hscrollbar_policy,CtkPolicyType *vscrollbar_policy);
Retrieves the current policy values for the horizontal and vertical
scrollbars. See ctk_scrolled_window_set_policy().
void ctk_scrolled_window_set_policy (CtkScrolledWindow *scrolled_window,CtkPolicyType hscrollbar_policy,CtkPolicyType vscrollbar_policy);
Sets the scrollbar policy for the horizontal and vertical scrollbars.
The policy determines when the scrollbar should appear; it is a value
from the CtkPolicyType enumeration. If CTK_POLICY_ALWAYS, the
scrollbar is always present; if CTK_POLICY_NEVER, the scrollbar is
never present; if CTK_POLICY_AUTOMATIC, the scrollbar is present only
if needed (that is, if the slider part of the bar would be smaller
than the trough — the display is larger than the page size).
void ctk_scrolled_window_add_with_viewport (CtkScrolledWindow *scrolled_window,CtkWidget *child);
Used to add children without native scrolling capabilities. This
is simply a convenience function; it is equivalent to adding the
unscrollable child to a viewport, then adding the viewport to the
scrolled window. If a child has native scrolling, use
ctk_container_add() instead of this function.
The viewport scrolls the child by moving its CdkWindow, and takes the size of the child to be the size of its toplevel CdkWindow. This will be very wrong for most widgets that support native scrolling; for example, if you add a widget such as CtkTreeView with a viewport, the whole widget will scroll, including the column headings. Thus, widgets with native scrolling support should not be used with the CtkViewport proxy.
A widget supports scrolling natively if it implements the CtkScrollable interface.
CtkCornerType
ctk_scrolled_window_get_placement (CtkScrolledWindow *scrolled_window);
Gets the placement of the contents with respect to the scrollbars
for the scrolled window. See ctk_scrolled_window_set_placement().
the current placement value.
See also ctk_scrolled_window_set_placement() and
ctk_scrolled_window_unset_placement().
void ctk_scrolled_window_set_placement (CtkScrolledWindow *scrolled_window,CtkCornerType window_placement);
Sets the placement of the contents with respect to the scrollbars for the scrolled window.
The default is CTK_CORNER_TOP_LEFT, meaning the child is
in the top left, with the scrollbars underneath and to the right.
Other values in CtkCornerType are CTK_CORNER_TOP_RIGHT,
CTK_CORNER_BOTTOM_LEFT, and CTK_CORNER_BOTTOM_RIGHT.
See also ctk_scrolled_window_get_placement() and
ctk_scrolled_window_unset_placement().
void
ctk_scrolled_window_unset_placement (CtkScrolledWindow *scrolled_window);
Unsets the placement of the contents with respect to the scrollbars
for the scrolled window. If no window placement is set for a scrolled
window, it defaults to CTK_CORNER_TOP_LEFT.
See also ctk_scrolled_window_set_placement() and
ctk_scrolled_window_get_placement().
Since: 2.10
CtkShadowType
ctk_scrolled_window_get_shadow_type (CtkScrolledWindow *scrolled_window);
Gets the shadow type of the scrolled window. See
ctk_scrolled_window_set_shadow_type().
void ctk_scrolled_window_set_shadow_type (CtkScrolledWindow *scrolled_window,CtkShadowType type);
Changes the type of shadow drawn around the contents of
scrolled_window
.
gboolean
ctk_scrolled_window_get_kinetic_scrolling
(CtkScrolledWindow *scrolled_window);
Returns the specified kinetic scrolling behavior.
Since: 3.4
void ctk_scrolled_window_set_kinetic_scrolling (CtkScrolledWindow *scrolled_window,gboolean kinetic_scrolling);
Turns kinetic scrolling on or off.
Kinetic scrolling only applies to devices with source
CDK_SOURCE_TOUCHSCREEN.
Since: 3.4
gboolean
ctk_scrolled_window_get_capture_button_press
(CtkScrolledWindow *scrolled_window);
Return whether button presses are captured during kinetic
scrolling. See ctk_scrolled_window_set_capture_button_press().
Since: 3.4
void ctk_scrolled_window_set_capture_button_press (CtkScrolledWindow *scrolled_window,gboolean capture_button_press);
Changes the behaviour of scrolled_window
with regard to the initial
event that possibly starts kinetic scrolling. When capture_button_press
is set to TRUE, the event is captured by the scrolled window, and
then later replayed if it is meant to go to the child widget.
This should be enabled if any child widgets perform non-reversible
actions on “button-press-event”. If they don't, and handle
additionally handle “grab-broken-event”, it might be better
to set capture_button_press
to FALSE.
This setting only has an effect if kinetic scrolling is enabled.
Since: 3.4
gboolean
ctk_scrolled_window_get_overlay_scrolling
(CtkScrolledWindow *scrolled_window);
Returns whether overlay scrolling is enabled for this scrolled window.
Since: 3.16
void ctk_scrolled_window_set_overlay_scrolling (CtkScrolledWindow *scrolled_window,gboolean overlay_scrolling);
Enables or disables overlay scrolling for this scrolled window.
Since: 3.16
gint
ctk_scrolled_window_get_min_content_width
(CtkScrolledWindow *scrolled_window);
Gets the minimum content width of scrolled_window
, or -1 if not set.
Since: 3.0
void ctk_scrolled_window_set_min_content_width (CtkScrolledWindow *scrolled_window,gint width);
Sets the minimum width that scrolled_window
should keep visible.
Note that this can and (usually will) be smaller than the minimum
size of the content.
It is a programming error to set the minimum content width to a value greater than “max-content-width”.
Since: 3.0
gint
ctk_scrolled_window_get_min_content_height
(CtkScrolledWindow *scrolled_window);
Gets the minimal content height of scrolled_window
, or -1 if not set.
Since: 3.0
void ctk_scrolled_window_set_min_content_height (CtkScrolledWindow *scrolled_window,gint height);
Sets the minimum height that scrolled_window
should keep visible.
Note that this can and (usually will) be smaller than the minimum
size of the content.
It is a programming error to set the minimum content height to a value greater than “max-content-height”.
Since: 3.0
gint
ctk_scrolled_window_get_max_content_width
(CtkScrolledWindow *scrolled_window);
Returns the maximum content width set.
Since: 3.22
void ctk_scrolled_window_set_max_content_width (CtkScrolledWindow *scrolled_window,gint width);
Sets the maximum width that scrolled_window
should keep visible. The
scrolled_window
will grow up to this width before it starts scrolling
the content.
It is a programming error to set the maximum content width to a value smaller than “min-content-width”.
Since: 3.22
gint
ctk_scrolled_window_get_max_content_height
(CtkScrolledWindow *scrolled_window);
Returns the maximum content height set.
Since: 3.22
void ctk_scrolled_window_set_max_content_height (CtkScrolledWindow *scrolled_window,gint height);
Sets the maximum height that scrolled_window
should keep visible. The
scrolled_window
will grow up to this height before it starts scrolling
the content.
It is a programming error to set the maximum content height to a value smaller than “min-content-height”.
Since: 3.22
gboolean
ctk_scrolled_window_get_propagate_natural_width
(CtkScrolledWindow *scrolled_window);
Reports whether the natural width of the child will be calculated and propagated through the scrolled window’s requested natural width.
Since: 3.22
void ctk_scrolled_window_set_propagate_natural_width (CtkScrolledWindow *scrolled_window,gboolean propagate);
Sets whether the natural width of the child should be calculated and propagated through the scrolled window’s requested natural width.
Since: 3.22
gboolean
ctk_scrolled_window_get_propagate_natural_height
(CtkScrolledWindow *scrolled_window);
Reports whether the natural height of the child will be calculated and propagated through the scrolled window’s requested natural height.
Since: 3.22
void ctk_scrolled_window_set_propagate_natural_height (CtkScrolledWindow *scrolled_window,gboolean propagate);
Sets whether the natural height of the child should be calculated and propagated through the scrolled window’s requested natural height.
Since: 3.22
struct CtkScrolledWindowClass {
CtkBinClass parent_class;
gint scrollbar_spacing;
/* Action signals for keybindings. Do not connect to these signals
*/
/* Unfortunately, CtkScrollType is deficient in that there is
* no horizontal/vertical variants for CTK_SCROLL_START/END,
* so we have to add an additional boolean flag.
*/
gboolean (*scroll_child) (CtkScrolledWindow *scrolled_window,
CtkScrollType scroll,
gboolean horizontal);
void (* move_focus_out) (CtkScrolledWindow *scrolled_window,
CtkDirectionType direction);
};
Determines how the size should be computed to achieve the one of the visibility mode for the scrollbars.
|
The scrollbar is always visible. The view size is independent of the content. |
||
|
The scrollbar will appear and disappear as necessary. For example, when all of a CtkTreeView can not be seen. |
||
|
The scrollbar should never appear. In this mode the content determines the size. |
||
|
Don't show a scrollbar, but don't force the size to follow the content. This can be used e.g. to make multiple scrolled windows share a scrollbar. Since: 3.16 |
Specifies which corner a child widget should be placed in when packed into a CtkScrolledWindow. This is effectively the opposite of where the scroll bars are placed.
“hadjustment” property“hadjustment” CtkAdjustment *
The CtkAdjustment for the horizontal position.
Owner: CtkScrolledWindow
Flags: Read / Write / Construct
“hscrollbar-policy” property“hscrollbar-policy” CtkPolicyType
When the horizontal scrollbar is displayed.
Owner: CtkScrolledWindow
Flags: Read / Write
Default value: CTK_POLICY_AUTOMATIC
“kinetic-scrolling” property “kinetic-scrolling” gboolean
Whether kinetic scrolling is enabled or not. Kinetic scrolling
only applies to devices with source CDK_SOURCE_TOUCHSCREEN.
Owner: CtkScrolledWindow
Flags: Read / Write
Default value: TRUE
Since: 3.4
“max-content-height” property “max-content-height” int
The maximum content height of scrolled_window
, or -1 if not set.
Owner: CtkScrolledWindow
Flags: Read / Write
Allowed values: >= -1
Default value: -1
Since: 3.22
“max-content-width” property “max-content-width” int
The maximum content width of scrolled_window
, or -1 if not set.
Owner: CtkScrolledWindow
Flags: Read / Write
Allowed values: >= -1
Default value: -1
Since: 3.22
“min-content-height” property “min-content-height” int
The minimum content height of scrolled_window
, or -1 if not set.
Owner: CtkScrolledWindow
Flags: Read / Write
Allowed values: >= -1
Default value: -1
Since: 3.0
“min-content-width” property “min-content-width” int
The minimum content width of scrolled_window
, or -1 if not set.
Owner: CtkScrolledWindow
Flags: Read / Write
Allowed values: >= -1
Default value: -1
Since: 3.0
“overlay-scrolling” property “overlay-scrolling” gboolean
Whether overlay scrolling is enabled or not. If it is, the scrollbars are only added as traditional widgets when a mouse is present. Otherwise, they are overlayed on top of the content, as narrow indicators.
Note that overlay scrolling can also be globally disabled, with the “ctk-overlay-scrolling” setting.
Owner: CtkScrolledWindow
Flags: Read / Write
Default value: TRUE
Since: 3.16
“propagate-natural-height” property “propagate-natural-height” gboolean
Whether the natural height of the child should be calculated and propagated through the scrolled window’s requested natural height.
This is useful in cases where an attempt should be made to allocate exactly enough space for the natural size of the child.
Owner: CtkScrolledWindow
Flags: Read / Write
Default value: FALSE
Since: 3.22
“propagate-natural-width” property “propagate-natural-width” gboolean
Whether the natural width of the child should be calculated and propagated through the scrolled window’s requested natural width.
This is useful in cases where an attempt should be made to allocate exactly enough space for the natural size of the child.
Owner: CtkScrolledWindow
Flags: Read / Write
Default value: FALSE
Since: 3.22
“shadow-type” property“shadow-type” CtkShadowType
Style of bevel around the contents.
Owner: CtkScrolledWindow
Flags: Read / Write
Default value: CTK_SHADOW_NONE
“vadjustment” property“vadjustment” CtkAdjustment *
The CtkAdjustment for the vertical position.
Owner: CtkScrolledWindow
Flags: Read / Write / Construct
“vscrollbar-policy” property“vscrollbar-policy” CtkPolicyType
When the vertical scrollbar is displayed.
Owner: CtkScrolledWindow
Flags: Read / Write
Default value: CTK_POLICY_AUTOMATIC
“window-placement” property“window-placement” CtkCornerType
Where the contents are located with respect to the scrollbars.
Owner: CtkScrolledWindow
Flags: Read / Write
Default value: CTK_CORNER_TOP_LEFT
“window-placement-set” property “window-placement-set” gboolean
Whether "window-placement" should be used to determine the location of the contents with respect to the scrollbars.
CtkScrolledWindow:window-placement-set has been deprecated since version 3.10 and should not be used in newly-written code.
This value is ignored and “window-placement” value is always honored.
Owner: CtkScrolledWindow
Flags: Read / Write
Default value: TRUE
Since: 2.10
“edge-overshot” signalvoid user_function (CtkScrolledWindow *scrolled_window, CtkPositionType pos, gpointer user_data)
The ::edge-overshot signal is emitted whenever user initiated scrolling makes the scrolled window firmly surpass (i.e. with some edge resistance) the lower or upper limits defined by the adjustment in that orientation.
A similar behavior without edge resistance is provided by the “edge-reached” signal.
Note: The pos
argument is LTR/RTL aware, so callers should be aware too
if intending to provide behavior on horizontal edges.
scrolled_window |
||
pos |
edge side that was hit |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
Since: 3.16
“edge-reached” signalvoid user_function (CtkScrolledWindow *scrolled_window, CtkPositionType pos, gpointer user_data)
The ::edge-reached signal is emitted whenever user-initiated scrolling makes the scrolled window exactly reach the lower or upper limits defined by the adjustment in that orientation.
A similar behavior with edge resistance is provided by the “edge-overshot” signal.
Note: The pos
argument is LTR/RTL aware, so callers should be aware too
if intending to provide behavior on horizontal edges.
scrolled_window |
||
pos |
edge side that was reached |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
Since: 3.16
“move-focus-out” signalvoid user_function (CtkScrolledWindow *scrolled_window, CtkDirectionType direction_type, gpointer user_data)
The ::move-focus-out signal is a
keybinding signal which gets
emitted when focus is moved away from the scrolled window by a
keybinding. The “move-focus” signal is emitted with
direction_type
on this scrolled window’s toplevel parent in the
container hierarchy. The default bindings for this signal are
Ctrl + Tab to move forward and Ctrl + Shift + Tab to move backward.
scrolled_window |
||
direction_type |
either |
|
user_data |
user data set when the signal handler was connected. |
Flags: Action
“scroll-child” signalgboolean user_function (CtkScrolledWindow *scrolled_window, CtkScrollType scroll, gboolean horizontal, gpointer user_data)
The ::scroll-child signal is a keybinding signal which gets emitted when a keybinding that scrolls is pressed. The horizontal or vertical adjustment is updated which triggers a signal that the scrolled window’s child may listen to and scroll itself.
scrolled_window |
||
scroll |
a CtkScrollType describing how much to scroll |
|
horizontal |
whether the keybinding scrolls the child horizontally or not |
|
user_data |
user data set when the signal handler was connected. |
Flags: Action