• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ pango_cairo_show_layout函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: contact_page_draw_footer

/* contact_page_draw_footer inserts the
 * page number at the end of each page
 * while printing*/
void
contact_page_draw_footer (GtkPrintOperation *operation,
                          GtkPrintContext *context,
                          gint page_nr)
{
	PangoFontDescription *desc;
	PangoLayout *layout;
	gdouble x, y, page_height, page_width, page_margin;
	/*gint n_pages;*/
	gchar *text;
	cairo_t *cr;
	GtkPageSetup *setup;

	/*Uncomment next if it is successful to get total number if pages in list view
	 * g_object_get (operation, "n-pages", &n_pages, NULL)*/
	text = g_strdup_printf (_("Page %d"), page_nr + 1);

	setup = gtk_print_context_get_page_setup ( context);
	page_height = gtk_page_setup_get_page_height (setup, GTK_UNIT_POINTS);
	page_width = gtk_page_setup_get_page_width (setup, GTK_UNIT_POINTS);
	page_margin = gtk_page_setup_get_bottom_margin (setup, GTK_UNIT_POINTS);

	desc = pango_font_description_from_string ("Sans Regular 8");
	layout = gtk_print_context_create_pango_layout (context);
	pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
	pango_layout_set_font_description (layout, desc);
	pango_layout_set_text (layout, text, -1);
	pango_layout_set_width (layout, -1);

	x = page_width / 2.0 - page_margin;
	y = page_height - page_margin / 2.0;

	cr = gtk_print_context_get_cairo_context (context);

	cairo_save (cr);
	cairo_set_source_rgb (cr, .0, .0, .0);
	cairo_move_to (cr, x, y);
	pango_cairo_show_layout (cr, layout);
	cairo_restore (cr);

	g_object_unref (layout);
	pango_font_description_free (desc);

	g_free (text);
}
开发者ID:jdapena,项目名称:evolution,代码行数:48,代码来源:e-contact-print.c


示例17: gitg_label_renderer_draw

void
gitg_label_renderer_draw(GtkWidget *widget, PangoFontDescription *font, cairo_t *context, GSList *labels, GdkRectangle *area)
{
    GSList *item;
    double pos = MARGIN + 0.5;

    cairo_save(context);
    cairo_set_line_width(context, 1.0);

    PangoContext *ctx = gtk_widget_get_pango_context(widget);
    PangoLayout *layout = pango_layout_new(ctx);
    pango_layout_set_font_description(layout, font);

    for (item = labels; item; item = item->next)
    {
        GitgRef *ref = (GitgRef *)item->data;
        gint w;
        gint h;
        gchar *smaller = g_strdup_printf("<span size='smaller'>%s</span>", ref->shortname);

        pango_layout_set_markup(layout, smaller, -1);
        pango_layout_get_pixel_size(layout, &w, &h);

        // draw rounded rectangle
        rounded_rectangle(context, pos + 0.5, area->y + MARGIN + 0.5, w + PADDING * 2, area->height - MARGIN * 2, 5);


        set_source_for_ref_type(context, ref->type);
        cairo_fill_preserve(context);

        cairo_set_source_rgb(context, 0, 0, 0);
        cairo_stroke(context);

        cairo_save(context);
        cairo_translate(context, pos + PADDING, area->y + (area->height - h) / 2.0 + 0.5);
        pango_cairo_show_layout(context, layout);
        cairo_restore(context);

        pos += w + PADDING * 2 + MARGIN;
        g_free(smaller);
    }

    g_object_unref(layout);
    cairo_restore(context);
}
开发者ID:krh,项目名称:gitg,代码行数:45,代码来源:gitg-label-renderer.c


示例18: cairo_menu_item_expose

static gboolean
cairo_menu_item_expose (GtkWidget *widget,GdkEventExpose *event)
{
  CairoMenuItemPrivate * priv = GET_PRIVATE(widget);  

  if (priv->cairo_style)
  {
    PangoLayout *layout;    
    double x,y,width,height;
    gchar * label;

    g_object_get (widget,
                  "label",&label,
                  NULL);
    cairo_t * cr = gdk_cairo_create (widget->window);
    g_debug ("%s:  bit depth = %d",__func__,gdk_drawable_get_depth (widget->window));
//    g_debug ("Region %d,%d: %dx%d",event->area.x, event->area.y,event->area.width, event->area.height);
    x = event->area.x;
    y = event->area.y;
    width = event->area.width;
    height = event->area.height;    
    cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);    
    cairo_set_source_rgba (cr,0.0,1.0,0.0,0.1);
    cairo_rectangle (cr, x,y,width,height);
    cairo_fill (cr);    
    layout = pango_cairo_create_layout (cr);

    pango_font_description_set_absolute_size (priv->font_description,  height * 0.8 * PANGO_SCALE);
    pango_layout_set_font_description (layout, priv->font_description);
    pango_layout_set_text (layout, label, -1);  

    cairo_set_source_rgba (cr,1.0,1.0,1.0,0.3);
    cairo_move_to (cr,x+height * 1.1,y+height*0.1);
    pango_cairo_show_layout (cr, layout);          
    cairo_destroy (cr);
    g_object_unref (layout);
    g_free (label);
    return TRUE;
  }
  else
  {
    return FALSE;
  }
}
开发者ID:micove,项目名称:awn-extras,代码行数:44,代码来源:cairo-menu-item.c


示例19: setup_font_sample

static void setup_font_sample(GtkWidget* darea, Antialiasing antialiasing, Hinting hinting)
{
	const char *str = "<span font=\"18\" style=\"normal\">abcfgop AO </span>"
					  "<span font=\"20\" style=\"italic\">abcfgop</span>";

	PangoContext *context;
	PangoLayout *layout;
	PangoFontDescription *fd;
	PangoRectangle extents;
	cairo_surface_t *surface;
	cairo_t *cr;
	int width, height;

	context = gtk_widget_get_pango_context (darea);
	set_fontoptions (context, antialiasing, hinting);
	layout = pango_layout_new (context);

	fd = pango_font_description_from_string ("Serif");
	pango_layout_set_font_description (layout, fd);
	pango_font_description_free (fd);

	pango_layout_set_markup (layout, str, -1);

	pango_layout_get_extents (layout, NULL, &extents);
	width = PANGO_PIXELS(extents.width) + 4;
	height = PANGO_PIXELS(extents.height) + 2;

	surface = cairo_image_surface_create (CAIRO_FORMAT_A8, width, height);
	cr = cairo_create (surface);

	cairo_move_to (cr, 2, 1);
	pango_cairo_show_layout (cr, layout);
	g_object_unref (layout);
	cairo_destroy (cr);

	g_object_set_data_full(G_OBJECT(darea), "sample-surface", surface, (GDestroyNotify) cairo_surface_destroy);

	gtk_widget_set_size_request (GTK_WIDGET(darea), width + 2, height + 2);
#if GTK_CHECK_VERSION (3, 0, 0)
	g_signal_connect(darea, "draw", G_CALLBACK(sample_draw), NULL);
#else
	g_signal_connect(darea, "expose_event", G_CALLBACK(sample_expose), NULL);
#endif
}
开发者ID:leigh123linux,项目名称:mate-control-center,代码行数:44,代码来源:appearance-font.c


示例20: doPrint

 static int doPrint(GtkPrintOperation *prt, GtkPrintContext *context,cairo_t *cr,gint page)
 {
	gdouble					maxHeight	= gtk_print_context_get_height(context);
	PangoFontDescription	*desc;
	gint					pg			= 0;
	gdouble					row			= 0;

	gchar					**text;
	gdouble					text_height;


	desc = pango_font_description_from_string(g_object_get_data(G_OBJECT(prt),"3270FontName"));

	for(text = g_object_get_data(G_OBJECT(prt),"3270Text");*text;text++)
	{
		gint		layout_height;
		PangoLayout	*layout			= gtk_print_context_create_pango_layout(context);

		pango_layout_set_font_description(layout, desc);
		pango_layout_set_text(layout, *text, -1);
		pango_layout_get_size(layout, NULL, &layout_height);
		text_height = ((gdouble)layout_height) / PANGO_SCALE;

		if((row+text_height) >= maxHeight)
		{
			row = 0;
			pg++;
		}

		row += text_height;

		if(cr && page == pg)
		{
			cairo_move_to(cr,0,row);
			pango_cairo_show_layout(cr, layout);
		}

		g_object_unref(layout);
	}

	pango_font_description_free(desc);

	return pg+1;
 }
开发者ID:laubstein,项目名称:pw3270,代码行数:44,代码来源:print.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ pango_font_description_free函数代码示例发布时间:2022-05-30
下一篇:
C++ pango_attr_list_unref函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap