Class CellRenderer

All Implemented Interfaces:
Proxy
Direct Known Subclasses:
CellRenderer.CellRenderer$Impl, CellRendererPixbuf, CellRendererProgress, CellRendererSpinner, CellRendererText, CellRendererToggle

@Generated("org.javagi.JavaGI") @Deprecated public abstract class CellRenderer extends InitiallyUnowned
Deprecated.
List views use widgets for displaying their contents

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 GObjects 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 GtkCellRendererToggle, which toggles when it gets activated by a mouse click, or it can be “editable” like GtkCellRendererText, 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 GtkCellRendererClass.activate or GtkCellRendererClass.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.

  • Constructor Details

    • CellRenderer

      public CellRenderer(MemorySegment address)
      Deprecated.
      Create a CellRenderer instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • CellRenderer

      public CellRenderer()
      Deprecated.
      Create a new CellRenderer.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Deprecated.
      Get the GType of the CellRenderer class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      Deprecated.
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected CellRenderer asParent()
      Deprecated.
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class InitiallyUnowned
      Returns:
      the instance as if it were its parent type
    • activate

      @Deprecated public boolean activate(Event event, Widget widget, String path, Rectangle backgroundArea, Rectangle cellArea, Set<CellRendererState> flags)
      Deprecated.
      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 event
      path - widget-dependent string representation of the event location; e.g. for GtkTreeView, a string representation of GtkTreePath
      backgroundArea - background area as passed to gtk_cell_renderer_render()
      cellArea - cell area as passed to gtk_cell_renderer_render()
      flags - render flags
      Returns:
      true if the event was consumed/handled
    • activate

      @Deprecated public boolean activate(Event event, Widget widget, String path, Rectangle backgroundArea, Rectangle cellArea, CellRendererState... flags)
      Deprecated.
      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 event
      path - widget-dependent string representation of the event location; e.g. for GtkTreeView, a string representation of GtkTreePath
      backgroundArea - background area as passed to gtk_cell_renderer_render()
      cellArea - cell area as passed to gtk_cell_renderer_render()
      flags - render flags
      Returns:
      true if the event was consumed/handled
    • getAlignedArea

      @Deprecated public void getAlignedArea(Widget widget, Set<CellRendererState> flags, Rectangle cellArea, Rectangle alignedArea)
      Deprecated.
      Gets the aligned area used by this CellRenderer inside cellArea. Used for finding the appropriate edit and focus rectangle.
      Parameters:
      widget - the GtkWidget this cell will be rendering to
      flags - render flags
      cellArea - cell area which would be passed to gtk_cell_renderer_render()
      alignedArea - the return location for the space inside cellArea that would actually be used to render.
    • getAlignedArea

      @Deprecated public void getAlignedArea(Widget widget, CellRendererState flags, Rectangle cellArea, Rectangle alignedArea)
      Deprecated.
      Gets the aligned area used by this CellRenderer inside cellArea. Used for finding the appropriate edit and focus rectangle.
      Parameters:
      widget - the GtkWidget this cell will be rendering to
      flags - render flags
      cellArea - cell area which would be passed to gtk_cell_renderer_render()
      alignedArea - the return location for the space inside cellArea that would actually be used to render.
    • getAlignment

      @Deprecated public void getAlignment(@Nullable Out<Float> xalign, @Nullable Out<Float> yalign)
      Deprecated.
      Fills in xalign and yalign with the appropriate values of cell.
      Parameters:
      xalign - location to fill in with the x alignment of the cell
      yalign - location to fill in with the y alignment of the cell
    • getFixedSize

      @Deprecated public void getFixedSize(@Nullable Out<Integer> width, @Nullable Out<Integer> height)
      Deprecated.
      Fills in width and height with the appropriate size of cell.
      Parameters:
      width - location to fill in with the fixed width of the cell
      height - location to fill in with the fixed height of the cell
    • getIsExpanded

      @Deprecated public boolean getIsExpanded()
      Deprecated.
      Checks whether the given GtkCellRenderer is expanded.
      Returns:
      true if the cell renderer is expanded
    • getIsExpander

      @Deprecated public boolean getIsExpander()
      Deprecated.
      Checks whether the given GtkCellRenderer is an expander.
      Returns:
      true if this CellRenderer is an expander, and false otherwise
    • getPadding

      @Deprecated public void getPadding(@Nullable Out<Integer> xpad, @Nullable Out<Integer> ypad)
      Deprecated.
      Fills in xpad and ypad with the appropriate values of cell.
      Parameters:
      xpad - location to fill in with the x padding of the cell
      ypad - location to fill in with the y padding of the cell
    • getPreferredHeight

      @Deprecated public void getPreferredHeight(Widget widget, @Nullable Out<Integer> minimumSize, @Nullable Out<Integer> naturalSize)
      Deprecated.
      Retrieves a renderer’s natural size when rendered to widget.
      Parameters:
      widget - the GtkWidget this cell will be rendering to
      minimumSize - location to store the minimum size
      naturalSize - location to store the natural size
    • getPreferredHeightForWidth

      @Deprecated public void getPreferredHeightForWidth(Widget widget, int width, @Nullable Out<Integer> minimumHeight, @Nullable Out<Integer> naturalHeight)
      Deprecated.
      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 to
      width - the size which is available for allocation
      minimumHeight - location for storing the minimum size
      naturalHeight - location for storing the preferred size
    • getPreferredSize

      @Deprecated public void getPreferredSize(Widget widget, @Nullable Requisition minimumSize, @Nullable Requisition naturalSize)
      Deprecated.
      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 to
      minimumSize - location for storing the minimum size
      naturalSize - location for storing the natural size
    • getPreferredWidth

      @Deprecated public void getPreferredWidth(Widget widget, @Nullable Out<Integer> minimumSize, @Nullable Out<Integer> naturalSize)
      Deprecated.
      Retrieves a renderer’s natural size when rendered to widget.
      Parameters:
      widget - the GtkWidget this cell will be rendering to
      minimumSize - location to store the minimum size
      naturalSize - location to store the natural size
    • getPreferredWidthForHeight

      @Deprecated public void getPreferredWidthForHeight(Widget widget, int height, @Nullable Out<Integer> minimumWidth, @Nullable Out<Integer> naturalWidth)
      Deprecated.
      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 to
      height - the size which is available for allocation
      minimumWidth - location for storing the minimum size
      naturalWidth - location for storing the preferred size
    • getRequestMode

      @Deprecated public SizeRequestMode getRequestMode()
      Deprecated.
      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

      @Deprecated public boolean getSensitive()
      Deprecated.
      Returns the cell renderer’s sensitivity.
      Returns:
      true if the cell renderer is sensitive
    • getState

      @Deprecated public Set<StateFlags> getState(@Nullable Widget widget, Set<CellRendererState> cellState)
      Deprecated.
      Translates the cell renderer state to GtkStateFlags, based on the cell renderer and widget sensitivity, and the given GtkCellRendererState.
      Parameters:
      widget - a GtkWidget
      cellState - cell renderer state
      Returns:
      the widget state flags applying to this CellRenderer
    • getState

      @Deprecated public Set<StateFlags> getState(@Nullable Widget widget, CellRendererState... cellState)
      Deprecated.
      Translates the cell renderer state to GtkStateFlags, based on the cell renderer and widget sensitivity, and the given GtkCellRendererState.
      Parameters:
      widget - a GtkWidget
      cellState - cell renderer state
      Returns:
      the widget state flags applying to this CellRenderer
    • getVisible

      @Deprecated public boolean getVisible()
      Deprecated.
      Returns the cell renderer’s visibility.
      Returns:
      true if the cell renderer is visible
    • isActivatable

      @Deprecated public boolean isActivatable()
      Deprecated.
      Checks whether the cell renderer can do something when activated.
      Returns:
      true if the cell renderer can do anything when activated
    • setAlignment

      @Deprecated public void setAlignment(float xalign, float yalign)
      Deprecated.
      Sets the renderer’s alignment within its available space.
      Parameters:
      xalign - the x alignment of the cell renderer
      yalign - the y alignment of the cell renderer
    • setFixedSize

      @Deprecated public void setFixedSize(int width, int height)
      Deprecated.
      Sets the renderer size to be explicit, independent of the properties set.
      Parameters:
      width - the width of the cell renderer, or -1
      height - the height of the cell renderer, or -1
    • setIsExpanded

      @Deprecated public void setIsExpanded(boolean isExpanded)
      Deprecated.
      Sets whether the given GtkCellRenderer is expanded.
      Parameters:
      isExpanded - whether this CellRenderer should be expanded
    • setIsExpander

      @Deprecated public void setIsExpander(boolean isExpander)
      Deprecated.
      Sets whether the given GtkCellRenderer is an expander.
      Parameters:
      isExpander - whether this CellRenderer is an expander
    • setPadding

      @Deprecated public void setPadding(int xpad, int ypad)
      Deprecated.
      Sets the renderer’s padding.
      Parameters:
      xpad - the x padding of the cell renderer
      ypad - the y padding of the cell renderer
    • setSensitive

      @Deprecated public void setSensitive(boolean sensitive)
      Deprecated.
      Sets the cell renderer’s sensitivity.
      Parameters:
      sensitive - the sensitivity of the cell
    • setVisible

      @Deprecated public void setVisible(boolean visible)
      Deprecated.
      Sets the cell renderer’s visibility.
      Parameters:
      visible - the visibility of the cell
    • snapshot

      @Deprecated public void snapshot(Snapshot snapshot, Widget widget, Rectangle backgroundArea, Rectangle cellArea, Set<CellRendererState> flags)
      Deprecated.
      Invokes the virtual render function of the GtkCellRenderer. The three passed-in rectangles are areas in cr. Most renderers will draw within cellArea; the xalign, yalign, xpad, and ypad fields of the GtkCellRenderer should be honored with respect to cellArea. backgroundArea includes the blank space around the cell, and also the area containing the tree expander; so the backgroundArea rectangles for all cells tile to cover the entire window.
      Parameters:
      snapshot - a GtkSnapshot to draw to
      widget - the widget owning window
      backgroundArea - entire cell area (including tree expanders and maybe padding on the sides)
      cellArea - area normally rendered by a cell renderer
      flags - flags that affect rendering
    • snapshot

      @Deprecated public void snapshot(Snapshot snapshot, Widget widget, Rectangle backgroundArea, Rectangle cellArea, CellRendererState... flags)
      Deprecated.
      Invokes the virtual render function of the GtkCellRenderer. The three passed-in rectangles are areas in cr. Most renderers will draw within cellArea; the xalign, yalign, xpad, and ypad fields of the GtkCellRenderer should be honored with respect to cellArea. backgroundArea includes the blank space around the cell, and also the area containing the tree expander; so the backgroundArea rectangles for all cells tile to cover the entire window.
      Parameters:
      snapshot - a GtkSnapshot to draw to
      widget - the widget owning window
      backgroundArea - entire cell area (including tree expanders and maybe padding on the sides)
      cellArea - area normally rendered by a cell renderer
      flags - flags that affect rendering
    • startEditing

      @Deprecated public @Nullable CellEditable startEditing(@Nullable Event event, Widget widget, String path, Rectangle backgroundArea, Rectangle cellArea, Set<CellRendererState> flags)
      Deprecated.
      Starts editing the contents of this cell, through a new GtkCellEditable widget created by the GtkCellRendererClass.start_editing virtual function.
      Parameters:
      event - a GdkEvent
      widget - widget that received the event
      path - widget-dependent string representation of the event location; e.g. for GtkTreeView, a string representation of GtkTreePath
      backgroundArea - background area as passed to gtk_cell_renderer_render()
      cellArea - 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

      @Deprecated public @Nullable CellEditable startEditing(@Nullable Event event, Widget widget, String path, Rectangle backgroundArea, Rectangle cellArea, CellRendererState... flags)
      Deprecated.
      Starts editing the contents of this cell, through a new GtkCellEditable widget created by the GtkCellRendererClass.start_editing virtual function.
      Parameters:
      event - a GdkEvent
      widget - widget that received the event
      path - widget-dependent string representation of the event location; e.g. for GtkTreeView, a string representation of GtkTreePath
      backgroundArea - background area as passed to gtk_cell_renderer_render()
      cellArea - 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

      @Deprecated public void stopEditing(boolean canceled)
      Deprecated.

      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
    • editingCanceled

      protected void editingCanceled()
      Deprecated.
      Signal gets emitted when the user cancels the process of editing a cell.
    • editingStarted

      protected void editingStarted(CellEditable editable, String path)
      Deprecated.
      Signal gets emitted when a cell starts to be edited.
    • onEditingCanceled

      Deprecated.

      This signal gets emitted when the user cancels the process of editing a cell. For example, an editable cell renderer could be written to cancel editing when the user presses Escape.

      See also: gtk_cell_renderer_stop_editing().

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitEditingCanceled

      public void emitEditingCanceled()
      Deprecated.
      Emits the "editing-canceled" signal. See onEditingCanceled(CellRenderer.EditingCanceledCallback).
    • onEditingStarted

      Deprecated.

      This signal gets emitted when a cell starts to be edited. The intended use of this signal is to do special setup on editable, e.g. adding a GtkEntryCompletion or setting up additional columns in a GtkComboBox.

      See gtk_cell_editable_start_editing() for information on the lifecycle of the editable and a way to do setup that doesn’t depend on the renderer.

      Note that GTK doesn't guarantee that cell renderers will continue to use the same kind of widget for editing in future releases, therefore you should check the type of editable before doing any specific setup, as in the following example:

      static void
      text_editing_started (GtkCellRenderer *cell,
                            GtkCellEditable *editable,
                            const char      *path,
                            gpointer         data)
      {
        if (GTK_IS_ENTRY (editable))
          {
            GtkEntry *entry = GTK_ENTRY (editable);
      
            // ... create a GtkEntryCompletion
      
            gtk_entry_set_completion (entry, completion);
          }
      }
      
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitEditingStarted

      public void emitEditingStarted(@Nullable CellEditable editable, String path)
      Deprecated.
      Emits the "editing-started" signal. See onEditingStarted(CellRenderer.EditingStartedCallback).