本文整理汇总了C++中cairo::RefPtr::show_text方法的典型用法代码示例。如果您正苦于以下问题:C++ RefPtr::show_text方法的具体用法?C++ RefPtr::show_text怎么用?C++ RefPtr::show_text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cairo::RefPtr
的用法示例。
在下文中一共展示了RefPtr::show_text方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawAxis
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();
}
示例2: sprintf
void Format7DrawingArea::DrawImageDimensionsText(
Cairo::RefPtr<Cairo::Context> refCairo,
unsigned int left, unsigned int top, unsigned int width, unsigned int height )
{
refCairo->save();
// Set the font parameters
refCairo->select_font_face(
"monospace",
Cairo::FONT_SLANT_NORMAL,
Cairo::FONT_WEIGHT_BOLD );
refCairo->set_font_size( 10 );
// Set draw color to black
refCairo->set_source_rgb(0.0, 0.0, 0.0);
// Get width / height of widget
int widgetWidth = 0;
int widgetHeight = 0;
get_window()->get_size( widgetWidth, widgetHeight );
// Create text for image offset
char imageOffsets[128];
sprintf(
imageOffsets,
"Start: (%d,%d) End: (%d,%d)",
left,
top,
left + width,
top + height );
Cairo::TextExtents offsetExtents;
refCairo->get_text_extents(imageOffsets, offsetExtents);
// Draw the offset text
refCairo->move_to(
(widgetWidth/2) - (offsetExtents.width/2),
(widgetHeight/2) - offsetExtents.height - (offsetExtents.height/2));
refCairo->show_text( imageOffsets );
// Create text for image dimensions
char imageDimensions[128];
sprintf(
imageDimensions,
"Dimensions: %d x %d",
width,
height);
Cairo::TextExtents dimensionsExtents;
refCairo->get_text_extents(imageDimensions, dimensionsExtents);
// Draw the dimensions text
refCairo->move_to(
(widgetWidth/2) - (dimensionsExtents.width/2),
(widgetHeight/2) + dimensionsExtents.height + (dimensionsExtents.height/2));
refCairo->show_text( imageDimensions );
refCairo->restore();
}
示例3:
void
Operation::draw_title(const Glib::RefPtr<Gtk::PrintContext>& print)
{
double pos_x, pos_y;
Cairo::RefPtr<Cairo::Context> cairo = print->get_cairo_context();
DICOM::SummaryInfo* info = const_cast<DICOM::SummaryInfo*>(&dicom_info_);
DICOM::StudyInfo* study = info->get_study_info();
// Show Institution Name
cairo->set_font_size(title_font_size_);
Cairo::TextExtents cur_ext, prev_ext;
cairo->get_text_extents( study->get_institution_name(), cur_ext);
pos_x = (width_ - cur_ext.width) / 2.;
pos_y = cur_ext.height + OFFSET;
cairo->move_to( pos_x, pos_y);
cairo->show_text(study->get_institution_name());
// Show Institution Address
prev_ext = cur_ext;
cairo->set_font_size(subtitle_font_size_);
cairo->get_text_extents( study->get_institution_address(), cur_ext);
pos_x = -(prev_ext.width + prev_ext.x_bearing +
cur_ext.width + cur_ext.x_bearing) / 2.;
pos_y = cur_ext.height + OFFSET;
cairo->rel_move_to( pos_x, pos_y);
cairo->show_text(study->get_institution_address());
// Show Study Description
prev_ext = cur_ext;
cairo->set_font_size(title_font_size_);
cairo->get_text_extents( study->get_description(), cur_ext);
pos_x = -(prev_ext.width + prev_ext.x_bearing +
cur_ext.width + cur_ext.x_bearing) / 2.;
pos_y = cur_ext.height + OFFSET;
cairo->rel_move_to( pos_x, pos_y);
cairo->show_text(study->get_description());
pos_x = -(width_ + cur_ext.width) / 2.;
pos_y = cur_ext.height + OFFSET;
cairo->rel_move_to( pos_x, pos_y);
cairo->stroke_preserve();
}
示例4:
bool
ButtonWidget::on_expose_event(GdkEventExpose* event)
{
Gtk::DrawingArea::on_expose_event(event);
Glib::RefPtr<Gdk::Window> window = get_window();
if(window)
{
Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
int w = get_allocation().get_width() - 10;
int h = get_allocation().get_height() - 10;
cr->set_source_rgb(0.0, 0.0, 0.0);
cr->set_line_width(1.0);
cr->translate(5, 5);
cr->rectangle(0, 0, w, h);
if (down)
cr->fill_preserve();
cr->stroke();
if (down)
cr->set_source_rgb(1.0, 1.0, 1.0);
// FIXME: There are better ways to center text
if (name.size() == 2)
cr->move_to(w/2-6, h/2+3);
else
cr->move_to(w/2-4, h/2+3);
cr->show_text(name);
}
return true;
}
示例5: sprintf
void Format7DrawingArea::DrawDisabledText(Cairo::RefPtr<Cairo::Context> refCairo)
{
refCairo->save();
// Set the font parameters
refCairo->select_font_face(
"monospace",
Cairo::FONT_SLANT_NORMAL,
Cairo::FONT_WEIGHT_BOLD );
refCairo->set_font_size( 10 );
// Set draw color to black
refCairo->set_source_rgb(0.0, 0.0, 0.0);
// Print current cursor position
char cursorPosition[128];
sprintf(
cursorPosition,
"Custom Image is not supported by this camera.");
// Get width / height of widget
int width;
int height;
get_window()->get_size( width, height );
Cairo::TextExtents textExtents;
refCairo->get_text_extents( cursorPosition, textExtents );
refCairo->move_to(
(width/2) - (textExtents.width/2),
(height/2) + textExtents.height + (textExtents.height/2));
refCairo->show_text( cursorPosition );
refCairo->restore();
}
示例6: main
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;
}
示例7: drawCairo
int drawCairo(const string& fname,
const valarray<double>& Xin, const valarray<double>& Yin,
const Hull& hull) {
#ifdef CAIRO_HAS_SVG_SURFACE
unsigned n=Xin.size();
assert(Yin.size()==n);
// normalise coords to range 0-1
valarray<double> X=Xin, Y=Yin;
X-=X.min();
Y-=Y.min();
X/=X.max();
Y/=Y.max();
Cairo::RefPtr<Cairo::SvgSurface> surface =
Cairo::SvgSurface::create(fname, width+2*border, height+2*border);
Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create(surface);
cr->save(); // save the state of the context
cr->set_source_rgba(0.0, 0.0, 0.0, 0.7);
// draw a circle at each coordinate
for(unsigned i=0;i<n;i++) {
dot(cr,xcoord(X[i]),ycoord(Y[i]));
}
cr->set_source_rgba(0.0, 0.0, 0.0, 0.3);
cr->move_to(xcoord(X[hull[0]]),ycoord(Y[hull[0]]));
for(unsigned i=1;i<hull.size();i++) {
cr->line_to(xcoord(X[hull[i]]),ycoord(Y[hull[i]]));
}
cr->line_to(xcoord(X[hull[0]]),ycoord(Y[hull[0]]));
cr->stroke();
cr->set_source_rgba(0.0, 0.0, 0.0, 1.);
for(vector<unsigned>::const_iterator i=hull.begin();i!=hull.end();++i) {
unsigned j=*i;
stringstream ss;
ss<<j;
printf("p[%d]=(%f,%f)\n",j,X[j],Y[j]);
cr->move_to(xcoord(X[j]),ycoord(Y[j]));
cr->show_text(ss.str());
cr->stroke();
}
cr->restore();
cr->show_page();
cout << "Wrote SVG file \"" << fname << "\"" << endl;
return 0;
#else
cout << "You must compile cairo with SVG support for this example to work."
<< endl;
return 1;
#endif
}
示例8: draw
void ICLayerLineString::draw(Cairo::RefPtr<Cairo::Context> cr, double scale,
std::set<int> select, bool DisplayID, double Alpha)
{
std::map<int, ICLayerObject*>::iterator it;
for (it = m_ICLayerObject.begin(); it != m_ICLayerObject.end(); it++)
{
if ((*it).second->selfIdExisting())
{
bool isSelect = false;
if (!select.empty())
{
std::set<int>::iterator it2;
it2 = select.find((*it).first);
if (it2 != select.end() && (*it2) == (*it).first)
{
drawLine(cr, (*it).second->getOGRGeometryObject(), scale, true);
isSelect = true;
} else
drawLine(cr, (*it).second->getOGRGeometryObject(), scale, false);
} else
drawLine(cr, (*it).second->getOGRGeometryObject(), scale, false);
if (DisplayID)
{
Cairo::TextExtents extents;
std::stringstream str;
str << (*it).first;
std::string text = str.str();
cr->select_font_face("Bitstream Vera Sans, Arial", Cairo::FONT_SLANT_NORMAL,
Cairo::FONT_WEIGHT_NORMAL);
cr->set_font_size(12 / scale);
Cairo::FontOptions font_options;
font_options.set_hint_style(Cairo::HINT_STYLE_NONE);
font_options.set_hint_metrics(Cairo::HINT_METRICS_OFF);
font_options.set_antialias(Cairo::ANTIALIAS_GRAY);
cr->set_font_options(font_options);
cr->save();
cr->get_text_extents(text, extents);
cr->move_to((*it).second->getCentroid().first,
(*it).second->getCentroid().second);
cr->scale(1, -1);
if (isSelect)
cr->set_source_rgba(0, 0, 0, Alpha);
cr->show_text(text);
cr->stroke();
cr->restore();
}
}
}
}
示例9: main
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<BoxFontFace> font = BoxFontFace::create();
cr->set_font_face(font);
cr->set_font_size(FONT_SIZE);
cr->show_text("cairomm!");
// Now show it with the toy text API to
// demonstrate how the glyphs match up
cr->move_to(TEXT_ORIGIN_X, TEXT_ORIGIN_Y);
cr->set_source_rgba(0.2, 0.2, 0.2, 0.3);
Cairo::RefPtr<Cairo::ToyFontFace> toy_font = Cairo::ToyFontFace::create(
"Bitstream Charter", Cairo::FONT_SLANT_NORMAL,
Cairo::FONT_WEIGHT_BOLD);
cr->set_font_face(toy_font);
cr->set_font_size(FONT_SIZE);
cr->show_text("cairomm!");
const char* filename = "user-font.png";
try {
surface->write_to_png(filename);
std::cout << "Wrote Image " << filename << std::endl;
return 0;
} catch (const std::exception& e) {
std::cout << "** Unable to write Image " << filename << std::endl;
return 1;
}
}
示例10: drawText
void NodeActivityDrawingArea::drawText() {
ActivityDrawingArea::drawText();
// This is where we draw on the window
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();
cr->save();
cr->set_line_width(2.0);
cr->set_source_rgb(1, 1, 1);
cr->set_font_size(12);
{
cr->move_to(width / 5, 20);
std::stringstream ss;
ss << "ID";
if (this->isPrimaryInput == true) {
ss << " (PIN)";
}
if (this->isPrimaryOutput == true) {
ss << " (POUT)";
}
ss<< ": " <<node->getUUIDString();
cr->show_text(ss.str());
}
{
std::stringstream ss;
cr->move_to(width / 5, 40);
int impulse_count = node->getImpulses().getSize();
int inputs_count = node->getConnector().getInputs().size();
int outputs_count = node->getConnector().getOutputs().size();
double threshold = node->getActivityThreshold();
ss << "Impulses: " << impulse_count;
ss << " Inputs: " << inputs_count;
ss << " Outputs: " << outputs_count;
ss << " Threshold: " << threshold;
cr->show_text(ss.str());
}
cr->restore();
}
示例11: draw_centered_text
void cairo::draw_centered_text( const Cairo::RefPtr<Cairo::Context>& cr, const std::string& utf8, const cairo_coord_t& pos )
{
cr->save();
Cairo::TextExtents texts;
cr->get_text_extents( utf8, texts );
cr->move_to( pos[0] - texts.width/2. - texts.x_bearing , pos[1] );
cr->show_text( utf8 );
cr->restore();
}
示例12: drawText
void ConnectionActivityDrawingArea::drawText() {
ActivityDrawingArea::drawText();
// This is where we draw on the window
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();
cr->save();
cr->set_line_width(2.0);
cr->set_source_rgb(1, 1, 1);
cr->set_font_size(12);
{
cr->move_to(width / 5, 20);
std::stringstream ss;
ss << "ID";
if (this->isPrimaryInput == true) {
ss << " (PIN)";
}
if (this->isPrimaryOutput == true) {
ss << " (POUT)";
}
ss << ": " << connection->getUUIDString();
cr->show_text(ss.str());
}
{
std::stringstream ss;
cr->move_to(width / 5, 40);
ss << "Impulses: " << connection->getImpulses().getSize();
// <<" compression: "<<fibril->getMutator().getCompression()
// <<" delay: " <<fibril->getMutator().getDelay();
cr->show_text(ss.str());
}
cr->restore();
}
示例13: on_expose_event
bool GMasterReturn::on_expose_event(GdkEventExpose* event)
{
// This is where we draw on the window
Glib::RefPtr<Gdk::Window> window = get_window();
if(window) // Only run if Window does exist
{
// clip to the area indicated by the expose event so that we only redraw
// the portion of the window that needs to be redrawn
Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
cr->rectangle(event->area.x, event->area.y,
event->area.width, event->area.height);
cr->clip();
cr->rectangle(event->area.x, event->area.y,
event->area.width, event->area.height);
cr->set_source_rgb(0.1 , 0.1 , 0.1 );
cr->fill();
Dial(cr, true, 35 , 0, value, DIAL_MODE_SEND ); // fader
// Dial text "A"
cr->select_font_face ("Impact" , Cairo::FONT_SLANT_NORMAL, Cairo::FONT_WEIGHT_BOLD);
cr->set_font_size ( 20 );
cr->move_to ( 10, 28);
switch ( ID )
{
case 0: setColour(cr, COLOUR_BLUE_1 ); cr->show_text ( "A" ); break;
case 1: setColour(cr, COLOUR_BLUE_1 ); cr->show_text ( "B" ); break;
case 2: setColour(cr, COLOUR_BLUE_1 ); cr->show_text ( "C" ); break;
}
}
return true;
}
示例14: drawAxis
void ConnectionActivityDrawingArea::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();
double max_delay = connection->getActivityTimer()->getStartingDelay();
//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);
{
std::stringstream ss_temp;
ss_temp << max_delay / 2;
cr->move_to(-40 + width / 2, 25 + height / 2);
cr->show_text(ss_temp.str());
}
{
std::stringstream ss_temp;
ss_temp << max_delay;
cr->move_to(width - 40, 25 + height / 2);
cr->show_text(ss_temp.str());
}
cr->stroke();
cr->restore();
}
示例15: draw
/* Draw the word cairo at NUM_TEXT different angles */
void draw(Cairo::RefPtr<Cairo::Context> cr, int width, int height)
{
int i, x_off, y_off;
Cairo::TextExtents extents;
std::string text("cairo");
cr->select_font_face("Bitstream Vera Sans", Cairo::FONT_SLANT_NORMAL,
Cairo::FONT_WEIGHT_NORMAL);
cr->set_font_size(TEXT_SIZE);
Cairo::FontOptions font_options;
font_options.set_hint_style(Cairo::HINT_STYLE_NONE);
font_options.set_hint_metrics(Cairo::HINT_METRICS_OFF);
font_options.set_antialias(Cairo::ANTIALIAS_GRAY);
cr->set_font_options(font_options);
cr->set_source_rgb(0.0, 0.0, 0.0);
cr->translate(width / 2.0, height / 2.0);
cr->get_text_extents(text, extents);
if (NUM_TEXT == 1)
{
x_off = y_off = 0;
}
else
{
y_off = (int) - floor(0.5 + extents.height / 2.0);
x_off = (int) floor(0.5 + (extents.height + 1.0) / (2.0 * tan (M_PI / NUM_TEXT)));
}
for (i=0; i < NUM_TEXT; i++)
{
cr->save();
cr->rotate(2 * M_PI * i / NUM_TEXT);
cr->set_line_width(1.0);
cr->set_source_rgb(1, 0, 0);
cr->stroke();
cr->move_to(x_off - extents.x_bearing, y_off - extents.y_bearing);
cr->set_source_rgb(0, 0, 0);
cr->show_text("Five Lights!");
cr->restore();
}
}