demos/gtk-demo/drawingarea.c: Use accessor functions to access GtkWidget
This commit is contained in:
parent
6a28e7b164
commit
e80db673b1
@ -25,15 +25,17 @@ scribble_configure_event (GtkWidget *widget,
|
|||||||
GdkEventConfigure *event,
|
GdkEventConfigure *event,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
|
GtkAllocation allocation;
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
|
|
||||||
if (surface)
|
if (surface)
|
||||||
cairo_surface_destroy (surface);
|
cairo_surface_destroy (surface);
|
||||||
|
|
||||||
surface = gdk_window_create_similar_surface (widget->window,
|
gtk_widget_get_allocation (widget, &allocation);
|
||||||
|
surface = gdk_window_create_similar_surface (gtk_widget_get_window (widget),
|
||||||
CAIRO_CONTENT_COLOR,
|
CAIRO_CONTENT_COLOR,
|
||||||
widget->allocation.width,
|
allocation.width,
|
||||||
widget->allocation.height);
|
allocation.height);
|
||||||
|
|
||||||
/* Initialize the surface to white */
|
/* Initialize the surface to white */
|
||||||
cr = cairo_create (surface);
|
cr = cairo_create (surface);
|
||||||
@ -55,7 +57,7 @@ scribble_expose_event (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
|
|
||||||
cr = gdk_cairo_create (widget->window);
|
cr = gdk_cairo_create (gtk_widget_get_window (widget));
|
||||||
|
|
||||||
cairo_set_source_surface (cr, surface, 0, 0);
|
cairo_set_source_surface (cr, surface, 0, 0);
|
||||||
gdk_cairo_rectangle (cr, &event->area);
|
gdk_cairo_rectangle (cr, &event->area);
|
||||||
@ -89,7 +91,7 @@ draw_brush (GtkWidget *widget,
|
|||||||
cairo_destroy (cr);
|
cairo_destroy (cr);
|
||||||
|
|
||||||
/* Now invalidate the affected region of the drawing area. */
|
/* Now invalidate the affected region of the drawing area. */
|
||||||
gdk_window_invalidate_rect (widget->window,
|
gdk_window_invalidate_rect (gtk_widget_get_window (widget),
|
||||||
&update_rect,
|
&update_rect,
|
||||||
FALSE);
|
FALSE);
|
||||||
}
|
}
|
||||||
@ -146,6 +148,7 @@ checkerboard_expose (GtkWidget *da,
|
|||||||
GdkEventExpose *event,
|
GdkEventExpose *event,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
|
GtkAllocation allocation;
|
||||||
gint i, j, xcount, ycount;
|
gint i, j, xcount, ycount;
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
|
|
||||||
@ -159,17 +162,18 @@ checkerboard_expose (GtkWidget *da,
|
|||||||
* works.
|
* works.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
cr = gdk_cairo_create (da->window);
|
cr = gdk_cairo_create (gtk_widget_get_window (da));
|
||||||
gdk_cairo_rectangle (cr, &event->area);
|
gdk_cairo_rectangle (cr, &event->area);
|
||||||
cairo_clip (cr);
|
cairo_clip (cr);
|
||||||
|
|
||||||
|
gtk_widget_get_allocation (da, &allocation);
|
||||||
xcount = 0;
|
xcount = 0;
|
||||||
i = SPACING;
|
i = SPACING;
|
||||||
while (i < da->allocation.width)
|
while (i < allocation.width)
|
||||||
{
|
{
|
||||||
j = SPACING;
|
j = SPACING;
|
||||||
ycount = xcount % 2; /* start with even/odd depending on row */
|
ycount = xcount % 2; /* start with even/odd depending on row */
|
||||||
while (j < da->allocation.height)
|
while (j < allocation.height)
|
||||||
{
|
{
|
||||||
if (ycount % 2)
|
if (ycount % 2)
|
||||||
cairo_set_source_rgb (cr, 0.45777, 0, 0.45777);
|
cairo_set_source_rgb (cr, 0.45777, 0, 0.45777);
|
||||||
|
Loading…
Reference in New Issue
Block a user