예제 #1
0
bool Simple_GOL_Area::on_button_press_event(GdkEventButton* event)
{
	if(event->type == GDK_BUTTON_PRESS)
	{
		if(event->button == 1)
		{	
			Gtk::Allocation allocation = get_allocation();
			
			int item_x = int(sim_data->get_width()*event->x/allocation.get_width());
			int item_y = int(sim_data->get_height()*event->y/allocation.get_height());
			std::cout << item_x << " " << item_y << "\n";
			
			mouse_button_one_down = (sim_data->get(item_x, item_y)+1)%2 + 1;
				
			sim_data->set(item_x, item_y, (sim_data->get(item_x, item_y)+1)%2);
			
			queue_draw();
		}
		else if(event->button == 3)
		{
			pause_toggle();
		}
	}
	
	return true;
}
예제 #2
0
파일: balls.cpp 프로젝트: jogojapan/simul
bool Balls::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
  Gtk::Allocation allocation = get_allocation();
  const int width = allocation.get_width();
  const int height = allocation.get_height();

  cr->save();
  cr->scale(width, height);

  cr->set_line_width(0.001);
  for (auto ball : balls_)
    {
      cr->set_source_rgb(ball.color_r,ball.color_g,ball.color_b);
      cr->arc(ball.p.x,ball.p.y,
              ball.rad,
              0,2*M_PI);
      cr->fill();
      cr->stroke();
    }

  cr->restore();

  const Ball &ball1 = balls_[balls_.size()-1];
  std::ostringstream info;
  info << "x = " << ball1.p.x << "\ny = " << ball1.p.y;
  infobox_.show(cr,width,height,info.str());

  return true;
}
예제 #3
0
void
perftime::on_size_allocate (Gtk::Allocation & a_r)
{
    Gtk::DrawingArea::on_size_allocate(a_r);
    m_window_x = a_r.get_width();
    m_window_y = a_r.get_height();
}
예제 #4
0
/** Get dimensions
 * @param width upon return contains width
 * @param height upon return contains height
 */
void
SkillGuiGraphDrawingArea::get_dimensions(double &width, double &height)
{
  Gtk::Allocation alloc = get_allocation();
  width  = alloc.get_width();
  height = alloc.get_height();
}
예제 #5
0
/* Callback on_draw */
bool SensorsMap::on_draw (const Cairo::RefPtr<Cairo::Context>& cr)
{
  /* Get window allocation */
  Gtk::Allocation allocation = get_allocation ();
  const int width = allocation.get_width ();
  const int height = allocation.get_height ();

  /* Get center of the window */
  int xc, yc;
  xc = width / 2;
  yc = height / 2;

// DEBUG
cr->set_line_width(10.0);

// draw red lines out from the center of the window
cr->set_source_rgb(0.8, 0.0, 0.0);
cr->move_to(0, 0);
cr->line_to(xc, yc);
cr->line_to(0, height);
cr->move_to(xc, yc);
cr->line_to(width, yc);
cr->stroke();
// END DEBUG

  /* Return success */
  return true;
}
예제 #6
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;
}
예제 #7
0
bool CircuitWidget::on_button_press_event (GdkEventButton* event)
{
    if (!circuit) {
        return true;
    } else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) {
        // Double-click.
        panning = false;
        if(circuitDrawer.usingLineLabels()) {
            // If a line label is double-clicked, edit it.
            Gtk::Allocation allocation = get_allocation();
            const int width = allocation.get_width();
            const int height = allocation.get_height();
            // translate mouse click coords into circuit diagram coords
            double x = (event->x - width/2.0 + ext.width/2.0)/scale + cx;// - cx*scale;
            double y = (event->y - height/2.0 + ext.height/2.0)/scale + cy;// - cy*scale;
            vector<int> selections;
            int res = pickRect(wirelabels, x, y, selections);
            if(res>=0) {
                edit_line_label(res);
            }
        }
        return true;
    } else if (event->button == 1) {
        panning = true;
        oldmousex = event->x;
        oldmousey = event->y;
        select_rect.x0 = event->x;
        select_rect.y0 = event->y;
        select_rect.width = 0;
        select_rect.height = 0;
        return true;
    } else {
        return true;
    }
}
void ActivityDrawingArea::drawAxis() {
	// draw a reference axis and pod info
	Glib::RefPtr < Gdk::Window > window = get_window();
	Cairo::RefPtr < Cairo::Context > cr = window->create_cairo_context();
	Gtk::Allocation allocation = get_allocation();
	const int width = allocation.get_width();
	const int height = allocation.get_height();

	//draw axis
	cr->save();
	cr->set_line_width(2.0);
	this->setSourceRGB(cr, currentColourScheme.getAxisColour());
	cr->set_font_size(12);

	cr->move_to(0, height / 2);
	cr->line_to(width, height / 2);

	cr->move_to(190, 25 + height / 2);
	cr->show_text("20");
	cr->move_to(390, 25 + height / 2);
	cr->show_text("40");
	cr->move_to(590, 25 + height / 2);
	cr->show_text("60");
	cr->move_to(790, 25 + height / 2);
	cr->show_text("80");

	cr->stroke();
	cr->restore();
}
예제 #9
0
void MapDrawArea::DrawOptimalPath(const Cairo::RefPtr<Cairo::Context>& cr)
{
	// This is where we draw on the window
	Gtk::Allocation allocation = get_allocation();
	const int width = allocation.get_width();
	const int height = allocation.get_height();
	const int lesser = MIN(width, height);
	const Coord maxXY = guiMapData.copyMaxCoord();

	// Copy the optimal path to the draw area
	std::vector<Coord> optimalPath = guiMapData.copyOptPath();

	// Plot the path
	cr->save();
	cr->set_source_rgb(1.0, 0.08, 0.58);	// pink for path
	cr->set_line_width(lesser * 0.005);
	cr->set_line_cap(Cairo::LINE_CAP_ROUND);

	for(std::vector<Coord>::iterator itr=optimalPath.begin();itr != optimalPath.end();++itr)
	{
		cr->move_to( int( float(width)*float(itr->x)/float(maxXY.x) ),int( height*float(itr->y)/float(maxXY.y)));
		cr->line_to( int( float(width)*float(itr->x)/float(maxXY.x) ),int( height*float(itr->y)/float(maxXY.y)));
		cr->stroke();
	}
}
예제 #10
0
void MapDrawArea::DrawObstacles(const Cairo::RefPtr<Cairo::Context>& cr)
{
	// Get size characteristics of the window
	Gtk::Allocation allocation = get_allocation();
	const int width = allocation.get_width();
	const int height = allocation.get_height();
	const int lesser = MIN(width, height);

	// We should be able to just store the obstacles and path once
	// Do need to update based on the window size
	std::vector<Coord> vObstacles = guiMapData.copyObstacles();
	Coord maxXY = guiMapData.copyMaxCoord();
	Coord originCoord = guiMapData.copyStartCoord();
	Coord goalCoord = guiMapData.copyEndCoord();

	// These have to be updated each iteration
	originCoord.x = int( float(width)*float(originCoord.x)/float(maxXY.x) );
	originCoord.y = int( float(height)*float(originCoord.y)/float(maxXY.y) );
	goalCoord.x = int( float(width)*float(goalCoord.x)/float(maxXY.x) );
	goalCoord.y = int( float(height)*float(goalCoord.y)/float(maxXY.y) );

	// Draw obstacles
	std::vector<Coord> scaledObstacleCoord;
	std::vector<Coord> rawObstacleCoord = guiMapData.copyObstacles();
	Coord stdCoord;

	// Adjust obstacle values based on window size
	for(std::vector<Coord>::const_iterator itr=rawObstacleCoord.begin();itr!=rawObstacleCoord.end();++itr)
	{
		stdCoord.x = int( float(width)*float(itr->x)/float(maxXY.x) );
		stdCoord.y = int( height*float(itr->y)/float(maxXY.y) );
		scaledObstacleCoord.push_back(stdCoord);
	}

	cr->save();
	cr->set_source_rgb(0.0, 0.0, 0.0);	// black for obstacles
	cr->set_line_width(lesser * 0.005);
	cr->set_line_cap(Cairo::LINE_CAP_ROUND);

	// Plot obstacles
	for(std::vector<Coord>::iterator itr=scaledObstacleCoord.begin();itr != scaledObstacleCoord.end();++itr)
	{
		cr->move_to( itr->x,itr->y );
		cr->line_to( itr->x,itr->y );
		cr->stroke();
	}

	// Plot start/end coord
	cr->save();
	cr->set_line_width(lesser * 0.015);
	cr->set_source_rgb(1.0, 0.0, 0.0);	// red for start point
	cr->move_to( originCoord.x,originCoord.y );
	cr->line_to( originCoord.x,originCoord.y );
	cr->stroke();
	cr->save();
	cr->set_source_rgb(0.0, 1.0, 0.0);	// green for end point
	cr->move_to( goalCoord.x,goalCoord.y );
	cr->line_to( goalCoord.x,goalCoord.y );
	cr->stroke();
}
예제 #11
0
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;
}
예제 #12
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();
}
예제 #13
0
void
perfnames::on_size_allocate (Gtk::Allocation & a)
{
    gui_drawingarea_gtk2::on_size_allocate(a);
    m_window_x = a.get_width();                     /* side-effect  */
    m_window_y = a.get_height();                    /* side-effect  */
}
예제 #14
0
void ActivityDrawingArea::drawPoints(std::map<double, double> & ps, const double reference_line) {
	//std::cout<<"ActivityDrawingArea::drawPoints: " <<std::endl;
	// This is where we draw on the window
	Glib::RefPtr < Gdk::Window > window = get_window();
	Cairo::RefPtr < Cairo::Context > cr = window->create_cairo_context();
	cr->save();
	Gtk::Allocation allocation = get_allocation();
	const int width = allocation.get_width();
	const int height = allocation.get_height();

	cr->set_line_width(2.0);
	//  std::cout<<"ActivityDrawingArea::drawPoints: colour: "<<"("<<main_colour[0]<<","<<main_colour[1]<<","<< main_colour[2] <<std::endl;
	this->setSourceRGB(cr, currentColourScheme.getMainColour());

	//scale the drawing in x and y
	double maxy = 0;
	std::map<double, double>::iterator it_ps = ps.begin();
	while (it_ps != ps.end()) {
		if (it_ps->second < 0 && -(it_ps->second) > maxy) {
			maxy = -(it_ps->second);
		} else if (it_ps->second > 0 && (it_ps->second) > maxy) {
			maxy = (it_ps->second);
		}
		++it_ps;
	}

	double scaley = 0.2 * (double) ActivityDrawingArea::ACTIVITY_HEIGHT / maxy;
	double scalex = 10;

	it_ps = ps.begin();
	if (it_ps != ps.end()) {
		cr->move_to(scalex * it_ps->first, (0.5 * height) - (scaley * it_ps->second));
	} else {
		cr->move_to(0, height / 2);
	}
	while (it_ps != ps.end()) {
		//	std::cout<<"ActivityDrawingArea::drawPoints: " << it_ps->first <<","<<-it_ps->second<<std::endl;
		cr->line_to((scalex * it_ps->first), (0.5 * height) - (scaley * it_ps->second));
		++it_ps;
	}
	cr->stroke();

	// draw reference line if not zero
	if (reference_line>0.00001 || reference_line < -0.00001) {
		Gdk::Color temp_colour(currentColourScheme.getMainColour());
		this->setSourceRGB(cr, Gdk::Color("tomato"));
		cr->set_line_width(1.0);
		const std::vector<double> dashed= { 1.0 };
		cr->set_dash(dashed, 1);
		double scaled_reference_line = (0.5 * height) - (scaley * reference_line);
		double neg_scaled_reference_line = (0.5 * height) + (scaley * reference_line);
		cr->move_to(0, scaled_reference_line);
		cr->line_to(width, scaled_reference_line);
		cr->move_to(0, neg_scaled_reference_line);
			cr->line_to(width, neg_scaled_reference_line);
		cr->stroke();
	}
	cr->restore();
}
예제 #15
0
파일: seqroll.cpp 프로젝트: EQ4/sequencer24
void
seqroll::on_size_allocate (Gtk::Allocation & a_r)
{
    Gtk::DrawingArea::on_size_allocate(a_r);
    m_window_x = a_r.get_width();
    m_window_y = a_r.get_height();
    update_sizes();
}
예제 #16
0
파일: seqkeys.cpp 프로젝트: EQ4/sequencer24
void
seqkeys::on_size_allocate (Gtk::Allocation & a_r)
{
    Gtk::DrawingArea::on_size_allocate(a_r);
    m_window_x = a_r.get_width();
    m_window_y = a_r.get_height();
    queue_draw();
}
예제 #17
0
파일: seqtime.cpp 프로젝트: EQ4/sequencer64
void
seqtime::on_size_allocate (Gtk::Allocation & a)
{
    gui_drawingarea_gtk2::on_size_allocate(a);
    m_window_x = a.get_width();
    m_window_y = a.get_height();
    update_sizes();
}
예제 #18
0
void
seqdata::on_size_allocate (Gtk::Allocation & r)
{
    gui_drawingarea_gtk2::on_size_allocate(r);
    m_window_x = r.get_width();
    m_window_y = r.get_height();
    update_sizes();
}
예제 #19
0
	void shuaxin__(){
	    Glib::RefPtr<Gdk::Window> w = da_->get_window();
	    if (w) {
	    	Gtk::Allocation a = da_->get_allocation();
	        Gdk::Rectangle r(0, 0,a.get_width(),a.get_height());
	        w->invalidate_rect(r, false);
	    }
	}
예제 #20
0
파일: ImageDrawable.cpp 프로젝트: lp0/fiv
void inline ImageDrawable::calcRenderedImage(shared_ptr<Image> image, const Gtk::Allocation &allocation,
		int &rwidth, int &rheight, double &rscale, double &rx, double &ry) {
	const int awidth = allocation.get_width();
	const int aheight = allocation.get_height();

	switch (image->getOrientation().first) {
	case Image::Rotate::ROTATE_NONE:
	case Image::Rotate::ROTATE_180:
	default:
		rwidth = image->width();
		rheight = image->height();
		break;

	case Image::Rotate::ROTATE_90:
	case Image::Rotate::ROTATE_270:
		rwidth = image->height();
		rheight = image->width();
		break;
	}

	if (std::isnan(zoom)) {
		rscale = min((double)awidth / rwidth, (double)aheight / rheight);

		if ((double)awidth / rwidth >= (double)aheight / rheight) {
			rx = ((double)awidth - rscale * rwidth) / 2;
			ry = 0;
		} else {
			rx = 0;
			ry = ((double)aheight - rscale * rheight) / 2;
		}
	} else {
		rscale = zoom;
		rx = x + dragOffsetX;
		ry = y + dragOffsetY;

		if (rwidth * rscale < awidth) {
			// Image width too small, centre horizontally
			rx = ((double)awidth - rscale * rwidth) / 2;
		} else if (rx > 0) {
			// Gap at the left of the image, move to the left edge
			rx = 0;
		} else if (rx + rwidth * rscale < awidth) {
			// Gap at the right of the image, move to the right edge
			rx = awidth - rwidth * rscale;
		}

		if (rheight * rscale < aheight) {
			// Image height too small, centre vertically
			ry = ((double)aheight - rscale * rheight) / 2;
		} else if (ry > 0) {
			// Gap at the top of the image, move to the top edge
			ry = 0;
		} else if (ry + rheight * rscale < aheight) {
			// Gap at the bottom of the image, move to the bottom edge
			ry = aheight - rheight * rscale;
		}
	}
}
예제 #21
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;
}
예제 #22
0
파일: BookReader.cpp 프로젝트: ShiYw/reader
bool BookArea::on_draw(const Cairo::RefPtr<Cairo::Context> & cr)
{

    Cairo::RefPtr<Cairo::Surface> surface = cr->get_target();

    PageDescriptor pd = pages.get(pagenum);

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

    const int rectangle_width = width;
    const int rectangle_height = height;

    //cr->set_antialias(ANTIALIAS_BEST);

    cr->set_source_rgb(1.0, 1.0, 1.0);
    DrawingUtils::draw_rectangle(cr, rectangle_width, rectangle_height);

    cr->set_source_rgb(0.15, 0.15, 0.15);
    //cr->set_source_rgb(1, 0.33, 0.33);

    int start_pos = 0;

    int itemid = 0;

    for(PageContentItem pci : pd.items) {

        if(pci.pct == PAGE_H1) {
            start_pos += DrawingUtils::draw_h1(cr, pci.content, rectangle_width, rectangle_height);
        }
        else if(pci.pct == PAGE_H2) {
            // Only pack out the header when it's not the first thing in the page
            if (itemid != 0) {
                start_pos += 35;
            }

            start_pos += DrawingUtils::draw_h2(cr, pci.content, rectangle_width, rectangle_height, start_pos);
            start_pos += 35;
        }
        else if(pci.pct == PAGE_PARAGRAPH) {
            start_pos += DrawingUtils::draw_text(cr, pci.content, rectangle_width, rectangle_height, start_pos);
        }
        else if(pci.pct == PAGE_FRAGMENT) {
            start_pos += DrawingUtils::draw_fragment(cr, pci.content, rectangle_width, rectangle_height, start_pos);
        }

        itemid++;

    }

    //auto it = book.opf_files[0].metadata.find(MetadataType::TITLE);
    //const ustring title = it->second.contents;
    cr->set_source_rgb(0.5, 0.5, 0.5);
    page_num_rect = DrawingUtils::draw_header(cr, rectangle_width, rectangle_height, "Pride and Prejudice", pagenum + 1);

    return true;
}
예제 #23
0
 double get_scale() {
   Glib::RefPtr<Gdk::Window> window = get_window();
   assert(window);
   Gtk::Allocation allocation = get_allocation();
   const int width = allocation.get_width();
   const int height = allocation.get_height();
   RefPtr<ImageSurface> img = gm.get_surface();
   return min(min(width/(double)img->get_width(), height/(double)img->get_height()), 1.0);
 }
예제 #24
0
void Simple_GOL_Area::draw_background(const Cairo::RefPtr<Cairo::Context>& cr)
{
	Gtk::Allocation allocation = get_allocation();
	const int width = allocation.get_width();
	const int height = allocation.get_height();
	cr->set_source_rgb(0,0,0);
	cr->rectangle(0, 0, width, height);
 	cr->fill();
}
예제 #25
0
bool ListView::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
    Gtk::Allocation allocation = get_allocation();

    const int width = allocation.get_width();
    const int height = allocation.get_height();

    return true;
}
예제 #26
0
파일: CamWnd.cpp 프로젝트: Zbyl/DarkRadiant
void CamWnd::onSizeAllocate(Gtk::Allocation& allocation)
{
    getCamera().width = allocation.get_width();
    getCamera().height = allocation.get_height();
    getCamera().updateProjection();

    m_window_observer->onSizeChanged(getCamera().width, getCamera().height);

    queueDraw();
}
예제 #27
0
파일: Display.cpp 프로젝트: tomkcook/ringer
void BellDisplay::on_size_allocate(Gtk::Allocation& allocation)
{
	Gtk::DrawingArea::on_size_allocate(allocation);
	set_allocation(allocation);

	if (mRenderWindow)
	{
		mRenderWindow->windowMovedOrResized();
		mCamera->setAspectRatio(Ogre::Real(allocation.get_width()) / Ogre::Real(allocation.get_height()));
	}
}
예제 #28
0
bool VistaDiagrama::on_expose_event(GdkEventExpose* event) {
	this->set_size_request(this->ancho, this->alto);

	// Gonzalo : TEST
	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();

		// coordinates for the center of the window
		int xc, yc;
		xc = width / 2;
		yc = height / 2;

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

		// 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();

		// draw red lines out from the center of the window
		cr->set_line_cap(Cairo::LINE_CAP_ROUND);
		cr->set_source_rgb(0.8, 0.0, 0.0);
		cr->move_to(20, 20);
		cr->line_to(xc, yc);
		cr->line_to(20, height - 20);

		cr->move_to(xc, yc);
		cr->line_to(width - 20, yc);
		cr->stroke();

		//RefPtr<Context> cr = this->get_window()->create_cairo_context();
		/*cr->set_source_rgba(1, 1, 1, 1); // white
		 cr->paint();
		 cr->set_source_rgba(0, 0, 0, 1); // negro

		 cr->move_to(0, 0);
		 cr->line_to(this->ancho, this->alto);

		 VistaEntidad * entidad = new VistaEntidad();

		 entidad->setposfin(10, 10);
		 entidad->setposfin(20, 20);

		 entidad->dibujar(cr);*/
	}

	//delete entidad;
	return true;
}
예제 #29
0
		virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
		{
			Gtk::Allocation allocation = get_allocation();
			const int width = allocation.get_width();
			const int height = allocation.get_height();
			
			if(!drawing)
			{
				sort(objects.begin(), objects.end(), PlaneObjectColection::compare);
			}
			
			drawing=1;
			
			unsigned int i;
			unsigned int j;
			
			cr->set_line_width(2);
			
			Coordenate temp;
			
			for(i=0; i<objects.size(); i++)
			{
				if(objects[i].get_num_nodos()<2 || objects[i].z>=camera.z) continue;
				
				cr->save();
				
				temp=get_draw_location(objects[i].get_nodo_position(0), width, height, 26.5/M_PI);
					
				cr->line_to(temp.x, temp.y);
				
				cr->move_to(temp.x, temp.y);
				
				for(j=1; j<objects[i].get_num_nodos(); j++)
				{
					temp=get_draw_location(objects[i].get_nodo_position(j), width, height, 26.5/M_PI);
					
					cr->line_to(temp.x, temp.y);
				}
				
				temp=get_draw_location(objects[i].get_nodo_position(0), width, height, 26.5/M_PI);
				cr->line_to(temp.x, temp.y);
				
				temp=get_draw_location(objects[i].get_nodo_position(1), width, height, 26.5/M_PI);
				cr->line_to(temp.x, temp.y);
				
				cr->set_source_rgba(double(objects[i].fill_color.red)/255, double(objects[i].fill_color.green)/255, double(objects[i].fill_color.blue)/255, double(objects[i].fill_color.alpha)/255);
				cr->fill_preserve();
				cr->set_source_rgba(double(objects[i].line_color.red)/255, double(objects[i].line_color.green)/255, double(objects[i].line_color.blue)/255, double(objects[i].line_color.alpha)/255);
				cr->stroke();
				cr->restore();
			}
			
			return 1;
		}
예제 #30
0
/** Zoom reset.
 * Reset zoom to 1. Enables scale override.
 */
void
SkillGuiGraphDrawingArea::zoom_reset()
{
  Gtk::Allocation alloc = get_allocation();
  if (__scale != 1.0 || ! __scale_override) {
    __scale = 1.0;
    __scale_override = true;
    __translation_x = (alloc.get_width()  - __bbw) / 2.0 + __pad_x;
    __translation_y = (alloc.get_height() - __bbh) / 2.0 + __bbh - __pad_y;
  }
  queue_draw();
}