diff options
Diffstat (limited to 'src/gtkext/gtkviewpanel.c')
-rw-r--r-- | src/gtkext/gtkviewpanel.c | 84 |
1 files changed, 56 insertions, 28 deletions
diff --git a/src/gtkext/gtkviewpanel.c b/src/gtkext/gtkviewpanel.c index ef1f94d..ebcd941 100644 --- a/src/gtkext/gtkviewpanel.c +++ b/src/gtkext/gtkviewpanel.c @@ -45,7 +45,7 @@ static void gtk_view_panel_adj_value_changed(GtkAdjustment *, GtkViewPanel *); static void gtk_view_panel_realize(GtkWidget *); /* Met à jour l'affichage du composant d'affichage. */ -static gboolean gtk_view_panel_expose(GtkWidget *, GdkEventExpose *); +static gboolean gtk_view_panel_draw(GtkWidget *, cairo_t *); @@ -72,10 +72,11 @@ static void gtk_view_panel_class_init(GtkViewPanelClass *class) widget_class = GTK_WIDGET_CLASS(class); widget_class->realize = gtk_view_panel_realize; - widget_class->expose_event = gtk_view_panel_expose; + widget_class->draw = gtk_view_panel_draw; class->set_scroll_adjustments = gtk_view_panel_set_scroll_adjustments; + /* widget_class->set_scroll_adjustments_signal = g_signal_new(("set_scroll_adjustments"), GTK_TYPE_VIEW_PANEL, @@ -86,6 +87,7 @@ static void gtk_view_panel_class_init(GtkViewPanelClass *class) G_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT); + */ } @@ -184,13 +186,13 @@ void gtk_view_panel_reclamp_adjustment(GtkAdjustment *adj, gboolean *changed) { gdouble value; /* Valeur actuelle */ - value = adj->value; + value = gtk_adjustment_get_value(adj); - value = CLAMP(value, 0, adj->upper - adj->page_size); + value = CLAMP(value, 0, gtk_adjustment_get_upper(adj) - gtk_adjustment_get_page_size(adj)); - if (value != adj->value) + if (value != gtk_adjustment_get_value(adj)) { - adj->value = value; + gtk_adjustment_set_value(adj, value); *changed = TRUE; } else *changed = FALSE; @@ -214,12 +216,12 @@ void gtk_view_panel_reclamp_adjustment(GtkAdjustment *adj, gboolean *changed) void gtk_view_panel_compute_allocation(GtkViewPanel *panel, GtkAllocation *alloc) { GtkWidget *widget; /* Autre version de la vue */ - GtkAllocation *allocation; /* Raccourci d'utilisation #1 */ + GtkAllocation allocation; /* Raccourci d'utilisation #1 */ gint border_width; /* Raccourci d'utilisation #2 */ widget = GTK_WIDGET(panel); - allocation = &widget->allocation; - border_width = GTK_CONTAINER(panel)->border_width; + gtk_widget_get_allocation(widget, &allocation); + border_width = gtk_container_get_border_width(GTK_CONTAINER(panel)); alloc->x = 0; alloc->y = 0; @@ -232,8 +234,8 @@ void gtk_view_panel_compute_allocation(GtkViewPanel *panel, GtkAllocation *alloc } */ - alloc->width = MAX(1, allocation->width - alloc->x * 2 - border_width * 2); - alloc->height = MAX(1, allocation->height - alloc->y * 2 - border_width * 2); + alloc->width = MAX(1, allocation.width - alloc->x * 2 - border_width * 2); + alloc->height = MAX(1, allocation.height - alloc->y * 2 - border_width * 2); } @@ -252,17 +254,21 @@ void gtk_view_panel_compute_allocation(GtkViewPanel *panel, GtkAllocation *alloc static void gtk_view_panel_realize(GtkWidget *widget) { + GtkAllocation allocation; /* Disposition du composant */ GdkWindowAttr attributes; /* Propriétés du composant */ guint attributes_mask; /* Masque de prise en compte */ - GdkColor white; /* Couleur de fond normale */ + GdkWindow *window; /* Fenêtre du composant */ + GdkRGBA white; /* Couleur de fond normale */ + + gtk_widget_get_allocation(widget, &allocation); gtk_widget_set_realized(widget, TRUE); attributes.window_type = GDK_WINDOW_CHILD; - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; + attributes.x = allocation.x; + attributes.y = allocation.y; + attributes.width = allocation.width; + attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.event_mask = gtk_widget_get_events(widget) @@ -270,10 +276,17 @@ static void gtk_view_panel_realize(GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y; - widget->window = gdk_window_new(gtk_widget_get_parent_window(widget), - &attributes, attributes_mask); + window = gdk_window_new(gtk_widget_get_parent_window(widget), + &attributes, attributes_mask); + + gtk_widget_set_window(widget, window); - gdk_window_set_user_data(widget->window, widget); + gdk_window_set_user_data(window, widget); + + gdk_rgba_parse(&white, "white"); + gtk_widget_override_background_color(widget, GTK_STATE_FLAG_NORMAL, &white); + + /* widget->style = gtk_style_attach(widget->style, widget->window); @@ -281,6 +294,7 @@ static void gtk_view_panel_realize(GtkWidget *widget) gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &white); GTK_VIEW_PANEL(widget)->gc = gdk_gc_new(GDK_DRAWABLE(widget->window)); + */ } @@ -288,7 +302,7 @@ static void gtk_view_panel_realize(GtkWidget *widget) /****************************************************************************** * * * Paramètres : widget = composant GTK à redessiner. * -* event = informations liées à l'événement. * +* cr = contexte graphique associé à l'événement. * * * * Description : Met à jour l'affichage du composant d'affichage. * * * @@ -298,18 +312,29 @@ static void gtk_view_panel_realize(GtkWidget *widget) * * ******************************************************************************/ -static gboolean gtk_view_panel_expose(GtkWidget *widget, GdkEventExpose *event) +static gboolean gtk_view_panel_draw(GtkWidget *widget, cairo_t *cr) { - GtkViewPanel *panel; + GtkViewPanel *panel; /* Autre version du composant */ +#if 0 GdkGCValues values; /* Propriétés du contexte */ GtkStyle *style; /* Style associé au composant */ GtkRequisition req; /* Taille allouée à l'élément */ GtkStateType state; /* Etat du composant */ - +#endif panel = GTK_VIEW_PANEL(widget); if (panel->show_border) { + GtkStyleContext *context; + + + context = gtk_widget_get_style_context(widget); + + gtk_render_background(context, cr, 0, 0, 250, 250); + + printf("Passage!\n"); + + /* gdk_gc_get_values(panel->gc, &values); style = gtk_widget_get_style(widget); @@ -322,7 +347,7 @@ static gboolean gtk_view_panel_expose(GtkWidget *widget, GdkEventExpose *event) FALSE, 0, 0, req.width - 1, req.height - 1); gdk_gc_set_foreground(panel->gc, &values.foreground); - + */ } return FALSE; @@ -539,6 +564,7 @@ void gtk_view_panel_scroll_to_address(GtkViewPanel *panel, vmpa_t addr) gint x; /* Abscisse à garantir */ gint y; /* Ordonnée à garantir */ GtkAdjustment *adj; /* Défilement à mettre à jour */ + double limit; /* Limite à ne pas dépasser */ if (panel->define != NULL) panel->define(panel, addr); @@ -546,16 +572,18 @@ void gtk_view_panel_scroll_to_address(GtkViewPanel *panel, vmpa_t addr) if (panel->get_coordinates(panel, addr, &x, &y)) { adj = panel->hadjustment; + limit = gtk_adjustment_get_upper(adj) - gtk_adjustment_get_page_size(adj); - if (x > (adj->upper - adj->page_size)) - x = adj->upper - adj->page_size; + if (x > limit) + x = limit; gtk_adjustment_set_value(adj, x); adj = panel->vadjustment; + limit = gtk_adjustment_get_upper(adj) - gtk_adjustment_get_page_size(adj); - if (y > (adj->upper - adj->page_size)) - y = adj->upper - adj->page_size; + if (y > limit) + y = limit; gtk_adjustment_set_value(adj, y); |