aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/e-cell-text.c
diff options
context:
space:
mode:
authorMiguel de Icaza <miguel@gnu.org>1999-11-27 03:25:02 +0800
committerArturo Espinosa <unammx@src.gnome.org>1999-11-27 03:25:02 +0800
commit465c8ae9a0cac78793cac6097b6bfbabc3a342de (patch)
tree6722a7709aaeccb913d73828d075301d68885cc4 /widgets/e-cell-text.c
parentb92f33ed1198949e1275f8b7580fa3e367a47450 (diff)
downloadgsoc2013-evolution-465c8ae9a0cac78793cac6097b6bfbabc3a342de.tar
gsoc2013-evolution-465c8ae9a0cac78793cac6097b6bfbabc3a342de.tar.gz
gsoc2013-evolution-465c8ae9a0cac78793cac6097b6bfbabc3a342de.tar.bz2
gsoc2013-evolution-465c8ae9a0cac78793cac6097b6bfbabc3a342de.tar.lz
gsoc2013-evolution-465c8ae9a0cac78793cac6097b6bfbabc3a342de.tar.xz
gsoc2013-evolution-465c8ae9a0cac78793cac6097b6bfbabc3a342de.tar.zst
gsoc2013-evolution-465c8ae9a0cac78793cac6097b6bfbabc3a342de.zip
Compute height using the ecell methods here. (eti_get_height): new method
1999-11-26 Miguel de Icaza <miguel@gnu.org> * e-table-item.c (eti_realize): Compute height using the ecell methods here. (eti_get_height): new method to compute dimensions. * e-cursors.c: use a different cursor. * e-table-model.h: kill height and row_height methods. * e-cell.c (ec_height): New method. * e-cell-text.c (ect_realize): Load the font from the canvas. (ect_draw): New color setup. Center in the row. (ect_height): Implement new method. 1999-11-26 Michael Meeks <mmeeks@gnu.org> * ROADMAP.e-table: small spelling/typo fixes. 1999-11-25 Miguel de Icaza <miguel@gnu.org> * e-table-item.c (eti_event): Work on mouse-button event svn path=/trunk/; revision=1439
Diffstat (limited to 'widgets/e-cell-text.c')
-rw-r--r--widgets/e-cell-text.c51
1 files changed, 37 insertions, 14 deletions
diff --git a/widgets/e-cell-text.c b/widgets/e-cell-text.c
index 49ffa153a7..da26302664 100644
--- a/widgets/e-cell-text.c
+++ b/widgets/e-cell-text.c
@@ -13,6 +13,8 @@
#define PARENT_TYPE e_cell_get_type()
+#define TEXT_PAD 2
+
typedef struct {
ECellView cell_view;
GdkGC *gc;
@@ -26,11 +28,22 @@ static ECellView *
ect_realize (ECell *ecell, GnomeCanvas *canvas)
{
ECellText *ect = E_CELL_TEXT (ecell);
- ECellTextView *ectv = g_new (ECellTextView, 1);
+ ECellTextView *ectv = g_new0 (ECellTextView, 1);
ectv->cell_view.ecell = ecell;
ectv->gc = gdk_gc_new (GTK_WIDGET (canvas)->window);
- ectv->font = gdk_fontset_load (ect->font_name ? ect->font_name : "fixed");
+ if (ect->font_name){
+ GdkFont *f;
+
+ f = gdk_fontset_load (ect->font_name);
+ ectv->font = f;
+ }
+ if (!ectv->font){
+ ectv->font = GTK_WIDGET (canvas)->style->font;
+
+ gdk_font_ref (ectv->font);
+ }
+
ectv->canvas = canvas;
return (ECellView *)ectv;
@@ -67,8 +80,6 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable, int col, int row, int x1
gdk_gc_set_clip_rectangle (text_view->gc, &rect);
- printf ("String is: [%s]\n", str);
-
switch (ect->justify){
case GTK_JUSTIFY_LEFT:
xoff = 1;
@@ -90,20 +101,23 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable, int col, int row, int x1
/* Draw now */
{
GtkWidget *w = GTK_WIDGET (text_view->canvas);
- GdkColor *background;
- int idx;
+ GdkColor *background, *foreground;
+ const int height = text_view->font->ascent + text_view->font->descent;
- if (selected)
- idx = GTK_STATE_SELECTED;
- else
- idx = GTK_STATE_NORMAL;
+ if (selected){
+ background = &w->style->bg [GTK_STATE_SELECTED];
+ foreground = &w->style->text [GTK_STATE_SELECTED];
+ } else {
+ background = &w->style->base [GTK_STATE_NORMAL];
+ foreground = &w->style->text [GTK_STATE_NORMAL];
+ }
- gdk_gc_set_foreground (text_view->gc, &w->style->bg [idx]);
+ gdk_gc_set_foreground (text_view->gc, background);
gdk_draw_rectangle (drawable, text_view->gc, TRUE,
rect.x, rect.y, rect.width, rect.height);
- gdk_gc_set_foreground (text_view->gc, &w->style->fg [idx]);
+ gdk_gc_set_foreground (text_view->gc, foreground);
gdk_draw_string (drawable, text_view->font, text_view->gc,
- x1 + xoff, y2 - text_view->font->descent, str);
+ x1 + xoff, y2 - text_view->font->descent - ((y2-y1-height)/2), str);
}
}
@@ -129,6 +143,14 @@ ect_event (ECellView *ecell_view, GdkEvent *event, int col, int row)
}
}
+static int
+ect_height (ECellView *ecell_view, int col, int row)
+{
+ ECellTextView *text_view = (ECellTextView *) ecell_view;
+
+ return (text_view->font->ascent + text_view->font->descent) + TEXT_PAD;
+}
+
static void
ect_destroy (GtkObject *object)
{
@@ -150,7 +172,8 @@ e_cell_text_class_init (GtkObjectClass *object_class)
ecc->unrealize = ect_unrealize;
ecc->draw = ect_draw;
ecc->event = ect_event;
-
+ ecc->height = ect_height;
+
parent_class = gtk_type_class (PARENT_TYPE);
}