本文整理汇总了C++中PANGO_PIXELS函数的典型用法代码示例。如果您正苦于以下问题:C++ PANGO_PIXELS函数的具体用法?C++ PANGO_PIXELS怎么用?C++ PANGO_PIXELS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PANGO_PIXELS函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: text_entry_get_cursor_rectangle
static void
text_entry_get_cursor_rectangle(struct text_entry *entry, struct rectangle *rectangle)
{
struct rectangle allocation;
PangoRectangle extents;
PangoRectangle cursor_pos;
widget_get_allocation(entry->widget, &allocation);
if (entry->preedit.text && entry->preedit.cursor < 0) {
rectangle->x = 0;
rectangle->y = 0;
rectangle->width = 0;
rectangle->height = 0;
return;
}
pango_layout_get_extents(entry->layout, &extents, NULL);
pango_layout_get_cursor_pos(entry->layout,
entry->cursor + entry->preedit.cursor,
&cursor_pos, NULL);
rectangle->x = allocation.x + (allocation.height / 2) + PANGO_PIXELS(cursor_pos.x);
rectangle->y = allocation.y + 10 + PANGO_PIXELS(cursor_pos.y);
rectangle->width = PANGO_PIXELS(cursor_pos.width);
rectangle->height = PANGO_PIXELS(cursor_pos.height);
}
开发者ID:etrunko,项目名称:weston,代码行数:28,代码来源:editor.c
示例2: char_bounds
/* Given a paragraph and offset in that paragraph, find the
* bounding rectangle for the character at the offset.
*/
void
char_bounds (Paragraph *para, int index, int width, PangoRectangle *rect)
{
GList *para_list;
int height = 0;
para_list = paragraphs;
while (para_list)
{
Paragraph *cur_para = para_list->data;
if (cur_para == para)
{
PangoRectangle pos;
pango_layout_index_to_pos (cur_para->layout, index, &pos);
rect->x = PANGO_PIXELS (MIN (pos.x, pos.x + pos.width));
rect->width = PANGO_PIXELS (ABS (pos.width));
rect->y = height + PANGO_PIXELS (pos.y);
rect->height = PANGO_PIXELS (pos.height);
}
height += cur_para->height;
para_list = para_list->next;
}
}
开发者ID:nihed,项目名称:magnetism,代码行数:31,代码来源:viewer-win32.c
示例3: unicodeGetXRanges
int unicodeGetXRanges(char *utf8, int utf8Length, int *resultPtr, int resultLength) {
int w, h, offsetX, offsetY;
int count, ch, i, j;
PangoRectangle rect;
count = unicodeLength(utf8, utf8Length);
if (resultLength < (2 * count)) return -1;
if (cachedLayout == NULL) {
cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_A8, 1, 1);
cairo_t *cr = cairo_create(surface);
cachedLayout = pango_cairo_create_layout(cr);
}
computeLayout(cachedLayout, utf8, utf8Length, &w, &h, &offsetX, &offsetY, NULL);
i = j = 0;
while ((i < utf8Length) && (j < (resultLength - 1))) {
pango_layout_index_to_pos(cachedLayout, i, &rect);
ch = utf8[i];
if ((ch & 0xE0) == 0xC0) i += 2;
else if ((ch & 0xF0) == 0xE0) i += 3;
else if ((ch & 0xF8) == 0xF0) i += 4;
else i += 1;
resultPtr[j] = PANGO_PIXELS(rect.x);
resultPtr[j + 1] = PANGO_PIXELS(rect.x + rect.width);
j += 2;
}
return count;
}
开发者ID:Adorkable-forkable,项目名称:Scratch.app.for.iOS,代码行数:31,代码来源:UnicodeOps-linux.c
示例4: m_ascent
wxFontProperties::wxFontProperties(wxFont* font):
m_ascent(0), m_descent(0), m_lineGap(0), m_lineSpacing(0), m_xHeight(0)
{
PangoContext* context = gdk_pango_context_get_for_screen( gdk_screen_get_default() );
PangoLayout* layout = pango_layout_new(context);
// and use it if it's valid
if ( font && font->Ok() )
{
pango_layout_set_font_description
(
layout,
font->GetNativeFontInfo()->description
);
}
PangoFontMetrics* metrics = pango_context_get_metrics (context, font->GetNativeFontInfo()->description, NULL);
int height = font->GetPixelSize().GetHeight();
m_ascent = PANGO_PIXELS(pango_font_metrics_get_ascent(metrics));
m_descent = PANGO_PIXELS(pango_font_metrics_get_descent(metrics));
int h;
const char* x = "x";
pango_layout_set_text( layout, x, strlen(x) );
pango_layout_get_pixel_size( layout, NULL, &h );
m_xHeight = h;
m_lineGap = (m_ascent + m_descent) / 4; // FIXME: How can we calculate this via Pango?
m_lineSpacing = m_ascent + m_descent;
pango_font_metrics_unref(metrics);
}
开发者ID:Gin-Rye,项目名称:duibrowser,代码行数:34,代码来源:fontprops.cpp
示例5: layout_iter_get_line_clip_region
/* Get a clip region to draw only part of a layout. index_ranges
* contains alternating range starts/stops. The region is the
* region which contains the given ranges, i.e. if you draw with the
* region as clip, only the given ranges are drawn.
*/
static cairo_region_t*
layout_iter_get_line_clip_region (PangoLayoutIter *iter,
gint x_origin,
gint y_origin,
const gint *index_ranges,
gint n_ranges)
{
PangoLayoutLine *line;
cairo_region_t *clip_region;
PangoRectangle logical_rect;
gint baseline;
gint i;
line = pango_layout_iter_get_line_readonly (iter);
clip_region = cairo_region_create ();
pango_layout_iter_get_line_extents (iter, NULL, &logical_rect);
baseline = pango_layout_iter_get_baseline (iter);
i = 0;
while (i < n_ranges)
{
gint *pixel_ranges = NULL;
gint n_pixel_ranges = 0;
gint j;
/* Note that get_x_ranges returns layout coordinates
*/
if (index_ranges[i*2+1] >= line->start_index &&
index_ranges[i*2] < line->start_index + line->length)
pango_layout_line_get_x_ranges (line,
index_ranges[i*2],
index_ranges[i*2+1],
&pixel_ranges, &n_pixel_ranges);
for (j = 0; j < n_pixel_ranges; j++)
{
GdkRectangle rect;
int x_off, y_off;
x_off = PANGO_PIXELS (pixel_ranges[2*j] - logical_rect.x);
y_off = PANGO_PIXELS (baseline - logical_rect.y);
rect.x = x_origin + x_off;
rect.y = y_origin - y_off;
rect.width = PANGO_PIXELS (pixel_ranges[2*j + 1] - logical_rect.x) - x_off;
rect.height = PANGO_PIXELS (baseline - logical_rect.y + logical_rect.height) - y_off;
cairo_region_union_rectangle (clip_region, &rect);
}
g_free (pixel_ranges);
++i;
}
return clip_region;
}
开发者ID:3dfxmadscientist,项目名称:gnome-apps,代码行数:62,代码来源:gdkpango.c
示例6: ScriptXtoCPRightToLeft
HRESULT ScriptXtoCPRightToLeft(
/*__in*/ int iX,
/*__in*/ int cChars,
/*__in*/ int cGlyphs,
/*__in*/ const WORD *pwLogClust,
/*__in*/ const SCRIPT_VISATTR *psva,
/*__in*/ const int *piAdvance,
/*__in*/ const SCRIPT_ANALYSIS *psa,
/*__out*/ int *piCP,
/*__out*/ int *piTrailing
)
{
// TODO: this implementation doesn't use pwLogClust
// which means it doesn't handle scripts whose clusters are not single Glyphs
int totalRunWidth = 0;
int pos = 0;
int index = 0;
// is iX isn't before run
if (iX < 0)
{
*piCP = cChars;
*piTrailing = 0;
return S_OK;
}
for (index = 0; index < cGlyphs; ++index)
totalRunWidth += piAdvance[index];
totalRunWidth = PANGO_PIXELS(totalRunWidth);
// is iX after run
if (iX >= totalRunWidth)
{
*piCP = -1;
*piTrailing = 1;
return S_OK;
}
// loop until pos in run is greater than or equal to iX
for (index = cGlyphs - 1; index >= 0 && pos < iX; --index)
pos += PANGO_PIXELS(piAdvance[index]);
// trailing or leading edge?
if (pos - iX > PANGO_PIXELS(piAdvance[index]/2))
*piTrailing = 0;
else
*piTrailing = 1;
*piCP = index + 1;
Assert(*piCP >= 0);
return S_OK;
}
开发者ID:FieldDB,项目名称:FieldWorks,代码行数:56,代码来源:UniscribeLinux.cpp
示例7: show_text
void
show_text(GtkWidget *window, const char *text)
{
GtkWidget *dialog, *content_area, *view, *sw;
GtkDialogFlags flags = GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT;
dialog = gtk_dialog_new_with_buttons(PACKAGE_NAME " Help",
GTK_WINDOW(window),
flags,
"_Close",
GTK_RESPONSE_CANCEL,
NULL);
content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL);
sw = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
GTK_SHADOW_IN);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
gtk_container_add_with_properties(GTK_CONTAINER(content_area), sw,
"expand", TRUE,
"fill", TRUE,
NULL);
view = gtk_text_view_new();
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view), GTK_WRAP_WORD);
gtk_text_buffer_set_text(gtk_text_view_get_buffer(GTK_TEXT_VIEW(view)),
text, -1);
gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(view), FALSE);
gtk_text_view_set_editable(GTK_TEXT_VIEW(view), FALSE);
/* Use font metrics to set the size of the text view. */
PangoContext *context = gtk_widget_get_pango_context(view);
PangoFontMetrics *metrics = pango_context_get_metrics(context, NULL, NULL);
gint char_width = pango_font_metrics_get_approximate_char_width(metrics);
gint ascent = pango_font_metrics_get_ascent(metrics);
gint descent = pango_font_metrics_get_descent(metrics);
gint height = PANGO_PIXELS(ascent + descent);
gint width = PANGO_PIXELS(char_width);
gtk_text_view_set_left_margin(GTK_TEXT_VIEW(view), 2 * width);
gtk_text_view_set_right_margin(GTK_TEXT_VIEW(view), 2 * width);
gtk_window_set_default_size(GTK_WINDOW(dialog), 70 * width, 20 * height);
gtk_container_add(GTK_CONTAINER(sw), view);
gtk_widget_show_all(dialog);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
}
开发者ID:ramsdell,项目名称:gtksudoku,代码行数:56,代码来源:showtext.c
示例8: mw_tooltip_timeout
gboolean mw_tooltip_timeout(GtkWidget *tv)
{
GtkAllocation allocation;
int scr_w,scr_h, w, h, x, y;
char *tooltiptext = NULL;
tooltiptext = get_tooltip_text();
tipwindow = gtk_window_new(GTK_WINDOW_POPUP);
gtk_widget_set_parent(tipwindow, tv);
gtk_widget_set_app_paintable(tipwindow, TRUE);
gtk_window_set_resizable(GTK_WINDOW(tipwindow), FALSE);
gtk_widget_set_name(tipwindow, "gtk-tooltips");
g_signal_connect(G_OBJECT(tipwindow), "expose_event",
G_CALLBACK(mw_paint_tip), NULL);
gtk_widget_ensure_style (tipwindow);
layout = gtk_widget_create_pango_layout (tipwindow, NULL);
pango_layout_set_wrap(layout, PANGO_WRAP_WORD);
pango_layout_set_width(layout, 300000);
pango_layout_set_markup(layout, tooltiptext, strlen(tooltiptext));
scr_w = gdk_screen_width();
scr_h = gdk_screen_height();
pango_layout_get_size (layout, &w, &h);
w = PANGO_PIXELS(w) + 8;
h = PANGO_PIXELS(h) + 8;
gdk_window_get_pointer(NULL, &x, &y, NULL);
if (!gtk_widget_get_has_window (mw.vbox))
{
gtk_widget_get_allocation (mw.vbox, &allocation);
y += allocation.y;
}
x -= ((w >> 1) + 4);
if ((x + w) > scr_w)
x -= (x + w) - scr_w;
else if (x < 0)
x = 0;
if ((y + h + 4) > scr_h)
y = y - h;
else
y = y + 6;
/*
g_object_unref(layout);
*/
g_free(tooltiptext);
gtk_widget_set_size_request(tipwindow, w, h);
gtk_window_move(GTK_WINDOW(tipwindow), x, y);
gtk_widget_show(tipwindow);
return FALSE;
}
开发者ID:abderrahim,项目名称:anjuta,代码行数:55,代码来源:list_tooltip.c
示例9: drawstring
/* subfunction of gtk_plot_cairo_draw_string(). */
static gint
drawstring(GtkPlotPC *pc,
gint angle,
gint dx, gint dy,
GtkPSFont *psfont, gint height,
const gchar *text)
{
cairo_t *cairo = GTK_PLOT_CAIRO(pc)->cairo;
PangoLayout *layout = GTK_PLOT_CAIRO(pc)->layout;
PangoFontDescription *font;
PangoRectangle rect;
PangoFontMap *map;
gint ret_value;
gint dpi_cairo, dpi_screen;
GdkScreen *screen = gdk_screen_get_default();
if(!text || strlen(text) == 0) return 0;
cairo_save(cairo);
map = pango_cairo_font_map_get_default();
dpi_cairo = pango_cairo_font_map_get_resolution(PANGO_CAIRO_FONT_MAP(map));
dpi_screen = gdk_screen_get_resolution(screen);
height *= (double)dpi_screen/(double)dpi_cairo;
font = gtk_psfont_get_font_description(psfont, height);
pango_layout_set_font_description(GTK_PLOT_CAIRO(pc)->layout, font);
pango_layout_set_text(GTK_PLOT_CAIRO(pc)->layout, text, strlen(text));
pango_layout_get_extents(GTK_PLOT_CAIRO(pc)->layout, NULL, &rect);
if (psfont->i18n_latinfamily && psfont->vertical) {
/* vertical-writing CJK postscript fonts. */
return rect.height;
}
else
{
/* horizontal writing */
if(angle == 90)
// cairo_translate(cairo, dx, dy-PANGO_PIXELS(rect.width));
cairo_translate(cairo, dx, dy);
else if(angle == 270)
cairo_translate(cairo, dx+PANGO_PIXELS(rect.height), dy);
else if(angle == 180)
cairo_translate(cairo, dx-PANGO_PIXELS(rect.width), dy);
else
cairo_translate(cairo, dx, dy);
}
cairo_rotate(cairo, -angle * G_PI / 180);
pango_cairo_update_layout(cairo, layout);
pango_cairo_show_layout(cairo, layout);
cairo_restore(cairo);
pango_font_description_free(font);
ret_value = (angle == 0 || angle == 180) ? rect.width : rect.height;
return PANGO_PIXELS(rect.width);
}
开发者ID:2tim,项目名称:gtkextra,代码行数:55,代码来源:gtkplotcairo.c
示例10: wxGTK_CONV_FONT
// Notice we don't check here the font. It is supposed to be OK before the call.
void wxTextMeasure::DoGetTextExtent(const wxString& string,
wxCoord *width,
wxCoord *height,
wxCoord *descent,
wxCoord *externalLeading)
{
if ( !m_context )
{
if ( width )
*width = 0;
if ( height )
*height = 0;
return;
}
// Set layout's text
const wxCharBuffer dataUTF8 = wxGTK_CONV_FONT(string, GetFont());
if ( !dataUTF8 )
{
// hardly ideal, but what else can we do if conversion failed?
wxLogLastError(wxT("GetTextExtent"));
return;
}
pango_layout_set_text(m_layout, dataUTF8, -1);
if ( m_dc )
{
// in device units
pango_layout_get_pixel_size(m_layout, width, height);
}
else // win
{
// the logical rect bounds the ink rect
PangoRectangle rect;
pango_layout_get_extents(m_layout, NULL, &rect);
*width = PANGO_PIXELS(rect.width);
*height = PANGO_PIXELS(rect.height);
}
if (descent)
{
PangoLayoutIter *iter = pango_layout_get_iter(m_layout);
int baseline = pango_layout_iter_get_baseline(iter);
pango_layout_iter_free(iter);
*descent = *height - PANGO_PIXELS(baseline);
}
if (externalLeading)
{
// No support for MSW-like "external leading" in Pango.
*externalLeading = 0;
}
}
开发者ID:CobaltBlues,项目名称:wxWidgets,代码行数:55,代码来源:textmeasure.cpp
示例11: gdk_threads_enter
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkFontPeer_getFontMetrics
(JNIEnv *env, jobject java_font, jdoubleArray java_metrics)
{
struct peerfont *pfont = NULL;
jdouble *native_metrics = NULL;
PangoFontMetrics *pango_metrics;
gdk_threads_enter();
pfont = (struct peerfont *) NSA_GET_FONT_PTR (env, java_font);
g_assert (pfont != NULL);
pango_metrics
= pango_context_get_metrics (pfont->ctx, pfont->desc,
gtk_get_default_language ());
native_metrics
= (*env)->GetDoubleArrayElements (env, java_metrics, NULL);
g_assert (native_metrics != NULL);
native_metrics[FONT_METRICS_ASCENT]
= PANGO_PIXELS (pango_font_metrics_get_ascent (pango_metrics));
native_metrics[FONT_METRICS_MAX_ASCENT]
= native_metrics[FONT_METRICS_ASCENT];
native_metrics[FONT_METRICS_DESCENT]
= PANGO_PIXELS (pango_font_metrics_get_descent (pango_metrics));
if (native_metrics[FONT_METRICS_DESCENT] < 0)
native_metrics[FONT_METRICS_DESCENT]
= - native_metrics[FONT_METRICS_DESCENT];
native_metrics[FONT_METRICS_MAX_DESCENT]
= native_metrics[FONT_METRICS_DESCENT];
native_metrics[FONT_METRICS_MAX_ADVANCE]
= PANGO_PIXELS (pango_font_metrics_get_approximate_char_width
(pango_metrics));
(*env)->ReleaseDoubleArrayElements (env,
java_metrics,
native_metrics, 0);
pango_font_metrics_unref (pango_metrics);
gdk_threads_leave();
}
开发者ID:BackupTheBerlios,项目名称:iphone-binutils-svn,代码行数:50,代码来源:gnu_java_awt_peer_gtk_GdkFontPeer.c
示例12: gnm_notebook_button_size_allocate
static void
gnm_notebook_button_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GnmNotebookButton *nbb = GNM_NOTEBOOK_BUTTON (widget);
gnm_notebook_button_ensure_layout (nbb);
nbb->x_offset =
(allocation->width - PANGO_PIXELS (nbb->logical.width)) / 2;
nbb->x_offset_active =
(allocation->width - PANGO_PIXELS (nbb->logical_active.width)) / 2;
GTK_WIDGET_CLASS(gnm_notebook_button_parent_class)
->size_allocate (widget, allocation);
}
开发者ID:nzinfo,项目名称:gnumeric,代码行数:15,代码来源:gnm-notebook.c
示例13: util_split_font_string
static gboolean
util_split_font_string(const gchar *font_name, gchar **name, gint *size)
{
PangoFontDescription *desc;
PangoFontMask mask;
gboolean retval = FALSE;
if (font_name == NULL) {
return FALSE;
}
mask = (PangoFontMask) (PANGO_FONT_MASK_FAMILY | PANGO_FONT_MASK_SIZE);
desc = pango_font_description_from_string(font_name);
if (!desc) {
return FALSE;
}
if ((pango_font_description_get_set_fields(desc) & mask) == mask) {
*size = PANGO_PIXELS(pango_font_description_get_size (desc));
*name = g_strdup(pango_font_description_get_family (desc));
retval = TRUE;
}
pango_font_description_free(desc);
return retval;
}
开发者ID:WangGL1985,项目名称:chmsee,代码行数:28,代码来源:gecko_utils.cpp
示例14: nsfont_position_in_string
/**
* Find the position in a string where an x coordinate falls.
*
* \param[in] fstyle style for this text
* \param[in] string UTF-8 string to measure
* \param[in] length length of string, in bytes
* \param[in] x coordinate to search for
* \param[out] char_offset updated to offset in string of actual_x, [0..length]
* \param[out] actual_x updated to x coordinate of character closest to x
* \return NSERROR_OK and char_offset and actual_x updated or appropriate
* error code on faliure
*/
static nserror
nsfont_position_in_string(const plot_font_style_t *fstyle,
const char *string,
size_t length,
int x,
size_t *char_offset,
int *actual_x)
{
int index;
PangoFontDescription *desc;
PangoRectangle pos;
nsfont_pango_check();
desc = nsfont_style_to_description(fstyle);
pango_layout_set_font_description(nsfont_pango_layout, desc);
pango_font_description_free(desc);
pango_layout_set_text(nsfont_pango_layout, string, length);
if (pango_layout_xy_to_index(nsfont_pango_layout,
x * PANGO_SCALE,
0, &index, 0) == FALSE) {
index = length;
}
pango_layout_index_to_pos(nsfont_pango_layout, index, &pos);
*char_offset = index;
*actual_x = PANGO_PIXELS(pos.x);
return NSERROR_OK;
}
开发者ID:arczi84,项目名称:NetSurf-68k,代码行数:45,代码来源:layout_pango.c
示例15: gtk_glwidget_create_font
void gtk_glwidget_create_font (GtkWidget *widget)
{
PangoFontDescription *font_desc;
PangoFont *font;
PangoFontMetrics *font_metrics;
font_list_base = qglGenLists (256);
font_desc = pango_font_description_from_string (font_string);
font = gdk_gl_font_use_pango_font (font_desc, 0, 256, font_list_base);
if(font != NULL)
{
font_metrics = pango_font_get_metrics (font, NULL);
font_height = pango_font_metrics_get_ascent (font_metrics) +
pango_font_metrics_get_descent (font_metrics);
font_height = PANGO_PIXELS (font_height);
pango_font_metrics_unref (font_metrics);
}
pango_font_description_free (font_desc);
}
开发者ID:AEonZR,项目名称:GtkRadiant,代码行数:25,代码来源:glwidget.cpp
示例16: myScreenUpdateFontHeight
gboolean
myScreenUpdateFontHeight (ScreenInfo *screen_info)
{
PangoFontDescription *desc;
PangoContext *context;
PangoFontMetrics *metrics;
GtkWidget *widget;
g_return_val_if_fail (screen_info != NULL, FALSE);
TRACE ("entering myScreenUpdateFontHeight");
widget = myScreenGetGtkWidget (screen_info);
context = getUIPangoContext (widget);
desc = getUIPangoFontDesc (widget);
if (desc && context)
{
metrics = pango_context_get_metrics (context, desc, NULL);
screen_info->font_height =
PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
pango_font_metrics_get_descent (metrics));
pango_font_metrics_unref (metrics);
return TRUE;
}
return FALSE;
}
开发者ID:Distrotech,项目名称:xfwm4,代码行数:28,代码来源:screen.c
示例17: gtk_anim_label_size_allocate
static void gtk_anim_label_size_allocate(GtkWidget * widget, GtkAllocation * allocation
)
{
PangoRectangle prect;
g_return_if_fail(widget != NULL);
g_return_if_fail(GTK_IS_ANIM_LABEL(widget));
g_return_if_fail(allocation != NULL);
widget->allocation = *allocation;
(*GTK_WIDGET_CLASS(parent_class)->size_allocate) (widget, allocation);
if (GTK_WIDGET_REALIZED(widget))
{
gdk_window_move_resize(widget->window, allocation->x, allocation->y, allocation->width, allocation->height);
if (((GTK_ANIM_LABEL(widget)->animate) || (GTK_ANIM_LABEL(widget)->auto_animate)) && (GTK_ANIM_LABEL(widget)->layout))
{
pango_layout_get_extents(GTK_ANIM_LABEL(widget)->layout, NULL, &prect);
if (PANGO_PIXELS(prect.width) < widget->allocation.width)
{
GTK_ANIM_LABEL(widget)->pos_x = 0;
gtk_anim_label_animate(GTK_ANIM_LABEL(widget), FALSE);
}
else if ((GTK_ANIM_LABEL(widget)->auto_animate) && (!GTK_ANIM_LABEL(widget)->animate))
{
GTK_ANIM_LABEL(widget)->pos_x = 0;
gtk_anim_label_animate(GTK_ANIM_LABEL(widget), TRUE);
}
}
}
}
开发者ID:krzyzanowskim,项目名称:GNUGadu,代码行数:34,代码来源:gtkanimlabel.c
示例18: 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));
}
开发者ID:nihed,项目名称:magnetism,代码行数:34,代码来源:viewer-win32.c
示例19: ol_scroll_window_get_font_height
static int
ol_scroll_window_get_font_height (OlScrollWindow *scroll)
{
ol_assert_ret (OL_IS_SCROLL_WINDOW (scroll), 0);
OlScrollWindowPrivate *priv = OL_SCROLL_WINDOW_GET_PRIVATE (scroll);
PangoContext *pango_context = gdk_pango_context_get ();
PangoLayout *pango_layout = pango_layout_new (pango_context);
PangoFontDescription *font_desc = pango_font_description_from_string (priv->font_name);
pango_layout_set_font_description (pango_layout, font_desc);
PangoFontMetrics *metrics = pango_context_get_metrics (pango_context,
pango_layout_get_font_description (pango_layout), /* font desc */
NULL); /* languague */
int height = 0;
int ascent, descent;
ascent = pango_font_metrics_get_ascent (metrics);
descent = pango_font_metrics_get_descent (metrics);
pango_font_metrics_unref (metrics);
height += PANGO_PIXELS (ascent + descent);
pango_font_description_free (font_desc);
g_object_unref (pango_layout);
g_object_unref (pango_context);
return height;
}
开发者ID:AhmadMAlam,项目名称:osd-lyrics-1,代码行数:26,代码来源:ol_scroll_window.c
示例20: reverse_engineer_spin_button
/* This function is based on reverse_engineer_stepper_box
* (and gtk2 sources) except it is for getting spin button
* size instead. It is not always right, and only returns
* a (hopefully more accurate) arrow box, not the entire
* button box, as the button box is passed correctly
* to paint_box and so only paint_arrow needs this.
*/
void
reverse_engineer_spin_button (GtkWidget *widget,
GtkArrowType arrow_type,
gint *x,
gint *y,
gint *width,
gint *height)
{
#ifdef GTK2
gint size = pango_font_description_get_size (widget->style->font_desc);
gint realheight, realwidth;
realwidth = MIN(PANGO_PIXELS (size), 30);
realwidth -= realwidth % 2; /* force even */
realwidth -= 2 * xthickness(widget->style);
realheight = ((widget->requisition.height) - 2 * ythickness(widget->style)) / 2;
realheight -= 1;
realwidth += 1;
*x += ((*width - realwidth) / 2);
*y += ((*height - realheight) / 2) + (arrow_type==GTK_ARROW_DOWN?1:-1);
*width = realwidth;
*height = realheight;
#endif
}
开发者ID:huangming,项目名称:configs,代码行数:35,代码来源:misc_functions.c
注:本文中的PANGO_PIXELS函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论