当前位置: 首页>>代码示例>>C++>>正文


C++ RefPtr::reset_clip方法代码示例

本文整理汇总了C++中cairo::RefPtr::reset_clip方法的典型用法代码示例。如果您正苦于以下问题:C++ RefPtr::reset_clip方法的具体用法?C++ RefPtr::reset_clip怎么用?C++ RefPtr::reset_clip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cairo::RefPtr的用法示例。


在下文中一共展示了RefPtr::reset_clip方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

/// 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();
}
开发者ID:BackupTheBerlios,项目名称:calo-svn,代码行数:34,代码来源:ViewWindow.cpp

示例2: on_draw

bool TransparentSlider::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
    auto window = get_window();

    Cairo::RectangleInt window_size;
    Cairo::RectangleInt clip;
    double x1, y1, x2, y2;
    cr->get_clip_extents(x1, y1, x2, y2);

    clip.height = _round(y2-y1);
    clip.width = _round(x2-x1);
    clip.x = _round(x1);
    clip.y = _round(y1);

    window_size.x = 0;
    window_size.y = 0;
    window_size.height = window->get_height();
    window_size.width = window->get_width();

    cr->save();

    if (_SUPPORTS_ALPHA) {
        cr->set_source_rgba(                    // transparent
                _adjustmentRed->get_value(),
                _adjustmentGreen->get_value(),
                _adjustmentBlue->get_value(),
                _adjustmentAlpha->get_value());
    } else {
        cr->set_source_rgb(                     // opaque
                _adjustmentRed->get_value(),
                _adjustmentGreen->get_value(),
                _adjustmentBlue->get_value());
    }
    cr->set_operator(Cairo::OPERATOR_SOURCE);

    if (clip.height==window_size.height && clip.width==window_size.width && clip.x==window_size.x && clip.y==window_size.y) {
    } else {
        window->invalidate(true);
    }
    cr->reset_clip();
    cr->paint();
    cr->restore();

    return Gtk::Window::on_draw(cr);
}
开发者ID:AthanasiusOfAlex,项目名称:gtk-examples,代码行数:45,代码来源:transparent-slider.cpp

示例3: fdesc

void 
ViewDrawingArea::draw_buffer()
{
#ifdef DEBUG
std::cerr << "VA->val:"<<_vadj->get_value() <<" VA->upper:"<<_vadj->get_upper() << std::endl << std::flush;
#endif

	Feed *feed = AppContext::get().get_feed();
	if (feed == NULL) 
		return;

	if (AppContext::get().get_display_type() == FULL)
	{
		render_full_article();
		return;
	}

	// Dimensions of drawing area
	Gtk::Allocation allocation = get_allocation();
	const int width = allocation.get_width();
	const int height = allocation.get_height();

	// First determine start item
	Cairo::RefPtr<Cairo::Context> cr = _pixmap->create_cairo_context();

#ifdef DEBUG
	/// This code was meant to investigate the 500ms delay with pango
	/// at start of rendering.
	if (!_layout_prepared)
	{
Glib::Timer sw;
sw.start();
		Glib::RefPtr<Pango::Layout> pl = Pango::Layout::create (cr);
		const char *fonts[] = {"Sans 10", "Sans 14"};
		for (unsigned i = 0; i < sizeof(fonts)/sizeof(const char*); ++i)
		{
			Pango::FontDescription fdesc (fonts[i]);
			pl->set_font_description (fdesc);
			pl->set_width (10 * Pango::SCALE); // force line break
			pl->set_markup ("<b>Show Us Your Freaky Geek Costumes</b>\nHitting the streets in a scary, tech-themed outfit this Halloween? We want to see it. Find out how your Sergey Brin costume (or is it David Duchovny?) could be featured on Wired News. test\n test");
			Pango::Rectangle irect, lrect;
			pl->get_extents (irect, lrect);
		}
		_layout_prepared = true;
sw.stop();
unsigned long l;
sw.elapsed(l);
std::cerr << "Time spent rendering: " << l << " us" << std::endl << std::flush;
	}
#endif

	const item_list_t items = feed->get_items();
	item_list_t::const_iterator start_item;
	const int n_items = items.size();
	double y = 0.0;

	if (n_items == 0)
		start_item = items.end();
	else
	{
		// Set start_item and h
		int start = static_cast<int> (_vadj->get_value());
		double h = 0.0;
		if (_vadj->get_value() > 0 && _vadj->get_value() == _vadj->get_upper())
		{
			// This will give a blank page when pulling the handle
			// full down. While unusual, it might make sense with
			// an ever-growing newslist.
			y = 0.0;
			start_item = items.end();
		}
		else
		{
			start_item = items.begin();
			for (int i = 0; i < start; ++i)
				++start_item;
			if (start < 0)
				start = 0;

			double prop = _vadj->get_value() - start;
			if (prop > 0.0)
			{
				(*start_item)->make_display_unit();
				ItemDisplayUnit *du = (*start_item)->get_display_unit();
				du->layout (cr);
				h = du->get_height();
			}
			y = - h * prop;
#ifdef DEBUG
std::cerr << "prop:"<<prop <<" y:"<<y << std::endl << std::flush;
#endif

		}
	}

	// clip to the area indicated by the expose event so that we only redraw
	// the portion of the window that needs to be redrawn
	cr->reset_clip();
	cr->rectangle (0.0, 0.0, width, height);
	cr->clip();
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:calo-svn,代码行数:101,代码来源:ViewWindow.cpp

示例4: on_draw


//.........这里部分代码省略.........
        //    JG
        cr->set_source_rgba(
                theme.forPreviewTitle().foreground().red,
                theme.forPreviewTitle().foreground().green,
                theme.forPreviewTitle().foreground().blue,
                theme.forPreviewTitle().foreground().alpha);
        cr->set_line_width(theme.forPreviewTitle().lineWith());
        cr->rectangle(pos_x, pos_y + 2, pos_width + 2, pos_height);
        cr->stroke();



        // draw title the clipping rectangle
        //cr->set_source_rgba(1.0, 1.0, 1.0, 0.0);

        cr->rectangle(pos_x, pos_y + 2, pos_width, pos_height);
        cr->clip_preserve();
        cr->stroke();




        cr->set_source_rgba(
                theme.forPreviewTitleText().foreground().red,
                theme.forPreviewTitleText().foreground().green,
                theme.forPreviewTitleText().foreground().blue,
                theme.forPreviewTitleText().foreground().alpha);

        auto layout = create_pango_layout(item->m_titlename);
        layout->set_font_description(font);
        //cr->set_source_rgba(1.0, 1.0, 1.0, 1.0); // white text
        cr->move_to(pos_x, pos_y + 2);
        layout->show_in_cairo_context(cr);
        cr->reset_clip(); // Reset the clipping 



        if (item->m_imageLoadedRequired) {
            GdkPixbuf *scaledpb = getScaledPixbuf(item);

            if (scaledpb == nullptr) {
                continue;
            }

            // show the loaded image. 
            showPreview(cr, scaledpb, idx);

            // Checks if the image have movement.
            if (item->isMovementDetected(scaledpb) && !item->m_isDynamic) {
                item->m_isDynamic = true;
            }

            // if no movement has been detected, means that the image 
            // is static and we don't need to reload it again 
            if (++item->m_frames > 3 && !item->m_isDynamic) {
                item->m_scaledPixbuf = scaledpb;
                item->m_frames = 0;
                item->m_imageLoadedRequired = false;
            }

            // if the image is static do not unreference the scaledpb.
            if (item->m_imageLoadedRequired)
                g_object_unref(scaledpb);

        } else {
            // show the loaded static image. 
开发者ID:yoosamui,项目名称:DockLight,代码行数:67,代码来源:Preview.cpp


注:本文中的cairo::RefPtr::reset_clip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。