Gtk.CellAreaContext

g GObject.Object GObject.Object Gtk.CellAreaContext Gtk.CellAreaContext GObject.Object->Gtk.CellAreaContext

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

allocate (width, height)

get_allocation ()

get_area ()

get_preferred_height ()

get_preferred_height_for_width (width)

get_preferred_width ()

get_preferred_width_for_height (height)

push_preferred_height (minimum_height, natural_height)

push_preferred_width (minimum_width, natural_width)

reset ()

Virtual Methods

Inherited:

GObject.Object (7)

do_allocate (width, height)

do_get_preferred_height_for_width (width)

do_get_preferred_width_for_height (height)

do_reset ()

Properties

Name

Type

Flags

Short Description

area

Gtk.CellArea

r/w/co

The Cell Area this context was created for

minimum-height

int

r

Minimum cached height

minimum-width

int

r

Minimum cached width

natural-height

int

r

Minimum cached height

natural-width

int

r

Minimum cached width

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.Object

r

Class Details

class Gtk.CellAreaContext(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Gtk.CellAreaContextClass

The Gtk.CellAreaContext object is created by a given Gtk.CellArea implementation via its Gtk.CellArea.do_create_context() virtual method and is used to store cell sizes and alignments for a series of Gtk.TreeModel rows that are requested and rendered in the same context.

Gtk.CellLayout widgets can create any number of contexts in which to request and render groups of data rows. However, it’s important that the same context which was used to request sizes for a given Gtk.TreeModel row also be used for the same row when calling other Gtk.CellArea APIs such as Gtk.CellArea.render() and Gtk.CellArea.event().

allocate(width, height)[source]
Parameters:
  • width (int) – the allocated width for all Gtk.TreeModel rows rendered with self, or -1.

  • height (int) – the allocated height for all Gtk.TreeModel rows rendered with self, or -1.

Allocates a width and/or a height for all rows which are to be rendered with self.

Usually allocation is performed only horizontally or sometimes vertically since a group of rows are usually rendered side by side vertically or horizontally and share either the same width or the same height. Sometimes they are allocated in both horizontal and vertical orientations producing a homogeneous effect of the rows. This is generally the case for Gtk.TreeView when Gtk.TreeView :fixed-height-mode is enabled.

New in version 3.0.

get_allocation()[source]
Returns:

width:

location to store the allocated width, or None

height:

location to store the allocated height, or None

Return type:

(width: int, height: int)

Fetches the current allocation size for self.

If the context was not allocated in width or height, or if the context was recently reset with Gtk.CellAreaContext.reset(), the returned value will be -1.

New in version 3.0.

get_area()[source]
Returns:

the Gtk.CellArea this context was created by.

Return type:

Gtk.CellArea

Fetches the Gtk.CellArea this self was created by.

This is generally unneeded by layouting widgets; however, it is important for the context implementation itself to fetch information about the area it is being used for.

For instance at Gtk.CellAreaContext.do_allocate() time it’s important to know details about any cell spacing that the Gtk.CellArea is configured with in order to compute a proper allocation.

New in version 3.0.

get_preferred_height()[source]
Returns:

minimum_height:

location to store the minimum height, or None

natural_height:

location to store the natural height, or None

Return type:

(minimum_height: int, natural_height: int)

Gets the accumulative preferred height for all rows which have been requested with this context.

After Gtk.CellAreaContext.reset() is called and/or before ever requesting the size of a Gtk.CellArea, the returned values are 0.

New in version 3.0.

get_preferred_height_for_width(width)[source]
Parameters:

width (int) – a proposed width for allocation

Returns:

minimum_height:

location to store the minimum height, or None

natural_height:

location to store the natural height, or None

Return type:

(minimum_height: int, natural_height: int)

Gets the accumulative preferred height for width for all rows which have been requested for the same said width with this context.

After Gtk.CellAreaContext.reset() is called and/or before ever requesting the size of a Gtk.CellArea, the returned values are -1.

New in version 3.0.

get_preferred_width()[source]
Returns:

minimum_width:

location to store the minimum width, or None

natural_width:

location to store the natural width, or None

Return type:

(minimum_width: int, natural_width: int)

Gets the accumulative preferred width for all rows which have been requested with this context.

After Gtk.CellAreaContext.reset() is called and/or before ever requesting the size of a Gtk.CellArea, the returned values are 0.

New in version 3.0.

get_preferred_width_for_height(height)[source]
Parameters:

height (int) – a proposed height for allocation

Returns:

minimum_width:

location to store the minimum width, or None

natural_width:

location to store the natural width, or None

Return type:

(minimum_width: int, natural_width: int)

Gets the accumulative preferred width for height for all rows which have been requested for the same said height with this context.

After Gtk.CellAreaContext.reset() is called and/or before ever requesting the size of a Gtk.CellArea, the returned values are -1.

New in version 3.0.

push_preferred_height(minimum_height, natural_height)[source]
Parameters:
  • minimum_height (int) – the proposed new minimum height for self

  • natural_height (int) – the proposed new natural height for self

Causes the minimum and/or natural height to grow if the new proposed sizes exceed the current minimum and natural height.

This is used by Gtk.CellAreaContext implementations during the request process over a series of Gtk.TreeModel rows to progressively push the requested height over a series of Gtk.CellArea.get_preferred_height() requests.

New in version 3.0.

push_preferred_width(minimum_width, natural_width)[source]
Parameters:
  • minimum_width (int) – the proposed new minimum width for self

  • natural_width (int) – the proposed new natural width for self

Causes the minimum and/or natural width to grow if the new proposed sizes exceed the current minimum and natural width.

This is used by Gtk.CellAreaContext implementations during the request process over a series of Gtk.TreeModel rows to progressively push the requested width over a series of Gtk.CellArea.get_preferred_width() requests.

New in version 3.0.

reset()[source]

Resets any previously cached request and allocation data.

When underlying Gtk.TreeModel data changes its important to reset the context if the content size is allowed to shrink. If the content size is only allowed to grow (this is usually an option for views rendering large data stores as a measure of optimization), then only the row that changed or was inserted needs to be (re)requested with Gtk.CellArea.get_preferred_width().

When the new overall size of the context requires that the allocated size changes (or whenever this allocation changes at all), the variable row sizes need to be re-requested for every row.

For instance, if the rows are displayed all with the same width from top to bottom then a change in the allocated width necessitates a recalculation of all the displayed row heights using Gtk.CellArea.get_preferred_height_for_width().

New in version 3.0.

do_allocate(width, height) virtual
Parameters:
  • width (int) – the allocated width for all Gtk.TreeModel rows rendered with context, or -1.

  • height (int) – the allocated height for all Gtk.TreeModel rows rendered with context, or -1.

Allocates a width and/or a height for all rows which are to be rendered with context.

Usually allocation is performed only horizontally or sometimes vertically since a group of rows are usually rendered side by side vertically or horizontally and share either the same width or the same height. Sometimes they are allocated in both horizontal and vertical orientations producing a homogeneous effect of the rows. This is generally the case for Gtk.TreeView when Gtk.TreeView :fixed-height-mode is enabled.

New in version 3.0.

do_get_preferred_height_for_width(width) virtual
Parameters:

width (int) – a proposed width for allocation

Returns:

minimum_height:

location to store the minimum height, or None

natural_height:

location to store the natural height, or None

Return type:

(minimum_height: int, natural_height: int)

Gets the accumulative preferred height for width for all rows which have been requested for the same said width with this context.

After Gtk.CellAreaContext.reset() is called and/or before ever requesting the size of a Gtk.CellArea, the returned values are -1.

New in version 3.0.

do_get_preferred_width_for_height(height) virtual
Parameters:

height (int) – a proposed height for allocation

Returns:

minimum_width:

location to store the minimum width, or None

natural_width:

location to store the natural width, or None

Return type:

(minimum_width: int, natural_width: int)

Gets the accumulative preferred width for height for all rows which have been requested for the same said height with this context.

After Gtk.CellAreaContext.reset() is called and/or before ever requesting the size of a Gtk.CellArea, the returned values are -1.

New in version 3.0.

do_reset() virtual

Resets any previously cached request and allocation data.

When underlying Gtk.TreeModel data changes its important to reset the context if the content size is allowed to shrink. If the content size is only allowed to grow (this is usually an option for views rendering large data stores as a measure of optimization), then only the row that changed or was inserted needs to be (re)requested with Gtk.CellArea.get_preferred_width().

When the new overall size of the context requires that the allocated size changes (or whenever this allocation changes at all), the variable row sizes need to be re-requested for every row.

For instance, if the rows are displayed all with the same width from top to bottom then a change in the allocated width necessitates a recalculation of all the displayed row heights using Gtk.CellArea.get_preferred_height_for_width().

New in version 3.0.

Property Details

Gtk.CellAreaContext.props.area
Name:

area

Type:

Gtk.CellArea

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The Gtk.CellArea this context was created by

New in version 3.0.

Gtk.CellAreaContext.props.minimum_height
Name:

minimum-height

Type:

int

Default Value:

-1

Flags:

READABLE

The minimum height for the Gtk.CellArea in this context for all Gtk.TreeModel rows that this context was requested for using Gtk.CellArea.get_preferred_height().

New in version 3.0.

Gtk.CellAreaContext.props.minimum_width
Name:

minimum-width

Type:

int

Default Value:

-1

Flags:

READABLE

The minimum width for the Gtk.CellArea in this context for all Gtk.TreeModel rows that this context was requested for using Gtk.CellArea.get_preferred_width().

New in version 3.0.

Gtk.CellAreaContext.props.natural_height
Name:

natural-height

Type:

int

Default Value:

-1

Flags:

READABLE

The natural height for the Gtk.CellArea in this context for all Gtk.TreeModel rows that this context was requested for using Gtk.CellArea.get_preferred_height().

New in version 3.0.

Gtk.CellAreaContext.props.natural_width
Name:

natural-width

Type:

int

Default Value:

-1

Flags:

READABLE

The natural width for the Gtk.CellArea in this context for all Gtk.TreeModel rows that this context was requested for using Gtk.CellArea.get_preferred_width().

New in version 3.0.