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


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

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


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

示例1: on_expose_event

bool CircuitWidget::on_expose_event(GdkEventExpose* event)
{

    (void)event; // placate compiler..
    Glib::RefPtr<Gdk::Window> window = get_window();
    if(window) {
        Gtk::Allocation allocation = get_allocation();
        const int width = allocation.get_width();
        const int height = allocation.get_height();
        double xc = width/2.0;
        double yc = height/2.0;

        Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
        circuitDrawer.renderCairo(cr->cobj());
        cr->rectangle(event->area.x, event->area.y,
                      event->area.width, event->area.height);
        cr->clip();
        cr->rectangle (0, 0, width, height);
        cr->set_source_rgb (1,1,1);
        cr->fill ();
        cr->translate (xc-ext.width/2.0-cx*scale, yc-ext.height/2.0-cy*scale);
        if (circuit) {
            rects = circuitDrawer.draw(*circuit, drawarch, drawparallel, ext, wirestart, wireend, scale, selections, ft_default, wirelabels);
            generate_layout_rects ();
        }
    }

    return true;
}
开发者ID:ti1024,项目名称:QCViewer,代码行数:29,代码来源:circuitwidget.cpp

示例2: draw_keyboard

void RegionChooser::draw_keyboard(const Cairo::RefPtr<Cairo::Context>& cr,
                                  int clip_low, int clip_high) {
    const int h = KEYBOARD_HEIGHT;
    const int w = get_width() - 1;
    const int bh = int(h * 0.55);

    Gdk::Cairo::set_source_rgba(cr, black);
    cr->rectangle(0.5, h1 + 0.5, w, h - 1);
    cr->stroke();

    int x1 = key_to_x(20.5, w);
    Gdk::Cairo::set_source_rgba(cr, grey1);
    cr->rectangle(1, h1 + 1, x1 - 1, h - 2);
    cr->fill();

    int x2 = key_to_x(109.5, w);
    Gdk::Cairo::set_source_rgba(cr, white);
    cr->rectangle(x1 + 1, h1 + 1, x2 - x1 - 1, h - 2);
    cr->fill();

    Gdk::Cairo::set_source_rgba(cr, grey1);
    cr->rectangle(x2 + 1, h1 + 1, w - x2 - 1, h - 2);
    cr->fill();

    Gdk::Cairo::set_source_rgba(cr, black);

    int clipkey1 = std::max(0, x_to_key_right(clip_low - 1, w));
    int clipkey2 = std::min(x_to_key_right(clip_high - 1, w) + 1, 128);

    for (int i = clipkey1 ; i < clipkey2 ; i++) {
        int note = (i + 3) % 12;
        int x = key_to_x(i, w);

        if (note == 1 || note == 4 || note == 6 ||
            note == 9 || note == 11) {
            // black key: short line in the middle, with a rectangle
            // on top
            int x2 = key_to_x(i + 0.5, w);
            cr->move_to(x2 + 0.5, h1 + bh + 0.5);
            cr->line_to(x2 + 0.5, h1 + h - 1);
            cr->stroke();

            int x3 = key_to_x(i + 1, w);
            cr->rectangle(x, h1 + 1, x3 - x + 1, bh);
            cr->fill();
        } else if (note == 3 || note == 8) {
            // C or F: long line to the left
            cr->move_to(x + 0.5, h1 + 1);
            cr->line_to(x + 0.5, h1 + h - 1);
            cr->stroke();
        }

        if (key_pressed[i]) draw_key(cr, i);

        if (note == 3) draw_digit(cr, i);
    }
}
开发者ID:lxlxlo,项目名称:LS-gigedit,代码行数:57,代码来源:regionchooser.cpp

示例3: draw_bar

// ----------------------------------------------------------------------------
// -- Function    : draw_bar(cr)
// --
// -- Takes       : cr = point to a cairo reference
// --
// -- Purpose     : Assumes value is already between 1 and 0!  Draws the bar
//                  on the provided cairo reference.
void BarWidget::draw_bar(Cairo::RefPtr<Cairo::Context> cr)
{
    // Get our bar coords
    Size size = get_avail_rect();
    Size* s = &size;

    // Draw the bg first
    cr->set_line_width(bar_bg_border_width);
    cr->rectangle(s->x, s->y, s->width, s->height);

    // -- bg border
    if (draw_bar_bg_border)
    {
        bar_bg_border_color->set_source(cr);
        cr->stroke_preserve();
    }
    // -- bg
    if (draw_bar_bg)
    {
        bar_bg_color->set_source(cr);
        cr->fill_preserve();
    }

    // Clear the path
    cr->begin_new_path();

    // -- Now we're drawing the value bar
    // Modify the size by our value / percent
    // If we're horz, modify the width.
    // If we're vert, modify the height.
    if (vertical)
        s->height = s->height * m_value;
    else
        s->width = s->width * m_value;

    // New path, draw!
    cr->set_line_width(bar_border_width);
    cr->rectangle(s->x, s->y, s->width, s->height);

    // -- bar border
    if (draw_bar_border)
    {
        bar_border_color->set_source(cr);
        cr->stroke_preserve();
    }

    // -- Draw the bar
    bar_color->set_source(cr);
    cr->fill();

    // clean up
    cr->begin_new_path();
    s = nullptr;
}
开发者ID:darylbutler,项目名称:sysmon,代码行数:61,代码来源:bar_widget.cpp

示例4: draw_node

void ListNode::draw_node(const Cairo::RefPtr<Cairo::Context> & cr, int x, int y) {
	cr->rectangle(x, y, field_w, field_h * numFields);
	cr->fill();

	cr->set_source_rgb(0.0, 0.0, 0.0);
	cr->set_line_width(2.0);
	for (int i = 0; i < numFields; i++) {
		cr->rectangle(x, y + (i * field_h), field_w, field_h);
		cr->stroke();
	}
}
开发者ID:BPHays,项目名称:visualize-structures,代码行数:11,代码来源:list.cpp

示例5: do_render

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();
}
开发者ID:egore,项目名称:meld,代码行数:50,代码来源:emblemcellrenderer.cpp

示例6: drawBackground

void ItemView::drawBackground(const Cairo::RefPtr<Cairo::Context>& cr, const int width, const int height)
{
    //fill background
    if (isSelected())
    {
        cr->set_source_rgb(1, 1, 1);
        cr->rectangle(0, 0, width, height);
        cr->fill();
    }
    else
    {
        cr->set_source_rgb(0.98, 0.98, 0.98);
        cr->rectangle(0, 0, width, height);
        cr->fill();
    }

    //time area
    Cairo::RefPtr<Cairo::LinearGradient> linearGradientTime = Cairo::LinearGradient::create(0, 0, 0, height);

    //set color by status
    ColorMode colorMode = getColorMode();

    if (colorMode == COLOR_INACTIVE)
    {
        //gray
        linearGradientTime->add_color_stop_rgb(0, 0.75, 0.75, 0.75);
        linearGradientTime->add_color_stop_rgb(1, 0.65, 0.65, 0.65);
    }

    if (colorMode == COLOR_ALARM)
    {
        //orange
        linearGradientTime->add_color_stop_rgb(0, 1.00, 0.60, 0.30);
        linearGradientTime->add_color_stop_rgb(1, 0.90, 0.50, 0.20);
    }

    if (colorMode == COLOR_OK)
    {
        //green
        linearGradientTime->add_color_stop_rgb(0, 0.40, 0.70, 0.45);
        linearGradientTime->add_color_stop_rgb(1, 0.30, 0.60, 0.35);
    }

    cr->set_source(linearGradientTime);
    cr->rectangle(0, 0, TIME_WIDTH, height);
    cr->fill();

    if (isSelected())
        drawInnerShadow(cr, width, height);
}
开发者ID:pzagawa,项目名称:myagenda,代码行数:50,代码来源:NoteItemView.cpp

示例7: on_expose_event

bool CompVis::on_expose_event(GdkEventExpose* event) {
    Glib::RefPtr<Gdk::Window> window = get_window();
    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();
        
    // 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->rectangle(event->area.x, event->area.y,
    event->area.width, event->area.height);
    cr->clip();
           
    rms_dB = 20*log10(rms);
    thresh_fraction = (threshold -  p_ports[p_threshold].min)/threshold_range;
    rms_dB_fraction = (rms_dB - p_ports[p_threshold].min)/threshold_range;

    // Draw the graph
    cr->set_source_rgb(0.5,0.1,0.1);
    cr->set_line_width(2);
    cr->move_to(0,height);

    if (rms_dB <= threshold) {
        cr->line_to(rms_dB_fraction*width, height-rms_dB_fraction*height);
        cr->line_to(rms_dB_fraction*width, height);
        cr->line_to(0,height);
    } else {
        cr->line_to(thresh_fraction*width, height-thresh_fraction*height);
        cr->line_to(rms_dB_fraction*width, height-(thresh_fraction*height + height*(rms_dB_fraction-thresh_fraction)/ratio));
        cr->line_to(rms_dB_fraction*width, height);
        cr->line_to(0,height);
    }
    cr->fill();

    // draw the compression curve:
    cr->set_source_rgb(0.1,0.1,0.1);
    cr->move_to(0, height);
    cr->line_to(thresh_fraction*width, height-thresh_fraction*height);
    cr->line_to(width, height-(thresh_fraction*height + height*(1-thresh_fraction)/ratio));
    cr->stroke();

    // Draw the gain
    cr->set_source_rgb(0.1,0.8,0.1);
    cr->rectangle(0,(float)height - (float)height*gain, 10, height);
    cr->fill();
    return true;
}
开发者ID:Joeboy,项目名称:joeboy-lv2-plugins,代码行数:48,代码来源:visual_compressor_gui.cpp

示例8: pw

void
Renderer_Dragbox::render_vfunc(
	const Glib::RefPtr<Gdk::Window>& drawable,
	const Gdk::Rectangle& /*expose_area*/
)
{
	assert(get_work_area());
	if(!get_work_area())
		return;

	// const synfig::Vector focus_point(get_work_area()->get_focus_point());
	// Warning : Unused focus_point
	int drawable_w = drawable->get_width();
	int drawable_h = drawable->get_height();

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

	const synfig::Vector::value_type window_startx(get_work_area()->get_window_tl()[0]);
	const synfig::Vector::value_type window_starty(get_work_area()->get_window_tl()[1]);
	const float pw(get_pw()),ph(get_ph());

	const synfig::Point& curr_point(get_curr_point());
	const synfig::Point& drag_point(get_drag_point());

	{
		cr->save();
		cr->set_line_cap(Cairo::LINE_CAP_BUTT);
		cr->set_line_join(Cairo::LINE_JOIN_MITER);
		cr->set_antialias(Cairo::ANTIALIAS_NONE);

		cr->set_line_width(1.0);
		cr->set_source_rgb(0,0,0);
		std::valarray<double> dashes(2);
		dashes[0]=5.0;
		dashes[1]=5.0;
		cr->set_dash(dashes, 0);

		Point tl(std::min(drag_point[0],curr_point[0]),std::min(drag_point[1],curr_point[1]));
		Point br(std::max(drag_point[0],curr_point[0]),std::max(drag_point[1],curr_point[1]));

		tl[0]=(tl[0]-window_startx)/pw;
		tl[1]=(tl[1]-window_starty)/ph;
		br[0]=(br[0]-window_startx)/pw;
		br[1]=(br[1]-window_starty)/ph;
		if(tl[0]>br[0])
			swap(tl[0],br[0]);
		if(tl[1]>br[1])
			swap(tl[1],br[1]);

		cr->rectangle(
			tl[0],
			tl[1],
			br[0]-tl[0],
			br[1]-tl[1]
		);
		cr->stroke();

		cr->restore();
	}
}
开发者ID:binarytemple,项目名称:synfig,代码行数:60,代码来源:renderer_dragbox.cpp

示例9:

/// 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

示例10: draw

void enigma_rotor_window::draw(Cairo::RefPtr<Cairo::Context> cr)
{
    vector<double> dashes;
    // Pattern used to draw a dashed line (15 pixels of line followed by 15 "empty" pixels)
    dashes.push_back(15.0);
    dashes.push_back(15.0);
    
    if (has_ellipse)
    {
        cr->save();
        
            // Draw background ellipse
            cr->set_source_rgb(bkg_r, bkg_g, bkg_b);
            draw_ellipse(cr, x, y, ellipse_width, ellipse_height);
            cr->fill();
            // Draw black border of background ellipse
            cr->set_source_rgb(BLACK);
            cr->set_line_width(1.2);
            draw_ellipse(cr, x, y, ellipse_width, ellipse_height);
            cr->stroke();
        
        cr->restore();
    }
    
    cr->save();  
    
        // Draw a line of width rotor_rim_width in the dash background colour
        cr->set_line_width(rotor_rim_width);
        cr->set_source_rgb(dash_bkg_r, dash_bkg_g, dash_bkg_b);
        cr->move_to(x + window_size, y - (2 * window_size));
        cr->line_to(x + window_size, y + (2 * window_size));
        cr->stroke();
        
        // Draw a dashed line in the dash colour inside the previously drawn line
        // This creates the impression of "notches" on the handle/rim
        cr->set_source_rgb(dash_r, dash_g, dash_b);
        cr->set_dash(dashes, ((wheel_pos - 'A') & 1) * 15); // modifying the offset creates illusion of movement
        
        cr->move_to(x + window_size, y - (2 * window_size));
        cr->line_to(x + window_size, y + (2 * window_size));
        cr->stroke();
        
        // Draw border around handle/rim
        cr->set_line_width(2.0);
        cr->unset_dash();
        cr->set_source_rgb(DARK_GREY);
        cr->rectangle(x + padded_size, y - (2 * window_size), rotor_rim_width, (4 * window_size));
        cr->stroke();
    
    cr->restore();

    draw_wheel_pos(cr, wheel_pos);
    
    if (has_ellipse)
    {
        // Draw screws
        upper->draw(cr);
        lower->draw(cr);    
    }
}
开发者ID:rmsk2,项目名称:rmsk2,代码行数:60,代码来源:rotor_window.cpp

示例11: draw_sim_data

//Lots of this function needs to be optimised, including the pixbuf/bitmap thing and having to draw pretty much double the squares
void Simple_GOL_Area::draw_sim_data(const Cairo::RefPtr<Cairo::Context>& cr, int window_width, int window_height)
{
	time_t seconds = time(NULL);
	std::cout << "Rendering Simulation " << seconds << "\n";
	
	if (sim_data->get_size() != 0)
	{
		int data_width =  sim_data->get_width();
		int data_height = sim_data->get_height();
		double step_value_x = double(window_width)/double(sim_data->get_width());
		double step_value_y = double(window_height)/double(sim_data->get_height());
		
		for(int i=0; i<data_width; i++)
		{
			for(int j=0; j<data_height; j++)
			{
				if(sim_data->get(i,j))
				{
					cr->set_source_rgb(1,1,1);
				}
				else
				{
					cr->set_source_rgb(0,0,0);
				}
				
				//Yet to figure out why I have to draw in the black squares as well. 
				cr->rectangle(int(i*step_value_x), int(j*step_value_y),
				 			int((i+1)*step_value_x), int((j+1)*step_value_y));
				//Use bitmap classes so that I don't have to fill every time
				cr->fill();
			}	
		}

	}
}
开发者ID:SeanFC,项目名称:Conways_GOL,代码行数:36,代码来源:Conways_Game_Of_Life.cpp

示例12: on_draw

bool Terminal::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
    Box::on_draw(cr);

    cr->set_source_rgb(1, 0, 0);
    cr->rectangle(dock_hint.x, dock_hint.y, dock_hint.x+dock_hint.width, dock_hint.y+dock_hint.height);
    cr->fill();
}
开发者ID:SvanT,项目名称:SvanTerm2000,代码行数:7,代码来源:terminal.cpp

示例13: switch

        /** Drawing event handler. */
        virtual bool
        on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
        {
            switch (_curShape) {
            case SHAPE_RECTANGLE:
                cr->rectangle(20, 20, 200, 100);
                cr->set_source_rgb(0, 0.8, 0);
                cr->fill_preserve();
                break;
            case SHAPE_ELLIPSE:
                cr->arc(150, 100, 90, 0, 2 * 3.14);
                cr->set_source_rgb(0.8, 0, 0);
                cr->fill_preserve();
                break;
            case SHAPE_TRIANGLE:
                cr->move_to(40, 40);
                cr->line_to(200, 40);
                cr->line_to(120, 160);
                cr->line_to(40, 40);
                cr->set_source_rgb(0.8, 0, 0.8);
                cr->fill_preserve();
                cr->set_line_cap(Cairo::LINE_CAP_ROUND);
                cr->set_line_join(Cairo::LINE_JOIN_ROUND);
                break;
            }

            cr->set_line_width(3);
            cr->set_source_rgb(0, 0, 0);
            cr->stroke();
            return true;
        }
开发者ID:vagran,项目名称:adk,代码行数:32,代码来源:main.cpp

示例14: on_expose_event

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;
}
开发者ID:crazyscot,项目名称:brot2,代码行数:35,代码来源:Canvas.cpp

示例15:

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;
}
开发者ID:pxlong,项目名称:tactile-sensors,代码行数:33,代码来源:guiRenderer2D.cpp


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