Package ch.bailu.gtk.gtk
Class CellRenderer
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.gobject.Object
ch.bailu.gtk.gobject.InitiallyUnowned
ch.bailu.gtk.gtk.CellRenderer
- All Implemented Interfaces:
PointerInterface
- Direct Known Subclasses:
CellRendererPixbuf
,CellRendererProgress
,CellRendererSpinner
,CellRendererText
,CellRendererToggle
An object for rendering a single cell
The `GtkCellRenderer` is a base class of a set of objects used for
rendering a cell to a `cairo_t`. These objects are used primarily by
the `GtkTreeView` widget, though they aren’t tied to them in any
specific way. It is worth noting that `GtkCellRenderer` is not a
`GtkWidget` and cannot be treated as such.
The primary use of a `GtkCellRenderer` is for drawing a certain graphical
elements on a `cairo_t`. Typically, one cell renderer is used to
draw many cells on the screen. To this extent, it isn’t expected that a
CellRenderer keep any permanent state around. Instead, any state is set
just prior to use using `GObject`s property system. Then, the
cell is measured using gtk_cell_renderer_get_preferred_size(). Finally, the cell
is rendered in the correct location using gtk_cell_renderer_snapshot().
There are a number of rules that must be followed when writing a new
`GtkCellRenderer`. First and foremost, it’s important that a certain set
of properties will always yield a cell renderer of the same size,
barring a style change. The `GtkCellRenderer` also has a number of
generic properties that are expected to be honored by all children.
Beyond merely rendering a cell, cell renderers can optionally
provide active user interface elements. A cell renderer can be
“activatable” like `GtkCellRenderer`Toggle,
which toggles when it gets activated by a mouse click, or it can be
“editable” like `GtkCellRenderer`Text, which
allows the user to edit the text using a widget implementing the
`GtkCellEditable` interface, e.g. `GtkEntry`.
To make a cell renderer activatable or editable, you have to
implement the `GtkCellRenderer`Class.activate or
`GtkCellRenderer`Class.start_editing virtual functions, respectively.
Many properties of `GtkCellRenderer` and its subclasses have a
corresponding “set” property, e.g. “cell-background-set” corresponds
to “cell-background”. These “set” properties reflect whether a property
has been set or not. You should not set them independently.
The `GtkCellRenderer` is a base class of a set of objects used for
rendering a cell to a `cairo_t`. These objects are used primarily by
the `GtkTreeView` widget, though they aren’t tied to them in any
specific way. It is worth noting that `GtkCellRenderer` is not a
`GtkWidget` and cannot be treated as such.
The primary use of a `GtkCellRenderer` is for drawing a certain graphical
elements on a `cairo_t`. Typically, one cell renderer is used to
draw many cells on the screen. To this extent, it isn’t expected that a
CellRenderer keep any permanent state around. Instead, any state is set
just prior to use using `GObject`s property system. Then, the
cell is measured using gtk_cell_renderer_get_preferred_size(). Finally, the cell
is rendered in the correct location using gtk_cell_renderer_snapshot().
There are a number of rules that must be followed when writing a new
`GtkCellRenderer`. First and foremost, it’s important that a certain set
of properties will always yield a cell renderer of the same size,
barring a style change. The `GtkCellRenderer` also has a number of
generic properties that are expected to be honored by all children.
Beyond merely rendering a cell, cell renderers can optionally
provide active user interface elements. A cell renderer can be
“activatable” like `GtkCellRenderer`Toggle,
which toggles when it gets activated by a mouse click, or it can be
“editable” like `GtkCellRenderer`Text, which
allows the user to edit the text using a widget implementing the
`GtkCellEditable` interface, e.g. `GtkEntry`.
To make a cell renderer activatable or editable, you have to
implement the `GtkCellRenderer`Class.activate or
`GtkCellRenderer`Class.start_editing virtual functions, respectively.
Many properties of `GtkCellRenderer` and its subclasses have a
corresponding “set” property, e.g. “cell-background-set” corresponds
to “cell-background”. These “set” properties reflect whether a property
has been set or not. You should not set them independently.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
Nested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDestroyNotify, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
activate
(Event event, Widget widget, Str path, Rectangle background_area, Rectangle cell_area, int flags) Passes an activate event to the cell renderer for possible processing.boolean
activate
(Event event, Widget widget, String path, Rectangle background_area, Rectangle cell_area, int flags) Passes an activate event to the cell renderer for possible processing.void
getAlignedArea
(Widget widget, int flags, Rectangle cell_area, Rectangle aligned_area) Gets the aligned area used by @cell inside @cell_area.void
getAlignment
(Flt xalign, Flt yalign) Fills in @xalign and @yalign with the appropriate values of @cell.static ClassHandler
void
getFixedSize
(Int width, Int height) Fills in @width and @height with the appropriate size of @cell.static int
boolean
Checks whether the given `GtkCellRenderer` is expanded.boolean
Checks whether the given `GtkCellRenderer` is an expander.void
getPadding
(Int xpad, Int ypad) Fills in @xpad and @ypad with the appropriate values of @cell.static long
static TypeSystem.TypeSize
void
getPreferredHeight
(Widget widget, Int minimum_size, Int natural_size) Retrieves a renderer’s natural size when rendered to @widget.void
getPreferredHeightForWidth
(Widget widget, int width, Int minimum_height, Int natural_height) Retrieves a cell renderers’s minimum and natural height if it were rendered to
@widget with the specified @width.void
getPreferredSize
(Widget widget, Requisition minimum_size, Requisition natural_size) Retrieves the minimum and natural size of a cell taking
into account the widget’s preference for height-for-width management.void
getPreferredWidth
(Widget widget, Int minimum_size, Int natural_size) Retrieves a renderer’s natural size when rendered to @widget.void
getPreferredWidthForHeight
(Widget widget, int height, Int minimum_width, Int natural_width) Retrieves a cell renderers’s minimum and natural width if it were rendered to
@widget with the specified @height.int
Gets whether the cell renderer prefers a height-for-width layout
or a width-for-height layout.boolean
Returns the cell renderer’s sensitivity.int
Translates the cell renderer state to `GtkStateFlags`,
based on the cell renderer and widget sensitivity, and
the given `GtkCellRenderer`State.static long
static TypeSystem.TypeSize
boolean
Returns the cell renderer’s visibility.boolean
Checks whether the cell renderer can do something when activated.Connect to signal "editing-canceled".Connect to signal "editing-started".void
setAlignment
(float xalign, float yalign) Sets the renderer’s alignment within its available space.void
setFixedSize
(int width, int height) Sets the renderer size to be explicit, independent of the properties set.void
setIsExpanded
(boolean is_expanded) Sets whether the given `GtkCellRenderer` is expanded.void
setIsExpander
(boolean is_expander) Sets whether the given `GtkCellRenderer` is an expander.void
setPadding
(int xpad, int ypad) Sets the renderer’s padding.void
setSensitive
(boolean sensitive) Sets the cell renderer’s sensitivity.void
setVisible
(boolean visible) Sets the cell renderer’s visibility.void
snapshot
(Snapshot snapshot, Widget widget, Rectangle background_area, Rectangle cell_area, int flags) Invokes the virtual render function of the `GtkCellRenderer`.startEditing
(Event event, Widget widget, Str path, Rectangle background_area, Rectangle cell_area, int flags) Starts editing the contents of this @cell, through a new `GtkCellEditable`
widget created by the `GtkCellRenderer`Class.start_editing virtual function.startEditing
(Event event, Widget widget, String path, Rectangle background_area, Rectangle cell_area, int flags) Starts editing the contents of this @cell, through a new `GtkCellEditable`
widget created by the `GtkCellRenderer`Class.start_editing virtual function.void
stopEditing
(boolean canceled) Informs the cell renderer that the editing is stopped.Methods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Field Details
-
SIGNAL_ON_EDITING_CANCELED
- See Also:
-
SIGNAL_ON_EDITING_STARTED
- See Also:
-
-
Constructor Details
-
CellRenderer
-
-
Method Details
-
getClassHandler
-
activate
public boolean activate(@Nonnull Event event, @Nonnull Widget widget, @Nonnull Str path, @Nonnull Rectangle background_area, @Nonnull Rectangle cell_area, int flags) Passes an activate event to the cell renderer for possible processing.
Some cell renderers may use events; for example, `GtkCellRendererToggle`
toggles when it gets a mouse click.- Parameters:
event
- a `GdkEvent`widget
- widget that received the eventpath
- widget-dependent string representation of the event location; e.g. for `GtkTreeView`, a string representation of `GtkTreePath`background_area
- background area as passed to gtk_cell_renderer_render()cell_area
- cell area as passed to gtk_cell_renderer_render()flags
- render flags- Returns:
- %TRUE if the event was consumed/handled
-
activate
public boolean activate(@Nonnull Event event, @Nonnull Widget widget, String path, @Nonnull Rectangle background_area, @Nonnull Rectangle cell_area, int flags) Passes an activate event to the cell renderer for possible processing.
Some cell renderers may use events; for example, `GtkCellRendererToggle`
toggles when it gets a mouse click.- Parameters:
event
- a `GdkEvent`widget
- widget that received the eventpath
- widget-dependent string representation of the event location; e.g. for `GtkTreeView`, a string representation of `GtkTreePath`background_area
- background area as passed to gtk_cell_renderer_render()cell_area
- cell area as passed to gtk_cell_renderer_render()flags
- render flags- Returns:
- %TRUE if the event was consumed/handled
-
getAlignedArea
public void getAlignedArea(@Nonnull Widget widget, int flags, @Nonnull Rectangle cell_area, @Nonnull Rectangle aligned_area) Gets the aligned area used by @cell inside @cell_area. Used for finding
the appropriate edit and focus rectangle.- Parameters:
widget
- the `GtkWidget` this cell will be rendering toflags
- render flagscell_area
- cell area which would be passed to gtk_cell_renderer_render()aligned_area
- the return location for the space inside @cell_area that would actually be used to render.
-
getAlignment
Fills in @xalign and @yalign with the appropriate values of @cell.- Parameters:
xalign
- location to fill in with the x alignment of the cellyalign
- location to fill in with the y alignment of the cell
-
getFixedSize
Fills in @width and @height with the appropriate size of @cell.- Parameters:
width
- location to fill in with the fixed width of the cellheight
- location to fill in with the fixed height of the cell
-
getIsExpanded
public boolean getIsExpanded()Checks whether the given `GtkCellRenderer` is expanded.- Returns:
- %TRUE if the cell renderer is expanded
-
getIsExpander
public boolean getIsExpander()Checks whether the given `GtkCellRenderer` is an expander.- Returns:
- %TRUE if @cell is an expander, and %FALSE otherwise
-
getPadding
Fills in @xpad and @ypad with the appropriate values of @cell.- Parameters:
xpad
- location to fill in with the x padding of the cellypad
- location to fill in with the y padding of the cell
-
getPreferredHeight
public void getPreferredHeight(@Nonnull Widget widget, @Nullable Int minimum_size, @Nullable Int natural_size) Retrieves a renderer’s natural size when rendered to @widget.- Parameters:
widget
- the `GtkWidget` this cell will be rendering tominimum_size
- location to store the minimum sizenatural_size
- location to store the natural size
-
getPreferredHeightForWidth
public void getPreferredHeightForWidth(@Nonnull Widget widget, int width, @Nullable Int minimum_height, @Nullable Int natural_height) Retrieves a cell renderers’s minimum and natural height if it were rendered to
@widget with the specified @width.- Parameters:
widget
- the `GtkWidget` this cell will be rendering towidth
- the size which is available for allocationminimum_height
- location for storing the minimum sizenatural_height
- location for storing the preferred size
-
getPreferredSize
public void getPreferredSize(@Nonnull Widget widget, @Nullable Requisition minimum_size, @Nullable Requisition natural_size) Retrieves the minimum and natural size of a cell taking
into account the widget’s preference for height-for-width management.- Parameters:
widget
- the `GtkWidget` this cell will be rendering tominimum_size
- location for storing the minimum sizenatural_size
- location for storing the natural size
-
getPreferredWidth
public void getPreferredWidth(@Nonnull Widget widget, @Nullable Int minimum_size, @Nullable Int natural_size) Retrieves a renderer’s natural size when rendered to @widget.- Parameters:
widget
- the `GtkWidget` this cell will be rendering tominimum_size
- location to store the minimum sizenatural_size
- location to store the natural size
-
getPreferredWidthForHeight
public void getPreferredWidthForHeight(@Nonnull Widget widget, int height, @Nullable Int minimum_width, @Nullable Int natural_width) Retrieves a cell renderers’s minimum and natural width if it were rendered to
@widget with the specified @height.- Parameters:
widget
- the `GtkWidget` this cell will be rendering toheight
- the size which is available for allocationminimum_width
- location for storing the minimum sizenatural_width
- location for storing the preferred size
-
getRequestMode
public int getRequestMode()Gets whether the cell renderer prefers a height-for-width layout
or a width-for-height layout.- Returns:
- The `GtkSizeRequestMode` preferred by this renderer.
-
getSensitive
public boolean getSensitive()Returns the cell renderer’s sensitivity.- Returns:
- %TRUE if the cell renderer is sensitive
-
getState
Translates the cell renderer state to `GtkStateFlags`,
based on the cell renderer and widget sensitivity, and
the given `GtkCellRenderer`State.- Parameters:
widget
- a `GtkWidget`cell_state
- cell renderer state- Returns:
- the widget state flags applying to @cell
-
getVisible
public boolean getVisible()Returns the cell renderer’s visibility.- Returns:
- %TRUE if the cell renderer is visible
-
isActivatable
public boolean isActivatable()Checks whether the cell renderer can do something when activated.- Returns:
- %TRUE if the cell renderer can do anything when activated
-
setAlignment
public void setAlignment(float xalign, float yalign) Sets the renderer’s alignment within its available space.- Parameters:
xalign
- the x alignment of the cell rendereryalign
- the y alignment of the cell renderer
-
setFixedSize
public void setFixedSize(int width, int height) Sets the renderer size to be explicit, independent of the properties set.- Parameters:
width
- the width of the cell renderer, or -1height
- the height of the cell renderer, or -1
-
setIsExpanded
public void setIsExpanded(boolean is_expanded) Sets whether the given `GtkCellRenderer` is expanded.- Parameters:
is_expanded
- whether @cell should be expanded
-
setIsExpander
public void setIsExpander(boolean is_expander) Sets whether the given `GtkCellRenderer` is an expander.- Parameters:
is_expander
- whether @cell is an expander
-
setPadding
public void setPadding(int xpad, int ypad) Sets the renderer’s padding.- Parameters:
xpad
- the x padding of the cell rendererypad
- the y padding of the cell renderer
-
setSensitive
public void setSensitive(boolean sensitive) Sets the cell renderer’s sensitivity.- Parameters:
sensitive
- the sensitivity of the cell
-
setVisible
public void setVisible(boolean visible) Sets the cell renderer’s visibility.- Parameters:
visible
- the visibility of the cell
-
snapshot
public void snapshot(@Nonnull Snapshot snapshot, @Nonnull Widget widget, @Nonnull Rectangle background_area, @Nonnull Rectangle cell_area, int flags) Invokes the virtual render function of the `GtkCellRenderer`. The three
passed-in rectangles are areas in @cr. Most renderers will draw within
@cell_area; the xalign, yalign, xpad, and ypad fields of the `GtkCellRenderer`
should be honored with respect to @cell_area. @background_area includes the
blank space around the cell, and also the area containing the tree expander;
so the @background_area rectangles for all cells tile to cover the entire
@window.- Parameters:
snapshot
- a `GtkSnapshot` to draw towidget
- the widget owning @windowbackground_area
- entire cell area (including tree expanders and maybe padding on the sides)cell_area
- area normally rendered by a cell rendererflags
- flags that affect rendering
-
startEditing
public CellEditable startEditing(@Nullable Event event, @Nonnull Widget widget, @Nonnull Str path, @Nonnull Rectangle background_area, @Nonnull Rectangle cell_area, int flags) Starts editing the contents of this @cell, through a new `GtkCellEditable`
widget created by the `GtkCellRenderer`Class.start_editing virtual function.- Parameters:
event
- a `GdkEvent`widget
- widget that received the eventpath
- widget-dependent string representation of the event location; e.g. for `GtkTreeView`, a string representation of `GtkTreePath`background_area
- background area as passed to gtk_cell_renderer_render()cell_area
- cell area as passed to gtk_cell_renderer_render()flags
- render flags- Returns:
- A new `GtkCellEditable` for editing this @cell, or %NULL if editing is not possible
-
startEditing
public CellEditable startEditing(@Nullable Event event, @Nonnull Widget widget, String path, @Nonnull Rectangle background_area, @Nonnull Rectangle cell_area, int flags) Starts editing the contents of this @cell, through a new `GtkCellEditable`
widget created by the `GtkCellRenderer`Class.start_editing virtual function.- Parameters:
event
- a `GdkEvent`widget
- widget that received the eventpath
- widget-dependent string representation of the event location; e.g. for `GtkTreeView`, a string representation of `GtkTreePath`background_area
- background area as passed to gtk_cell_renderer_render()cell_area
- cell area as passed to gtk_cell_renderer_render()flags
- render flags- Returns:
- A new `GtkCellEditable` for editing this @cell, or %NULL if editing is not possible
-
stopEditing
public void stopEditing(boolean canceled) Informs the cell renderer that the editing is stopped.
If @canceled is %TRUE, the cell renderer will emit the
`GtkCellRenderer`::editing-canceled signal.
This function should be called by cell renderer implementations
in response to the `GtkCellEditable::editing-done` signal of
`GtkCellEditable`.- Parameters:
canceled
- %TRUE if the editing has been canceled
-
onEditingCanceled
Connect to signal "editing-canceled".
SeeCellRenderer.OnEditingCanceled.onEditingCanceled()
for signal description.
FieldSIGNAL_ON_EDITING_CANCELED
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
onEditingStarted
Connect to signal "editing-started".
SeeCellRenderer.OnEditingStarted.onEditingStarted(ch.bailu.gtk.gtk.CellEditable, ch.bailu.gtk.type.Str)
for signal description.
FieldSIGNAL_ON_EDITING_STARTED
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-