diff options
Diffstat (limited to 'libstorycode/gtk')
-rw-r--r-- | libstorycode/gtk/gtknarrativeview.c | 47 | ||||
-rw-r--r-- | libstorycode/gtk/gtknarrativeview.h | 1 |
2 files changed, 44 insertions, 4 deletions
diff --git a/libstorycode/gtk/gtknarrativeview.c b/libstorycode/gtk/gtknarrativeview.c index 5bf45dd..1d0a1c2 100644 --- a/libstorycode/gtk/gtknarrativeview.c +++ b/libstorycode/gtk/gtknarrativeview.c @@ -487,11 +487,28 @@ static double para_top(Narrative *n, int pnum) static void draw_para_highlight(cairo_t *cr, Narrative *n, int cursor_para) { double cx, cy, cw, ch; + struct narrative_item *item; + + cx = 0.0; + cy = para_top(n, cursor_para); - cx = n->space_l; - cy = n->space_t + para_top(n, cursor_para); - cw = n->items[cursor_para].slide_w; - ch = n->items[cursor_para].slide_h; + item = &n->items[cursor_para]; + + if ( item->type == NARRATIVE_ITEM_SLIDE ) { + cw = item->slide_w; + ch = item->slide_h; + } else { + if ( item->layout != NULL ) { + PangoRectangle rect; + pango_layout_get_extents(item->layout, NULL, &rect); + cw = pango_units_to_double(rect.width) + item->space_r + item->space_l; + ch = pango_units_to_double(rect.height) + item->space_b + item->space_t; + } else { + cw = 0.0; + ch = 0.0; + fprintf(stderr, "No layout when drawing highlight box\n"); + } + } cairo_new_path(cr); cairo_rectangle(cr, cx, cy, cw, ch); @@ -1176,3 +1193,25 @@ GtkWidget *gtk_narrative_view_new(Presentation *p) return GTK_WIDGET(nview); } + + +void gtk_narrative_view_set_para_highlight(GtkNarrativeView *e, int para_highlight) +{ + e->para_highlight = para_highlight; + redraw(e); +} + + +int gtk_narrative_view_get_cursor_para(GtkNarrativeView *e) +{ + return e->cpos.para; +} + + +void gtk_narrative_view_set_cursor_para(GtkNarrativeView *e, signed int pos) +{ + e->cpos.para = pos; + e->cpos.pos = 0; + e->cpos.trail = 0; + redraw(e); +} diff --git a/libstorycode/gtk/gtknarrativeview.h b/libstorycode/gtk/gtknarrativeview.h index fdcfed6..9cbdcbd 100644 --- a/libstorycode/gtk/gtknarrativeview.h +++ b/libstorycode/gtk/gtknarrativeview.h @@ -100,6 +100,7 @@ struct _gtknarrativeviewclass typedef struct _gtknarrativeview GtkNarrativeView; typedef struct _gtknarrativeviewclass GtkNarrativeViewClass; +extern GType gtk_narrative_view_get_type(void); extern GtkWidget *gtk_narrative_view_new(Presentation *p); extern void gtk_narrative_view_set_logical_size(GtkNarrativeView *e, double w, double h); |