本文整理汇总了C++中pango_layout_set_width函数的典型用法代码示例。如果您正苦于以下问题:C++ pango_layout_set_width函数的具体用法?C++ pango_layout_set_width怎么用?C++ pango_layout_set_width使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pango_layout_set_width函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw_header
static void
draw_header (GtkPrintContext * cnt, gint pn, gint pc)
{
cairo_t *cr;
PangoFontDescription *desc;
PangoLayout *layout;
gint pw, tw, th;
gchar *page;
cr = gtk_print_context_get_cairo_context (cnt);
pw = gtk_print_context_get_width (cnt);
layout = gtk_print_context_create_pango_layout (cnt);
desc = pango_font_description_from_string (HEADER_FONT);
pango_layout_set_font_description (layout, desc);
pango_font_description_free (desc);
pango_layout_set_text (layout, options.common_data.uri, -1);
pango_layout_get_pixel_size (layout, &tw, &th);
if (tw > pw)
{
pango_layout_set_width (layout, pw);
pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_START);
pango_layout_get_pixel_size (layout, &tw, &th);
}
cairo_move_to (cr, (pw - tw) / 2, (HEADER_HEIGHT - th) / 2);
pango_cairo_show_layout (cr, layout);
page = g_strdup_printf ("%d/%d", pn, pc);
pango_layout_set_text (layout, page, -1);
g_free (page);
pango_layout_set_width (layout, -1);
pango_layout_get_pixel_size (layout, &tw, &th);
cairo_move_to (cr, pw - tw - 4, (HEADER_HEIGHT - th) / 2);
pango_cairo_show_layout (cr, layout);
g_object_unref (layout);
cairo_move_to (cr, 0.0, HEADER_HEIGHT);
cairo_line_to (cr, pw, HEADER_HEIGHT);
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_set_line_width (cr, 1);
cairo_stroke (cr);
}
示例2: SetUpStatusBarStuff
void SetUpStatusBarStuff (GtkWidget* aWindow)
{
_String fName = baseDirectory & "GTKResources/striped.xpm";
statusBarLayout = pango_layout_new (screenPContext);
statusBarFontDesc = pango_font_description_new ();
stripedFill = gdk_pixmap_create_from_xpm (GDK_DRAWABLE(aWindow->window), NULL, NULL, fName.sData);
stripedFillGC = gdk_gc_new (GDK_DRAWABLE(aWindow->window));
if (stripedFill)
{
gdk_gc_set_fill (stripedFillGC,GDK_TILED);
gdk_gc_set_tile (stripedFillGC,stripedFill);
}
else
{
printf ("Failed to load a status bar .xpm from %s\n", fName.sData);
}
gdk_gc_set_line_attributes (stripedFillGC, 1, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
GdkColor saveFG = {0,0,0,0};
gdk_gc_set_foreground (stripedFillGC, &saveFG);
pango_font_description_set_family (statusBarFontDesc, statusBarFont.face.sData);
pango_font_description_set_style (statusBarFontDesc, (statusBarFont.style & HY_FONT_ITALIC) ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);
pango_font_description_set_weight (statusBarFontDesc, (statusBarFont.style & HY_FONT_BOLD) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL);
pango_font_description_set_size (statusBarFontDesc, statusBarFont.size*PANGO_SCALE);
pango_layout_set_font_description (statusBarLayout, statusBarFontDesc ); // ref ?
pango_layout_set_width (statusBarLayout, -1);
redButtonIcon = (GdkPixbuf*)ProcureIconResource(4000);
yellowButtonIcon = (GdkPixbuf*)ProcureIconResource(4001);
greenButtonIcon = (GdkPixbuf*)ProcureIconResource(4002);
orangeButtonIcon = (GdkPixbuf*)ProcureIconResource(4003);
}
示例3: gt_graphics_cairo_new_from_context
GtGraphics* gt_graphics_cairo_new_from_context(cairo_t *context,
unsigned int width,
unsigned int height)
{
GtGraphics *g;
GtGraphicsCairo *gc;
char buf[64];
g = gt_graphics_create(gt_graphics_cairo_class());
gc = gt_graphics_cairo_cast(g);
gc->width = width;
gc->height = height;
gc->margin_x = gc->margin_y = 20;
gc->from_context = true;
gc->cr = context;
gc->layout = pango_cairo_create_layout(gc->cr);
pango_layout_set_width(gc->layout, -1);
gt_assert(gc->layout);
snprintf(buf, 64, "Sans %d", TEXT_SIZE_DEFAULT);
gc->desc = pango_font_description_from_string(buf);
pango_layout_set_font_description(gc->layout, gc->desc);
pango_font_description_free(gc->desc);
cairo_set_line_join(context, CAIRO_LINE_JOIN_ROUND);
cairo_set_line_cap(context, CAIRO_LINE_CAP_ROUND);
return g;
}
示例4: mw_paint_tip
static
void mw_paint_tip(GtkWidget *widget, GdkEventExpose *event)
{
GtkStyle *style;
GdkWindow *window;
char *tooltiptext = get_tooltip_text();
if(tooltiptext == NULL) tooltiptext = g_strdup("oeps");
pango_layout_set_markup(layout, tooltiptext, strlen(tooltiptext));
pango_layout_set_wrap(layout, PANGO_WRAP_WORD);
pango_layout_set_width(layout, 300000);
style = gtk_widget_get_style (tipwindow);
window = gtk_widget_get_window (tipwindow);
gtk_paint_flat_box (style, window, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
NULL, tipwindow, "tooltip", 0, 0, -1, -1);
gtk_paint_layout (style, window, GTK_STATE_NORMAL, TRUE,
NULL, tipwindow, "tooltip", 4, 4, layout);
/*
g_object_unref(layout);
*/
g_free(tooltiptext);
return;
}
示例5: tooltip_update
void tooltip_update()
{
if (!g_tooltip.tooltip_text) {
tooltip_hide(0);
return;
}
tooltip_update_geometry();
if (just_shown) {
if (!panel_horizontal)
y -= height / 2; // center vertically
just_shown = FALSE;
}
tooltip_adjust_geometry();
XMoveResizeWindow(server.display, g_tooltip.window, x, y, width, height);
// Stuff for drawing the tooltip
cairo_surface_t *cs = cairo_xlib_surface_create(server.display, g_tooltip.window, server.visual, width, height);
cairo_t *c = cairo_create(cs);
Color bc = g_tooltip.bg->fill_color;
Border b = g_tooltip.bg->border;
if (server.real_transparency) {
clear_pixmap(g_tooltip.window, 0, 0, width, height);
draw_rect(c, b.width, b.width, width - 2 * b.width, height - 2 * b.width, b.radius - b.width / 1.571);
cairo_set_source_rgba(c, bc.rgb[0], bc.rgb[1], bc.rgb[2], bc.alpha);
} else {
cairo_rectangle(c, 0., 0, width, height);
cairo_set_source_rgb(c, bc.rgb[0], bc.rgb[1], bc.rgb[2]);
}
cairo_fill(c);
cairo_set_line_width(c, b.width);
if (server.real_transparency)
draw_rect(c, b.width / 2.0, b.width / 2.0, width - b.width, height - b.width, b.radius);
else
cairo_rectangle(c, b.width / 2.0, b.width / 2.0, width - b.width, height - b.width);
cairo_set_source_rgba(c, b.color.rgb[0], b.color.rgb[1], b.color.rgb[2], b.color.alpha);
cairo_stroke(c);
Color fc = g_tooltip.font_color;
cairo_set_source_rgba(c, fc.rgb[0], fc.rgb[1], fc.rgb[2], fc.alpha);
PangoLayout *layout = pango_cairo_create_layout(c);
pango_layout_set_font_description(layout, g_tooltip.font_desc);
pango_layout_set_wrap(layout, PANGO_WRAP_WORD);
pango_layout_set_text(layout, g_tooltip.tooltip_text, -1);
PangoRectangle r1, r2;
pango_layout_get_pixel_extents(layout, &r1, &r2);
pango_layout_set_width(layout, width * PANGO_SCALE);
pango_layout_set_height(layout, height * PANGO_SCALE);
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
// I do not know why this is the right way, but with the below cairo_move_to it seems to be centered (horiz. and
// vert.)
cairo_move_to(c,
-r1.x / 2 + g_tooltip.bg->border.width + g_tooltip.paddingx,
-r1.y / 2 + 1 + g_tooltip.bg->border.width + g_tooltip.paddingy);
pango_cairo_show_layout(c, layout);
g_object_unref(layout);
cairo_destroy(c);
cairo_surface_destroy(cs);
}
示例6: tooltip_update_geometry
void tooltip_update_geometry()
{
Panel *panel = g_tooltip.panel;
int screen_width = server.monitors[panel->monitor].x + server.monitors[panel->monitor].width;
cairo_surface_t *cs = cairo_xlib_surface_create(server.display, g_tooltip.window, server.visual, width, height);
cairo_t *c = cairo_create(cs);
PangoLayout *layout = pango_cairo_create_layout(c);
pango_layout_set_font_description(layout, g_tooltip.font_desc);
PangoRectangle r1, r2;
pango_layout_set_text(layout, "1234567890", -1);
pango_layout_get_pixel_extents(layout, &r1, &r2);
int max_width = MIN(r2.width * 7, screen_width * 2 / 3);
pango_layout_set_width(layout, max_width * PANGO_SCALE);
pango_layout_set_text(layout, g_tooltip.tooltip_text, -1);
pango_layout_set_wrap(layout, PANGO_WRAP_WORD);
pango_layout_get_pixel_extents(layout, &r1, &r2);
width = 2 * g_tooltip.bg->border.width + 2 * g_tooltip.paddingx + r2.width;
height = 2 * g_tooltip.bg->border.width + 2 * g_tooltip.paddingy + r2.height;
if (panel_horizontal && panel_position & BOTTOM)
y = panel->posy - height;
else if (panel_horizontal && panel_position & TOP)
y = panel->posy + panel->area.height;
else if (panel_position & LEFT)
x = panel->posx + panel->area.width;
else
x = panel->posx - width;
g_object_unref(layout);
cairo_destroy(c);
cairo_surface_destroy(cs);
}
示例7: gtk_label_layoutable_size_allocate
static void
gtk_label_layoutable_size_allocate (GtkLayoutable *layoutable,
GtkAllocation *allocation)
{
GtkLabel *label = GTK_LABEL (layoutable);
if (gtk_label_get_line_wrap (label))
{
PangoLayout *layout;
PangoRectangle rect;
/* Make it span the entire line. */
layout = gtk_label_get_layout (label);
pango_layout_set_width (layout, allocation->width * PANGO_SCALE);
pango_layout_get_extents (layout, NULL, &rect);
allocation->width = rect.width / PANGO_SCALE + label->misc.xpad * 2;
allocation->height = rect.height / PANGO_SCALE + label->misc.ypad * 2;
gtk_misc_set_alignment (&label->misc, 0.0, 0.0);
gtk_widget_size_allocate (GTK_WIDGET (label), allocation);
}
else
(gtk_label_parent_layoutable_iface->size_allocate) (layoutable, allocation);
}
示例8: content_draw
void
content_draw (GtkWidget *widget,
cairo_t *cr)
{
PangoContext *context;
PangoLayout *title_layout;
PangoLayout *sub_layout;
PangoFontDescription *desc;
int width, height;
int sub_width;
width = gdk_window_get_width (gtk_widget_get_window (widget));
height = gdk_window_get_height (gtk_widget_get_window (widget));
cairo_translate (cr, width / 2, height / 2);
context = gdk_pango_context_get_for_screen (gtk_widget_get_screen (widget));
title_layout = pango_layout_new (context);
pango_layout_set_text (title_layout, _("This session is locked"), -1);
desc = pango_font_description_from_string (TITLE_FONT);
pango_layout_set_font_description (title_layout, desc);
pango_font_description_free (desc);
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 1.0);
pango_cairo_update_layout (cr, title_layout);
pango_layout_get_size (title_layout, &width, &height);
cairo_save (cr);
/* Adjust the translation to the middle left of the icon */
cairo_translate (cr, - width / PANGO_SCALE / 2 - height / PANGO_SCALE, - height / PANGO_SCALE / 2);
draw_lock_icon (cr, height / PANGO_SCALE);
cairo_restore (cr);
cairo_move_to (cr, - width / PANGO_SCALE / 2 + height / PANGO_SCALE, - height / PANGO_SCALE);
pango_cairo_show_layout (cr, title_layout);
g_object_unref (title_layout);
sub_layout = pango_layout_new (context);
pango_layout_set_text (sub_layout, _("You'll be redirected to the unlock dialog automatically in a few seconds"), -1);
pango_layout_set_wrap (sub_layout, PANGO_WRAP_WORD_CHAR);
pango_layout_set_width (sub_layout, width + 2 * height);
desc = pango_font_description_from_string (MESSAGE_FONT);
pango_layout_set_font_description (sub_layout, desc);
pango_font_description_free (desc);
cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, 1.0);
pango_cairo_update_layout (cr, sub_layout);
pango_layout_get_size (sub_layout, &sub_width, NULL);
cairo_move_to (cr, - (width + 2 * height) / PANGO_SCALE / 2, height / PANGO_SCALE);
cairo_scale (cr, (width + 2 * height) / (gdouble)sub_width, (width + 2 * height) / (gdouble)sub_width);
pango_cairo_show_layout (cr, sub_layout);
g_object_unref (sub_layout);
g_object_unref (context);
}
示例9: print_tree_view_list_draw_cell
/**
* draw a cell of a model
*
* \param context the GtkPrintContext
* \param line_position the position to insert the column
* \param column_position the position to insert the data
*
* \return the new column_position
* */
static gint print_tree_view_list_draw_cell ( GtkPrintContext *context,
gint line_position,
gint column_position,
gint column,
const gchar *text )
{
PangoLayout *layout;
/* draw first the column */
column_position = print_tree_view_list_draw_column ( column_position, line_position );
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 );
return column_position;
}
示例10: draw_taskbarname
void draw_taskbarname(void* obj, cairo_t* c) {
Taskbarname* taskbar_name = obj;
Taskbar* taskbar = taskbar_name->area.parent;
PangoLayout* layout;
color_T* config_text = (taskbar->desktop == server.desktop)
? &taskbarname_active_font
: &taskbarname_font;
int state =
(taskbar->desktop == server.desktop) ? TASKBAR_ACTIVE : TASKBAR_NORMAL;
taskbar_name->state_pix[state] = taskbar_name->area.pix;
// draw content
layout = pango_cairo_create_layout(c);
pango_layout_set_font_description(layout, taskbarname_font_desc);
pango_layout_set_width(layout, taskbar_name->area.width * PANGO_SCALE);
pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
pango_layout_set_text(layout, taskbar_name->name, strlen(taskbar_name->name));
{
double colors[4];
color_extract_components_to_array(config_text, colors);
cairo_set_source_rgba(c, colors[0], colors[1], colors[2], colors[3]);
}
pango_cairo_update_layout(c, layout);
cairo_move_to(c, 0, taskbar_name->posy);
pango_cairo_show_layout(c, layout);
g_object_unref(layout);
// printf("draw_taskbarname %s ******************************\n",
// taskbar_name->name);
}
示例11: create_layout_with_attrs
static PangoLayout *
create_layout_with_attrs (GtkWidget *widget,
GdTwoLinesRenderer *self,
PangoEllipsizeMode ellipsize)
{
PangoLayout *layout;
gint wrap_width;
PangoWrapMode wrap_mode;
PangoAlignment alignment;
g_object_get (self,
"wrap-width", &wrap_width,
"wrap-mode", &wrap_mode,
"alignment", &alignment,
NULL);
layout = pango_layout_new (gtk_widget_get_pango_context (widget));
pango_layout_set_ellipsize (layout, ellipsize);
pango_layout_set_wrap (layout, wrap_mode);
pango_layout_set_alignment (layout, alignment);
if (wrap_width != -1)
pango_layout_set_width (layout, wrap_width * PANGO_SCALE);
return layout;
}
示例12: size_allocate
/* Handle a size allocation by re-laying-out each paragraph to
* the new width, setting the new size for the layout and
* then queing a redraw
*/
void
size_allocate (GtkWidget *layout, GtkAllocation *allocation)
{
GList *tmp_list;
guint height = 0;
PangoDirection base_dir = pango_context_get_base_dir (context);
tmp_list = paragraphs;
while (tmp_list)
{
Paragraph *para = tmp_list->data;
PangoRectangle logical_rect;
tmp_list = tmp_list->next;
pango_layout_set_alignment (para->layout,
base_dir == PANGO_DIRECTION_LTR ? PANGO_ALIGN_LEFT : PANGO_ALIGN_RIGHT);
pango_layout_set_width (para->layout, layout->allocation.width * PANGO_SCALE);
pango_layout_get_extents (para->layout, NULL, &logical_rect);
para->height = PANGO_PIXELS (logical_rect.height);
height += para->height;
}
gtk_layout_set_size (GTK_LAYOUT (layout), allocation->width, height);
if (GTK_LAYOUT (layout)->yoffset + allocation->height > height)
gtk_adjustment_set_value (GTK_LAYOUT (layout)->vadjustment, (float)(height - allocation->height));
}
示例13: e_contact_output
static void
e_contact_output (GtkPrintContext *context,
PangoFontDescription *font,
gdouble x,
gdouble y,
gdouble width,
const gchar *text)
{
PangoLayout *layout;
gdouble indent;
cairo_t *cr;
layout = gtk_print_context_create_pango_layout (context);
if (width == -1 || get_font_width (context, font, text) <= width)
indent = .0;
else
indent = get_font_width (context, font, " ");
pango_layout_set_font_description (layout, font);
pango_layout_set_text (layout, text, -1);
pango_layout_set_width (layout, pango_units_from_double (width));
pango_layout_set_indent (layout, pango_units_from_double (indent));
pango_layout_set_wrap (layout, PANGO_WRAP_WORD_CHAR);
cr = gtk_print_context_get_cairo_context (context);
cairo_save (cr);
cairo_move_to (cr, x, y);
pango_cairo_show_layout (cr, layout);
cairo_restore (cr);
g_object_unref (layout);
}
示例14: ZDrawSongInfo
void ZDrawSongInfo(IDirectFB *dfb, IDirectFBSurface *dfbsurface, const gchar *title, const gchar *artist,
gint w, gint h, DFBColor *color, DFBColor *strokeColor, double strokeWidth, const PangoFontDescription *desc)
{
cairo_t *cr = NULL;
cairo_surface_t *surface = NULL;
cairo_surface_t *cairosurface = NULL;
PangoLayout *layout = NULL;
if(!dfb || !dfbsurface)
return;
/* prepare layout */
layout = pango_layout_new(gdk_pango_context_get());
pango_layout_set_single_paragraph_mode (layout, TRUE);
pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
pango_layout_set_width(layout, w* PANGO_SCALE);
pango_layout_set_font_description(layout, desc);
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h);
cr = cairo_create(surface);
/* Draw title */
if(title) {
pango_layout_set_text(layout, title, -1);
cairo_move_to(cr, 0, 0);
pango_cairo_layout_path(cr, layout);
ZCairoSetDFBColor(cr, strokeColor);
cairo_set_line_width(cr, strokeWidth);
cairo_stroke_preserve(cr);
ZCairoSetDFBColor(cr, color);
cairo_fill(cr);
}
/* Draw artist */
if(artist) {
pango_layout_set_text(layout, artist, -1);
cairo_move_to(cr, 0, h/2);
pango_cairo_layout_path(cr, layout);
ZCairoSetDFBColor(cr, strokeColor);
cairo_set_line_width(cr, strokeWidth);
cairo_stroke_preserve(cr);
ZCairoSetDFBColor(cr, color);
cairo_fill(cr);
}
g_object_unref(layout);
cairo_destroy(cr);
/* Draw cairo_surface to dfbsurface */
/* create surface */
cairosurface = cairo_directfb_surface_create(dfb, dfbsurface);
cr = cairo_create(cairosurface);
cairo_set_source_surface(cr, surface, 0, 0);
cairo_paint(cr);
cairo_destroy(cr);
cairo_surface_destroy(surface);
cairo_surface_destroy(cairosurface);
}
示例15: pango_cairo_create_layout
TextAsset::Size
TextAsset::computeSizeOfText(cairo_t* cairoContext,
const std::string textString,
int bounds,
PangoFontDescription* font,
Rect* tight,
float* lineHeightOut)
{
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(), (int)textString.length());
pango_layout_set_alignment(layout, _alignment);
pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
const Size maxTextureSize(bounds, 1024);
pango_layout_set_width(layout, pango_units_from_double(maxTextureSize.width));
pango_layout_set_height(layout, pango_units_from_double(maxTextureSize.height));
pango_layout_set_font_description(layout, font);
applyLeading(cairoContext, layout, font);
PangoRectangle estimateSize;
PangoRectangle ink;
pango_layout_get_pixel_extents(layout, &ink, &estimateSize);
// If the text is right or center aligned the offsets will contain all the
// leading space. We ignore that for the size because drawText will draw
// in the larger box. The tight box below will get the offsets so we know
// where to draw so the text lands in the same tight box.
Size res(estimateSize.width, estimateSize.height);
if (tight != NULL) {
float lineHeight;
float xHeight = charHeight(cairoContext, font, 'x', &lineHeight);
if (lineHeightOut != NULL) {
*lineHeightOut = lineHeight;
}
const float capHeight = charHeight(cairoContext, font, 'Y');
const float ascender = pango_units_to_double(pango_layout_get_baseline(layout));
const float topSpace = ascender - capHeight;
const float bottomSpace = MAX(lineHeight - ascender - (capHeight - xHeight), 0);
if (res.height > topSpace + bottomSpace) {
*tight = Rect(estimateSize.x,
estimateSize.y + topSpace,
res.width,
res.height - topSpace - bottomSpace);
} else {
*tight = Rect(0, 0, res.width, res.height);
}
}
g_object_unref(layout);
return res;
}