Commit aa672123 authored by Jody Goldberg's avatar Jody Goldberg

Adjust the contrast metric back to the obvious choice now that we have

more verbose colour selection.

Better dialog layout in the presence of big fonts.

support applying coloured borders.
parent cf86b104
No preview for this file type
No preview for this file type
......@@ -161,9 +161,6 @@ Gnumeric Spread Sheet task list
Borders:
- pattern selector needs tooltips, button like appearance, and
white backgrounds for the patterns.
Font:
Font selector needs to display whether bold / italic / font name
is unique, and if so to show which it is.
......@@ -228,6 +225,8 @@ Office 2000 and 'explorer' compatibility.
we are taking ages. In those cases, we could probably:
1. Preallocate all cells.
2. Pre-parse formulas
3. Pre-render contents.
* Rendering
......@@ -242,3 +241,7 @@ Office 2000 and 'explorer' compatibility.
* Rework dependencies to only supply one level of indirection.
* Think about allowing a formula to specify that it does not depend on the
contents of a reference, only the adress (ie the AREAS function)
* Drawing
* Rework borders to agregate the lines and draw them after backgrounds
* Scale the fonts in item-bar by zoom factor.
1999-11-06 Jody Goldberg <jgoldberg@home.com>
* ms-excel-read.c (black_or_white_contrast) : Revert to 50% as a
contrast boundary (3*0x10000/2) ~= 0x1800
* ms-excel-read.c (ms_excel_get_style_from_xf) : Add more debug
output, and support 0 as a contrast colour.
1999-11-05 Jody Goldberg <jgoldberg@home.com>
* ms-excel-read.c (ms_excel_palette_get) : Split the contrast logic
......
......@@ -791,7 +791,7 @@ black_or_white_contrast (StyleColor const * contrast)
}
#endif
/* guess the minimum hacked pseudo-luminosity */
if (guess < (0x20000)) {
if (guess < (0x18000)) {
#ifndef NO_DEBUG_EXCEL
if (ms_excel_color_debug > 1)
puts("Contrast is White");
......@@ -1007,7 +1007,7 @@ ms_excel_get_style_from_xf (ExcelSheet *sheet, guint16 xfidx)
mstyle_set_pattern (mstyle, xf->fill_pattern_idx);
/* Solid patterns seem to reverse the meaning */
if (xf->fill_pattern_idx == 1) {
if (xf->fill_pattern_idx == 1 && xf->pat_foregnd_col != 0) {
pattern_index = xf->pat_backgnd_col;
back_index = xf->pat_foregnd_col;
} else {
......@@ -1015,6 +1015,13 @@ ms_excel_get_style_from_xf (ExcelSheet *sheet, guint16 xfidx)
back_index = xf->pat_backgnd_col;
}
#ifndef NO_DEBUG_EXCEL
if (ms_excel_color_debug > 4) {
printf ("back = %d, pat = %d, font = %d, pat_style = %d\n",
pattern_index, back_index, font_index, xf->fill_pattern_idx);
}
#endif
/* ICK : FIXME
* There must be a cleaner way of doing this
*/
......@@ -1023,10 +1030,10 @@ ms_excel_get_style_from_xf (ExcelSheet *sheet, guint16 xfidx)
if (font_index == 127)
{
/* The font is auto. Lets look for info elsewhere */
if (back_index == 64 || back_index == 65)
if (back_index == 64 || back_index == 65 || back_index == 0)
{
/* Everything is auto default to black text/pattern on white */
if (pattern_index == 64 || pattern_index == 65)
if (pattern_index == 64 || pattern_index == 65 || pattern_index == 0)
{
back_color = style_color_new (0xffff, 0xffff, 0xffff);
font_color = pattern_color = style_color_new (0, 0, 0);
......@@ -1049,7 +1056,7 @@ ms_excel_get_style_from_xf (ExcelSheet *sheet, guint16 xfidx)
font_color = black_or_white_contrast (back_color);
/* Pattern is auto contrast it to back */
if (pattern_index == 64 || pattern_index == 65)
if (pattern_index == 64 || pattern_index == 65 || pattern_index == 0)
pattern_color = font_color;
else
pattern_color =
......@@ -1062,10 +1069,10 @@ ms_excel_get_style_from_xf (ExcelSheet *sheet, guint16 xfidx)
font_color = ms_excel_palette_get (sheet->wb->palette,
font_index);
if (back_index == 64 || back_index == 65)
if (back_index == 64 || back_index == 65 || back_index == 0)
{
/* contrast back to font and pattern to back */
if (pattern_index == 64 || pattern_index == 65)
if (pattern_index == 64 || pattern_index == 65 || pattern_index == 0)
{
/* Contrast back to font, and pattern to back */
back_color = black_or_white_contrast (font_color);
......@@ -1085,7 +1092,7 @@ ms_excel_get_style_from_xf (ExcelSheet *sheet, guint16 xfidx)
back_index);
/* Pattern is auto contrast it to back */
if (pattern_index == 64 || pattern_index == 65)
if (pattern_index == 64 || pattern_index == 65 || pattern_index == 0)
pattern_color = black_or_white_contrast (back_color);
else
pattern_color =
......@@ -1129,7 +1136,10 @@ static void
ms_excel_set_xf (ExcelSheet *sheet, int col, int row, guint16 xfidx)
{
Range range;
MStyle *mstyle = ms_excel_get_style_from_xf (sheet, xfidx);
MStyle *mstyle;
printf ("%s!%s%d : ", sheet->gnum_sheet->name, col_name(col), row+1);
mstyle = ms_excel_get_style_from_xf (sheet, xfidx);
if (mstyle == NULL)
return;
......
......@@ -968,7 +968,6 @@ None
<class>GtkFrame</class>
<name>frame13</name>
<border_width>3</border_width>
<width>114</width>
<label>Color</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
......@@ -989,7 +988,6 @@ None
<widget>
<class>GtkVBox</class>
<name>vbox19</name>
<width>120</width>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
......@@ -1042,7 +1040,7 @@ None
<use_alpha>False</use_alpha>
<title>Pick a font color</title>
<child>
<padding>0</padding>
<padding>4</padding>
<expand>False</expand>
<fill>False</fill>
</child>
......
......@@ -92,6 +92,7 @@ typedef struct
gboolean is_selected;
BorderLocations index;
guint rgba;
gboolean is_set;
} BorderPicker;
typedef struct _FormatState
......@@ -1139,11 +1140,19 @@ static struct
};
static MStyleBorder *
border_get_mstyle (FormatState *state, BorderLocations loc)
border_get_mstyle (FormatState const *state, BorderLocations const loc)
{
StyleColor *color = style_color_new (0, 0, 0);
/* state->border.edge[loc].rgba; */
BorderPicker const * edge = & state->border.edge[loc];
int const r = (edge->rgba >> 24) & 0xff;
int const g = (edge->rgba >> 16) & 0xff;
int const b = (edge->rgba >> 8) & 0xff;
StyleColor *color =
style_color_new ((r << 8)|r, (g << 8)|g, (b << 8)|b);
/* Dont set borders that have not been changed */
if (!edge->is_set)
return NULL;
return border_fetch (state->border.edge[loc].pattern_index, color,
border_get_orientation (loc + MSTYLE_BORDER_TOP));
}
......@@ -1157,6 +1166,7 @@ border_format_has_changed (FormatState *state, BorderPicker *edge)
int i;
gboolean changed = FALSE;
edge->is_set = TRUE;
if (edge->rgba != state->border.color.rgba) {
edge->rgba = state->border.color.rgba;
......@@ -1414,11 +1424,11 @@ cb_border_color (GtkObject *obj, guint r, guint g, guint b, guint a,
#undef V
/*
* Initialize the feilds of a BorderPicker, connect signals and
* Initialize the fields of a BorderPicker, connect signals and
* hide if needed.
*/
static void
init_border_button (FormatState * state, BorderLocations const i,
init_border_button (FormatState *state, BorderLocations const i,
GtkWidget *button, gboolean const hide)
{
g_return_if_fail (button != NULL);
......@@ -1429,6 +1439,7 @@ init_border_button (FormatState * state, BorderLocations const i,
state->border.edge[i].state = state;
state->border.edge[i].index = i;
state->border.edge[i].button = GTK_TOGGLE_BUTTON (button);
state->border.edge[i].is_set = FALSE;
gtk_signal_connect (GTK_OBJECT (button), "toggled",
GTK_SIGNAL_FUNC (cb_border_toggle),
......@@ -1725,7 +1736,6 @@ dialog_cell_format (Workbook *wb, Sheet *sheet)
*
* Translation to/from an MStyle.
* - border to
* - border from
*
* Formats
* - regexps to recognize parameterized formats (ie percent 4 decimals)
......
......@@ -1090,6 +1090,17 @@ selection_foreach_range (Sheet *sheet,
static gboolean
cb_set_row_height(Sheet *sheet, ColRowInfo *info, void *height)
{
/* TODO : Only do this for rows which have default or auto heights.
* Only shrink if there is nothing with a bigger font.
*
* Bug 3364
*
* Solution. We will need to maintain a flag in the ColRow struct
* to distinguish between user selected size and auto selected size.
*
* We will also need to reuse the auto size code from double clicking
* on the dividers.
*/
sheet_row_set_internal_height (sheet, info, *((double *)height));
return FALSE;
}
......
......@@ -20,6 +20,11 @@
#include "utils.h"
#include "selection.h"
/* Sizes for column/row headers */
#define COLUMN_HEADER_HEIGHT 20
#define ROW_HEADER_WIDTH 60
static GtkTableClass *sheet_view_parent_class;
void
......@@ -137,6 +142,16 @@ sheet_view_set_zoom_factor (SheetView *sheet_view, double factor)
gnome_canvas_set_pixels_per_unit (GNOME_CANVAS (sheet_view->col_canvas), factor);
gnome_canvas_set_pixels_per_unit (GNOME_CANVAS (sheet_view->row_canvas), factor);
gtk_widget_set_usize (GTK_WIDGET (sheet_view->col_canvas),
-1, COLUMN_HEADER_HEIGHT * factor);
gnome_canvas_set_scroll_region (GNOME_CANVAS (sheet_view->col_canvas), 0, 0,
1000000*factor, COLUMN_HEADER_HEIGHT*factor);
gtk_widget_set_usize (GTK_WIDGET (sheet_view->row_canvas),
ROW_HEADER_WIDTH * factor, -1);
gnome_canvas_set_scroll_region (GNOME_CANVAS (sheet_view->row_canvas), 0, 0,
ROW_HEADER_WIDTH*factor, 1200000*factor);
gnome_canvas_scroll_to (GNOME_CANVAS (sheet_view->sheet_view), 0, 0);
gnome_canvas_scroll_to (GNOME_CANVAS (sheet_view->col_canvas), 0, 0);
gnome_canvas_scroll_to (GNOME_CANVAS (sheet_view->row_canvas), 0, 0);
......@@ -165,12 +180,12 @@ new_canvas_bar (SheetView *sheet_view, GtkOrientation o, GnomeCanvasItem **itemp
/* FIXME: need to set the correct scrolling regions. This will do for now */
if (o == GTK_ORIENTATION_VERTICAL){
w = 60;
w = ROW_HEADER_WIDTH;
h = -1;
gnome_canvas_set_scroll_region (GNOME_CANVAS (canvas), 0, 0, w, 1200000);
} else {
w = -1;
h = 20;
h = COLUMN_HEADER_HEIGHT;
gnome_canvas_set_scroll_region (GNOME_CANVAS (canvas), 0, 0, 1000000, h);
}
gtk_widget_set_usize (canvas, w, h);
......
......@@ -20,6 +20,11 @@
#include "utils.h"
#include "selection.h"
/* Sizes for column/row headers */
#define COLUMN_HEADER_HEIGHT 20
#define ROW_HEADER_WIDTH 60
static GtkTableClass *sheet_view_parent_class;
void
......@@ -137,6 +142,16 @@ sheet_view_set_zoom_factor (SheetView *sheet_view, double factor)
gnome_canvas_set_pixels_per_unit (GNOME_CANVAS (sheet_view->col_canvas), factor);
gnome_canvas_set_pixels_per_unit (GNOME_CANVAS (sheet_view->row_canvas), factor);
gtk_widget_set_usize (GTK_WIDGET (sheet_view->col_canvas),
-1, COLUMN_HEADER_HEIGHT * factor);
gnome_canvas_set_scroll_region (GNOME_CANVAS (sheet_view->col_canvas), 0, 0,
1000000*factor, COLUMN_HEADER_HEIGHT*factor);
gtk_widget_set_usize (GTK_WIDGET (sheet_view->row_canvas),
ROW_HEADER_WIDTH * factor, -1);
gnome_canvas_set_scroll_region (GNOME_CANVAS (sheet_view->row_canvas), 0, 0,
ROW_HEADER_WIDTH*factor, 1200000*factor);
gnome_canvas_scroll_to (GNOME_CANVAS (sheet_view->sheet_view), 0, 0);
gnome_canvas_scroll_to (GNOME_CANVAS (sheet_view->col_canvas), 0, 0);
gnome_canvas_scroll_to (GNOME_CANVAS (sheet_view->row_canvas), 0, 0);
......@@ -165,12 +180,12 @@ new_canvas_bar (SheetView *sheet_view, GtkOrientation o, GnomeCanvasItem **itemp
/* FIXME: need to set the correct scrolling regions. This will do for now */
if (o == GTK_ORIENTATION_VERTICAL){
w = 60;
w = ROW_HEADER_WIDTH;
h = -1;
gnome_canvas_set_scroll_region (GNOME_CANVAS (canvas), 0, 0, w, 1200000);
} else {
w = -1;
h = 20;
h = COLUMN_HEADER_HEIGHT;
gnome_canvas_set_scroll_region (GNOME_CANVAS (canvas), 0, 0, 1000000, h);
}
gtk_widget_set_usize (canvas, w, h);
......
......@@ -314,7 +314,6 @@ void sheet_selection_set_border (Sheet *sheet,
void sheet_create_styles (Sheet *sheet);
void sheet_destroy_styles (Sheet *sheet);
GList *sheet_get_style_list (Sheet *sheet);
void sheet_zoom_styles (Sheet *sheet, double factor);
void sheet_styles_dump (Sheet *sheet);
void sheet_cells_update (Sheet *sheet, Range r,
gboolean render_text);
......
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