Commit b6d04cff authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

Major rationalization of pts vs pixels and the use of margins.

Some redraw speedups and the addition of XL2000 style alpha bended selections.

2000-02-13  Jody Goldberg <jgoldberg@home.com>

	* ./src/sheet-view.c (sheet_view_redraw_cell_region) : redraw the
	  bounding grid lines too.

	* src/item-cursor.c (item_cursor_get_pixel_coords) : Clip the cursor
	  region to the visible range.  The layout still needs cleaning to
	  match the 'correct' way of implementing canvas-items, but this
	  heuristic saves us lots of iterations through the accumulator for
	  the size of the entire sheet.

2000-02-12  Jody Goldberg <jgoldberg@home.com>

	* src/gnumeric-sheet.c : Use visible flag and adjust to naming and
	  margin changes.

	* src/item-bar.c (colrow_tip_setlabel) : Use the format provided by
	  XL2000.  Things are correct for rows, colwidth are quoted in pts
	  rather than char widths.
	(get_col_from_pos) : Use visible flag.
	(item_bar_start_resize) : Function renaming.
	(is_pointer_on_division) : Ditto.
	(item_bar_draw) : Changes to margins.

	* src/item-edit.c : Function renaming.
	* src/item-cursor.c : Ditto.  decrease spacing for auto handle.

	* src/item-grid.c (item_grid_draw) : Remove inversion process for the
	  selection.  Instead have the cells draw their background
	  differently.  Use the visible flag.
	(item_grid_paint_empty_cell) : Ditto.
	(item_grid_paint_cell) : Ditto.

	* src/mstyle.c (mstyle_new_default) : The default vert alignment is BOTTOM.

	* src/pattern.c (gnumeric_background_set_gc) : Draw the background of
	  a selected cell differently.

	* src/print-cell.c (DIM) : margins are already included.
	(print_cell_text) : Adjust argument order to more closely match
	  cell_draw.  Add support for vertical alignment of 1 line cells.
	  Invert control of single vs multiple lines.
	(print_cell) : Adjust to changes in the arguments.
	(print_cell_range) : Use the visible flag.
	  Draw line at the boundary rather than pretending there were
	  additional rows/cols.

	* src/print.c (compute_groups) : size_pts INCLUDES margins.  Use 'visible' flag.
	(print_page) : Adjust to function renaming.
	(print_range_used_units) : Ditto.

	* src/selection.c : Include sheet-view directly for now.
	(cb_set_row_height) : Adjust to function renaming.

	* src/sheet-view.c (sheet_view_redraw_cell_region) : Adjust to function
	  renaming.
	(sheet_view_redraw_headers) : Ditto.
	(sheet_view_set_zoom_factor) : Ditto.
	(sheet_view_col_size_changed) : Ditto.
	(sheet_view_row_size_changed) : Ditto.
	(sheet_view_comment_get_points) : Ditto.

	* src/sheet.[ch] : Rationalize function names, and add glossary.
	Make the use of margins and sizes (in points and pixels) consistant.

	(sheet_col_get_external_width : Delete.
	(sheet_row_get_external_height : Delete.
	(sheet_col_get_distance : Rename sheet_col_get_distance_pixels.
	(sheet_row_get_distance : Rename sheet_row_get_distance_pixels.
	(sheet_row_get_unit_distance : Rename sheet_row_get_distance_pts.
	(sheet_col_get_unit_distance : Rename sheet_col_get_distance_pts.
	(sheet_col_set_width : Rename sheet_col_set_size_pixels.
	(sheet_col_set_width_units : Rename sheet_col_set_size_pts.
	(sheet_row_set_height : Rename sheet_row_set_size_pixels.
	(sheet_row_set_height_units) : Rename sheet_row_set_size_pts.
	(sheet_get_default_external_col_width) : Rename sheet_col_get_default_size_pts.
	(sheet_get_default_external_row_height): Rename sheet_row_get_default_size_pts.
	(sheet_col_set_internal_width) : sheet_col_set_internal_size_pts.
	(sheet_row_set_internal_height): sheet_row_set_internal_size_pts.
	(sheet_{row,col}_set_default_size_pts) : New functions.

	(sheet_init_default_styles) : Tune to match XL defaults.

	* src/sort.c : Use g_strcasecmp, and include <stdlib.h>

	* src/style.c (style_color_new) : Init the selection colour as a 50%
	  alpha blend with lavender.

	* src/style.h : Change default font to be Helvetica 9 because it will
	  scale better when the standard 96 dpi resolution is assumed.
	  Add a selected_color to StyleColor.

	* src/value-sheet.c : Include <gnome.h> to get the
	  internationalization support.

	* src/workbook-cmd-format.c (workbook_cmd_format_column_auto_fit) :
	  sheet_col_set_width -> sheet_col_set_size_pixels.
	(workbook_cmd_format_column_width) :
	  sheet_col_set_width_units -> sheet_col_set_size_pts.
	(workbook_cmd_format_row_auto_fit) :
          sheet_row_set_height -> sheet_row_set_size_pixels
	(workbook_cmd_format_row_height) :
	  sheet_row_set_height_units -> sheet_row_set_size_pts.

	* src/xml-io.c (xml_read_rows_info) : Rename
	  sheet_row_set_height_units -> sheet_row_set_size_pts.
	(xml_read_cols_info) : Rename
	  sheet_col_set_height_units -> sheet_col_set_size_pts.
	(xml_read_colrow_info) : Remove hack with negative pixels.
	  Use 'visible' flag instead.
	(xml_write_colrow_info) : Ditto.
parent 8484b94b
2000-02-13 Jody Goldberg <jgoldberg@home.com>
* ./src/sheet-view.c (sheet_view_redraw_cell_region) : redraw the
bounding grid lines too.
* src/item-cursor.c (item_cursor_get_pixel_coords) : Clip the cursor
region to the visible range. The layout still needs cleaning to
match the 'correct' way of implementing canvas-items, but this
heuristic saves us lots of iterations through the accumulator for
the size of the entire sheet.
2000-02-12 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-sheet.c : Use visible flag and adjust to naming and
margin changes.
* src/item-bar.c (colrow_tip_setlabel) : Use the format provided by
XL2000. Things are correct for rows, colwidth are quoted in pts
rather than char widths.
(get_col_from_pos) : Use visible flag.
(item_bar_start_resize) : Function renaming.
(is_pointer_on_division) : Ditto.
(item_bar_draw) : Changes to margins.
* src/item-edit.c : Function renaming.
* src/item-cursor.c : Ditto. decrease spacing for auto handle.
* src/item-grid.c (item_grid_draw) : Remove inversion process for the
selection. Instead have the cells draw their background
differently. Use the visible flag.
(item_grid_paint_empty_cell) : Ditto.
(item_grid_paint_cell) : Ditto.
* src/mstyle.c (mstyle_new_default) : The default vert alignment is BOTTOM.
* src/pattern.c (gnumeric_background_set_gc) : Draw the background of
a selected cell differently.
* src/print-cell.c (DIM) : margins are already included.
(print_cell_text) : Adjust argument order to more closely match
cell_draw. Add support for vertical alignment of 1 line cells.
Invert control of single vs multiple lines.
(print_cell) : Adjust to changes in the arguments.
(print_cell_range) : Use the visible flag.
Draw line at the boundary rather than pretending there were
additional rows/cols.
* src/print.c (compute_groups) : size_pts INCLUDES margins. Use 'visible' flag.
(print_page) : Adjust to function renaming.
(print_range_used_units) : Ditto.
* src/selection.c : Include sheet-view directly for now.
(cb_set_row_height) : Adjust to function renaming.
* src/sheet-view.c (sheet_view_redraw_cell_region) : Adjust to function
renaming.
(sheet_view_redraw_headers) : Ditto.
(sheet_view_set_zoom_factor) : Ditto.
(sheet_view_col_size_changed) : Ditto.
(sheet_view_row_size_changed) : Ditto.
(sheet_view_comment_get_points) : Ditto.
* src/sheet.[ch] : Rationalize function names, and add glossary.
Make the use of margins and sizes (in points and pixels) consistant.
(sheet_col_get_external_width : Delete.
(sheet_row_get_external_height : Delete.
(sheet_col_get_distance : Rename sheet_col_get_distance_pixels.
(sheet_row_get_distance : Rename sheet_row_get_distance_pixels.
(sheet_row_get_unit_distance : Rename sheet_row_get_distance_pts.
(sheet_col_get_unit_distance : Rename sheet_col_get_distance_pts.
(sheet_col_set_width : Rename sheet_col_set_size_pixels.
(sheet_col_set_width_units : Rename sheet_col_set_size_pts.
(sheet_row_set_height : Rename sheet_row_set_size_pixels.
(sheet_row_set_height_units) : Rename sheet_row_set_size_pts.
(sheet_get_default_external_col_width) : Rename sheet_col_get_default_size_pts.
(sheet_get_default_external_row_height): Rename sheet_row_get_default_size_pts.
(sheet_col_set_internal_width) : sheet_col_set_internal_size_pts.
(sheet_row_set_internal_height): sheet_row_set_internal_size_pts.
(sheet_{row,col}_set_default_size_pts) : New functions.
(sheet_init_default_styles) : Tune to match XL defaults.
* src/sort.c : Use g_strcasecmp, and include <stdlib.h>
* src/style.c (style_color_new) : Init the selection colour as a 50%
alpha blend with lavender.
* src/style.h : Change default font to be Helvetica 9 because it will
scale better when the standard 96 dpi resolution is assumed.
Add a selected_color to StyleColor.
* src/value-sheet.c : Include <gnome.h> to get the
internationalization support.
* src/workbook-cmd-format.c (workbook_cmd_format_column_auto_fit) :
sheet_col_set_width -> sheet_col_set_size_pixels.
(workbook_cmd_format_column_width) :
sheet_col_set_width_units -> sheet_col_set_size_pts.
(workbook_cmd_format_row_auto_fit) :
sheet_row_set_height -> sheet_row_set_size_pixels
(workbook_cmd_format_row_height) :
sheet_row_set_height_units -> sheet_row_set_size_pts.
* src/xml-io.c (xml_read_rows_info) : Rename
sheet_row_set_height_units -> sheet_row_set_size_pts.
(xml_read_cols_info) : Rename
sheet_col_set_height_units -> sheet_col_set_size_pts.
(xml_read_colrow_info) : Remove hack with negative pixels.
Use 'visible' flag instead.
(xml_write_colrow_info) : Ditto.
2000-02-12 Gregory McLean <gregm@gnu.org>
* src/functions/fn-financial.c: Added documentation and examples.
......
2000-02-13 Jody Goldberg <jgoldberg@home.com>
* ./src/sheet-view.c (sheet_view_redraw_cell_region) : redraw the
bounding grid lines too.
* src/item-cursor.c (item_cursor_get_pixel_coords) : Clip the cursor
region to the visible range. The layout still needs cleaning to
match the 'correct' way of implementing canvas-items, but this
heuristic saves us lots of iterations through the accumulator for
the size of the entire sheet.
2000-02-12 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-sheet.c : Use visible flag and adjust to naming and
margin changes.
* src/item-bar.c (colrow_tip_setlabel) : Use the format provided by
XL2000. Things are correct for rows, colwidth are quoted in pts
rather than char widths.
(get_col_from_pos) : Use visible flag.
(item_bar_start_resize) : Function renaming.
(is_pointer_on_division) : Ditto.
(item_bar_draw) : Changes to margins.
* src/item-edit.c : Function renaming.
* src/item-cursor.c : Ditto. decrease spacing for auto handle.
* src/item-grid.c (item_grid_draw) : Remove inversion process for the
selection. Instead have the cells draw their background
differently. Use the visible flag.
(item_grid_paint_empty_cell) : Ditto.
(item_grid_paint_cell) : Ditto.
* src/mstyle.c (mstyle_new_default) : The default vert alignment is BOTTOM.
* src/pattern.c (gnumeric_background_set_gc) : Draw the background of
a selected cell differently.
* src/print-cell.c (DIM) : margins are already included.
(print_cell_text) : Adjust argument order to more closely match
cell_draw. Add support for vertical alignment of 1 line cells.
Invert control of single vs multiple lines.
(print_cell) : Adjust to changes in the arguments.
(print_cell_range) : Use the visible flag.
Draw line at the boundary rather than pretending there were
additional rows/cols.
* src/print.c (compute_groups) : size_pts INCLUDES margins. Use 'visible' flag.
(print_page) : Adjust to function renaming.
(print_range_used_units) : Ditto.
* src/selection.c : Include sheet-view directly for now.
(cb_set_row_height) : Adjust to function renaming.
* src/sheet-view.c (sheet_view_redraw_cell_region) : Adjust to function
renaming.
(sheet_view_redraw_headers) : Ditto.
(sheet_view_set_zoom_factor) : Ditto.
(sheet_view_col_size_changed) : Ditto.
(sheet_view_row_size_changed) : Ditto.
(sheet_view_comment_get_points) : Ditto.
* src/sheet.[ch] : Rationalize function names, and add glossary.
Make the use of margins and sizes (in points and pixels) consistant.
(sheet_col_get_external_width : Delete.
(sheet_row_get_external_height : Delete.
(sheet_col_get_distance : Rename sheet_col_get_distance_pixels.
(sheet_row_get_distance : Rename sheet_row_get_distance_pixels.
(sheet_row_get_unit_distance : Rename sheet_row_get_distance_pts.
(sheet_col_get_unit_distance : Rename sheet_col_get_distance_pts.
(sheet_col_set_width : Rename sheet_col_set_size_pixels.
(sheet_col_set_width_units : Rename sheet_col_set_size_pts.
(sheet_row_set_height : Rename sheet_row_set_size_pixels.
(sheet_row_set_height_units) : Rename sheet_row_set_size_pts.
(sheet_get_default_external_col_width) : Rename sheet_col_get_default_size_pts.
(sheet_get_default_external_row_height): Rename sheet_row_get_default_size_pts.
(sheet_col_set_internal_width) : sheet_col_set_internal_size_pts.
(sheet_row_set_internal_height): sheet_row_set_internal_size_pts.
(sheet_{row,col}_set_default_size_pts) : New functions.
(sheet_init_default_styles) : Tune to match XL defaults.
* src/sort.c : Use g_strcasecmp, and include <stdlib.h>
* src/style.c (style_color_new) : Init the selection colour as a 50%
alpha blend with lavender.
* src/style.h : Change default font to be Helvetica 9 because it will
scale better when the standard 96 dpi resolution is assumed.
Add a selected_color to StyleColor.
* src/value-sheet.c : Include <gnome.h> to get the
internationalization support.
* src/workbook-cmd-format.c (workbook_cmd_format_column_auto_fit) :
sheet_col_set_width -> sheet_col_set_size_pixels.
(workbook_cmd_format_column_width) :
sheet_col_set_width_units -> sheet_col_set_size_pts.
(workbook_cmd_format_row_auto_fit) :
sheet_row_set_height -> sheet_row_set_size_pixels
(workbook_cmd_format_row_height) :
sheet_row_set_height_units -> sheet_row_set_size_pts.
* src/xml-io.c (xml_read_rows_info) : Rename
sheet_row_set_height_units -> sheet_row_set_size_pts.
(xml_read_cols_info) : Rename
sheet_col_set_height_units -> sheet_col_set_size_pts.
(xml_read_colrow_info) : Remove hack with negative pixels.
Use 'visible' flag instead.
(xml_write_colrow_info) : Ditto.
2000-02-12 Gregory McLean <gregm@gnu.org>
* src/functions/fn-financial.c: Added documentation and examples.
......
This file is meant to hold a list of small tasks that need doing that would be
appropriate for new developers.
Description Difficulty Integration
------------------------------------------------------ ---------- -----------
- Dialog to change the order of sheets. Easy Low
......@@ -25,6 +28,9 @@ Description Difficulty Integration
- Add tooltips for colours in
src/widgets/widget-color-combo.c Low Low.
- Save/Restore the values of the last selected colours Low Low.
from the toolbar for background or font.
Difficulty: an estimate of how hard the task would be for the average hacker.
(This is not an estimate of project size; a project can be very big, but
......
2000-02-12 Jody Goldberg <jgoldberg@home.com>
* ms-excel-read.c (ms_excel_read_default_col_width) : Margins are
internal now.
(ms_excel_read_default_row_height) : Ditto.
(ms_excel_read_colinfo) : Ditto.
(ms_excel_read_row) : Adjust to changes in margins and step closer to
handling think margins.
* ms-excel-write.c (write_rowinfo) : Use the size_pts member directly.
(write_colinfos) :
* ms-obj.c (object_anchor_to_position) : Adjust to name and semantic
changes of size_pixels. Denominate things in pixels.
2000-02-06 Michael Meeks <michael@helixcode.com>
* ms-excel-read.c (ms_excel_read_workbook): Move failed sheet removal
......
......@@ -2460,7 +2460,7 @@ get_units_net_of_margins (double units, const ColRowInfo * cri)
/* Return an arbitary non 0 value on catastrophic failure */
g_return_val_if_fail (cri != NULL, 1.);
units -= (cri->margin_a + cri->margin_b);
units -= (cri->margin_a + cri->margin_b + 1);
if (units < 0)
units = 1.;
return units;
......@@ -2482,17 +2482,32 @@ ms_excel_read_row (BiffQuery *q, ExcelSheet *sheet)
guint16 const height = MS_OLE_GET_GUINT16(q->data+6);
guint16 const flags = MS_OLE_GET_GUINT16(q->data+12);
guint16 const xf = MS_OLE_GET_GUINT16(q->data+14) & 0xfff;
/* If the bit is on it indicates that the row is of 'standard' height.
* However the remaining bits still include the size.
*/
gboolean const is_std_height = (height & 0x8000) != 0;
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug > 1)
printf ("Row %d height 0x%x;\n", row+1, height);
#endif
if ((height & 0x8000) == 0) {
/* TODO : Set put mechanism in place to increase the margins */
/* TODO : sync the approach used for the columns with the row.
* columns actually set the size even when it is the default.
* Why ?
*/
/* TODO : We should store the default row style too.
* Which has precedence rows or cols ??
*/
if (!is_std_height) {
double hu = get_row_height_units (height);
/* Subtract margins */
hu = get_units_net_of_margins
(hu, sheet_row_get_info (sheet->gnum_sheet, row));
sheet_row_set_height_units (sheet->gnum_sheet, row, hu, TRUE);
sheet_row_set_size_pts (sheet->gnum_sheet, row, hu, TRUE);
}
/* FIXME : We should associate a style region with the row segment */
......@@ -2549,12 +2564,9 @@ ms_excel_read_colinfo (BiffQuery *q, ExcelSheet *sheet)
g_return_if_fail (firstcol < SHEET_MAX_COLS);
if (width != 0) {
/* Size seems to include margins and the lower grid line */
double const char_width = get_base_char_width (sheet);
col_width = (width * char_width) / 256.;
/* Subtract margins */
col_width = get_units_net_of_margins
(col_width, sheet_col_get_info (sheet->gnum_sheet, firstcol));
} else
/* Columns are of default width */
col_width = sheet->gnum_sheet->cols.default_style.size_pts;
......@@ -2563,8 +2575,7 @@ ms_excel_read_colinfo (BiffQuery *q, ExcelSheet *sheet)
if (lastcol >= SHEET_MAX_COLS)
lastcol = SHEET_MAX_COLS-1;
for (lp = firstcol; lp <= lastcol; ++lp)
sheet_col_set_width_units (sheet->gnum_sheet,
lp, col_width, TRUE);
sheet_col_set_size_pts (sheet->gnum_sheet, lp, col_width, TRUE);
/* TODO : We should associate a style region with the columns */
if (hidden)
......@@ -2915,7 +2926,6 @@ ms_excel_read_default_row_height (BiffQuery *q, ExcelSheet *sheet)
guint16 const flags = MS_OLE_GET_GUINT16(q->data);
guint16 const height = MS_OLE_GET_GUINT16(q->data+2);
double height_units;
ColRowInfo *cri;
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug > 1) {
......@@ -2927,12 +2937,7 @@ ms_excel_read_default_row_height (BiffQuery *q, ExcelSheet *sheet)
}
#endif
height_units = get_row_height_units (height);
cri = &sheet->gnum_sheet->rows.default_style;
/* Subtract margins */
height_units = get_units_net_of_margins (height_units, cri);
/* Don't know why, but it's too late now to just change the
default */
sheet_row_set_internal_height (sheet->gnum_sheet, cri, height_units);
sheet_row_set_default_size_pts (sheet->gnum_sheet, height_units, FALSE, FALSE);
}
/**
......@@ -2949,7 +2954,6 @@ ms_excel_read_default_col_width (BiffQuery *q, ExcelSheet *sheet)
guint16 const width = MS_OLE_GET_GUINT16(q->data);
double char_width = EXCEL_DEFAULT_CHAR_WIDTH;
double col_width;
ColRowInfo *cri;
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug > 1) {
......@@ -2958,12 +2962,7 @@ ms_excel_read_default_col_width (BiffQuery *q, ExcelSheet *sheet)
#endif
char_width = get_base_char_width (sheet);
col_width = width * char_width;
cri = &sheet->gnum_sheet->cols.default_style;
/* Subtract margins */
col_width = get_units_net_of_margins (col_width, cri);
/* Don't know why, but it's too late now to
just change the default */
sheet_col_set_internal_width (sheet->gnum_sheet, cri, col_width);
sheet_col_set_default_size_pts (sheet->gnum_sheet, col_width, FALSE, FALSE);
}
static void
......
......@@ -2519,7 +2519,7 @@ write_default_row_height (BiffPut *bp, ExcelSheet *sheet)
guint16 options = 0x0;
guint16 height;
def_height = sheet_get_default_external_row_height (sheet->gnum_sheet);
def_height = sheet_row_get_default_size_pts (sheet->gnum_sheet);
height = (guint16) (20. * def_height);
#ifndef NO_DEBUG_EXCEL
if (ms_excel_write_debug > 1) {
......@@ -2625,7 +2625,7 @@ write_default_col_width (BiffPut *bp, ExcelSheet *sheet)
double width_chars;
guint16 width;
def_width = sheet_get_default_external_col_width (sheet->gnum_sheet);
def_width = sheet_col_get_default_size_pts (sheet->gnum_sheet);
width_chars = def_width / get_base_char_width (sheet);
width = (guint16) (width_chars + .5);
......@@ -2696,7 +2696,8 @@ write_colinfos (BiffPut *bp, ExcelSheet *sheet)
col.xf = 0x0f;
for (i = 0; i < sheet->maxx; i++) {
width = sheet_col_get_external_width (sheet->gnum_sheet, i);
ColRowInfo const *ci = sheet_col_get_info (sheet->gnum_sheet, i);
width = ci->size_pts;
if (width != col.width) {
if (i > 0) {
col.last = i - 1;
......@@ -2981,7 +2982,9 @@ write_rowinfo (BiffPut *bp, ExcelSheet *sheet, guint32 row, guint32 width)
guint8 *data;
MsOlePos pos;
double points = sheet_row_get_external_height (sheet->gnum_sheet, row);
ColRowInfo const *ri = sheet_row_get_info (sheet->gnum_sheet, row);
double points = width = ri->size_pts;
/* We don't worry about standard height. I haven't seen it
* indicated in any actual sheet. */
guint16 height = (guint16) (20. * points);
......
......@@ -66,16 +66,14 @@ object_anchor_to_position (double points[4], MSObj*obj, Sheet const * sheet,
if (i & 1) { /* odds are rows */
ColRowInfo const *ri = sheet_row_get_info (sheet, pos);
points[i] = ri->size_pts;
points[i] = ri->size_pixels;
points[i] *= nths / row_denominator;
points[i] += ri->margin_a +
sheet_row_get_unit_distance (sheet, 0, pos);
points[i] += sheet_row_get_distance_pixels (sheet, 0, pos);
} else {
ColRowInfo const *ci = sheet_col_get_info (sheet, pos);
points[i] = ci->size_pts;
points[i] = ci->size_pixels;
points[i] *= nths / 1024.;
points[i] += ci->margin_a +
sheet_col_get_unit_distance (sheet, 0, pos);
points[i] += sheet_col_get_distance_pixels (sheet, 0, pos);
}
}
......
......@@ -59,6 +59,7 @@ GNUMERIC_BASE_SOURCES = \
cell.h \
cell.c \
cell-draw.c \
cell-draw.h \
cellspan.c \
clipboard.c \
clipboard.h \
......
......@@ -39,7 +39,7 @@ application_init (void)
app.clipboard_copied_contents = NULL;
app.clipboard_sheet = NULL;
/* FIXME : 101 as the default will scale Helvetica-10 to Helvetica-14
/* FIXME : 96 as the default will scale Helvetica-9 to Helvetica-12
* which is not too ugly. Ideally we could get the correct values here but,
*
* XFree86-3) lies. It defaults to 75x75 dpi and only allows the user to
......@@ -47,21 +47,20 @@ application_init (void)
* XFree86-4) Makes a better guess, but still seems to use the same
* resolution for both directions.
*
* The trouble is that this value is not correct. To get a pixel match
* my monitor is closer to 120x110.
* XL seems to assume that everything is 96 dpi.
*
* I'll leave it as is for now, and revisit the solution when we shake
* out the flaws in the display code.
*/
app.horizontal_dpi = 101.;
app.vertical_dpi = 101.;
app.horizontal_dpi = 96.;
app.vertical_dpi = 96.;
gnome_config_push_prefix ("Gnumeric/Screen_Resolution/");
app.horizontal_dpi =
gnome_config_get_float_with_default ("Horizontal_dpi=101",
gnome_config_get_float_with_default ("Horizontal_dpi=96",
&h_was_default);
app.vertical_dpi =
gnome_config_get_float_with_default ("Vertical_dpi=101",
gnome_config_get_float_with_default ("Vertical_dpi=96",
&v_was_default);
if (h_was_default)
......
......@@ -16,7 +16,8 @@
#include "pattern.h"
static void
draw_overflow (GdkDrawable *drawable, GdkGC *gc, GdkFont *font, int x1, int y1, int text_base, int width, int height)
draw_overflow (GdkDrawable *drawable, GdkGC *gc, GdkFont *font,
int x1, int y1, int text_base, int width, int height)
{
int const len = gdk_string_width (font, "#");
int count = (len != 0) ? (width / len) : 0;
......@@ -103,15 +104,33 @@ cell_split_text (GdkFont *font, char const *text, int const width)
/*
* Returns the number of columns used for the draw
*
* G G
* r r
* i i
* d d
*
* Grid line a------+
* |mmmmmm|
* |m m|
* |mmmmmm|
* Grid line +------+
*
* 'm' == margin
* ' ' == space for contents
*
* @x1 : The pixel coord within the drawable of the upper left corner
* of the gridlines (marked a).
* @y1 : The pixel coord within the drawable of the upper left corner
* of the gridlines (marked a).
*/
int
cell_draw (Cell *cell, MStyle *mstyle,
SheetView *sheet_view, GdkGC *gc,
GdkDrawable *drawable, int x1, int y1)
SheetView *sheet_view, GdkGC *gc, GdkDrawable *drawable,
int x1, int y1, gboolean const is_selected)
{
GdkFont *font;
StyleFont *style_font;
GdkColor *col;
StyleFont *style_font = sheet_view_get_style_font (cell->sheet, mstyle);
GdkFont *font = style_font_gdk_font (style_font);
GdkRectangle rect;
GnumericSheet *gsheet;
GnomeCanvas *canvas;
......@@ -121,43 +140,66 @@ cell_draw (Cell *cell, MStyle *mstyle,
int text_base;
int font_height;
int halign;
int do_multi_line;
gboolean is_single_line;
char *text;
gsheet = GNUMERIC_SHEET (sheet_view->sheet_view);
g_return_val_if_fail (GNUMERIC_IS_SHEET (gsheet), 1);
canvas = GNOME_CANVAS (gsheet);
style_font = sheet_view_get_style_font (cell->sheet, mstyle);
font = style_font_gdk_font (style_font);
text_base = y1 + cell->row->size_pixels - font->descent;
cell_get_span (cell, &start_col, &end_col);
/* Get the sizes exclusive of margins and grids */
width = COL_INTERNAL_WIDTH (cell->col);
height = ROW_INTERNAL_HEIGHT (cell->row);
font_height = style_font_get_height (style_font);
switch (mstyle_get_align_v (mstyle)) {
default:
g_warning ("Unhandled cell vertical alignment\n");
case VALIGN_JUSTIFY:
case VALIGN_TOP:
/*
* y1 == top grid line.
* add top margin
* add font ascent
*/
text_base = y1 + font->ascent + cell->row->margin_a;
break;
case VALIGN_CENTER:
text_base = y1 + font->ascent + cell->row->margin_a +
(height - font_height) / 2;
break;
case VALIGN_BOTTOM:
/*
* y1+row->size_pixels == bottom grid line.
* subtract bottom margin
* subtract font descent
*/
text_base = y1 + cell->row->size_pixels - font->descent - cell->row->margin_b;
break;
}
halign = cell_get_horizontal_align (cell, mstyle_get_align_h (mstyle));
/* if a number overflows, do special drawing */
if (width < cell->width && cell_is_number (cell)) {
if (width < cell->width_pixel && cell_is_number (cell)) {
draw_overflow (drawable, gc, font,
x1 + cell->col->margin_a,
y1, text_base,
x1 + cell->col->margin_a + 1,
y1 + cell->row->margin_a + 1,
text_base,
width, height);
style_font_unref (style_font);
return 1;
}
if (halign == HALIGN_JUSTIFY ||
mstyle_get_align_v (mstyle) == VALIGN_JUSTIFY ||
mstyle_get_fit_in_cell (mstyle))
do_multi_line = TRUE;
else
do_multi_line = FALSE;
is_single_line = (halign != HALIGN_JUSTIFY &&
mstyle_get_align_v (mstyle) != VALIGN_JUSTIFY &&
!mstyle_get_fit_in_cell (mstyle));
if (cell && cell->text && cell->text->str)
text = cell->text->str;
......@@ -168,34 +210,87 @@ cell_draw (Cell *cell, MStyle *mstyle,
text = "Pending";
}
if (do_multi_line) {
GList *lines, *l;
int cell_pixel_height = ROW_INTERNAL_HEIGHT (cell->row);
int line_count, x_offset, y_offset, inter_space;
lines = cell_split_text (font, text, width);
line_count = g_list_length (lines);
rect.x = x1 + 1;
rect.y = y1 + 1;
rect.width = cell->col->size_pixels - 1;
rect.height = cell->row->size_pixels - 1;
/* Set the clip rectangle */
gdk_gc_set_clip_rectangle (gc, &rect);
if (gnumeric_background_set_gc (mstyle, gc, canvas) || end_col != start_col)
gdk_draw_rectangle (drawable, gc, TRUE,
rect.x, rect.y, rect.width, rect.height);
/* And now reset the previous foreground color */
gdk_gc_set_fill (gc, GDK_SOLID);
if (cell->render_color)
gdk_gc_set_foreground (gc, &cell->render_color->color);
else {
col = &mstyle_get_color (mstyle, MSTYLE_COLOR_FORE)->color;
gdk_gc_set_foreground (gc, col);
/* This rectangle has the whole area used by this cell
* including the surrounding grid lines */
rect.x = x1;
rect.y = y1;
rect.width = sheet_col_get_distance_pixels (cell->sheet,
start_col, end_col + 1) + 1;
rect.height = cell->row->size_pixels + 1;
/*
* x1, y1 are relative to this cell origin, but the cell might be using
* columns to the left (if it is set to right justify or center justify)
* compute the pixel difference
*/
if (start_col != cell->col->pos)
rect.x -= sheet_col_get_distance_pixels (cell->sheet,
start_col, cell->col->pos);
/* Draw the background if there is one */
if (gnumeric_background_set_gc (mstyle, gc, canvas, is_selected))
gdk_draw_rectangle (drawable, gc, TRUE,
rect.x, rect.y, rect.width, rect.height);
/* If we are spaning columns we need to erase the INTERIOR grid lines */
else if (end_col != start_col)
gdk_draw_rectangle (drawable, gc, TRUE,
rect.x+1, rect.y+1, rect.width-2, rect.height-2);
/* And now reset the previous foreground color */
gdk_gc_set_fill (gc, GDK_SOLID);
if (cell->render_color)
gdk_gc_set_foreground (gc, &cell->render_color->color);
else
gdk_gc_set_foreground (gc, &mstyle_get_color (mstyle, MSTYLE_COLOR_FORE)->color);
/* Do not allow text to impinge upon the grid lines or margins */
rect.x += 1 + cell->col->margin_a;
rect.y += 1 + cell->row->margin_a;
rect.width -= 2 + cell->col->margin_a + cell->col->margin_b;
rect.height -= 2 + cell->row->margin_a + cell->row->margin_b;
gdk_gc_set_clip_rectangle (gc, &rect);
if (is_single_line) {
int total, len;
len = 0;
switch (halign) {
case HALIGN_FILL:
printf ("FILL!\n");
len = gdk_string_width (font, text);
/* fall through */
case HALIGN_LEFT:
x1 += 1 + cell->col->margin_a;
break;
case HALIGN_RIGHT:
x1 += cell->col->size_pixels - 1 - cell->col->margin_b - cell->width_pixel;
break;
case HALIGN_CENTER:
x1 += 1 + cell->col->margin_a + (width - cell->width_pixel) / 2;
break;
default:
g_warning ("Single-line justification style not supported\n");
x1 += 1 + cell->col->margin_a;
}
total = 0;
do {
gdk_draw_text (drawable, font, gc, x1,
text_base, text, strlen (text));
x1 += len;
total += len;
} while (halign == HALIGN_FILL && total < rect.width && len > 0);
} else {
GList *l, *lines = cell_split_text (font, text, width);
int line_count = g_list_length (lines);
int x_offset, y_offset, inter_space;
switch (mstyle_get_align_v (mstyle)) {
case VALIGN_TOP:
y_offset = 0;
......@@ -203,7 +298,7 @@ cell_draw (Cell *cell, MStyle *mstyle,
break;
case VALIGN_CENTER:
y_offset = (cell_pixel_height -
y_offset = (height -
(line_count * font_height)) / 2;
inter_space = font_height;