AdgTable

AdgTable — A tabular entity

Synopsis

                    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);

Object Hierarchy

  GObject
   +----GInitiallyUnowned
         +----AdgEntity
               +----AdgTable
                     +----AdgTitleBlock

Properties

  "has-frame"                gboolean              : Read / Write
  "table-dress"              AdgDress              : Read / Write

Description

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).

Details

AdgTableCell

typedef struct _AdgTableCell AdgTableCell;

An opaque structure referring to the cell of an AdgTableRow. Any row can have an unlimited number of cells.


AdgTableRow

typedef struct _AdgTableRow AdgTableRow;

An opaque structure referring to a row of an AdgTable. Any table can have an unlimited number of rows.


AdgTable

typedef struct _AdgTable AdgTable;

All fields are private and should not be used directly. Use its public methods instead.


adg_table_new ()

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

adg_table_set_table_dress ()

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.

table :

an AdgTable

dress :

the new AdgDress to use

adg_table_get_table_dress ()

AdgDress            adg_table_get_table_dress           (AdgTable *table);

Gets the table dress to be used in rendering table.

table :

an AdgTable

Returns :

the current table dress

adg_table_switch_frame ()

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.

table :

an AdgTable

new_state :

the new state of the frame

adg_table_has_frame ()

gboolean            adg_table_has_frame                 (AdgTable *table);

Returns the state of the "has-frame" property.

table :

an AdgTable

Returns :

the current state

adg_table_get_n_rows ()

guint               adg_table_get_n_rows                (AdgTable *table);

Gets the number of rows stored in table.

table :

an AdgTable

Returns :

the number of rows or 0 on empty table or errors

adg_table_row_new ()

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().

table :

an AdgTable

Returns :

the newly created row or NULL on errors

adg_table_row_new_before ()

AdgTableRow *       adg_table_row_new_before            (AdgTableRow *row);

Creates a new empty row with default height and inserts it just before row.

row :

a valid AdgTableRow

Returns :

the newly created row or NULL on errors

adg_table_row_delete ()

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.

row :

a valid AdgTableRow

adg_table_row_get_n_cells ()

guint               adg_table_row_get_n_cells           (const AdgTableRow *row);

Gets the number of cells stored in row.

row :

a valid AdgTableRow

Returns :

the number of cells or 0 on empty row or errors

adg_table_row_set_height ()

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.

row :

a valid AdgTableRow

height :

the new height

adg_table_row_get_height ()

gdouble             adg_table_row_get_height            (AdgTableRow *row);

Gets the height of row.

row :

a valid AdgTableRow

Returns :

the requested height or 0 on errors

adg_table_row_get_extents ()

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.

row :

a valid AdgTableRow

Returns :

the extents of row or NULL on errors

adg_table_cell_new ()

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.

row :

a valid AdgTableRow

width :

width of the cell

Returns :

the newly created cell or NULL on errors

adg_table_cell_new_before ()

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.

cell :

a valid AdgTableCell

width :

width of the cell

Returns :

the newly created cell or NULL on errors

adg_table_cell_new_full ()

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.

row :

a valid AdgTableRow

width :

width of the cell

name :

name to associate

title :

title to render

value :

value to render

Returns :

the newly created cell or NULL on errors

adg_table_cell ()

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.

table :

an AdgTable

name :

the name of a cell

Returns :

the requested cell or NULL if not found

adg_table_cell_delete ()

void                adg_table_cell_delete               (AdgTableCell *cell);

Deletes cell removing it from the container row and freeing any resource associated to it.

cell :

a valid AdgTableCell

adg_table_cell_set_name ()

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.

cell :

a valid AdgTableCell

name :

the new name of cell

adg_table_cell_get_name ()

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.

cell :

a valid AdgTableCell

Returns :

the name bound of cell or NULL on no name or errors

adg_table_cell_set_title ()

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.

cell :

a valid AdgTableCell

title :

the new title entity

adg_table_cell_set_text_title ()

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().

cell :

a valid AdgTableCell

title :

a text string

adg_table_cell_title ()

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.

cell :

a valid AdgTableCell

Returns :

the title entity or NULL for undefined title

adg_table_cell_set_value ()

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.

cell :

a valid AdgTableCell

value :

the new value entity

adg_table_cell_set_text_value ()

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().

cell :

a valid AdgTableCell

value :

a text string

adg_table_cell_value ()

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.

cell :

a valid AdgTableCell

Returns :

the value entity or NULL for undefined value

adg_table_cell_set_value_pos ()

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.

cell :

a valid AdgTableCell

from_factor :

the alignment factor on the value entity

to_factor :

the alignment factor on the cell

adg_table_cell_set_value_pos_explicit ()

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.

cell :

a valid AdgTableCell

from_x :

the x alignment factor on the entity

from_y :

the y alignment factor on the entity

to_x :

the x alignment factor on the cell

to_y :

the y alignment factor on the cell

adg_table_cell_set_width ()

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.

cell :

a valid AdgTableCell

width :

the new width

adg_table_cell_get_width ()

gdouble             adg_table_cell_get_width            (AdgTableCell *cell);

Gets the width of cell.

cell :

a valid AdgTableCell

Returns :

the requested width or 0 on errors

adg_table_cell_switch_frame ()

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.

cell :

a valid AdgTableCell

new_state :

the new frame state

adg_table_cell_has_frame ()

gboolean            adg_table_cell_has_frame            (AdgTableCell *cell);

Gets the frame flag of cell.

cell :

a valid AdgTableCell

Returns :

the frame flag

adg_table_cell_get_extents ()

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.

cell :

a valid AdgTableCell

Returns :

the extents of cell or NULL on errors

Property Details

The "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


The "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

AdgTable was last modified by gtk-doc on Sun 20 Mar 2011 09:36:52 PM CET
Hosted by Get Automatic Drawing Generation at SourceForge.net. Fast, secure and Free Open Source software downloads
Search on this domain