AdgTable — A tabular entity
AdgTableCell; AdgTableRow; AdgTable; AdgTable * adg_table_new (void); void adg_table_set_table_dress (AdgTable *table, AdgDress dress); AdgDress adg_table_get_table_dress (AdgTable *table); void adg_table_switch_frame (AdgTable *table, gboolean new_state); gboolean adg_table_has_frame (AdgTable *table); guint adg_table_get_n_rows (AdgTable *table); AdgTableRow * adg_table_row_new (AdgTable *table); AdgTableRow * adg_table_row_new_before (AdgTableRow *row); void adg_table_row_delete (AdgTableRow *row); guint adg_table_row_get_n_cells (const AdgTableRow *row); void adg_table_row_set_height (AdgTableRow *row, gdouble height); gdouble adg_table_row_get_height (AdgTableRow *row); const CpmlExtents * adg_table_row_get_extents (AdgTableRow *row); AdgTableCell * adg_table_cell_new (AdgTableRow *row, gdouble width); AdgTableCell * adg_table_cell_new_before (AdgTableCell *cell, gdouble width); AdgTableCell * adg_table_cell_new_full (AdgTableRow *row, gdouble width, const gchar *name, const gchar *title, const gchar *value); AdgTableCell * adg_table_cell (AdgTable *table, const gchar *name); void adg_table_cell_delete (AdgTableCell *cell); void adg_table_cell_set_name (AdgTableCell *cell, const gchar *name); const gchar * adg_table_cell_get_name (AdgTableCell *cell); void adg_table_cell_set_title (AdgTableCell *cell, AdgEntity *title); void adg_table_cell_set_text_title (AdgTableCell *cell, const gchar *title); AdgEntity * adg_table_cell_title (AdgTableCell *cell); void adg_table_cell_set_value (AdgTableCell *cell, AdgEntity *value); void adg_table_cell_set_text_value (AdgTableCell *cell, const gchar *value); AdgEntity * adg_table_cell_value (AdgTableCell *cell); void adg_table_cell_set_value_pos (AdgTableCell *cell, const AdgPair *from_factor, const AdgPair *to_factor); void adg_table_cell_set_value_pos_explicit (AdgTableCell *cell, gdouble from_x, gdouble from_y, gdouble to_x, gdouble to_y); void adg_table_cell_set_width (AdgTableCell *cell, gdouble width); gdouble adg_table_cell_get_width (AdgTableCell *cell); void adg_table_cell_switch_frame (AdgTableCell *cell, gboolean new_state); gboolean adg_table_cell_has_frame (AdgTableCell *cell); const CpmlExtents * adg_table_cell_get_extents (AdgTableCell *cell);
The AdgTable is the entity to be used for rendering data arranged in tabular evironments.
To define a table, you should add to its internal model any number
of row using adg_table_row_new() or adg_table_row_new_before().
Every row could be segmented with different cells by using
adg_table_cell_new() or adg_table_cell_new_before(). Any cell can
be filled with a title and a value: the font to be used will be
picked up from the AdgTableStyle got by resolving the
"table-dress" property.
The default title is placed at the upper left corner of the cell
while the value is centered up to the bottom edge of the cell.
Anyway, the value position can be customized by using the
adg_table_cell_set_value_pos() method. Anyway, both entities react
to the common map displacements.
Some convenient functions to easily create title and value entities
with plain text are provided: adg_table_cell_new_full(),
adg_table_cell_set_text_title() and adg_table_cell_set_text_value().
When using these methods keep in mind the underlying AdgToyText
entities will be displaced accordingly to the
"cell-padding" value (not used when setting the
entities throught other APIs).
typedef struct _AdgTableCell AdgTableCell;
An opaque structure referring to the cell of an AdgTableRow. Any row can have an unlimited number of cells.
typedef struct _AdgTableRow AdgTableRow;
An opaque structure referring to a row of an AdgTable. Any table can have an unlimited number of rows.
typedef struct _AdgTable AdgTable;
All fields are private and should not be used directly. Use its public methods instead.
AdgTable * adg_table_new (void);
Creates a new empty table entity. The "local-method" property is set by default to ADG_MIX_DISABLED, that is the table is not subject to any local transformations.
|
Returns : |
the newly created table entity |
void adg_table_set_table_dress (AdgTable *table, AdgDress dress);
Sets a new table dress for rendering table. The new dress
must be related to the original dress for this property:
you cannot set a dress used for line styles to a dress
managing fonts.
The check is done by calling adg_dress_are_related() with
dress and the previous dress as arguments. Check out its
documentation for details on what is a related dress.
AdgDress adg_table_get_table_dress (AdgTable *table);
Gets the table dress to be used in rendering table.
|
|
an AdgTable |
|
Returns : |
the current table dress |
void adg_table_switch_frame (AdgTable *table, gboolean new_state);
Sets the "has-frame" property: TRUE will draw a frame around the whole table using the "frame-dress" dress of the table style.
|
|
an AdgTable |
|
|
the new state of the frame |
gboolean adg_table_has_frame (AdgTable *table);
Returns the state of the "has-frame" property.
|
|
an AdgTable |
|
Returns : |
the current state |
guint adg_table_get_n_rows (AdgTable *table);
Gets the number of rows stored in table.
|
|
an AdgTable |
|
Returns : |
the number of rows or 0 on empty table or errors
|
AdgTableRow * adg_table_row_new (AdgTable *table);
Creates a new empty row and appends it at the end of the rows
yet present in table. By default, the height of this new
row will be the fallback value provided by the table style:
you can override it by using adg_table_row_set_height().
|
|
an AdgTable |
|
Returns : |
the newly created row or NULL on errors |
AdgTableRow * adg_table_row_new_before (AdgTableRow *row);
Creates a new empty row with default height and inserts it
just before row.
|
|
a valid AdgTableRow |
|
Returns : |
the newly created row or NULL on errors |
void adg_table_row_delete (AdgTableRow *row);
Removes row from its owner table and frees every resources allocated
by it. This means also the eventual cells owned by row will be freed.
|
|
a valid AdgTableRow |
guint adg_table_row_get_n_cells (const AdgTableRow *row);
Gets the number of cells stored in row.
|
|
a valid AdgTableRow |
|
Returns : |
the number of cells or 0 on empty row or errors |
void adg_table_row_set_height (AdgTableRow *row,
gdouble height);
Sets a new height on row. The extents will be invalidated to
recompute the whole layout of the table. Specifying 0 in
height will use the default height set in the table style.
|
|
a valid AdgTableRow |
|
|
the new height |
gdouble adg_table_row_get_height (AdgTableRow *row);
Gets the height of row.
|
|
a valid AdgTableRow |
|
Returns : |
the requested height or 0 on errors |
const CpmlExtents * adg_table_row_get_extents (AdgTableRow *row);
Gets the extents of row. This function is useful only after the
arrange() phase as in the other situation the extents will likely
be not up to date.
|
|
a valid AdgTableRow |
|
Returns : |
the extents of row or NULL on errors
|
AdgTableCell * adg_table_cell_new (AdgTableRow *row,
gdouble width);
Creates a new empty cell without a frame and appends it at the
end of the cells yet present in row. You can add content to the
cell by using adg_table_cell_set_title() and
adg_table_cell_set_value() or enable the frame with
adg_table_cell_switch_frame().
A positive width value specifies the width of this cell in global
space: if the width of its content (that is, either the title or the
value entity) will be greater than width, it will be rendered
outside the cell boundary box, luckely overwriting the adiacent
cells.
Using 0 as width means the width of the cell will be automatically
adjusted to the maximum width of its content.
Negative width values are not allowed: this condition will raise a warning without any further processing.
|
|
a valid AdgTableRow |
|
|
width of the cell |
|
Returns : |
the newly created cell or NULL on errors |
AdgTableCell * adg_table_cell_new_before (AdgTableCell *cell,
gdouble width);
Creates a new cell and inserts it rigthly before the cell cell.
This works similarily and accepts the same parameters as the
adg_table_cell_new() function.
|
|
a valid AdgTableCell |
|
|
width of the cell |
|
Returns : |
the newly created cell or NULL on errors |
AdgTableCell * adg_table_cell_new_full (AdgTableRow *row,
gdouble width,
const gchar *name,
const gchar *title,
const gchar *value);
A convenient function to append a framed cell to row with a
specific title and value text. The font to use for rendering
title and value will be picked up from the table style, so
be sure to have the correct table dress set before calling
this function.
row and width have the same meanings as in adg_table_cell_new():
check its documentation for details.
name is an optional identifier to univoquely access this cell
by using adg_table_cell(). The identifier must be univoque:
if there is yet a cell with the same name a warning message will
be raised and the function will fail.
|
|
a valid AdgTableRow |
|
|
width of the cell |
|
|
name to associate |
|
|
title to render |
|
|
value to render |
|
Returns : |
the newly created cell or NULL on errors |
AdgTableCell * adg_table_cell (AdgTable *table, const gchar *name);
Gets the cell named name inside table. Only named cells can be
retrieved by this method.
|
|
an AdgTable |
|
|
the name of a cell |
|
Returns : |
the requested cell or NULL if not found |
void adg_table_cell_delete (AdgTableCell *cell);
Deletes cell removing it from the container row and freeing
any resource associated to it.
|
|
a valid AdgTableCell |
void adg_table_cell_set_name (AdgTableCell *cell,
const gchar *name);
Sets a new name on cell: this will allow to access cell by
name at a later time using the adg_table_cell() API.
|
|
a valid AdgTableCell |
|
|
the new name of cell
|
const gchar * adg_table_cell_get_name (AdgTableCell *cell);
Gets the name assigned to cell. This function is highly inefficient
as the cell names are stored in a hash table optimized to get a cell
from a name. Getting the name from a cell involves a full hash table
inspection.
|
|
a valid AdgTableCell |
|
Returns : |
the name bound of cell or NULL on no name or errors
|
void adg_table_cell_set_title (AdgTableCell *cell,
AdgEntity *title);
Sets title as the new title entity of cell. The top left
corner of the bounding box of title will be cohincident to
the top left corner of the cell extents, taking into accounts
eventual padding spaces specified by the table style.
The old internal entity is unrefenrenced while the title (if
not NULL) is refenenced with g_object_ref_sink().
title can be NULL, in which case the old entity is removed.
|
|
a valid AdgTableCell |
|
|
the new title entity |
void adg_table_cell_set_text_title (AdgTableCell *cell,
const gchar *title);
Convenient function to set a the title of a cell using an AdgToyText
entity with the font dress picked from "table-dress" with
a call to adg_table_style_get_title_dress().
|
|
a valid AdgTableCell |
|
|
a text string |
AdgEntity * adg_table_cell_title (AdgTableCell *cell);
Gets the current title of cell. The returned string is owned
by cell and must not be modified or freed.
|
|
a valid AdgTableCell |
|
Returns : |
the title entity or NULL for undefined title |
void adg_table_cell_set_value (AdgTableCell *cell,
AdgEntity *value);
Sets value as the new value entity of cell. The bottom middle
point of the bounding box of value will be cohincident to the
bottom middle point of the cell extents, taking into accounts
eventual padding spaces specified by the table style.
The old internal entity is unrefenrenced while the value (if
not NULL) is refenenced with g_object_ref_sink().
value can be NULL, in which case the old entity is removed.
|
|
a valid AdgTableCell |
|
|
the new value entity |
void adg_table_cell_set_text_value (AdgTableCell *cell,
const gchar *value);
Convenient function to set a the value of a cell using an AdgToyText
entity with a value font dress picked from "table-dress" with
a call to adg_table_style_get_value_dress().
|
|
a valid AdgTableCell |
|
|
a text string |
AdgEntity * adg_table_cell_value (AdgTableCell *cell);
Gets the current value of cell. The returned string is owned
by cell and must not be modified or freed.
|
|
a valid AdgTableCell |
|
Returns : |
the value entity or NULL for undefined value |
void adg_table_cell_set_value_pos (AdgTableCell *cell,
const AdgPair *from_factor,
const AdgPair *to_factor);
Sets a new custom position for the value entity of cell. The
from_factor specifies the source point (as a fraction of the
value extents) while the to_factor is the destination point
(specified as a fraction of the cell extents) the source point
must be moved to.
|
|
a valid AdgTableCell |
|
|
the alignment factor on the value entity |
|
|
the alignment factor on the cell |
void adg_table_cell_set_value_pos_explicit
(AdgTableCell *cell,
gdouble from_x,
gdouble from_y,
gdouble to_x,
gdouble to_y);
A convenient wrapper around adg_table_cell_set_value_pos()
that uses explicit factors instead of AdgPair.
|
|
a valid AdgTableCell |
|
|
the x alignment factor on the entity |
|
|
the y alignment factor on the entity |
|
|
the x alignment factor on the cell |
|
|
the y alignment factor on the cell |
void adg_table_cell_set_width (AdgTableCell *cell,
gdouble width);
Sets a new width on cell. The extents on the whole table
will be invalidated, so will be recomputed in the next
arrange() phase.
|
|
a valid AdgTableCell |
|
|
the new width |
gdouble adg_table_cell_get_width (AdgTableCell *cell);
Gets the width of cell.
|
|
a valid AdgTableCell |
|
Returns : |
the requested width or 0 on errors |
void adg_table_cell_switch_frame (AdgTableCell *cell,
gboolean new_state);
Sets the frame flag of cell: if new_state is TRUE, a frame around
cell will be rendered using the "cell-dress" dress
of the table style.
|
|
a valid AdgTableCell |
|
|
the new frame state |
gboolean adg_table_cell_has_frame (AdgTableCell *cell);
Gets the frame flag of cell.
|
|
a valid AdgTableCell |
|
Returns : |
the frame flag |
const CpmlExtents * adg_table_cell_get_extents (AdgTableCell *cell);
Gets the extents of cell. This function is useful only after the
arrange() phase as in the other situation the extents will likely
be not up to date.
|
|
a valid AdgTableCell |
|
Returns : |
the extents of cell or NULL on errors
|
"has-frame" property"has-frame" gboolean : Read / Write
If enabled, a frame using the proper dress found in this table style will be drawn around the table extents.
Default value: TRUE
"table-dress" property"table-dress" AdgDress : Read / Write
The dress to use for stroking this entity.
Allowed values: [G_MAXINT,G_MININT]
Default value: 0