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


C++ pango_cairo_show_layout函数代码示例

本文整理汇总了C++中pango_cairo_show_layout函数的典型用法代码示例。如果您正苦于以下问题:C++ pango_cairo_show_layout函数的具体用法?C++ pango_cairo_show_layout怎么用?C++ pango_cairo_show_layout使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: draw_page

static void draw_page(GtkPrintOperation *operation,
			GtkPrintContext *context,
			gint page_nr,
			gpointer user_data)
{
	cairo_t *cr;
	PangoLayout *layout;
	double w, h;
	struct graphics_context gc = { .printer = 1 };

	cr = gtk_print_context_get_cairo_context(context);
	gc.cr = cr;

	layout=gtk_print_context_create_pango_layout(context);

	w = gtk_print_context_get_width(context);
	h = gtk_print_context_get_height(context);

	/* Do the profile on the top half of the page.. */
	plot(&gc, w, h/2, current_dive);

	pango_cairo_show_layout(cr,layout);
	g_object_unref(layout);
}

static void begin_print(GtkPrintOperation *operation, gpointer user_data)
{
}

static GtkPrintSettings *settings = NULL;

void do_print(void)
{
	GtkPrintOperation *print;
	GtkPrintOperationResult res;

	print = gtk_print_operation_new();
	if (settings != NULL)
		gtk_print_operation_set_print_settings(print, settings);
	gtk_print_operation_set_n_pages(print, 1);
	g_signal_connect(print, "begin_print", G_CALLBACK(begin_print), NULL);
	g_signal_connect(print, "draw_page", G_CALLBACK(draw_page), NULL);
	res = gtk_print_operation_run(print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
					 GTK_WINDOW(main_window), NULL);
	if (res == GTK_PRINT_OPERATION_RESULT_APPLY) {
		if (settings != NULL)
			g_object_unref(settings);
		settings = g_object_ref(gtk_print_operation_get_print_settings(print));
	}
	g_object_unref(print);
}
开发者ID:teni,项目名称:subsurface,代码行数:51,代码来源:print.c

示例2: draw

static void
draw (cairo_t *cr, PangoLayout *layout, unsigned int i)
{
  cairo_set_source_rgba (cr, 1, 1, 1, 1);
  cairo_paint (cr);
  cairo_set_source_rgba (cr, 1, 1, 1, 0);
  cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);

  cairo_identity_matrix (cr);
  cairo_scale (cr, (100 + i) / 100.,  (100 + i) / 100.);
  pango_cairo_update_layout (cr, layout);

  pango_cairo_show_layout (cr, layout);
}
开发者ID:kvk30,项目名称:Tuxpaint-Android,代码行数:14,代码来源:test-pangocairo-threads.c

示例3: ly_3lrc_widget_draw_text

void ly_3lrc_widget_draw_text (cairo_t *cr, gchar *text, gchar *font)
{
	PangoLayout *layout;
	PangoFontDescription *desc;
	
	layout = pango_cairo_create_layout (cr);
	pango_layout_set_text (layout, text, -1);
	desc = pango_font_description_from_string (font);
	pango_layout_set_font_description (layout, desc);
	pango_font_description_free (desc);
	pango_cairo_update_layout (cr, layout);
	pango_cairo_show_layout (cr, layout);
	g_object_unref (layout);
}
开发者ID:lovesnow,项目名称:linnya,代码行数:14,代码来源:lrc_widget.c

示例4: cairo_move_to

void
TextAsset::drawText(cairo_t* cairoContext,
                    const std::string& textString,
                    const Rect& rect,
                    PangoFontDescription* inFontDescription,
                    bool outlineEnabled)
{
    cairo_move_to(cairoContext, rect.x, rect.y);

    PangoLayout* layout = pango_cairo_create_layout(cairoContext);

    // Kerning
    PangoAttrList* attr_list = pango_attr_list_new();
    PangoAttribute* spacing_attr = pango_attr_letter_spacing_new(pango_units_from_double(_kern));
    pango_attr_list_insert(attr_list, spacing_attr);
    pango_layout_set_attributes(layout, attr_list);

    pango_cairo_context_set_resolution(pango_layout_get_context(layout), DISPLAY_RESOLUTION);
    pango_layout_set_text(layout, textString.c_str(), textString.length());
    pango_layout_set_font_description(layout, inFontDescription);
    pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
    pango_layout_set_width(layout, pango_units_from_double(rect.size.width + WIDTH_PADDING));
    pango_layout_set_height(layout, pango_units_from_double(rect.size.height + HEIGHT_PADDING));
    pango_layout_set_alignment(layout, _alignment);
    applyLeading(cairoContext, layout, inFontDescription);

    pango_cairo_show_layout(cairoContext, layout);

    // Core Text defines positive outline width values as stroke only
    if (_outlineThickness <= 0.0f) {
        cairo_fill_preserve(cairoContext);
    }

    // Outline
    if (outlineEnabled && _outlineThickness != 0.0f) {
        const float outlineThickness = (fabsf(_outlineThickness) / 100.0f) * _fontSize * CLIENT_TO_SERVER_SCALE;
        cairo_set_source_rgba(cairoContext,
                              _outlineColor.red,
                              _outlineColor.green,
                              _outlineColor.blue,
                              _outlineColor.alpha);
        pango_cairo_layout_path(cairoContext, layout);
        cairo_set_line_width(cairoContext, outlineThickness);
        cairo_stroke(cairoContext);
    } else {
        cairo_new_path(cairoContext);
    }

    g_object_unref(layout);
}
开发者ID:CaringLabs,项目名称:MediaFramework,代码行数:50,代码来源:TextAsset.cpp

示例5: _draw_page_results

static void _draw_page_results (GtkPrintContext *context, GwPageInfo *page, GwPrintData *data)
{
    //Declarations
    GtkTextView *view;
    GtkTextBuffer *buffer;
    PangoLayout *layout;
    char *text;
    PangoFontDescription *desc;
    int width;
    int height;
    gdouble drawable_width, drawable_height;
    cairo_t *cr;
    gint line_start;
    gint line_end;

    //Initializations
    view = gw_searchwindow_get_current_textview (data->window);
    buffer = gtk_text_view_get_buffer (view);
    text = gtk_text_buffer_get_text (buffer, &(page->start), &(page->end), FALSE);
    layout = gtk_print_context_create_pango_layout (context);
    desc = pango_font_description_from_string ("sans 10");
    drawable_width = gtk_print_context_get_width (context);
    drawable_height = gtk_print_context_get_height (context);
    cr = gtk_print_context_get_cairo_context (context);
    line_start = 0;
    line_end = 0;

    //Draw
    if (text != NULL)
    {
      cairo_move_to (cr, 5, 10);
      pango_layout_set_font_description (layout, desc);
      pango_layout_set_markup (layout, text, -1);
      pango_layout_set_width (layout, drawable_width * PANGO_SCALE);
      pango_layout_set_alignment (layout, PANGO_ALIGN_LEFT);
      pango_layout_set_height (layout, drawable_height * PANGO_SCALE);
      pango_layout_get_size (layout, &width, &height);
      pango_cairo_show_layout (cr, layout);
      
      //Adjust the end GtkTextIter to the cutoff in the visible cairo context
      line_start = gtk_text_iter_get_line (&page->start);
      line_end = line_start + pango_layout_get_line_count (layout) - 1;
      gtk_text_buffer_get_iter_at_line (buffer, &(page->end), line_end);
    }

    //Cleanup
    if (text != NULL) g_free (text);
    if (layout != NULL) g_object_unref (layout);
    if (desc != NULL) pango_font_description_free (desc);
}
开发者ID:kyoushuu,项目名称:gwaei,代码行数:50,代码来源:printing.c

示例6: cairo_save

void TextView::drawText(cairo_t * cr, Text * t) {
	cairo_save(cr);

	cairo_translate(cr, t->getX(), t->getY());

	PangoLayout * layout = initPango(cr, t);
	String str = t->getText();
	pango_layout_set_text(layout, str.c_str(), str.size());

	pango_cairo_show_layout(cr, layout);

	g_object_unref(layout);

	cairo_restore(cr);
}
开发者ID:wbrenna,项目名称:xournalpp,代码行数:15,代码来源:TextView.cpp

示例7: cairo_save

void wnobj::draw_text(cairo_t *cr, double x, double y, double w, double h, PangoLayout * layout, gdouble alpha, bool highlight)
{
	cairo_save(cr);
	cairo_set_source_rgba(cr, 1, 1, 1, alpha);
	cairo_rectangle(cr, x, y, w, h);
	cairo_fill(cr);
	cairo_move_to(cr, x, y);
	if (highlight) {
		cairo_set_source_rgb(cr, 0, 0, 1);
	} else {
		cairo_set_source_rgba(cr, 0, 0, 0, alpha);
	}
	pango_cairo_show_layout(cr, layout);
	cairo_restore(cr);
}
开发者ID:PurlingNayuki,项目名称:stardictproject,代码行数:15,代码来源:court_widget.cpp

示例8: about_dialog_anim_expose

static gboolean
about_dialog_anim_expose (GtkWidget       *widget,
                          GdkEventExpose  *event,
                          GimpAboutDialog *dialog)
{
  GtkStyle      *style = gtk_widget_get_style (widget);
  cairo_t       *cr;
  GtkAllocation  allocation;
  gint           x, y;
  gint           width, height;

  if (! dialog->visible)
    return FALSE;

  cr = gdk_cairo_create (event->window);

  gdk_cairo_set_source_color (cr, &style->text[GTK_STATE_NORMAL]);

  gtk_widget_get_allocation (widget, &allocation);
  pango_layout_get_pixel_size (dialog->layout, &width, &height);

  x = (allocation.width  - width)  / 2;
  y = (allocation.height - height) / 2;

  if (dialog->textrange[1] > 0)
    {
      GdkRegion *covered_region;

      covered_region = gdk_pango_layout_get_clip_region (dialog->layout,
                                                         x, y,
                                                         dialog->textrange, 1);

      gdk_region_intersect (covered_region, event->region);

      gdk_cairo_region (cr, covered_region);
      cairo_clip (cr);

      gdk_region_destroy (covered_region);
    }

  cairo_move_to (cr, x, y);

  pango_cairo_show_layout (cr, dialog->layout);

  cairo_destroy (cr);

  return FALSE;
}
开发者ID:MichaelMure,项目名称:Gimp-Cage-Tool,代码行数:48,代码来源:about-dialog.c

示例9: ygtk_steps_draw

static gboolean ygtk_steps_draw (GtkWidget *widget, cairo_t *cr)
{
	GTK_WIDGET_CLASS (ygtk_steps_parent_class)->draw(widget, cr);

	YGtkSteps *steps = YGTK_STEPS (widget);
	gboolean reverse = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
	GList *children = gtk_container_get_children (GTK_CONTAINER (widget)), *i;

	cairo_set_source_rgb (cr, 0, 0, 0);
	int n = 0;
	for (i = children; i; i = i->next, n++) {
		GtkWidget *label = i->data;
                GtkAllocation alloc;
                gtk_widget_get_allocation(label, &alloc);

		if (g_object_get_data (G_OBJECT (label), "is-header"))
			continue;
		PangoLayout *layout;
		if (n < steps->current_step)
			layout = steps->check_mark_layout;
		else if (n == steps->current_step)
			layout = steps->current_mark_layout;
		else //if (n > steps->current_step)
			layout = steps->todo_mark_layout;
		int x = alloc.x, y = alloc.y;
		if (reverse) {
			PangoRectangle rect;
			pango_layout_get_pixel_extents (layout, NULL, &rect);
			x += alloc.width - rect.width - 4;
		}
		else
			x += 4;
		if (n == steps->current_step) {
			int offset;
			if (steps->current_mark_frame < CURRENT_MARK_FRAMES_NB/2)
				offset = steps->current_mark_frame * CURRENT_MARK_ANIMATION_OFFSET;
			else
				offset = (CURRENT_MARK_FRAMES_NB - steps->current_mark_frame) *
				      CURRENT_MARK_ANIMATION_OFFSET;
			x += offset * (reverse ? 1 : -1);
		}

		cairo_move_to (cr, x, y);
		pango_cairo_show_layout (cr, layout);
	}
	g_list_free (children);
	return 	FALSE;
}
开发者ID:anaselli,项目名称:libyui-gtk,代码行数:48,代码来源:ygtksteps.c

示例10: iupDrawText

void iupDrawText(IdrawCanvas* dc, const char* text, int len, int x, int y, unsigned char r, unsigned char g, unsigned char b, const char* font)
{
  PangoLayout* fontlayout = (PangoLayout*)iupgtkGetPangoLayout(font);

  pango_layout_set_text(fontlayout, iupgtkStrConvertToUTF8(text), len);

  cairo_set_source_rgba(dc->image_cr, iupCOLOR8ToDouble(r),
                                       iupCOLOR8ToDouble(g),
                                       iupCOLOR8ToDouble(b),
                                       1.0);

  pango_cairo_update_layout(dc->image_cr, fontlayout);

  cairo_move_to(dc->image_cr, x, y);
  pango_cairo_show_layout(dc->image_cr, fontlayout);
}
开发者ID:kmx,项目名称:mirror-iup,代码行数:16,代码来源:iupgtk_draw_cairo.c

示例11: moblin_netbook_draw_layout

/* this function is copied from the mist gtk engine */
static void
moblin_netbook_draw_layout (GtkStyle        *style,
                            GdkWindow       *window,
                            GtkStateType     state_type,
                            gboolean         use_text,
                            GdkRectangle    *area,
                            GtkWidget       *widget,
                            const char      *detail,
                            int              x,
                            int              y,
                            PangoLayout      *layout)
{
  GdkGC *gc;

  gc = use_text ? style->text_gc[state_type] : style->fg_gc[state_type];

  if (area)
    {
      gdk_gc_set_clip_rectangle (gc, area);
    }

  if (DETAIL ("accellabel") && state_type == GTK_STATE_NORMAL)
    {
      cairo_t *cr;

      cr = moblin_netbook_cairo_create (window, area);

      cairo_set_source_rgba (cr,
                             style->fg[state_type].red / 65535.0,
                             style->fg[state_type].green / 65535.0,
                             style->fg[state_type].blue / 65535.0,
                             0.5);
      cairo_move_to (cr, x, y);
      pango_cairo_show_layout (cr, layout);
      cairo_stroke (cr);

      cairo_destroy (cr);

    }
  else
    gdk_draw_layout (window, gc, x, y, layout);

  if (area)
    {
      gdk_gc_set_clip_rectangle (gc, NULL);
    }
}
开发者ID:dudochkin-victor,项目名称:netbook-theme,代码行数:48,代码来源:moblin-netbook-style.c

示例12: fo_doc_cairo_render_layout

/**
 * fo_doc_cairo_render_layout:
 * @fo_doc: 
 * @area_layout: 
 * @x: 
 * @y: 
 * 
 * 
 **/
void
fo_doc_cairo_render_layout (FoDoc   *fo_doc,
			    FoArea  *area_layout,
			    gdouble  x,
			    gdouble  y)
{
  g_return_if_fail (FO_IS_DOC_CAIRO (fo_doc));
  g_return_if_fail (FO_DOC_CAIRO (fo_doc)->cr != NULL);
  g_return_if_fail (FO_IS_AREA_LAYOUT (area_layout));

  cairo_move_to (FO_DOC_CAIRO (fo_doc)->cr,
		 x,
		 FO_DOC_CAIRO (fo_doc)->page_height - y);
  pango_cairo_show_layout (FO_DOC_CAIRO (fo_doc)->cr,
			   fo_layout_get_pango_layout (fo_area_layout_get_layout (area_layout)));

}
开发者ID:hrs-allbsd,项目名称:xmlroff,代码行数:26,代码来源:fo-doc-cairo.c

示例13: assert

void ttext::rerender(const bool force) const
{
	if(surface_dirty_ || force) {
		assert(layout_);

		recalculate(force);
		surface_dirty_ = false;

		int width  = rect_.x + rect_.width;
		int height = rect_.y + rect_.height;
		if(maximum_width_  > 0) { width  = std::min(width, maximum_width_); }
		if(maximum_height_ > 0) { height = std::min(height, maximum_height_); }

		cairo_format_t format = CAIRO_FORMAT_ARGB32;
		const unsigned stride = cairo_format_stride_for_width(format, width);

		create_surface_buffer(stride * height);

		cairo_surface_t* cairo_surface =
			cairo_image_surface_create_for_data(surface_buffer_, format, width, height, stride);
		cairo_t* cr = cairo_create(cairo_surface);

		/* set color (used for foreground). */
		cairo_set_source_rgba(cr,
			 (foreground_color_ >> 24)         / 256.0,
			((foreground_color_ >> 16) & 0xFF) / 256.0,
			((foreground_color_ >> 8)  & 0xFF) / 256.0,
			(foreground_color_         & 0xFF) / 256.0);

		pango_cairo_show_layout(cr, layout_);

		// The cairo surface is in CAIRO_FORMAT_ARGB32 which uses
		// pre-multiplied alpha. SDL doesn't use that so the pixels need to be
		// decoded again.
		for(int y = 0; y < height; ++y) {
			for(int x = 0; x < width; ++x) {
				unsigned char* pixel = &surface_buffer_[(y * width + x) * 4];
				decode_pixel(pixel);
			}
		}

		surface_.assign(SDL_CreateRGBSurfaceFrom(
			surface_buffer_, width, height, 32, stride, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000));
		cairo_destroy(cr);
		cairo_surface_destroy(cairo_surface);
	}
开发者ID:shikadilord,项目名称:wesnoth,代码行数:46,代码来源:text.cpp

示例14: gt_graphics_cairo_draw_text_right

void gt_graphics_cairo_draw_text_right(GtGraphics *gg, double x, double y,
                                       const char *text)
{
  PangoRectangle ink;
  GtGraphicsCairo *g = gt_graphics_cairo_cast(gg);
  gt_assert(g && text && g->layout);

  pango_layout_set_text(g->layout, text, -1);

  /* get text extents */
  pango_layout_get_pixel_extents(g->layout, &ink, NULL);

  cairo_set_source_rgb(g->cr, 0, 0, 0);
  /* draw text w/ its right end at the given coords */
  cairo_move_to(g->cr, x-(ink.width)-1, y-g->font_height);
  pango_cairo_show_layout(g->cr, g->layout);
}
开发者ID:simongog,项目名称:genometools,代码行数:17,代码来源:graphics_cairo.c

示例15: print_transactions_list_draw_row

/**
 * draw a line of a transaction
 *
 * \param
 *
 * \return the new line_position
 * */
static gint print_transactions_list_draw_row ( GtkPrintContext *context,
					      CustomRecord *record,
					      gint line_position )
{
    gint column;
    gfloat alignment[] = {
	PANGO_ALIGN_CENTER, PANGO_ALIGN_CENTER, PANGO_ALIGN_LEFT, 
	PANGO_ALIGN_CENTER, PANGO_ALIGN_RIGHT, PANGO_ALIGN_RIGHT, PANGO_ALIGN_RIGHT
    };

    for (column=0 ; column<CUSTOM_MODEL_VISIBLE_COLUMNS ; column++)
    {
	PangoLayout *layout;
	gchar *text;
	gint column_position;

	column_position = columns_position[column];

	/* draw first the column */
	column_position = print_transactions_list_draw_column (column_position, line_position);

	/* get the text */
	text = record -> visible_col[column];
	if (!text)
	    continue;

	cairo_move_to (cr, column_position, line_position);

	/* create the new layout */
	layout = gtk_print_context_create_pango_layout (context);

	pango_layout_set_text (layout, text, -1);
	pango_layout_set_font_description (layout, gsb_data_print_config_get_font_transactions ());
	pango_layout_set_width (layout,columns_width[column]);
	pango_layout_set_alignment (layout, alignment[column]);
	pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END);

	pango_cairo_show_layout (cr, layout);
	g_object_unref (layout);
    }
    /* go to the next row */
    line_position = line_position + size_row;

    return line_position;
}
开发者ID:philippedelorme,项目名称:grisbi,代码行数:52,代码来源:print_transactions_list.c


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