static void table_set_spacing (HTMLEngine *e, HTMLTable *t, gint spacing, gboolean relative, HTMLUndoDirection dir) { HTMLTableSetAttrUndo *undo; gint new_spacing; if (!t || !HTML_IS_TABLE (t)) return; if (relative) new_spacing = t->spacing + spacing; else new_spacing = spacing; if (new_spacing < 0) new_spacing = 0; if (new_spacing == t->spacing) return; undo = attr_undo_new (HTML_TABLE_SPACING); undo->attr.spacing = t->spacing; html_undo_add_action (e->undo, e, html_undo_action_new ("Set table spacing", table_set_spacing_undo_action, HTML_UNDO_DATA (undo), html_cursor_get_position (e->cursor), html_cursor_get_position (e->cursor)), dir); t->spacing = new_spacing; html_object_change_set (HTML_OBJECT (t), HTML_CHANGE_ALL_CALC); html_engine_schedule_update (e); }
static void table_set_bg_color (HTMLEngine *e, HTMLTable *t, GdkColor *c, HTMLUndoDirection dir) { HTMLTableSetAttrUndo *undo; undo = attr_undo_new (HTML_TABLE_BGCOLOR); if (t->bgColor) { undo->attr.color.color = *t->bgColor; undo->attr.color.has_bg_color = TRUE; } else undo->attr.color.has_bg_color = FALSE; html_undo_add_action (e->undo, e, html_undo_action_new ("Set table background color", table_set_bg_color_undo_action, HTML_UNDO_DATA (undo), html_cursor_get_position (e->cursor), html_cursor_get_position (e->cursor)), dir); if (c) { if (!t->bgColor) t->bgColor = gdk_color_copy (c); *t->bgColor = *c; } else { if (t->bgColor) gdk_color_free (t->bgColor); t->bgColor = NULL; } html_engine_queue_draw (e, HTML_OBJECT (t)); }
static void insert_row_setup_undo (HTMLEngine *e, gint row, guint position_before, HTMLUndoDirection dir) { html_undo_add_action (e->undo, e, html_undo_action_new ("Insert table row", insert_row_undo_action, insert_undo_data_new (row), html_cursor_get_position (e->cursor), html_cursor_get_position (e->cursor)), dir); }
inline HTMLInterval * html_interval_new_from_cursor (HTMLCursor *a, HTMLCursor *b) { HTMLCursor *begin, *end; if (html_cursor_get_position (a) < html_cursor_get_position (b)) { begin = a; end = b; } else { begin = b; end = a; } return html_interval_new (begin->object, end->object, begin->offset, end->offset); }
static void table_set_align (HTMLEngine *e, HTMLTable *t, HTMLHAlignType align, HTMLUndoDirection dir) { HTMLTableSetAttrUndo *undo; /* table gone */ if (!t) return; g_return_if_fail (HTML_OBJECT (t)->parent); undo = attr_undo_new (HTML_TABLE_ALIGN); undo->attr.align = HTML_CLUE (HTML_OBJECT (t)->parent)->halign; if (align == HTML_HALIGN_NONE || align == HTML_HALIGN_CENTER) { if (HTML_IS_CLUEALIGNED (HTML_OBJECT (t)->parent)) { HTMLObject *aclue = HTML_OBJECT (t)->parent; html_clue_remove (HTML_CLUE (aclue), HTML_OBJECT (t)); html_clue_append_after (HTML_CLUE (aclue->parent), HTML_OBJECT (t), aclue); html_clue_remove (HTML_CLUE (aclue->parent), aclue); html_object_destroy (aclue); } } else if (align == HTML_HALIGN_LEFT || align == HTML_HALIGN_RIGHT) { if (HTML_IS_CLUEFLOW (HTML_OBJECT (t)->parent)) { HTMLObject *aclue, *flow = HTML_OBJECT (t)->parent; html_clue_remove (HTML_CLUE (flow), HTML_OBJECT (t)); aclue = html_cluealigned_new (NULL, 0, 0, flow->max_width, 100); html_clue_append (HTML_CLUE (flow), aclue); html_clue_append (HTML_CLUE (aclue), HTML_OBJECT (t)); } } else g_assert_not_reached (); html_undo_add_action (e->undo, e, html_undo_action_new ("Set table align", table_set_align_undo_action, HTML_UNDO_DATA (undo), html_cursor_get_position (e->cursor), html_cursor_get_position (e->cursor)), dir); HTML_CLUE (HTML_OBJECT (t)->parent)->halign = align; html_object_change_set (HTML_OBJECT (t)->parent, HTML_CHANGE_ALL_CALC); html_engine_schedule_update (e); }
static void table_set_padding (HTMLEngine *e, HTMLTable *t, gint padding, gboolean relative, HTMLUndoDirection dir) { HTMLTableSetAttrUndo *undo; gint r, c; gint new_padding; if (!t || !HTML_IS_TABLE (t)) return; if (relative) new_padding = t->padding + padding; else new_padding = padding; if (new_padding < 0) new_padding = 0; if (new_padding == t->padding) return; undo = attr_undo_new (HTML_TABLE_PADDING); undo->attr.padding = t->padding; html_undo_add_action (e->undo, e, html_undo_action_new ("Set table padding", table_set_padding_undo_action, HTML_UNDO_DATA (undo), html_cursor_get_position (e->cursor), html_cursor_get_position (e->cursor)), dir); t->padding = new_padding; for (r = 0; r < t->totalRows; r++) for (c = 0; c < t->totalCols; c++) if (t->cells[r][c]->col == c && t->cells[r][c]->row == r) { HTML_CLUEV (t->cells[r][c])->padding = new_padding; HTML_OBJECT (t->cells[r][c])->change |= HTML_CHANGE_ALL_CALC; } html_object_change_set (HTML_OBJECT (t), HTML_CHANGE_ALL_CALC); html_engine_schedule_update (e); }
static void insert_column_setup_undo (HTMLEngine *e, gint col, guint position_before, HTMLUndoDirection dir) { html_undo_add_action (e->undo, e, html_undo_action_new ("Insert table column", insert_column_undo_action, insert_undo_data_new (col), html_cursor_get_position (e->cursor), position_before), dir); }
static void table_set_bg_pixmap (HTMLEngine *e, HTMLTable *t, gchar *url, HTMLUndoDirection dir) { HTMLImagePointer *iptr; HTMLTableSetAttrUndo *undo; undo = attr_undo_new (HTML_TABLE_BGPIXMAP); undo->attr.pixmap = t->bgPixmap ? g_strdup (t->bgPixmap->url) : NULL; html_undo_add_action (e->undo, e, html_undo_action_new ("Set table background pixmap", table_set_bg_pixmap_undo_action, HTML_UNDO_DATA (undo), html_cursor_get_position (e->cursor), html_cursor_get_position (e->cursor)), dir); iptr = t->bgPixmap; t->bgPixmap = url ? html_image_factory_register (e->image_factory, NULL, url, TRUE) : NULL; if (iptr) html_image_factory_unregister (e->image_factory, iptr, NULL); html_engine_queue_draw (e, HTML_OBJECT (t)); }
static void delete_row_setup_undo (HTMLEngine *e, HTMLTableCell **row_cells, gint size, guint position_after, gint row, HTMLUndoDirection dir) { html_undo_add_action (e->undo, e, html_undo_action_new ("Delete table row", delete_row_undo_action, HTML_UNDO_DATA (delete_cells_undo_new (row_cells, size, row)), html_cursor_get_position (e->cursor), position_after), dir); }
static void delete_column_setup_undo (HTMLEngine *e, HTMLTableCell **column, gint size, guint position_after, gint col, HTMLUndoDirection dir) { html_undo_add_action (e->undo, e, html_undo_action_new ("Delete table column", delete_column_undo_action, HTML_UNDO_DATA (delete_cells_undo_new (column, size, col)), html_cursor_get_position (e->cursor), position_after), dir); }
static void table_set_border_width (HTMLEngine *e, HTMLTable *t, gint border_width, gboolean relative, HTMLUndoDirection dir) { HTMLTableSetAttrUndo *undo; gint new_border; if (!t || !HTML_IS_TABLE (t)) return; if (relative) new_border = t->border + border_width; else new_border = border_width; if (new_border < 0) new_border = 0; if (new_border == t->border) return; undo = attr_undo_new (HTML_TABLE_BORDER); undo->attr.border = t->border; html_engine_freeze (e); t->border = new_border; html_object_change_set (HTML_OBJECT (t), HTML_CHANGE_ALL_CALC); html_engine_thaw (e); html_undo_add_action (e->undo, e, html_undo_action_new ("Set table border width", table_set_border_width_undo_action, HTML_UNDO_DATA (undo), html_cursor_get_position (e->cursor), html_cursor_get_position (e->cursor)), dir); }
static void table_set_width (HTMLEngine *e, HTMLTable *t, gint width, gboolean percent, HTMLUndoDirection dir) { HTMLTableSetAttrUndo *undo; undo = attr_undo_new (HTML_TABLE_WIDTH); undo->attr.width.width = HTML_OBJECT (t)->percent ? HTML_OBJECT (t)->percent : (HTML_OBJECT (t)->flags & HTML_OBJECT_FLAG_FIXEDWIDTH ? t->specified_width : 0); undo->attr.width.percent = HTML_OBJECT (t)->percent != 0; html_undo_add_action (e->undo, e, html_undo_action_new ("Set table width", table_set_width_undo_action, HTML_UNDO_DATA (undo), html_cursor_get_position (e->cursor), html_cursor_get_position (e->cursor)), dir); if (percent) { HTML_OBJECT (t)->percent = width; HTML_OBJECT (t)->flags &= ~ HTML_OBJECT_FLAG_FIXEDWIDTH; t->specified_width = 0; } else { HTML_OBJECT (t)->percent = 0; t->specified_width = width; if (width) HTML_OBJECT (t)->flags |= HTML_OBJECT_FLAG_FIXEDWIDTH; else HTML_OBJECT (t)->flags &= ~ HTML_OBJECT_FLAG_FIXEDWIDTH; } html_object_change_set (HTML_OBJECT (t), HTML_CHANGE_ALL_CALC); html_engine_schedule_update (e); }