Esempio n. 1
0
bool Canvas::on_expose_event(GdkEventExpose * evt) {
	Glib::RefPtr<Gdk::Window> window = get_window();
	if (!window) return false; // no window yet?

	if (!seen_first_expose_event) {
		seen_first_expose_event = true;
		main->controlsWindow().starting_position();
	}

	Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();

	if (!surface) return true; // Haven't rendered yet? Nothing we can do
	if (evt) {
		cr->rectangle(evt->area.x, evt->area.y, evt->area.width, evt->area.height);
		cr->clip();
	}

	cr->set_source(surface, 0, 0);
	cr->paint();

	if (main->dragrect.is_active() && main->dragrect.surface_valid()) {
		cr->save();
		cr->set_source(main->dragrect.get_surface(), 0, 0);
		cr->paint();
		cr->restore();
	}

	if (main->hud_active()) {
		Cairo::RefPtr<Cairo::Surface>& sfc = main->get_hud_surface();
		if (sfc)
			cr->set_source(sfc, 0, 0); // TODO HUD position
		cr->paint();
	}
	return true;
}
bool ScreenAreaCairo::on_draw(const Cairo::RefPtr<Cairo::Context>& poContext)
{
    DrawingArea::on_draw(poContext);
    Cairo::RefPtr<Cairo::ImageSurface> poImage;
    Cairo::RefPtr<Cairo::SurfacePattern> poPattern;
    Cairo::Matrix oMatrix;
    const int iScaledPitch = (m_iScaledWidth + 1) * sizeof(u32);

    //poContext->set_identity_matrix();
    poContext->scale(m_dScaleFactor, m_dScaleFactor);

    poImage = Cairo::ImageSurface::create((u8*)m_puiPixels, Cairo::FORMAT_RGB24,
        m_iScaledWidth, m_iScaledHeight, iScaledPitch);

    //cairo_matrix_init_translate(&oMatrix, -m_iAreaLeft, -m_iAreaTop);
    poPattern = Cairo::SurfacePattern::create(poImage);
    poPattern->set_filter(Cairo::FILTER_NEAREST);
    //poPattern->set_matrix (oMatrix);
    poContext->set_source_rgb(0.0, 0.0, 0.0);
    poContext->paint();

    poContext->set_source(poPattern);
    poContext->paint();

    return true;
}
Esempio n. 3
0
void EmblemCellRenderer::do_render(const Cairo::RefPtr<Cairo::Context>& context, int widget, int background_area, Gdk::Rectangle &cell_area, int flags) {
    context->translate(cell_area.get_x(), cell_area.get_y());
    context->rectangle(0, 0, cell_area.get_width(), cell_area.get_height());
    context->clip();

    // TODO: Incorporate padding
    context->push_group();
    if (!this->_icon_name.empty()) {
        Glib::RefPtr<Gdk::Pixbuf> pixbuf = this->_get_pixbuf(this->_icon_name, this->_icon_size);
        context->set_operator(Cairo::OPERATOR_SOURCE);
        // Assumes square icons; may break if we don't get the requested size
        int height_offset = int((cell_area.get_height() - pixbuf->get_height())/2);
        Gdk::Cairo::set_source_pixbuf(context, pixbuf, 0, height_offset);
        context->rectangle(0, height_offset,
                          pixbuf->get_width(), pixbuf->get_height());
        context->fill();

        if (this->_tint_color) {
            Gdk::RGBA* c = this->_tint_color;
            gushort r = c->get_red();
            gushort g = c->get_green();
            gushort b = c->get_blue();
            // Figure out the difference between our tint colour and an
            // empirically determined (i.e., guessed) satisfying luma and
            // adjust the base colours accordingly
            double luma = (r + r + b + g + g + g) / 6.;
            double extra_luma = (1.2 - luma) / 3.;
            r = std::min(r + extra_luma, 1.);
            g = std::min(g + extra_luma, 1.);
            b = std::min(b + extra_luma, 1.);
            context->set_source_rgba(r, g, b, 0.4);
            context->set_operator(Cairo::OPERATOR_ATOP);
            context->paint();
        }

        if (!this->_emblem_name.empty()) {
            Glib::RefPtr<Gdk::Pixbuf> pixbuf = this->_get_pixbuf(this->_emblem_name, this->_emblem_size);
            int x_offset = this->_icon_size - this->_emblem_size;
            context->set_operator(Cairo::OPERATOR_OVER);
            Gdk::Cairo::set_source_pixbuf(context, pixbuf, x_offset, 0);
            context->rectangle(x_offset, 0,
                              cell_area.get_width(), this->_emblem_size);
            context->fill();
        }
    }

    context->pop_group_to_source();
    context->set_operator(Cairo::OPERATOR_OVER);
    context->paint();
}
Esempio n. 4
0
void CairoPlugin::init()
{
    int height, width;

    preferredSize(width, height);

    m_img = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, width, height);
    m_store = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, width, height);
    m_ctx = Cairo::Context::create(m_img);

    Cairo::RefPtr < Cairo::Context > ctx = Cairo::Context::create(m_store);

    ctx->save();
    ctx->set_source_rgb(1.0, 1.0, 1.0);
    ctx->set_operator(Cairo::OPERATOR_SOURCE);
    ctx->paint();
    ctx->set_operator(Cairo::OPERATOR_OVER);
    ctx->restore();

    m_ctx->save();
    m_ctx->set_source_rgb(1.0, 1.0, 1.0);
    m_ctx->set_operator(Cairo::OPERATOR_SOURCE);
    m_ctx->paint();
    m_ctx->set_operator(Cairo::OPERATOR_OVER);
    m_ctx->restore();

    m_init = false;
    m_need = true;
}
Esempio n. 5
0
static void ClearCanvas(Cairo::RefPtr<Cairo::Context>& cr)
{
    CairoStateSave save(cr);

    cr->set_operator(Cairo::OPERATOR_CLEAR);
    cr->paint();
}
Esempio n. 6
0
void NodeRenderer::icon(const Cairo::RefPtr<Cairo::Context>& cr, AssetCache& cache)
{
	// path to icon not set
	if (s->icon_image.str().size() == 0 || s->icon_width == 0.0 || s->icon_height == 0.0)
		return;

	cr->save();

	Cairo::RefPtr<Cairo::ImageSurface> image = cache.getImage(s->icon_image.str());
	double width = s->icon_width < 0 ? image->get_width() : s->icon_width;
	double height = s->icon_height < 0 ? image->get_height() : s->icon_height;
	double x0 = floor(location.x - width/2.0);
	double y0 = floor(location.y - height/2.0);
	cr->translate(x0, y0);
	cr->scale(width / image->get_width(),
			  height / image->get_height());
	cr->set_source(image, 0, 0);

	if (s->icon_opacity < 1.0)
		cr->paint_with_alpha(s->icon_opacity);
	else
		cr->paint();

	cr->restore();
}
Esempio n. 7
0
	void renderLabels(const char* path)
	{
		BOOST_TEST_MESSAGE("Render: " << path);

		Cairo::RefPtr<Cairo::Surface> surface = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32,
			META_TILE_SIZE * TILE_SIZE, META_TILE_SIZE * TILE_SIZE);
		Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create(surface);
		cr->set_source_rgba(0.0, 0.0, 0.0, 1.0);

		cr->save();
		cr->set_source_rgba(1.0, 1.0, 1.0, 1.0);
		cr->paint();
		cr->restore();

		std::vector<std::pair<string, FloatPoint>> toPlace;
		toPlace.push_back(std::pair<string, FloatPoint>("Karlsruhe", FloatPoint(40, 200)));
		toPlace.push_back(std::pair<string, FloatPoint>("Mannheim", FloatPoint(400, 200)));
		toPlace.push_back(std::pair<string, FloatPoint>("Stuttgard", FloatPoint(200, 260)));
		toPlace.push_back(std::pair<string, FloatPoint>("München", FloatPoint(380, 660)));
		toPlace.push_back(std::pair<string, FloatPoint>("Pforzheim", FloatPoint(200, 600)));
		toPlace.push_back(std::pair<string, FloatPoint>("Wien", FloatPoint(240, 680)));
		toPlace.push_back(std::pair<string, FloatPoint>("Paris", FloatPoint(40, 880)));
		toPlace.push_back(std::pair<string, FloatPoint>("Rom", FloatPoint(-40, 880)));
		toPlace.push_back(std::pair<string, FloatPoint>("Nothing", FloatPoint(400, 760)));
		toPlace.push_back(std::pair<string, FloatPoint>("To See", FloatPoint(720, 880)));
		toPlace.push_back(std::pair<string, FloatPoint>("Here", FloatPoint(720, 560)));
		toPlace.push_back(std::pair<string, FloatPoint>("Bielefeld", FloatPoint(420, 840)));
		renderer->renderLabels(cr, toPlace);

		BOOST_TEST_MESSAGE("Writing.");
		surface->flush();
		surface->write_to_png(path);
	}
Esempio n. 8
0
bool RegionChooser::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
    double clipx1, clipx2, clipy1, clipy2;
    cr->get_clip_extents(clipx1, clipy1, clipx2, clipy2);
#endif

    cr->save();
    cr->set_line_width(1);

#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
    const Gdk::Color bg = get_style()->get_bg(Gtk::STATE_NORMAL);
#else
    const Gdk::RGBA bg = get_style_context()->get_background_color();
#endif
    Gdk::Cairo::set_source_rgba(cr, bg);
    cr->paint();

    if (clipy2 > h1) {
        draw_keyboard(cr, clipx1, clipx2);
    }

    if (clipy1 < h1 && instrument) {
        draw_regions(cr, clipx1, clipx2);
    }

    cr->restore();

    return true;
}
bool MyWidget::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
  const double scale_x = (double)get_allocation().get_width() / m_scale;
  const double scale_y = (double)get_allocation().get_height() / m_scale;

  // paint the background
  Gdk::Cairo::set_source_rgba(cr, get_style_context()->get_background_color());
  cr->paint();

  // draw the foreground
  Gdk::Cairo::set_source_rgba(cr, get_style_context()->get_color());
  cr->move_to(155.*scale_x, 165.*scale_y);
  cr->line_to(155.*scale_x, 838.*scale_y);
  cr->line_to(265.*scale_x, 900.*scale_y);
  cr->line_to(849.*scale_x, 564.*scale_y);
  cr->line_to(849.*scale_x, 438.*scale_y);
  cr->line_to(265.*scale_x, 100.*scale_y);
  cr->line_to(155.*scale_x, 165.*scale_y);
  cr->move_to(265.*scale_x, 100.*scale_y);
  cr->line_to(265.*scale_x, 652.*scale_y);
  cr->line_to(526.*scale_x, 502.*scale_y);
  cr->move_to(369.*scale_x, 411.*scale_y);
  cr->line_to(633.*scale_x, 564.*scale_y);
  cr->move_to(369.*scale_x, 286.*scale_y);
  cr->line_to(369.*scale_x, 592.*scale_y);
  cr->move_to(369.*scale_x, 286.*scale_y);
  cr->line_to(849.*scale_x, 564.*scale_y);
  cr->move_to(633.*scale_x, 564.*scale_y);
  cr->line_to(155.*scale_x, 838.*scale_y);
  cr->stroke();

  return true;
}
Esempio n. 10
0
void Drawable::draw(const Cairo::RefPtr<Cairo::Context>& context,
                    ImageBuffer& buff) {
  context->save();
  // std::cout << getImageName() << std::endl;
  auto image = buff.getImage(getImageName(), flipped_, scaleX, scaleY);

  // int width = image->get_width();
  // int height = image->get_height();
  proto::Position pos = getPosition();

  int x = c_.scaleWidth(pos.x);
  int y = c_.scaleHeight(pos.y);

  // Gdk::Cairo::set_source_pixbuf(context, image, pos.x + width / 2,
  //                               pos.y - height / 2);
  Gdk::Cairo::set_source_pixbuf(context, image, x, offset_ + y);
  context->paint();

  // context->set_source_rgb(0.8, 0.0, 0.0);
  // context->move_to(pos.x, pos.y);
  // context->line_to(pos.x + width / 2, pos.y - height / 2);
  // context->line_to(pos.x + width / 2, pos.y + height / 2);
  // context->line_to(pos.x - width / 2, pos.y + height / 2);
  // context->line_to(pos.x - width / 2, pos.y - height / 2);
  // context->line_to(pos.x + width / 2, pos.y - height / 2);
  // context->stroke();

  context->restore();
}
void FillColorMenuToolButton::drawImageSurface(const Cairo::RefPtr<Cairo::Context> context)
{
	Gdk::Cairo::set_source_pixbuf (context, pixbuf_, 3.0, 0.0);
    context->paint();
	
	drawColorRectangle (context, 0.5, getImageHeight() - 4.5, getImageWidth() - 0.5, 5 - 0.5);
}
bool MapDrawingArea::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
    cr->translate(tran_x, tran_y);
    cr->set_source(surface, 0, 0);
    cr->paint();
    return true;
}
Esempio n. 13
0
  bool on_draw(const Cairo::RefPtr<Cairo::Context>& c) {
    Gtk::Allocation allocation = get_allocation();
    const int width = allocation.get_width();
    const int height = allocation.get_height();

    RefPtr<ImageSurface> img = gm.get_surface();
    double s = get_scale();
    if (s < 1.0)
      c->scale(s,s);
    c->set_source_rgb(0, 0, 0);
    c->paint();
    c->set_source(img, 0, 0);
    c->paint();

    return true;
  }
Esempio n. 14
0
bool Window::OnDraw(const Cairo::RefPtr<Cairo::Context> & cr)
{
	cr->set_source_rgba(0.337, 0.612, 0.117, 0.9);
	cr->paint();
	
	return false;
}
Esempio n. 15
0
bool guiRenderer2D::on_expose_event(GdkEventExpose* event) {

	Glib::RefPtr<Gdk::Window> window = get_window();
	if(window) {
		Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
		if(event) {
			// clip to the area indicated by the expose event so that we only
			// redraw the portion of the window that needs to be redrawn
			//printf("event->area.x: %d, event->area.y: %d, event->area.width: %d, event->area.height: %d\n", event->area.x, event->area.y, event->area.width, event->area.height );
			cr->rectangle(event->area.x, event->area.y,	event->area.width, event->area.height);
			cr->clip();
		}

		// Background
		// cr->set_source_rgb(0.0, 0.0, 0.0);
		cr->set_source_rgb(1.0, 1.0, 1.0);
		cr->paint();

		if(m_isRendering && m_layoutAvailable) {
			Gtk::Allocation allocation = get_allocation();
			int width = allocation.get_width();
			int height = allocation.get_height();

			if(width != m_widgetWidth || height != m_widgetHeight ) { // Allocation changed
				rescaleSensorLayout(width, height);
			}

			drawMatrices(cr, width, height, false);
		}
	}

	return true;
}
Esempio n. 16
0
/// Same as draw_buffer, with only the curr_item's full text
void
ViewDrawingArea::render_full_article()
{
	// Dimensions of drawing area
	Gtk::Allocation allocation = get_allocation();
	const int height = allocation.get_height();
	const int width = allocation.get_width();

	Cairo::RefPtr<Cairo::Context> cr = _pixmap->create_cairo_context();
	cr->reset_clip();
	cr->rectangle (0.0, 0.0, width, height);
	cr->clip();
	cr->set_source_rgb (1.0, 1.0, 1.0);
	cr->paint();
	cr->set_source_rgb (0.0, 0.0, 0.0);

	Item *item = AppContext::get().get_curr_item();
	item->make_display_unit();
	ItemDisplayUnit *du = item->get_display_unit();
	du->render (cr, 0, -_vadj->get_value());
	cr->show_page();
	
	double h = du->get_height();
	if (h > height)
		_vadj->set_upper (h - height);
	else
		_vadj->set_upper (0);

	_vadj->set_page_size (height);
	_vadj->set_step_increment (height * 1.0/16.0);
	_vadj->set_page_increment (height * 15.0/16.0);
	_vadj->changed();
}
Esempio n. 17
0
int main(int, char**) {
	Cairo::RefPtr<Cairo::ImageSurface> surface = Cairo::ImageSurface::create(
			Cairo::FORMAT_ARGB32, WIDTH, HEIGHT);
	Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create(surface);
	// fill background in white
	cr->set_source_rgb(1.0, 1.0, 1.0);
	cr->paint();

	// draw a little dot at the point where text will be drawn
	cr->arc(TEXT_ORIGIN_X, TEXT_ORIGIN_Y, FONT_SIZE / 4.0, 0, 2 * M_PI);
	cr->set_source_rgba(0.0, 1.0, 0.0, 0.5);
	cr->fill();

	// draw the text
	cr->move_to(TEXT_ORIGIN_X, TEXT_ORIGIN_Y);
	cr->set_source_rgb(0.8, 0.2, 0.2);
	Cairo::RefPtr<Cairo::ToyFontFace> font = Cairo::ToyFontFace::create(
			"Bitstream Charter", Cairo::FONT_SLANT_ITALIC,
			Cairo::FONT_WEIGHT_BOLD);
	cr->set_font_face(font);
	cr->set_font_size(FONT_SIZE);
	cr->show_text("cairomm!");
	surface->write_to_png("toy-text.png");
	return 0;
}
Esempio n. 18
0
/**
 * Paint the scaledpb GdkPixbuf to the cairo context.
 * @param Cairo::Context cr
 * @param GdkPixbuf* scaledpb
 * @param the current idx
 */
void Preview::showPreview(const Cairo::RefPtr<Cairo::Context>& cr, GdkPixbuf* scaledpb, int idx)
{
    Glib::RefPtr<Gdk::Pixbuf> preview = IconLoader::PixbufConvert(scaledpb);
    Gdk::Cairo::set_source_pixbuf(cr, preview, (m_previewWidth * idx) +
            20, DEF_PREVIEW_PIXBUF_TOP);

    cr->paint();
}
Esempio n. 19
0
bool AdvEnvGUIScope::on_expose_event(GdkEventExpose* event)
{
	Glib::RefPtr<Gdk::Window> window = get_window();
	if (window)
	{
		float len, x, y, xscale, yscale;

		Gtk::Allocation allocation = get_allocation();
		const int width = allocation.get_width();
		const int height = allocation.get_height();

		Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
		cr->set_line_width(2.0);
		cr->set_source_rgb(0.0, 0.0, 0.0);
		cr->paint();

		cr->set_source_rgb(0.0, 0.8, 0.0);

		cr->rectangle(event->area.x, event->area.y, event->area.width, event->area.height);
		cr->clip();

		cr->move_to(width, height);

		len = m_valueDelay + m_valueAttackTime1 + m_valueAttackTime2 + m_valueAttackTime3 + m_valueAttackTime4 + m_valueReleaseTime1 + m_valueReleaseTime2 + m_valueReleaseTime3 + SUSTAIN_LEN;
		xscale = (float) width / len;
		yscale = (float) (height - 6);

		x = m_valueDelay * xscale;
		cr->line_to((int) x, height);
		x += m_valueAttackTime1 * xscale;
		y = m_valueAttackLevel1 * yscale;
		cr->line_to((int) x, height - (int) y);
		x += m_valueAttackTime2 * xscale;
		y = m_valueAttackLevel2 * yscale;
		cr->line_to((int) x, height - (int) y);
		x += m_valueAttackTime3 * xscale;
		y = m_valueAttackLevel3 * yscale;
		cr->line_to((int) x, height - (int) y);
		x += m_valueAttackTime4 * xscale;
		y = m_valueSustain * yscale;
		cr->line_to((int) x, height - (int) y);
		x += SUSTAIN_LEN * xscale;
		cr->line_to((int) x, height - (int) y);
		x += m_valueReleaseTime1 * xscale;
		y = m_valueReleaseLevel1 * yscale;
		cr->line_to((int) x, height - (int) y);
		x += m_valueReleaseTime2 * xscale;
		y = m_valueReleaseLevel2 * yscale;
		cr->line_to((int) x, height - (int) y);
		x += m_valueReleaseTime3 * xscale;
		cr->line_to((int) x, height);
		x = m_valueDelay * xscale;
		cr->line_to((int) x, height);
		cr->stroke();
	}

	return true;
}
Esempio n. 20
0
bool MyArea::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
	if (!m_PxlBuf)
		return false;

	Gdk::Cairo::set_source_pixbuf(cr, m_PxlBuf, 0, 0);
	cr->paint();

	return true;
}
Esempio n. 21
0
	void clear()
	{
		cr->save();

		cr->set_operator(Cairo::OPERATOR_CLEAR);
		cr->set_source_rgba(1.0, 1.0, 1.0, 1.0);
		cr->paint();

		cr->restore();
	}
Esempio n. 22
0
 // helper function to draw an image
 void Draw::draw_img(const Cairo::RefPtr<Cairo::Context>& cr, const Glib::RefPtr<Gdk::Pixbuf>&  img,
     const double translate_x, const double translate_y, const double scale_x, const double scale_y)
 {
     cr->save();
     cr->translate(translate_x, translate_y);
     cr->scale(scale_x, scale_y);
     Gdk::Cairo::set_source_pixbuf(cr, img);
     cr->paint();
     cr->restore();
 }
Esempio n. 23
0
bool MyPaintBox::on_expose_event(GdkEventExpose *event) {
    call_paint_func(event);
    Cairo::RefPtr<Cairo::Context> cr = Glib::wrap(event->window, true)->create_cairo_context();
    gdk_cairo_region(cr->cobj(), event->region);
    cr->clip();
    cr->set_source_rgba(0.0, 0.0, 0.0, 1-background_adj->get_value());
    cr->paint();
    foreach(sigc::bind(sigc::mem_fun(this, &MyPaintBox::propagate_expose), event));
    return true;
}
Esempio n. 24
0
  /** Post-process files. Only valid for PNGs. */
  void postprocess()
  {
    printf("Post-processing PNG files, resizing to %fx%f\n", maxwidth, maxheight);
    struct dirent *d;
    DIR *output_dir = opendir(outdir.c_str());
    while ((d = readdir(output_dir)) != NULL) {
      if (fnmatch("*.png", d->d_name, FNM_PATHNAME | FNM_PERIOD) == 0) {
	infile = outdir + "/" + d->d_name;
	Cairo::RefPtr<Cairo::ImageSurface> imgs = Cairo::ImageSurface::create_from_png(infile);
	if ( (imgs->get_height() != maxheight) || (imgs->get_width() != maxwidth)) {
	  // need to re-create
	  char *tmpout = strdup((outdir + "/tmpXXXXXX").c_str());
	  FILE *f = fdopen(mkstemp(tmpout), "w");
	  outfile = tmpout;
	  free(tmpout);

	  Cairo::RefPtr<Cairo::ImageSurface> outs = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32,
										(int)ceilf(maxwidth),
										(int)ceilf(maxheight));
	  double tx = (maxwidth  - imgs->get_width()) / 2.0;
	  double ty = (maxheight - imgs->get_height()) / 2.0;
	  printf("Re-creating %s for post-processing, "
		 "resizing from %ix%i, tx=%f, ty=%f\n", infile.c_str(),
		 imgs->get_width(), imgs->get_height(), tx, ty);
	  Cairo::RefPtr<Cairo::Context> cc = Cairo::Context::create(outs);
	  if (white_bg) {
	    cc->set_source_rgb(1, 1, 1);
	    cc->paint();
	  }
	  cc->set_source(imgs, tx, ty);
	  cc->paint();
	  outs->write_to_png(&SkillGuiBatchRenderer::write_func, f);
	  imgs.clear();
	  cc.clear();
	  outs.clear();
	  fclose(f);
	  rename(outfile.c_str(), infile.c_str());
	}
      }
    }
    closedir(output_dir);
  }
Esempio n. 25
0
bool ColorArea::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
    cr->set_source_rgba(_color.red / 255.0,
                        _color.green / 255.0,
                        _color.blue / 255.0,
                        _color.alpha / 255.0);

    cr->paint();

    return true;
}
Esempio n. 26
0
bool MyArea_private::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
	if (pixbuf == 0) return false;
	cr->set_source_rgba(0xff, 0xff, 0xff, 0xff);
	cr->rectangle(0, 0, 800, 640);
	cr->fill();
	Gdk::Cairo::set_source_pixbuf(cr, pixbuf);
	cr->paint();
	cr->stroke();
	return true;
}
Esempio n. 27
0
    void NodeSurface::DrawIcon( 
        Cairo::RefPtr<Cairo::Context> refCairo, 
        Cairo::RefPtr<Cairo::ImageSurface> refIconSurface,
        Glib::RefPtr<Gdk::Pixbuf> pixbufIcon,
        int x,
        int y )
    {
        refCairo->save();

        Cairo::RefPtr<Cairo::Context> refCairoIcon = Cairo::Context::create(refIconSurface);
        Gdk::Cairo::set_source_pixbuf( refCairoIcon, pixbufIcon, 0.0, 0.0 );
        refCairoIcon->paint();

        int width = pixbufIcon->get_width();
        int height = pixbufIcon->get_height();

        refCairo->set_source( refIconSurface, x - (width/2), y - (height/2) );
        refCairo->paint();

        refCairo->restore();
    }     
Esempio n. 28
0
void Window::draw(Cairo::RefPtr<Cairo::Context> ctx)
{
	ctx->save();
    ctx->set_source_rgb(0.9, 0.9, 0.9);
    ctx->paint();
    ctx->restore();

    ctx->save();
    ctx->set_line_width(1.0);
    ctx->rectangle(0, 0, width, height);
    ctx->stroke();
    ctx->restore();
}
Esempio n. 29
0
Cairo::RefPtr<Cairo::ImageSurface> ImagesStorage::loadFrenchCard(Cairo::RefPtr<Cairo::ImageSurface> sourceImages, Preference::Card card)
{
	Cairo::RefPtr<Cairo::ImageSurface> cardImage = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, 
		sourceImages->get_width() / 13.0, sourceImages->get_height() / 5.0);
	Cairo::RefPtr<Cairo::Context> cardsImagesDrawer = Cairo::Context::create( cardImage );
	cardsImagesDrawer->set_source_rgb(1, 1, 1);
	double x = getFrenchCardCoord(card, CT_X, sourceImages->get_width());
	double y = getFrenchCardCoord(card, CT_Y, sourceImages->get_height());
	cardsImagesDrawer->set_source(sourceImages, -x, -y);
	cardsImagesDrawer->rectangle(0, 0, sourceImages->get_width() / 13.0, sourceImages->get_height() / 5.0);
	cardsImagesDrawer->clip();
	cardsImagesDrawer->paint();
	return cardImage;
}
Esempio n. 30
0
bool ImageView::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
    if(!myImage)
        return false;

    Gtk::Allocation allocation = get_allocation();
    const int height = allocation.get_height();
    const int width = allocation.get_width();


    Gdk::Cairo::set_source_pixbuf(cr, myImage);
    cr->paint();
    return true;
}