Commit aca66eeb authored by Almer S. Tigelaar's avatar Almer S. Tigelaar Committed by Almer S. Tigelaar

Add shrink flag. (cb_autofit_height_no_shrink): Callback function for new

2001-05-14  Almer S. Tigelaar  <almer@gnome.org>

	* src/colrow.c (rows_height_update): Add shrink flag.
	(cb_autofit_height_no_shrink): Callback function for new
	autofit without shrinking functionality.

	* src/commands.c (cmd_paste_cut_redo): Adjust for change
	to rows_height_update.
	(cmd_paste_copy_undo): Idem.
	(cmd_autoformat_undo): Idem.
	(cmd_format_undo): Idem.

	* src/clipboard.c (clipboard_paste_region): Idem.

	* src/sheet.c (sheet_clear_region): Idem.
	(sheet_apply_style): Idem.
parent f1eb6bf6
2001-05-14 Almer S. Tigelaar <almer@gnome.org>
* src/colrow.c (rows_height_update): Add shrink flag.
(cb_autofit_height_no_shrink): Callback function for new
autofit without shrinking functionality.
* src/commands.c (cmd_paste_cut_redo): Adjust for change
to rows_height_update.
(cmd_paste_copy_undo): Idem.
(cmd_autoformat_undo): Idem.
(cmd_format_undo): Idem.
* src/clipboard.c (clipboard_paste_region): Idem.
* src/sheet.c (sheet_clear_region): Idem.
(sheet_apply_style): Idem.
2001-05-14 Almer S. Tigelaar <almer@gnome.org>
* src/commands.c (cmd_paste_copy_impl): New, contains
......
2001-05-14 Almer S. Tigelaar <almer@gnome.org>
* src/colrow.c (rows_height_update): Add shrink flag.
(cb_autofit_height_no_shrink): Callback function for new
autofit without shrinking functionality.
* src/commands.c (cmd_paste_cut_redo): Adjust for change
to rows_height_update.
(cmd_paste_copy_undo): Idem.
(cmd_autoformat_undo): Idem.
(cmd_format_undo): Idem.
* src/clipboard.c (clipboard_paste_region): Idem.
* src/sheet.c (sheet_clear_region): Idem.
(sheet_apply_style): Idem.
2001-05-14 Almer S. Tigelaar <almer@gnome.org>
* src/commands.c (cmd_paste_copy_impl): New, contains
......
2001-05-14 Almer S. Tigelaar <almer@gnome.org>
* src/colrow.c (rows_height_update): Add shrink flag.
(cb_autofit_height_no_shrink): Callback function for new
autofit without shrinking functionality.
* src/commands.c (cmd_paste_cut_redo): Adjust for change
to rows_height_update.
(cmd_paste_copy_undo): Idem.
(cmd_autoformat_undo): Idem.
(cmd_format_undo): Idem.
* src/clipboard.c (clipboard_paste_region): Idem.
* src/sheet.c (sheet_clear_region): Idem.
(sheet_apply_style): Idem.
2001-05-14 Almer S. Tigelaar <almer@gnome.org>
* src/commands.c (cmd_paste_copy_impl): New, contains
......
2001-05-14 Almer S. Tigelaar <almer@gnome.org>
* src/colrow.c (rows_height_update): Add shrink flag.
(cb_autofit_height_no_shrink): Callback function for new
autofit without shrinking functionality.
* src/commands.c (cmd_paste_cut_redo): Adjust for change
to rows_height_update.
(cmd_paste_copy_undo): Idem.
(cmd_autoformat_undo): Idem.
(cmd_format_undo): Idem.
* src/clipboard.c (clipboard_paste_region): Idem.
* src/sheet.c (sheet_clear_region): Idem.
(sheet_apply_style): Idem.
2001-05-14 Almer S. Tigelaar <almer@gnome.org>
* src/commands.c (cmd_paste_copy_impl): New, contains
......
2001-05-14 Almer S. Tigelaar <almer@gnome.org>
* src/colrow.c (rows_height_update): Add shrink flag.
(cb_autofit_height_no_shrink): Callback function for new
autofit without shrinking functionality.
* src/commands.c (cmd_paste_cut_redo): Adjust for change
to rows_height_update.
(cmd_paste_copy_undo): Idem.
(cmd_autoformat_undo): Idem.
(cmd_format_undo): Idem.
* src/clipboard.c (clipboard_paste_region): Idem.
* src/sheet.c (sheet_clear_region): Idem.
(sheet_apply_style): Idem.
2001-05-14 Almer S. Tigelaar <almer@gnome.org>
* src/commands.c (cmd_paste_copy_impl): New, contains
......
......@@ -435,7 +435,7 @@ clipboard_paste_region (WorkbookControl *wbc,
sheet_flag_format_update_range (pt->sheet, &pt->range);
if (pt->paste_flags & PASTE_UPDATE_ROW_HEIGHT)
rows_height_update (pt->sheet, &pt->range);
rows_height_update (pt->sheet, &pt->range, FALSE);
return FALSE;
}
......
......@@ -507,23 +507,43 @@ cb_autofit_height (ColRowInfo *info, void *sheet)
return FALSE;
}
static gboolean
cb_autofit_height_no_shrink (ColRowInfo *info, void *sheet)
{
/* If the size was not set by the user then auto resize */
if (!info->hard_size) {
int const new_size = sheet_row_size_fit_pixels (sheet, info->pos);
int const default_size = sheet_row_get_default_size_pixels (sheet);
if (new_size > 0 && new_size > default_size)
sheet_row_set_size_pixels (sheet, info->pos, new_size, FALSE);
}
return FALSE;
}
/**
* rows_height_update
* @sheet: The sheet,
* @range: The range whose rows should be resized.
* @shrink: If set to FALSE, rows will never shrink!
*
* Use this function having changed the font size to auto
* resize the row heights to make the text fit nicely.
**/
void
rows_height_update (Sheet *sheet, Range const * range)
rows_height_update (Sheet *sheet, Range const * range, gboolean shrink)
{
/* FIXME : this needs to check font sizes and contents rather than
* just contents. Empty cells will cause resize also
*/
colrow_foreach (&sheet->rows, range->start.row, range->end.row,
&cb_autofit_height, sheet);
if (shrink)
colrow_foreach (&sheet->rows, range->start.row, range->end.row,
&cb_autofit_height, sheet);
else
colrow_foreach (&sheet->rows, range->start.row, range->end.row,
&cb_autofit_height_no_shrink, sheet);
}
/*****************************************************************************/
struct colrow_visiblity
......
......@@ -102,6 +102,7 @@ void colrow_set_visibility_list (Sheet *sheet, gboolean is_col,
int colrow_find_adjacent_visible (Sheet *sheet, gboolean const is_col,
int const index, gboolean forward);
void rows_height_update (Sheet *sheet, Range const *range);
void rows_height_update (Sheet *sheet, Range const *range,
gboolean shrink);
#endif /* GNUMERIC_COLROW_H */
......@@ -1380,7 +1380,7 @@ cmd_format_undo (GnumericCommand *cmd, WorkbookControl *wbc)
r = l2->data;
sheet_range_calc_spans (me->sheet, *r, flags);
if (flags != SPANCALC_SIMPLE)
rows_height_update (me->sheet, r);
rows_height_update (me->sheet, r, TRUE);
sheet_flag_format_update_range (me->sheet, r);
}
}
......@@ -2320,7 +2320,7 @@ cmd_paste_cut_redo (GnumericCommand *cmd, WorkbookControl *wbc)
/* Backup row heights and adjust row heights to fit */
me->saved_sizes = colrow_save_sizes (me->info.target_sheet, FALSE, tmp.start.row, tmp.end.row);
rows_height_update (me->info.target_sheet, &tmp);
rows_height_update (me->info.target_sheet, &tmp, FALSE);
/* Make sure the destination is selected */
if (me->move_selection)
......@@ -2465,7 +2465,7 @@ cmd_paste_copy_impl (GnumericCommand *cmd, WorkbookControl *wbc,
} else {
me->saved_sizes = colrow_save_sizes (me->dst.sheet, FALSE, me->dst.range.start.row,
me->dst.range.end.row);
rows_height_update (me->dst.sheet, &me->dst.range);
rows_height_update (me->dst.sheet, &me->dst.range, FALSE);
}
me->content = content;
......@@ -2759,7 +2759,7 @@ cmd_autoformat_undo (GnumericCommand *cmd, WorkbookControl *wbc)
r = l2->data;
sheet_range_calc_spans (me->sheet, *r, flags);
if (flags != SPANCALC_SIMPLE)
rows_height_update (me->sheet, r);
rows_height_update (me->sheet, r, TRUE);
}
}
......
......@@ -456,7 +456,7 @@ sheet_apply_style (Sheet *sheet,
sheet_range_calc_spans (sheet, *range, spanflags);
if (spanflags != SPANCALC_SIMPLE)
rows_height_update (sheet, range);
rows_height_update (sheet, range, TRUE);
sheet_redraw_range (sheet, range);
}
......@@ -2858,7 +2858,7 @@ sheet_clear_region (WorkbookControl *wbc, Sheet *sheet,
if (clear_flags & CLEAR_FORMATS) {
sheet_style_set_range (sheet, &r, sheet_style_default (sheet));
sheet_range_calc_spans (sheet, r, SPANCALC_RE_RENDER|SPANCALC_RESIZE);
rows_height_update (sheet, &r);
rows_height_update (sheet, &r, TRUE);
}
if (clear_flags & CLEAR_COMMENTS) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment