diff options
Diffstat (limited to 'src/gtkext')
-rw-r--r-- | src/gtkext/gtkblockview.c | 91 |
1 files changed, 27 insertions, 64 deletions
diff --git a/src/gtkext/gtkblockview.c b/src/gtkext/gtkblockview.c index 19510cb..ad0aded 100644 --- a/src/gtkext/gtkblockview.c +++ b/src/gtkext/gtkblockview.c @@ -111,7 +111,7 @@ static gboolean gtk_block_view_button_press(GtkWidget *, GdkEventButton *event); /* Met à jour l'affichage de la vue sous forme de bloc. */ static gboolean gtk_block_view_expose(GtkWidget *widget, GdkEventExpose *event); -static void gtk_block_view_paint(GtkBlockView *view); + static void gtk_block_view_destroy(GtkObject *object); @@ -254,7 +254,7 @@ static gboolean gtk_block_view_button_press(GtkWidget *widget, GdkEventButton *e { gboolean result; /* Décision à retourner */ GtkBlockView *view; /* Composant GTK réel */ - gdouble y; /* Position à manipuler */ + int y; /* Position à manipuler */ GRenderingLine *line; /* Ligne de rendu visée */ result = FALSE; @@ -275,12 +275,6 @@ static gboolean gtk_block_view_button_press(GtkWidget *widget, GdkEventButton *e } - if (result) - { - /* TODO: regions */ - gtk_block_view_paint(view); - } - return result; } @@ -304,7 +298,8 @@ void gtk_block_view_update_margin(GRenderingLine *line, GtkBlockView *view) { - gtk_block_view_paint(view); + /* TODO : à améliorer ! */ + gtk_widget_queue_draw(GTK_WIDGET(view)); @@ -331,45 +326,7 @@ void gtk_block_view_update_margin(GRenderingLine *line, GtkBlockView *view) static gboolean gtk_block_view_expose(GtkWidget *widget, GdkEventExpose *event) { - GtkBinViewClass *parent_class; /* Version pure du parent */ - - g_return_val_if_fail(widget != NULL, FALSE); - g_return_val_if_fail(GTK_IS_BLOCK_VIEW(widget), FALSE); - g_return_val_if_fail(event != NULL, FALSE); - - gtk_block_view_paint(GTK_BLOCK_VIEW(widget)); - - - - /* - - -gdk_gc_set_clip_region (GdkGC *gc, - const GdkRegion *region); - -gdk_window_invalidate_region (GdkWindow *window, - const GdkRegion *region, - gboolean invalidate_children); -gdk_window_begin_paint_region (GdkWindow *window, - const GdkRegion *region); -void gdk_window_end_paint (GdkWindow *window); - */ - - - - parent_class = GTK_BIN_VIEW_CLASS(g_type_class_peek_parent(GTK_BLOCK_VIEW_GET_CLASS(widget))); - - GTK_WIDGET_CLASS(parent_class)->expose_event(widget, event); - - return TRUE; - -} - - -static void -gtk_block_view_paint(GtkBlockView *view) -{ - GtkWidget *widget; /* Version GTK du composant */ + GtkBinView *view; /* Autre version du composant */ GdkGCValues values; /* Propriétés du contexte */ GdkColor white; /* Couleur du fond */ int width; /* Largeur de l'élément */ @@ -377,37 +334,43 @@ gtk_block_view_paint(GtkBlockView *view) int y; /* Ordonnée du haut d'une ligne*/ GRenderingLine *iter; /* Boucle de parcours */ - widget = GTK_WIDGET(view); - gdk_gc_get_values(GTK_BIN_VIEW(view)->gc, &values); + view = GTK_BIN_VIEW(widget); + + gdk_window_begin_paint_region(GDK_DRAWABLE(widget->window), event->region); + + gdk_gc_set_clip_region(view->gc, event->region); + + gdk_gc_get_values(view->gc, &values); gdk_color_white(gtk_widget_get_colormap(widget), &white); - gdk_gc_set_foreground(GTK_BIN_VIEW(view)->gc, &white); + gdk_gc_set_foreground(view->gc, &white); gtk_widget_get_size_request(widget, &width, &height); - gdk_draw_rectangle(GDK_DRAWABLE(widget->window), GTK_BIN_VIEW(widget)->gc, + gdk_draw_rectangle(GDK_DRAWABLE(widget->window), view->gc, TRUE, 0, 0, width, height); - gdk_gc_set_foreground(GTK_BIN_VIEW(view)->gc, &values.foreground); + gdk_gc_set_foreground(view->gc, &values.foreground); - gdk_draw_layout(GDK_DRAWABLE(widget->window), GTK_BIN_VIEW(view)->gc, - 2 * MARGIN_SPACE + view->line_height, 0, - view->layout); + y = event->area.y; + iter = g_rendering_line_find_by_y(view->lines, view->last, &y); - y = 0; + y = event->area.y - y; - for (iter = GTK_BIN_VIEW(view)->lines; - iter != NULL; - iter = g_rendering_line_get_next_iter(GTK_BIN_VIEW(view)->lines, iter, GTK_BIN_VIEW(view)->last)) + for ( ; iter != NULL; + iter = g_rendering_line_get_next_iter(view->lines, iter, view->last)) { - g_rendering_line_draw(iter, GDK_DRAWABLE(widget->window), GTK_BIN_VIEW(view)->gc, - MARGIN_SPACE, 2 * MARGIN_SPACE + view->line_height, - y, view->line_height, view->rendering); + g_rendering_line_draw(iter, GDK_DRAWABLE(widget->window), view->gc, + MARGIN_SPACE, 2 * MARGIN_SPACE + GTK_BLOCK_VIEW(view)->line_height, + y, GTK_BLOCK_VIEW(view)->line_height, GTK_BLOCK_VIEW(view)->rendering); - y += view->line_height; + y += GTK_BLOCK_VIEW(view)->line_height; } + gdk_window_end_paint(GDK_DRAWABLE(widget->window)); + + return TRUE; } |