mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-11 13:10:07 +00:00
testgtk: Replace gdk_draw_rectangle() with Cairo
This commit is contained in:
parent
0a451f508b
commit
8630657324
@ -562,14 +562,13 @@ pattern_expose (GtkWidget *widget,
|
|||||||
color = g_object_get_data (G_OBJECT (window), "pattern-color");
|
color = g_object_get_data (G_OBJECT (window), "pattern-color");
|
||||||
if (color)
|
if (color)
|
||||||
{
|
{
|
||||||
GdkGC *tmp_gc = gdk_gc_new (window);
|
cairo_t *cr = gdk_cairo_create (window);
|
||||||
gdk_gc_set_rgb_fg_color (tmp_gc, color);
|
|
||||||
|
|
||||||
gdk_draw_rectangle (window, tmp_gc, TRUE,
|
gdk_cairo_set_source_color (cr, color);
|
||||||
event->area.x, event->area.y,
|
gdk_cairo_rectangle (cr, &event->area);
|
||||||
event->area.width, event->area.height);
|
cairo_fill (cr);
|
||||||
|
|
||||||
g_object_unref (tmp_gc);
|
cairo_destroy (cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -1778,18 +1777,26 @@ gridded_geometry_expose (GtkWidget *widget,
|
|||||||
GdkEventExpose *event)
|
GdkEventExpose *event)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
|
cairo_t *cr;
|
||||||
|
|
||||||
gdk_draw_rectangle (widget->window, widget->style->base_gc[widget->state], TRUE,
|
cr = gdk_cairo_create (widget->window);
|
||||||
0, 0, widget->allocation.width, widget->allocation.height);
|
|
||||||
|
cairo_rectangle (cr, 0, 0, widget->allocation.width, widget->allocation.height);
|
||||||
|
gdk_cairo_set_source_color (cr, &widget->style->base[widget->state]);
|
||||||
|
cairo_fill (cr);
|
||||||
|
|
||||||
for (i = 0 ; i * GRID_SIZE < widget->allocation.width; i++)
|
for (i = 0 ; i * GRID_SIZE < widget->allocation.width; i++)
|
||||||
for (j = 0 ; j * GRID_SIZE < widget->allocation.height; j++)
|
for (j = 0 ; j * GRID_SIZE < widget->allocation.height; j++)
|
||||||
{
|
{
|
||||||
if ((i + j) % 2 == 0)
|
if ((i + j) % 2 == 0)
|
||||||
gdk_draw_rectangle (widget->window, widget->style->text_gc[widget->state], TRUE,
|
cairo_rectangle (cr, i * GRID_SIZE, j * GRID_SIZE, GRID_SIZE, GRID_SIZE);
|
||||||
i * GRID_SIZE, j * GRID_SIZE, GRID_SIZE, GRID_SIZE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gdk_cairo_set_source_color (cr, &widget->style->text[widget->state]);
|
||||||
|
cairo_fill (cr);
|
||||||
|
|
||||||
|
cairo_destroy (cr);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5421,43 +5428,33 @@ cursor_expose_event (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
GtkDrawingArea *darea;
|
GtkDrawingArea *darea;
|
||||||
GdkDrawable *drawable;
|
GdkDrawable *drawable;
|
||||||
GdkGC *black_gc;
|
|
||||||
GdkGC *gray_gc;
|
|
||||||
GdkGC *white_gc;
|
|
||||||
guint max_width;
|
guint max_width;
|
||||||
guint max_height;
|
guint max_height;
|
||||||
|
cairo_t *cr;
|
||||||
|
|
||||||
g_return_val_if_fail (widget != NULL, TRUE);
|
g_return_val_if_fail (widget != NULL, TRUE);
|
||||||
g_return_val_if_fail (GTK_IS_DRAWING_AREA (widget), TRUE);
|
g_return_val_if_fail (GTK_IS_DRAWING_AREA (widget), TRUE);
|
||||||
|
|
||||||
darea = GTK_DRAWING_AREA (widget);
|
darea = GTK_DRAWING_AREA (widget);
|
||||||
drawable = widget->window;
|
drawable = widget->window;
|
||||||
white_gc = widget->style->white_gc;
|
|
||||||
gray_gc = widget->style->bg_gc[GTK_STATE_NORMAL];
|
|
||||||
black_gc = widget->style->black_gc;
|
|
||||||
max_width = widget->allocation.width;
|
max_width = widget->allocation.width;
|
||||||
max_height = widget->allocation.height;
|
max_height = widget->allocation.height;
|
||||||
|
|
||||||
gdk_draw_rectangle (drawable, white_gc,
|
cr = gdk_cairo_create (drawable);
|
||||||
TRUE,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
max_width,
|
|
||||||
max_height / 2);
|
|
||||||
|
|
||||||
gdk_draw_rectangle (drawable, black_gc,
|
cairo_set_source_rgb (cr, 1, 1, 1);
|
||||||
TRUE,
|
cairo_rectangle (cr, 0, 0, max_width, max_height / 2);
|
||||||
0,
|
cairo_fill (cr);
|
||||||
max_height / 2,
|
|
||||||
max_width,
|
|
||||||
max_height / 2);
|
|
||||||
|
|
||||||
gdk_draw_rectangle (drawable, gray_gc,
|
cairo_set_source_rgb (cr, 0, 0, 0);
|
||||||
TRUE,
|
cairo_rectangle (cr, 0, max_height / 2, max_width, max_height / 2);
|
||||||
max_width / 3,
|
cairo_fill (cr);
|
||||||
max_height / 3,
|
|
||||||
max_width / 3,
|
gdk_cairo_set_source_color (cr, &widget->style->bg[GTK_STATE_NORMAL]);
|
||||||
max_height / 3);
|
cairo_rectangle (cr, max_width / 3, max_height / 3, max_width / 3, max_height / 3);
|
||||||
|
cairo_fill (cr);
|
||||||
|
|
||||||
|
cairo_destroy (cr);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -9770,6 +9767,7 @@ scroll_test_expose (GtkWidget *widget, GdkEventExpose *event,
|
|||||||
{
|
{
|
||||||
gint i,j;
|
gint i,j;
|
||||||
gint imin, imax, jmin, jmax;
|
gint imin, imax, jmin, jmax;
|
||||||
|
cairo_t *cr;
|
||||||
|
|
||||||
imin = (event->area.x) / 10;
|
imin = (event->area.x) / 10;
|
||||||
imax = (event->area.x + event->area.width + 9) / 10;
|
imax = (event->area.x + event->area.width + 9) / 10;
|
||||||
@ -9781,13 +9779,16 @@ scroll_test_expose (GtkWidget *widget, GdkEventExpose *event,
|
|||||||
event->area.x, event->area.y,
|
event->area.x, event->area.y,
|
||||||
event->area.width, event->area.height);
|
event->area.width, event->area.height);
|
||||||
|
|
||||||
|
cr = gdk_cairo_create (widget->window);
|
||||||
|
|
||||||
for (i=imin; i<imax; i++)
|
for (i=imin; i<imax; i++)
|
||||||
for (j=jmin; j<jmax; j++)
|
for (j=jmin; j<jmax; j++)
|
||||||
if ((i+j) % 2)
|
if ((i+j) % 2)
|
||||||
gdk_draw_rectangle (widget->window,
|
cairo_rectangle (cr, 10*i, 10*j - (int)adj->value, 1+i%10, 1+j%10);
|
||||||
widget->style->black_gc,
|
|
||||||
TRUE,
|
cairo_fill (cr);
|
||||||
10*i, 10*j - (int)adj->value, 1+i%10, 1+j%10);
|
|
||||||
|
cairo_destroy (cr);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -10376,11 +10377,12 @@ layout_expose_handler (GtkWidget *widget, GdkEventExpose *event)
|
|||||||
{
|
{
|
||||||
GtkLayout *layout;
|
GtkLayout *layout;
|
||||||
GdkWindow *bin_window;
|
GdkWindow *bin_window;
|
||||||
|
cairo_t *cr;
|
||||||
|
|
||||||
gint i,j;
|
gint i,j;
|
||||||
gint imin, imax, jmin, jmax;
|
gint imin, imax, jmin, jmax;
|
||||||
|
|
||||||
layout = GTK_LAYOUT (widget);
|
layout = GTK_LAYOUT (widget);
|
||||||
|
|
||||||
bin_window = gtk_layout_get_bin_window (layout);
|
bin_window = gtk_layout_get_bin_window (layout);
|
||||||
|
|
||||||
if (event->window != bin_window)
|
if (event->window != bin_window)
|
||||||
@ -10392,15 +10394,19 @@ layout_expose_handler (GtkWidget *widget, GdkEventExpose *event)
|
|||||||
jmin = (event->area.y) / 10;
|
jmin = (event->area.y) / 10;
|
||||||
jmax = (event->area.y + event->area.height + 9) / 10;
|
jmax = (event->area.y + event->area.height + 9) / 10;
|
||||||
|
|
||||||
|
cr = gdk_cairo_create (bin_window);
|
||||||
|
|
||||||
for (i=imin; i<imax; i++)
|
for (i=imin; i<imax; i++)
|
||||||
for (j=jmin; j<jmax; j++)
|
for (j=jmin; j<jmax; j++)
|
||||||
if ((i+j) % 2)
|
if ((i+j) % 2)
|
||||||
gdk_draw_rectangle (bin_window,
|
cairo_rectangle (cr,
|
||||||
widget->style->black_gc,
|
10*i, 10*j,
|
||||||
TRUE,
|
1+i%10, 1+j%10);
|
||||||
10*i, 10*j,
|
|
||||||
1+i%10, 1+j%10);
|
|
||||||
|
|
||||||
|
cairo_fill (cr);
|
||||||
|
|
||||||
|
cairo_destroy (cr);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user