Beispiel #1
0
static void
paint_window(GtkWidget *widget, WindowData *windata) {
    cairo_t         *context;
    cairo_surface_t *surface;
    cairo_t         *cr;

    if (windata->width == 0 || windata->height == 0) {
            windata->width = MAX (windata->win->allocation.width, 1);
            windata->height = MAX (windata->win->allocation.height, 1);
    }

    context = gdk_cairo_create (widget->window);

    cairo_set_operator (context, CAIRO_OPERATOR_SOURCE);
    surface = cairo_surface_create_similar (cairo_get_target (context),
                                            CAIRO_CONTENT_COLOR_ALPHA,
                                            widget->allocation.width,
                                            widget->allocation.height);
    cr = cairo_create (surface);

    fill_background (widget, windata, cr);

    cairo_destroy (cr);
    cairo_set_source_surface (context, surface, 0, 0);
    cairo_paint (context);
    cairo_surface_destroy (surface);
    cairo_destroy (context);

    update_shape (windata);
}
static gboolean
countdown_expose_cb(GtkWidget *pie, GdkEventExpose *event,
					WindowData *windata)
{
	cairo_t *context;
	cairo_surface_t *surface;
	cairo_t *cr;

	context = gdk_cairo_create(pie->window);

	cairo_set_operator(context, CAIRO_OPERATOR_SOURCE);
	surface = cairo_surface_create_similar(cairo_get_target(context),
										   CAIRO_CONTENT_COLOR_ALPHA,
										   pie->allocation.width,
										   pie->allocation.height);
	cr = cairo_create(surface);

	cairo_translate (cr, -pie->allocation.x, -pie->allocation.y);
	fill_background (pie, windata, cr);
	cairo_translate (cr, pie->allocation.x, pie->allocation.y);
	
	draw_pie (pie, windata, cr);

	cairo_destroy(cr);
	cairo_set_source_surface(context, surface, 0, 0);
	cairo_paint(context);
	cairo_surface_destroy(surface);
	cairo_destroy(context);
	return TRUE;
}
static void
update_shape (GtkTooltip *tooltip)
{
  GdkBitmap *mask;
  cairo_t *cr;
  gint width, height, tooltip_radius;

  gtk_widget_style_get (tooltip->window,
                        "tooltip-radius", &tooltip_radius,
                        NULL);

  if (tooltip_radius == 0 ||
      gtk_widget_is_composited (tooltip->window))
    {
      gtk_widget_shape_combine_mask (tooltip->window, NULL, 0, 0);
      return;
    }

  gtk_window_get_size (GTK_WINDOW (tooltip->window), &width, &height);
  mask = (GdkBitmap *) gdk_pixmap_new (NULL, width, height, 1);
  cr = gdk_cairo_create (mask);

  fill_background (tooltip->window, cr,
                   &tooltip->window->style->black,
                   &tooltip->window->style->black,
                   255);
  gtk_widget_shape_combine_mask (tooltip->window, mask, 0, 0);

  cairo_destroy (cr);
  g_object_unref (mask);
}
Beispiel #4
0
void JohnHeadCheat (void)
{
gameStates.app.cheats.bJohnHeadOn = !gameStates.app.cheats.bJohnHeadOn;
LoadBackgroundBitmap();
fill_background();
HUDInitMessage (gameStates.app.cheats.bJohnHeadOn? TXT_HI_JOHN : TXT_BYE_JOHN);
}
Beispiel #5
0
void graph_render(graph_state_t* state, struct background * bg, SDL_Color line_color)
{
    rect_t r;
    if(!state->history) return;

    r.x = 0;
    r.y = 0;
    r.w = state->width;
    r.h = state->height;

    fill_background(graph_surface, &r, bg);

    int prevX = x_to_pixel(state, state->history[0]);
    for(int i = 1; i < state->width; i++)
    {
        int x = x_to_pixel(state, state->history[i]);
        int delta = 0;
        if(x > prevX) delta = 1;
        if(x < prevX) delta = -1;
        //surf, x, y1, y2, r,g,b,a
        vlineRGBA(graph_surface, state->width - i, prevX + delta, x, line_color.r, line_color.g, line_color.b, 255);
        //surf, x1, y1, x2, y2, r,g,b,a
        prevX = x;
    }
}
static gboolean
paint_window(GtkWidget *widget,
			 GdkEventExpose *event,
			 WindowData *windata)
{
	if (windata->width == 0) {
		windata->width = windata->win->allocation.width;
		windata->height = windata->win->allocation.height;
	}
	
	if (!(windata->enable_transparency))
	{
			GdkPixmap *mask;
			cairo_t *mask_cr;
			mask = gdk_pixmap_new (NULL, windata->width, 
						     windata->height, 1);
			mask_cr = gdk_cairo_create ((GdkDrawable *) mask);
			cairo_set_operator (mask_cr, CAIRO_OPERATOR_CLEAR);
			cairo_paint (mask_cr);

			cairo_set_operator (mask_cr, CAIRO_OPERATOR_OVER);
			cairo_set_source_rgba (mask_cr, 1, 1, 1, 1);
            nodoka_rounded_rectangle (mask_cr, 0, 0, 
                windata->width, windata->height, 6);
			cairo_fill (mask_cr);
			gdk_window_shape_combine_mask (windata->win->window,
						       (GdkBitmap *) mask, 0,0);
			gdk_pixmap_unref (mask);
			cairo_destroy (mask_cr);
	}

	cairo_t *context;
	cairo_surface_t *surface;
	cairo_t *cr;

	context = gdk_cairo_create(widget->window);

	cairo_set_operator(context, CAIRO_OPERATOR_SOURCE);
	surface = cairo_surface_create_similar(cairo_get_target(context),
										   CAIRO_CONTENT_COLOR_ALPHA,
										   widget->allocation.width,
										   widget->allocation.height);
	cr = cairo_create(surface);

	fill_background(widget, windata, cr);

	cairo_destroy(cr);
	cairo_set_source_surface(context, surface, 0, 0);
	cairo_paint(context);
	cairo_surface_destroy(surface);
	cairo_destroy(context);

	return FALSE;
}
Beispiel #7
0
static void handle_visible_line_without_cache(raster_t *raster)
{
    geometry_t *geometry;
    raster_cache_t *cache;

    geometry = raster->geometry;

    /* If screen is scrolled to the right, we need to fill with the
       background color the blank part on the left.  */

    fill_background(raster);

    /* Draw the graphics and sprites.  */
    raster_modes_draw_line(raster->modes, raster_line_get_real_mode(raster));
    draw_sprites(raster);
    raster_line_draw_borders(raster);

    cache = &raster->cache[raster->current_line];

    if (raster->dont_cache
        || (raster->sprite_status != NULL
        && raster->sprite_status->dma_msk != 0)
        || cache->is_dirty
        || cache->blank
        || cache->border_color != raster->border_color
    /* FIXME: Done differently in another place.  */
        || cache->open_right_border != raster->open_right_border
        || cache->open_left_border != raster->open_left_border
        || cache->idle_background_color != raster->idle_background_color
        || cache->xsmooth_color != raster->xsmooth_color) {
        cache->blank = 0;
        cache->is_dirty = 0;
        cache->border_color = raster->border_color;
        cache->open_right_border = raster->open_right_border;
        cache->open_left_border = raster->open_left_border;
        cache->xsmooth_color = raster->xsmooth_color;
        cache->idle_background_color = raster->idle_background_color;

        add_line_to_area(raster->update_area, map_current_line_to_area(raster),
                         0, raster->geometry->screen_size.width - 1);
    } else {
        /* Still do some minimal caching anyway.  */
        /* Only update the part between the borders.  */
        add_line_to_area(raster->update_area, map_current_line_to_area(raster),
                         geometry->gfx_position.x,
                         geometry->gfx_position.x
                         + geometry->gfx_size.width - 1);
    }
}
Beispiel #8
0
static void paint_window (GtkWidget  *widget,
			  cairo_t    *cr,
			  WindowData *windata)
{
	cairo_surface_t *surface;
	cairo_t *cr2;

	if (windata->width == 0 || windata->height == 0)
	{
		GtkAllocation allocation;

		gtk_widget_get_allocation (windata->win, &allocation);

		windata->width = MAX (allocation.width, 1);
		windata->height = MAX (allocation.height, 1);
	}

	cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);


	surface = cairo_surface_create_similar (cairo_get_target (cr),
						CAIRO_CONTENT_COLOR_ALPHA,
						windata->width,
						windata->height);

	cr2 = cairo_create (surface);

	/* transparent background */
	cairo_rectangle (cr2, 0, 0, windata->width, windata->height);
	cairo_set_source_rgba (cr2, 0.0, 0.0, 0.0, 0.0);
	cairo_fill (cr2);

	fill_background (widget, windata, cr2);

	cairo_destroy(cr2);

	cairo_save (cr);
	cairo_set_source_surface(cr, surface, 0, 0);
	cairo_paint(cr);
	update_shape_region (surface, windata);
	cairo_restore (cr);

	cairo_surface_destroy(surface);
}
static void
paint_countdown (GtkWidget  *pie,
		 cairo_t    *cr,
		 WindowData *windata)
{
	GtkStyle* style;
	cairo_t* cr2;
	cairo_surface_t* surface;

	style = gtk_widget_get_style(windata->win);
	GtkAllocation alloc;
	gtk_widget_get_allocation(pie, &alloc);
	cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
	surface = cairo_surface_create_similar (cairo_get_target(cr),
						CAIRO_CONTENT_COLOR_ALPHA,
						alloc.width,
						alloc.height);

	cr2 = cairo_create (surface);

	fill_background (pie, windata, cr2);

	if (windata->timeout > 0)
	{
		gdouble pct = (gdouble) windata->remaining / (gdouble) windata->timeout;

		gdk_cairo_set_source_color (cr2, &style->bg[GTK_STATE_ACTIVE]);

		cairo_move_to (cr2, PIE_RADIUS, PIE_RADIUS);
		cairo_arc_negative (cr2, PIE_RADIUS, PIE_RADIUS, PIE_RADIUS, -G_PI_2, -(pct * G_PI * 2) - G_PI_2);
		cairo_line_to (cr2, PIE_RADIUS, PIE_RADIUS);
		cairo_fill (cr2);
	}

	cairo_destroy(cr2);

	cairo_save (cr);
	cairo_set_source_surface (cr, surface, 0, 0);
	cairo_paint (cr);
	cairo_restore (cr);

	cairo_surface_destroy(surface);
}
Beispiel #10
0
// Applying the background to the screen
void background::apply_background(SDL_Surface* surface)
{
    apply_surface(0,0, background_corner_ul, surface, NULL);

    int max_size_x = (surface->w - (2 * background_corner_ul->w)  );
    int max_size_y = (surface->h - (2 * background_corner_ul->h)  );
    int x;
    for(x = background_corner_ul->w ; x < max_size_x; x += background_up->w)
    {
        apply_surface(x,0, background_up, surface, NULL);
    }


    apply_surface(x, 0, background_corner_ur, surface, NULL);

    int y;
    for(y = background_corner_ul->h ; y < max_size_y; y += background_left->h)
    {
        apply_surface(0,y, background_left, surface, NULL);
    }

    apply_surface(0,y, background_corner_dl, surface, NULL);

    apply_surface(x,y, background_corner_dr, surface, NULL);

    for(y = background_corner_ul->h ; y < max_size_y; y += background_right->h)
    {
        apply_surface(x,y, background_right, surface, NULL);
    }

    for(x = background_corner_ul->w ; x < max_size_x; x += background_down->w)
    {
        apply_surface(x,y, background_down, surface, NULL);
    }

    fill_background(background_tile, surface, background_corner_ul->w, background_corner_ul->h);

    SDL_Flip(surface);

}
Beispiel #11
0
static gboolean
gtk_tooltip_paint_window (GtkTooltip *tooltip)
{
  guchar tooltip_alpha;
  gint tooltip_radius;

  gtk_widget_style_get (tooltip->window,
                        "tooltip-alpha", &tooltip_alpha,
                        "tooltip-radius", &tooltip_radius,
                        NULL);

  if (tooltip_alpha != 255 || tooltip_radius != 0)
    {
      cairo_t *cr;

      cr = gdk_cairo_create (tooltip->window->window);
      fill_background (tooltip->window, cr,
                       &tooltip->window->style->bg [GTK_STATE_NORMAL],
                       &tooltip->window->style->bg [GTK_STATE_SELECTED],
                       tooltip_alpha);
      cairo_destroy (cr);

      update_shape (tooltip);
    }
  else
    {
      gtk_paint_flat_box (tooltip->window->style,
                          tooltip->window->window,
                          GTK_STATE_NORMAL,
                          GTK_SHADOW_OUT,
                          NULL,
                          tooltip->window,
                          "tooltip",
                          0, 0,
                          tooltip->window->allocation.width,
                          tooltip->window->allocation.height);
    }

  return FALSE;
}
Beispiel #12
0
static void
paint_window (GtkWidget  *widget,
	      cairo_t    *cr,
	      WindowData *windata)
{
	cairo_t*         cr2;
	cairo_surface_t* surface;
	GtkAllocation    allocation;

	gtk_widget_get_allocation(windata->win, &allocation);

	if (windata->width == 0)
	{
			windata->width = allocation.width;
			windata->height = allocation.height;
	}

	cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);

	gtk_widget_get_allocation(widget, &allocation);

	surface = cairo_surface_create_similar (cairo_get_target (cr),
						CAIRO_CONTENT_COLOR_ALPHA,
						allocation.width,
						allocation.height);

	cr2 = cairo_create (surface);

	fill_background(widget, windata, cr2);
	draw_border(widget, windata, cr2);
	draw_stripe(widget, windata, cr2);
	cairo_fill (cr2);
	cairo_destroy (cr2);

	cairo_set_source_surface (cr, surface, 0, 0);
	cairo_paint(cr);
	cairo_surface_destroy(surface);
}
Beispiel #13
0
static void handle_visible_line_with_cache(raster_t *raster)
{
    int needs_update;
    unsigned int changed_start, changed_end;
    raster_cache_t *cache;

    cache = &raster->cache[raster->current_line];

    /* Check for "major" changes first.  If there is any, just write straight
       to the cache without any comparisons and redraw the whole line.  */
    /* check_for_major_changes_and_update() is embedded here because of some
       VAC++ bug.  */
    {
        unsigned int video_mode;
        int line;

        video_mode = raster_line_get_real_mode(raster);

        line = raster->current_line - raster->geometry->gfx_position.y
            - raster->ysmooth - 1;

        if (cache->is_dirty
            || raster->dont_cache
            || cache->n != line
            || cache->xsmooth != raster->xsmooth
            || cache->video_mode != video_mode
            || cache->blank
            || cache->ycounter != raster->ycounter
            || cache->border_color != raster->border_color
            || cache->display_xstart != raster->display_xstart
            || cache->display_xstop != raster->display_xstop
            || (cache->open_right_border && !raster->open_right_border)
            || (cache->open_left_border && !raster->open_left_border)
            || cache->xsmooth_color != raster->xsmooth_color
            || cache->idle_background_color
            != raster->idle_background_color) {

            unsigned int changed_start_char, changed_end_char;
            int r;

            cache->n = line;
            cache->xsmooth = raster->xsmooth;
            cache->video_mode = video_mode;
            cache->blank = 0;
            cache->ycounter = raster->ycounter;
            cache->border_color = raster->border_color;
            cache->display_xstart = raster->display_xstart;
            cache->display_xstop = raster->display_xstop;
            cache->open_right_border = raster->open_right_border;
            cache->open_left_border = raster->open_left_border;
            cache->xsmooth_color = raster->xsmooth_color;
            cache->idle_background_color = raster->idle_background_color;

            /* Fill the space between the border and the graphics with the
             background color (necessary if `xsmooth' is != 0).  */

            fill_background(raster);

            if (raster->sprite_status != NULL)
                (raster->fill_sprite_cache)(raster, cache,
                                            &changed_start_char,
                                            &changed_end_char);

            r = raster_modes_fill_cache(raster->modes,
                                        video_mode,
                                        cache,
                                        &changed_start_char,
                                        &changed_end_char, 1);

            /* [ `changed_start' ; `changed_end' ] now covers the whole line, as
             we have called fill_cache() with `1' as the last parameter (no
             check).  */
            raster_modes_draw_line_cached(raster->modes, video_mode,
                                          cache,
                                          changed_start_char,
                                          changed_end_char);

            if (raster->sprite_status != NULL)
                (raster->draw_sprites_when_cache_enabled)(raster, cache);

            changed_start = 0;
            changed_end = raster->geometry->screen_size.width - 1;

            raster_line_draw_borders(raster);

            needs_update = 1;
        } else {
            needs_update = 0;
        }
    }

    if (!needs_update) {
        /* There are no `major' changes: try to do some optimization.  */
        needs_update = update_for_minor_changes(raster,
                                                &changed_start,
                                                &changed_end);
    }

    if (needs_update) {
        add_line_to_area(raster->update_area, map_current_line_to_area(raster),
                         changed_start, changed_end);
    }

    cache->is_dirty = 0;
}