Commit e08bd4a0 authored by Arturo Espinosa's avatar Arturo Espinosa

First take at cell coloring -miguel

parent 671734ca
1998-09-10 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.c (cell_draw): Fix center alignment code.
1998-09-10 Tom Dyas <tdyas@romulus.rutgers.edu>
* src/func.c: Made install_symbols public.
......@@ -69,7 +73,6 @@
an arbitrary cell to the text as if it were typed by the user.
(sheet_fill_selection_with): Fill the selection with a string.
>>>>>>> 1.88
1998-09-04 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/gnumeric-sheet.c (gnumeric_sheet_key): Fix the way the
......
1998-09-10 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.c (cell_draw): Fix center alignment code.
1998-09-10 Tom Dyas <tdyas@romulus.rutgers.edu>
* src/func.c: Made install_symbols public.
......@@ -69,7 +73,6 @@
an arbitrary cell to the text as if it were typed by the user.
(sheet_fill_selection_with): Fill the selection with a string.
>>>>>>> 1.88
1998-09-04 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/gnumeric-sheet.c (gnumeric_sheet_key): Fix the way the
......
1998-09-10 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.c (cell_draw): Fix center alignment code.
1998-09-10 Tom Dyas <tdyas@romulus.rutgers.edu>
* src/func.c: Made install_symbols public.
......@@ -69,7 +73,6 @@
an arbitrary cell to the text as if it were typed by the user.
(sheet_fill_selection_with): Fill the selection with a string.
>>>>>>> 1.88
1998-09-04 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/gnumeric-sheet.c (gnumeric_sheet_key): Fix the way the
......
1998-09-10 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.c (cell_draw): Fix center alignment code.
1998-09-10 Tom Dyas <tdyas@romulus.rutgers.edu>
* src/func.c: Made install_symbols public.
......@@ -69,7 +73,6 @@
an arbitrary cell to the text as if it were typed by the user.
(sheet_fill_selection_with): Fill the selection with a string.
>>>>>>> 1.88
1998-09-04 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/gnumeric-sheet.c (gnumeric_sheet_key): Fix the way the
......
......@@ -25,10 +25,10 @@ GNOME Spread Sheet task list
** Keyboard shortcuts
We need to implement all of the useful key shortcuts. These are:
CTRL+SPACEBAR Select column
CTRL+A Select all
SHIFT+SPACEBAR Select row
We need to *Document*:
CTRL+SPACEBAR Select column
CTRL+A Select all
SHIFT+SPACEBAR Select row
Selection keys+CTRL Extend selection to boundary of worksheet
SHIFT+BACKSPACE Collapse selection to active cell
......@@ -41,6 +41,12 @@ GNOME Spread Sheet task list
I have the specs for the XS3 format. SC should be
trivial to support as well (from the guile sources)
Add a format registration input point.
* Pluing
Add support for loading plugins.
* Scrolling
** Scrollbar scrolling
......
......@@ -127,6 +127,20 @@ cell_set_font (Cell *cell, char *font_name)
cell_set_font_from_style (cell, style_font);
}
void
cell_set_foreground (Cell *cell, gushort red, gushort green, gushort blue)
{
g_return_if_fail (cell != NULL);
if (cell->style->valid_flags & STYLE_FORE_COLOR)
style_color_unref (cell->style->fore_color);
cell->style->valid_flags |= STYLE_FORE_COLOR;
cell->style->fore_color = style_color_new (red, green, blue);
cell_queue_redraw (cell);
}
/*
* cell_set_rendered_text
* @cell: the cell we will modify
......@@ -771,9 +785,12 @@ cell_draw (Cell *cell, void *sv, GdkGC *gc, GdkDrawable *drawable, int x1, int y
halign = cell_get_horizontal_align (cell);
text = CELL_TEXT_GET (cell);
if ((cell->style->valid_flags & STYLE_BACK_COLOR) && cell->style->back_color){
if (cell->style->valid_flags & STYLE_BACK_COLOR)
gdk_gc_set_background (gc, &cell->style->back_color->color);
}
if (cell->style->valid_flags & STYLE_FORE_COLOR)
gdk_gc_set_foreground (gc, &cell->style->fore_color->color);
/* if a number overflows, do special drawing */
if (width < cell->width && cell_is_number (cell)){
......
......@@ -68,6 +68,7 @@ void cell_set_formula (Cell *cell, char *text);
void cell_set_format (Cell *cell, char *format);
void cell_set_font (Cell *cell, char *font_name);
void cell_set_font_from_style (Cell *cell, StyleFont *style_font);
void cell_set_foreground (Cell *cell, gushort red, gushort green, gushort blue);
void cell_set_alignment (Cell *cell, int halign, int valign, int orientation, int auto_return);
void cell_set_halign (Cell *cell, StyleHAlignFlags halign);
void cell_set_rendered_text (Cell *cell, char *rendered_text);
......
......@@ -36,6 +36,8 @@ static GtkWidget *auto_return;
static GSList *foreground_radio_list;
static GSList *background_radio_list;
static GnomeColorPicker *foreground_cs;
/* Points to the first cell in the selection */
static Cell *first_cell;
......@@ -639,7 +641,7 @@ apply_font_format (Style *style, Sheet *sheet, CellList *cells)
static GtkWidget *
create_foreground_radio (GtkWidget *prop_win)
{
GtkWidget *frame, *table, *r1, *r2, *cs;
GtkWidget *frame, *table, *r1, *r2;
int e = GTK_FILL | GTK_EXPAND;
frame = gtk_frame_new (_("Text color"));
......@@ -651,10 +653,11 @@ create_foreground_radio (GtkWidget *prop_win)
r2 = gtk_radio_button_new_with_label (foreground_radio_list,
_("Use this color"));
cs = gnome_color_picker_new ();
foreground_cs = GNOME_COLOR_PICKER (gnome_color_picker_new ());
gtk_table_attach (GTK_TABLE (table), r1, 0, 1, 0, 1, e, 0, 4, 2);
gtk_table_attach (GTK_TABLE (table), r2, 0, 1, 1, 2, e, 0, 4, 2);
gtk_table_attach (GTK_TABLE (table), cs, 1, 2, 1, 2, 0, 0, 0, 0);
gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (foreground_cs),
1, 2, 1, 2, 0, 0, 0, 0);
return frame;
}
......@@ -715,6 +718,15 @@ create_coloring_page (GtkWidget *prop_win, CellList *cells)
static void
apply_coloring_format (Style *style, Sheet *sheet, CellList *cells)
{
double rd, gd, bd, ad;
gnome_color_picker_get_d (foreground_cs, &rd, &gd, &bd, &ad);
for (; cells; cells = cells->next){
Cell *cell = cells->data;
cell_set_foreground (cell, rd * 65535, gd * 65535, bd * 65535);
}
}
static struct {
......@@ -767,7 +779,8 @@ cell_properties_close (void)
GnomePropertyBox *pbox = GNOME_PROPERTY_BOX (cell_format_prop_win);
gtk_main_quit ();
cell_format_last_page_used = gtk_notebook_current_page (pbox->notebook);
cell_format_last_page_used = gtk_notebook_current_page (
GTK_NOTEBOOK (pbox->notebook));
gtk_widget_destroy (cell_format_prop_win);
cell_format_prop_win = 0;
}
......@@ -812,7 +825,7 @@ dialog_cell_format (Sheet *sheet)
GTK_SIGNAL_FUNC (cell_properties_close), NULL);
gtk_notebook_set_page (
GNOME_PROPERTY_BOX(prop_win)->notebook,
GTK_NOTEBOOK (GNOME_PROPERTY_BOX(prop_win)->notebook),
cell_format_last_page_used);
gtk_widget_show (prop_win);
......
......@@ -36,6 +36,8 @@ static GtkWidget *auto_return;
static GSList *foreground_radio_list;
static GSList *background_radio_list;
static GnomeColorPicker *foreground_cs;
/* Points to the first cell in the selection */
static Cell *first_cell;
......@@ -639,7 +641,7 @@ apply_font_format (Style *style, Sheet *sheet, CellList *cells)
static GtkWidget *
create_foreground_radio (GtkWidget *prop_win)
{
GtkWidget *frame, *table, *r1, *r2, *cs;
GtkWidget *frame, *table, *r1, *r2;
int e = GTK_FILL | GTK_EXPAND;
frame = gtk_frame_new (_("Text color"));
......@@ -651,10 +653,11 @@ create_foreground_radio (GtkWidget *prop_win)
r2 = gtk_radio_button_new_with_label (foreground_radio_list,
_("Use this color"));
cs = gnome_color_picker_new ();
foreground_cs = GNOME_COLOR_PICKER (gnome_color_picker_new ());
gtk_table_attach (GTK_TABLE (table), r1, 0, 1, 0, 1, e, 0, 4, 2);
gtk_table_attach (GTK_TABLE (table), r2, 0, 1, 1, 2, e, 0, 4, 2);
gtk_table_attach (GTK_TABLE (table), cs, 1, 2, 1, 2, 0, 0, 0, 0);
gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (foreground_cs),
1, 2, 1, 2, 0, 0, 0, 0);
return frame;
}
......@@ -715,6 +718,15 @@ create_coloring_page (GtkWidget *prop_win, CellList *cells)
static void
apply_coloring_format (Style *style, Sheet *sheet, CellList *cells)
{
double rd, gd, bd, ad;
gnome_color_picker_get_d (foreground_cs, &rd, &gd, &bd, &ad);
for (; cells; cells = cells->next){
Cell *cell = cells->data;
cell_set_foreground (cell, rd * 65535, gd * 65535, bd * 65535);
}
}
static struct {
......@@ -767,7 +779,8 @@ cell_properties_close (void)
GnomePropertyBox *pbox = GNOME_PROPERTY_BOX (cell_format_prop_win);
gtk_main_quit ();
cell_format_last_page_used = gtk_notebook_current_page (pbox->notebook);
cell_format_last_page_used = gtk_notebook_current_page (
GTK_NOTEBOOK (pbox->notebook));
gtk_widget_destroy (cell_format_prop_win);
cell_format_prop_win = 0;
}
......@@ -812,7 +825,7 @@ dialog_cell_format (Sheet *sheet)
GTK_SIGNAL_FUNC (cell_properties_close), NULL);
gtk_notebook_set_page (
GNOME_PROPERTY_BOX(prop_win)->notebook,
GTK_NOTEBOOK (GNOME_PROPERTY_BOX(prop_win)->notebook),
cell_format_last_page_used);
gtk_widget_show (prop_win);
......
......@@ -171,12 +171,29 @@ style_border_new_plain (void)
}
StyleColor *
style_color_new (char *color)
style_color_new (gushort red, gushort green, gushort blue)
{
g_warning ("Style color not yet implemented\n");
g_warning ("Remember to deallocate colors\n");
return NULL;
static GdkColormap *colormap;
StyleColor *sc;
GdkColor key;
key.red = red;
key.green = green;
key.blue = blue;
sc = g_hash_table_lookup (style_color_hash, &key);
if (!sc){
sc = g_new (StyleColor, 1);
sc->color = key;
if (!colormap)
colormap = gtk_widget_get_default_colormap ();
gdk_color_alloc (colormap, &sc->color);
g_hash_table_insert (style_color_hash, sc, sc);
sc->ref_count = 0;
}
sc->ref_count++;
return sc;
}
void
......@@ -214,8 +231,8 @@ style_new (void)
style->format = style_format_new ("General");
style->font = style_font_new ("-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*", 14);
style->border = style_border_new_plain ();
style->fore_color = NULL;
style->back_color = NULL;
style->fore_color = style_color_new (0, 0, 0);
style->back_color = style_color_new (0xff, 0xff, 0xff);
style->halign = HALIGN_GENERAL;
style->valign = VALIGN_CENTER;
style->orientation = ORIENT_HORIZ;
......@@ -288,14 +305,12 @@ style_duplicate (Style *original)
style->border = NULL;
if (style->valid_flags & STYLE_FORE_COLOR)
if (style->fore_color)
style_color_ref (style->fore_color);
style_color_ref (style->fore_color);
else
style->fore_color = NULL;
if (style->valid_flags & STYLE_BACK_COLOR)
if (style->back_color)
style_color_ref (style->back_color);
style_color_ref (style->back_color);
else
style->back_color = NULL;
......@@ -368,7 +383,9 @@ color_equal (gconstpointer v, gconstpointer v2)
StyleColor *k1 = (StyleColor *) v;
StyleColor *k2 = (StyleColor *) v2;
if (k1->color.pixel == k2->color.pixel)
if (k1->color.red == k2->color.red &&
k1->color.green == k2->color.green &&
k1->color.blue == k2->color.blue)
return 1;
return 0;
......@@ -379,7 +396,7 @@ color_hash (gconstpointer v)
{
StyleColor *k = (StyleColor *)v;
return k->color.pixel;
return (k->color.red << 16) | (k->color.green << 8) | (k->color.blue);
}
void
......
......@@ -87,7 +87,7 @@ typedef enum {
#define STYLE_SHADING 8
#define STYLE_ALIGN 16
#define STYLE_FORE_COLOR 32
#define STYLE_BACK_COLOR 32
#define STYLE_BACK_COLOR 64
/* Define all of the styles we actually know about */
#define STYLE_ALL (STYLE_FORMAT | STYLE_FONT | STYLE_BORDER | STYLE_ALIGN | \
......@@ -124,7 +124,7 @@ StyleFont *style_font_new (char *font_name, int units);
void style_font_ref (StyleFont *sf);
void style_font_unref (StyleFont *sf);
StyleColor *style_color_new (char *color);
StyleColor *style_color_new (gushort red, gushort green, gushort blue);
void style_color_ref (StyleColor *sc);
void style_color_unref (StyleColor *sc);
......
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