Commit 3cad2420 authored by Miguel de Icaza's avatar Miguel de Icaza Committed by Arturo Espinosa

New file. Implement the style manager for the spreadsheet.

1998-07-10  Miguel de Icaza  <miguel@nuclecu.unam.mx>

	* src/style.c: New file.  Implement the style manager for the
	spreadsheet.
parent 491136d7
1998-07-10 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/style.c: New file. Implement the style manager for the
spreadsheet.
1998-07-09 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/*: Dropped the ColInfo and RowInfo structures, they are now
......
1998-07-10 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/style.c: New file. Implement the style manager for the
spreadsheet.
1998-07-09 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/*: Dropped the ColInfo and RowInfo structures, they are now
......
1998-07-10 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/style.c: New file. Implement the style manager for the
spreadsheet.
1998-07-09 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/*: Dropped the ColInfo and RowInfo structures, they are now
......
1998-07-10 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/style.c: New file. Implement the style manager for the
spreadsheet.
1998-07-09 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/*: Dropped the ColInfo and RowInfo structures, they are now
......
......@@ -25,6 +25,7 @@ gnumeric_SOURCES = \
main.c \
sheet.c \
sheet.h \
style.c \
style.h \
workbook.c
......
......@@ -37,6 +37,8 @@ typedef struct {
int margin_a; /* in pixels: top/left margin */
int margin_b; /* in pixels: bottom/right margin */
int pixels; /* we compute this from the above parameters */
unsigned int selected:1; /* is this selected? */
} ColRowInfo;
typedef struct {
......
......@@ -7,7 +7,7 @@
/* The signals we emit */
enum {
ITEM_BAR_TEST,
ITEM_BAR_COLUMN_CLICKED,
ITEM_BAR_LAST_SIGNAL
};
static guint item_bar_signals [ITEM_BAR_LAST_SIGNAL] = { 0 };
......@@ -104,16 +104,26 @@ get_col_name (int n)
}
static void
bar_draw_cell (ItemBar *item_bar, GdkDrawable *drawable, char *str, int x1, int y1, int x2, int y2)
bar_draw_cell (ItemBar *item_bar, GdkDrawable *drawable, ColRowInfo *info, char *str, int x1, int y1, int x2, int y2)
{
GtkWidget *canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (item_bar)->canvas);
GdkFont *font = canvas->style->font;
int len, texth;
GdkGC *gc;
int len, texth, shadow;
len = gdk_string_width (font, str);
texth = gdk_string_height (font, str);
gtk_draw_shadow (canvas->style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
if (info->selected){
shadow = GTK_SHADOW_IN;
gc = canvas->style->dark_gc [GTK_STATE_NORMAL];
} else {
shadow = GTK_SHADOW_OUT;
gc = canvas->style->bg_gc [GTK_STATE_ACTIVE];
}
gdk_draw_rectangle (drawable, gc, TRUE, x1 + 1, y1 + 1, x2-x1-2, y2-y1-2);
gtk_draw_shadow (canvas->style, drawable, GTK_STATE_NORMAL, shadow,
x1, y1, x2-x1, y2-y1);
gdk_draw_string (drawable, font, item_bar->gc, x1 + ((x2 - x1)-len)/2,
y2 - font->descent,
......@@ -145,7 +155,7 @@ item_bar_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int w
pixels = ri->pixels;
if (total+pixels >= y){
str = get_row_name (element);
bar_draw_cell (item_bar, drawable, str,
bar_draw_cell (item_bar, drawable, ri, str,
-x, 1 + total - y,
item->canvas->width - x,
1 + total + pixels - y);
......@@ -155,7 +165,7 @@ item_bar_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int w
pixels = ci->pixels;
if (total+pixels >= x){
str = get_col_name (element);
bar_draw_cell (item_bar, drawable, str,
bar_draw_cell (item_bar, drawable, ci, str,
1 + total - x, -y,
1 + total + pixels - x,
item->canvas->height - y);
......@@ -185,7 +195,7 @@ static int
is_pointer_on_division (ItemBar *item_bar, int pos)
{
ColRowInfo *cri;
int i, total, pixels;
int i, total;
total = 0;
......@@ -235,6 +245,13 @@ item_bar_event (GnomeCanvasItem *item, GdkEvent *event)
pos = event->motion.x;
set_cursor (item_bar, pos);
break;
case GDK_BUTTON_PRESS:
if (item_bar->orientation == GTK_ORIENTATION_VERTICAL)
pos = event->button.y;
else
pos = event->button.x;
break;
default:
return FALSE;
}
......
......@@ -86,7 +86,7 @@ item_cursor_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, in
int cursor_width, cursor_height;
GdkPoint points [40];
int draw_external, draw_internal, draw_handle, draw_center;
int remove;
int premove;
item_cursor_get_pixel_coords (item_cursor, &xd, &yd,
&cursor_width, &cursor_height);
......@@ -117,20 +117,20 @@ item_cursor_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, in
};
if (draw_handle)
remove = 5;
premove = 5;
else
remove = 0;
premove = 0;
if (draw_external){
points [0].x = dx + cursor_width + 1;
points [0].y = dy + cursor_height + 1 - remove;
points [0].y = dy + cursor_height + 1 - premove;
points [1].x = points [0].x;
points [1].y = dy - 1;
points [2].x = dx - 1;
points [2].y = dy - 1;
points [3].x = dx - 1;
points [3].y = dy + cursor_height + 1;
points [4].x = dx + cursor_width + 1 - remove;
points [4].x = dx + cursor_width + 1 - premove;
points [4].y = points [3].y;
gdk_draw_lines (drawable, item_cursor->gc, points, 5);
}
......
......@@ -7,7 +7,8 @@ main (int argc, char *argv [])
Workbook *wb;
gnome_init ("Gnumeric", NULL, argc, argv, 0, NULL);
style_init ();
wb = workbook_new_with_sheets (1);
gtk_widget_show (wb->toplevel);
......
......@@ -7,7 +7,8 @@ main (int argc, char *argv [])
Workbook *wb;
gnome_init ("Gnumeric", NULL, argc, argv, 0, NULL);
style_init ();
wb = workbook_new_with_sheets (1);
gtk_widget_show (wb->toplevel);
......
......@@ -14,7 +14,8 @@ sheet_init_dummy_stuff (Sheet *sheet)
c.pixels = 0;
c.margin_a = 0;
c.margin_b = 0;
c.selected = 0;
sheet->default_col_style = c;
/* Initialize some of the columns */
......@@ -34,6 +35,7 @@ sheet_init_dummy_stuff (Sheet *sheet)
sheet->default_row_style.pixels = 0;
sheet->default_row_style.margin_a = 0;
sheet->default_row_style.margin_b = 0;
sheet->default_row_style.selected = 0;
for (y = 0; y < 6; y += 2){
rp = g_new0 (ColRowInfo, 1);
......@@ -41,6 +43,7 @@ sheet_init_dummy_stuff (Sheet *sheet)
*rp = sheet->default_row_style;
rp->pos = y;
rp->units = (20 * (y + 1));
rp->selected = 1;
sheet->rows_info = g_list_append (sheet->rows_info, rp);
}
}
......
......@@ -10,6 +10,7 @@ typedef struct {
typedef struct {
int ref_count;
char *font_name;
int units;
GdkFont *font;
} StyleFont;
......@@ -77,4 +78,29 @@ typedef struct {
unsigned int orientation:4;
} Style;
void style_init (void);
Style *style_new (void);
StyleFormat *style_format_new (char *name);
void style_format_ref (StyleFormat *sf);
void style_format_unref (StyleFormat *sf);
StyleFont *style_font_new (char *font_name, int units);
void style_font_ref (StyleFont *sf);
void style_font_unref (StyleFont *sf);
StyleBorder *style_border_new_plain (void);
void style_border_ref (StyleBorder *sb);
void style_border_unref (StyleBorder *sb);
StyleBorder *style_border_new (StyleBorderType left,
StyleBorderType right,
StyleBorderType top,
StyleBorderType bottom,
GdkColor *left_color,
GdkColor *right_color,
GdkColor *top_color,
GdkColor *bottom_color);
#endif /* GNUMERIC_STYLE_H */
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