Class WrapBox
- All Implemented Interfaces:
Accessible,Buildable,ConstraintTarget,Orientable,Proxy
AdwWrapBox is similar to Box, but can wrap lines when the
widgets cannot fit otherwise. Unlike FlowBox, the children aren't
arranged into a grid and behave more like words in a wrapping label.
Like GtkBox, AdwWrapBox is orientable and has spacing:
WrapBox:child-spacingbetween children in the same line;WrapBox:line-spacingbetween lines.
Note
Unlike GtkBox, AdwWrapBox cannot follow the CSS border-spacing
property.
Use the [property@WrapBox:natural-line-length] property to determine the
layout's natural size, e.g. when using it in a [class@Gtk.Popover].
Normally, a horizontal AdwWrapBox wraps left to right and top to bottom
for left-to-right languages. Both of these directions can be reversed, using
the [property@WrapBox:pack-direction] and [property@WrapBox:wrap-reverse]
properties. Additionally, the alignment of each line can be controlled with
the [property@WrapBox:align] property.
Lines can be justified using the [property@WrapBox:justify] property, filling
the entire line by either increasing child size or spacing depending on the
value. Set [property@WrapBox:justify-last-line] to justify the last line as
well.
By default, AdwWrapBox wraps as soon as the previous line cannot fit any
more children without shrinking them past their natural size. Set
[property@WrapBox:wrap-policy] to [enum@Adw.WrapPolicy.MINIMUM] to only wrap
once all the children in the previous line have been shrunk to their minimum
size.
To make each line take the same amount of space, set
[property@WrapBox:line-homogeneous] to TRUE.
Spacing and natural line length can scale with the text scale factor, use the
[property@WrapBox:child-spacing-unit], [property@WrapBox:line-spacing-unit]
and/or [property@WrapBox:natural-line-length-unit] properties to enable that
behavior.
See [class@WrapLayout].
## CSS nodes
AdwWrapBox uses a single CSS node with name wrap-box.
## Accessibility
AdwWrapBox uses the GTK_ACCESSIBLE_ROLE_GROUP role.
- Since:
- 1.7
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classWrapBox.Builder<B extends WrapBox.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classNested classes/interfaces inherited from class org.gnome.gtk.Widget
Widget.DestroyCallback, Widget.DirectionChangedCallback, Widget.HideCallback, Widget.KeynavFailedCallback, Widget.MapCallback, Widget.MnemonicActivateCallback, Widget.MoveFocusCallback, Widget.QueryTooltipCallback, Widget.RealizeCallback, Widget.ShowCallback, Widget.StateFlagsChangedCallback, Widget.UnmapCallback, Widget.UnrealizeCallback, Widget.Widget$Impl, Widget.WidgetClassNested classes/interfaces inherited from class org.gnome.gobject.InitiallyUnowned
InitiallyUnowned.InitiallyUnownedClassNested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClassNested classes/interfaces inherited from interface org.gnome.gtk.Accessible
Accessible.Accessible$Impl, Accessible.AccessibleInterfaceNested classes/interfaces inherited from interface org.gnome.gtk.Buildable
Buildable.Buildable$Impl, Buildable.BuildableIfaceNested classes/interfaces inherited from interface org.gnome.gtk.ConstraintTarget
ConstraintTarget.ConstraintTarget$Impl, ConstraintTarget.ConstraintTargetInterfaceNested classes/interfaces inherited from interface org.gnome.gtk.Orientable
Orientable.Orientable$Impl, Orientable.OrientableIface -
Constructor Summary
ConstructorsConstructorDescriptionWrapBox()Creates a new WrapBox.WrapBox(MemorySegment address) Create a WrapBox proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoidAddschildas the last child toself.protected WrapBoxasParent()Returns this instance as if it were its parent type.static WrapBox.Builder<? extends WrapBox.Builder> builder()AWrapBox.Builderobject constructs aWrapBoxwith the specified properties.floatgetAlign()Gets the alignment of the children within each line.intGets spacing between widgets on the same line.Gets the length unit for child spacing.Gets whether and how each complete line is stretched to fill the entire widget.booleanGets whether the last line should be stretched to fill the entire widget.booleanGets whether all lines should take the same amount of space.intGets the spacing between lines.Gets the length unit for line spacing.intGets the natural size for each line.Gets the length unit for line spacing.Gets the direction children are packed in each line.static @Nullable TypegetType()Get the GType of the WrapBox classGets the policy for line wrapping.booleanGets whether wrap direction is reversed.voidinsertChildAfter(Widget child, @Nullable Widget sibling) Insertschildin the position aftersiblingin the list of this WrapBox children.voidAddschildas the first child toself.voidRemoves a child widget fromself.voidRemoves all children fromself.voidreorderChildAfter(Widget child, @Nullable Widget sibling) Moveschildto the position aftersiblingin the list of this WrapBox children.voidsetAlign(float align) Sets the alignment of the children within each line.voidsetChildSpacing(int childSpacing) Sets the spacing between widgets on the same line.voidSets the length unit for child spacing.voidsetJustify(JustifyMode justify) Determines whether and how each complete line should be stretched to fill the entire widget.voidsetJustifyLastLine(boolean justifyLastLine) Sets whether the last line should be stretched to fill the entire widget.voidsetLineHomogeneous(boolean homogeneous) Sets whether all lines should take the same amount of space.voidsetLineSpacing(int lineSpacing) Sets the spacing between lines.voidsetLineSpacingUnit(LengthUnit unit) Sets the length unit for line spacing.voidsetNaturalLineLength(int naturalLineLength) Sets the natural size for each line.voidSets the length unit for natural line length.voidsetPackDirection(PackDirection packDirection) Sets the direction children are packed in each line.voidsetWrapPolicy(WrapPolicy wrapPolicy) Sets the policy for line wrapping.voidsetWrapReverse(boolean wrapReverse) Sets whether wrap direction should be reversed.Methods inherited from class org.gnome.gtk.Widget
actionSetEnabled, activateActionIfExists, activateDefault, activateWidget, addController, addCssClass, addMnemonicLabel, addTickCallback, allocate, childFocus, computeBounds, computeExpand, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, cssChanged, directionChanged, disposeTemplate, dragCheckThreshold, emitDestroy, emitDirectionChanged, emitHide, emitKeynavFailed, emitMap, emitMnemonicActivate, emitMoveFocus, emitQueryTooltip, emitRealize, emitShow, emitStateFlagsChanged, emitUnmap, emitUnrealize, errorBell, focus, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getBaseline, getCanFocus, getCanTarget, getChildVisible, getClipboard, getColor, getCssClasses, getCssName, getCursor, getDefaultDirection, getDirection, getDisplay, getFirstChild, getFocusable, getFocusChild, getFocusOnClick, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getLastChild, getLayoutManager, getLimitEvents, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getMemoryLayout, getName, getNative, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPreferredSize, getPrevSibling, getPrimaryClipboard, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth, grabFocus, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, moveFocus, observeChildren, observeControllers, onDestroy, onDirectionChanged, onHide, onKeynavFailed, onMap, onMnemonicActivate, onMoveFocus, onQueryTooltip, onRealize, onShow, onStateFlagsChanged, onUnmap, onUnrealize, pick, pick, queryTooltip, queueAllocate, queueDraw, queueResize, realize, removeController, removeCssClass, removeMnemonicLabel, removeTickCallback, root, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setDefaultDirection, setDirection, setFocusable, setFocusChild, setFocusOnClick, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setLimitEvents, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setOpacity, setOverflow, setParent, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setStateFlags, setTooltipMarkup, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible, shouldLayout, show, sizeAllocate, sizeAllocate, snapshot, snapshotChild, stateFlagsChanged, systemSettingChanged, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unroot, unsetStateFlags, unsetStateFlagsMethods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCodeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.gnome.gtk.Accessible
announce, getAccessibleParent, getAccessibleRole, getAtContext, getBounds, getFirstAccessibleChild, getNextAccessibleSibling, getPlatformState, resetProperty, resetRelation, resetState, setAccessibleParent, updateNextAccessibleSibling, updatePlatformState, updateProperty, updateRelation, updateStateMethods inherited from interface org.gnome.gtk.Buildable
getBuildableIdMethods inherited from interface org.gnome.gtk.Orientable
getOrientation, setOrientation
-
Constructor Details
-
WrapBox
Create a WrapBox proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
WrapBox
public WrapBox()Creates a new WrapBox.
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName(). This will call the native function pointer of this virtual method in the typeclass of the parent type. -
append
Addschildas the last child toself.- Parameters:
child- the widget to append- Since:
- 1.7
-
getAlign
public float getAlign()Gets the alignment of the children within each line.- Returns:
- the child alignment
- Since:
- 1.7
-
getChildSpacing
public int getChildSpacing()Gets spacing between widgets on the same line.- Returns:
- spacing between widgets on the same line
- Since:
- 1.7
-
getChildSpacingUnit
Gets the length unit for child spacing.- Returns:
- the length unit
- Since:
- 1.7
-
getJustify
Gets whether and how each complete line is stretched to fill the entire widget.- Returns:
- the justify mode
- Since:
- 1.7
-
getJustifyLastLine
public boolean getJustifyLastLine()Gets whether the last line should be stretched to fill the entire widget.- Returns:
- whether the last line is justified
- Since:
- 1.7
-
getLineHomogeneous
public boolean getLineHomogeneous()Gets whether all lines should take the same amount of space.- Returns:
- whether lines should be homogeneous
- Since:
- 1.7
-
getLineSpacing
public int getLineSpacing()Gets the spacing between lines.See
WrapBox:line-spacing-unit.- Returns:
- the line spacing
- Since:
- 1.7
-
getLineSpacingUnit
Gets the length unit for line spacing.- Returns:
- the length unit
- Since:
- 1.7
-
getNaturalLineLength
public int getNaturalLineLength()Gets the natural size for each line.- Returns:
- the natural length
- Since:
- 1.7
-
getNaturalLineLengthUnit
Gets the length unit for line spacing.- Returns:
- the length unit
- Since:
- 1.7
-
getPackDirection
Gets the direction children are packed in each line.- Returns:
- the line direction
- Since:
- 1.7
-
getWrapPolicy
Gets the policy for line wrapping.- Returns:
- the wrap policy
- Since:
- 1.7
-
getWrapReverse
public boolean getWrapReverse()Gets whether wrap direction is reversed.- Returns:
- whether wrap direction is reversed
- Since:
- 1.7
-
insertChildAfter
Insertschildin the position aftersiblingin the list of this WrapBox children.If
siblingisNULL, insertschildat the first position.- Parameters:
child- the widget to insertsibling- the sibling after which to insertchild- Since:
- 1.7
-
prepend
Addschildas the first child toself.- Parameters:
child- the widget to prepend- Since:
- 1.7
-
remove
Removes a child widget fromself.The child must have been added before with
append(org.gnome.gtk.Widget),prepend(org.gnome.gtk.Widget), orinsertChildAfter(org.gnome.gtk.Widget, org.gnome.gtk.Widget).- Parameters:
child- the child to remove- Since:
- 1.7
-
removeAll
public void removeAll()Removes all children fromself.- Since:
- 1.8
-
reorderChildAfter
Moveschildto the position aftersiblingin the list of this WrapBox children.If
siblingisNULL, moveschildto the first position.- Parameters:
child- the widget to move, must be a child of this WrapBoxsibling- the sibling to movechildafter- Since:
- 1.7
-
setAlign
public void setAlign(float align) Sets the alignment of the children within each line.0 means the children are placed at the start of the line, 1 means they are placed at the end of the line. 0.5 means they are placed in the middle of the line.
Alignment is only used when
WrapBox:justifyis set toADW_JUSTIFY_NONE, or on the last line when theWrapBox:justify-last-lineisFALSE.- Parameters:
align- the child alignment- Since:
- 1.7
-
setChildSpacing
public void setChildSpacing(int childSpacing) Sets the spacing between widgets on the same line.See
WrapBox:child-spacing-unit.- Parameters:
childSpacing- the child spacing- Since:
- 1.7
-
setChildSpacingUnit
Sets the length unit for child spacing.Allows the spacing to vary depending on the text scale factor.
See
WrapBox:child-spacing.- Parameters:
unit- the length unit- Since:
- 1.7
-
setJustify
Determines whether and how each complete line should be stretched to fill the entire widget.If set to
ADW_JUSTIFY_FILL, each widget in the line will be stretched, keeping consistent spacing, so that the line fills the entire widget.If set to
ADW_JUSTIFY_SPREAD, the spacing between widgets will be increased, keeping widget sizes intact. The first and last widget will be aligned with the beginning and end of the line. If the line only contains a single widget, it will be stretched regardless.If set to
ADW_JUSTIFY_NONE, the line will not be stretched and the children will be placed together within the line, according toWrapBox:align.By default this doesn't affect the last line, as it will be incomplete. Use
WrapBox:justify-last-lineto justify it as well.- Parameters:
justify- the justify mode- Since:
- 1.7
-
setJustifyLastLine
public void setJustifyLastLine(boolean justifyLastLine) Sets whether the last line should be stretched to fill the entire widget.See
WrapBox:justify.- Parameters:
justifyLastLine- whether to justify the last line- Since:
- 1.7
-
setLineHomogeneous
public void setLineHomogeneous(boolean homogeneous) Sets whether all lines should take the same amount of space.- Parameters:
homogeneous- whether lines should be homogeneous- Since:
- 1.7
-
setLineSpacing
public void setLineSpacing(int lineSpacing) Sets the spacing between lines.- Parameters:
lineSpacing- the line spacing- Since:
- 1.7
-
setLineSpacingUnit
Sets the length unit for line spacing.Allows the spacing to vary depending on the text scale factor.
See
WrapBox:line-spacing.- Parameters:
unit- the length unit- Since:
- 1.7
-
setNaturalLineLength
public void setNaturalLineLength(int naturalLineLength) Sets the natural size for each line.It should be used to limit the line lengths, for example when used in popovers.
See
WrapBox:natural-line-length-unit.- Parameters:
naturalLineLength- the natural length- Since:
- 1.7
-
setNaturalLineLengthUnit
Sets the length unit for natural line length.Allows the length to vary depending on the text scale factor.
See
WrapBox:natural-line-length.- Parameters:
unit- the length unit- Since:
- 1.7
-
setPackDirection
Sets the direction children are packed in each line.- Parameters:
packDirection- the new line direction- Since:
- 1.7
-
setWrapPolicy
Sets the policy for line wrapping.If set to
ADW_WRAP_NATURAL, the box will wrap to the next line as soon as the previous line cannot fit any more children without shrinking them past their natural size.If set to
ADW_WRAP_MINIMUM, the box will try to fit as many children into each line as possible, shrinking them down to their minimum size before wrapping to the next line.- Parameters:
wrapPolicy- the new wrap policy- Since:
- 1.7
-
setWrapReverse
public void setWrapReverse(boolean wrapReverse) Sets whether wrap direction should be reversed.By default, lines wrap downwards in a horizontal box, and towards the end in a vertical box. If set to
TRUE, they wrap upwards or towards the start respectively.- Parameters:
wrapReverse- whether to reverse wrap direction- Since:
- 1.7
-
builder
AWrapBox.Builderobject constructs aWrapBoxwith the specified properties. Use the variousset...()methods to set properties, and finish construction withWrapBox.Builder.build().- Returns:
- the builder object
-