static gboolean fm_list_view_draw(GtkWidget* view_, cairo_t* cr, FMListView* view) { g_return_val_if_fail(FM_IS_LIST_VIEW(view), FALSE); GOFDirectoryAsync *dir = fm_directory_view_get_current_directory (FM_DIRECTORY_VIEW (view)); if (gof_directory_async_is_empty (dir)) { PangoLayout* layout = gtk_widget_create_pango_layout(GTK_WIDGET(view), NULL); gchar *str = g_strconcat("<span size='x-large'>", _("This folder is empty."), "</span>", NULL); pango_layout_set_markup (layout, str, -1); PangoRectangle extents; /* Get hayout height and width */ pango_layout_get_extents(layout, NULL, &extents); gdouble width = pango_units_to_double(extents.width); gdouble height = pango_units_to_double(extents.height); gtk_render_layout(gtk_widget_get_style_context(GTK_WIDGET(view)), cr, (double)gtk_widget_get_allocated_width(GTK_WIDGET(view))/2 - width/2, (double)gtk_widget_get_allocated_height(GTK_WIDGET(view))/2 - height/2, layout); } return FALSE; }
static void icon_shape_renderer (cairo_t *cr, PangoAttrShape *attr, gboolean do_path, gpointer user_data) { IconShapeData *data = user_data; gdouble x, y; cairo_get_current_point (cr, &x, &y); if (GPOINTER_TO_UINT (attr->data) == data->placeholder) { gdouble ascent; gdouble height; GdkPixbuf *pixbuf; GtkIconInfo *info; ascent = pango_units_to_double (attr->ink_rect.y); height = pango_units_to_double (attr->ink_rect.height); info = gtk_icon_theme_lookup_by_gicon (gtk_icon_theme_get_default (), data->icon, (gint)height, GTK_ICON_LOOKUP_FORCE_SIZE | GTK_ICON_LOOKUP_USE_BUILTIN); pixbuf = gtk_icon_info_load_icon (info, NULL); g_object_unref (info); cairo_set_operator (cr, CAIRO_OPERATOR_OVER); cairo_reset_clip (cr); gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y + ascent); cairo_paint (cr); g_object_unref (pixbuf); } }
static void _CalcAbsSizes(RefPtr<Pango::Layout> lay, double& wdh, double& hgt) { int t_wdh, t_hgt; lay->get_size(t_wdh, t_hgt); wdh = pango_units_to_double(t_wdh); hgt = pango_units_to_double(t_hgt); }
static void e_contact_print_letter_heading (EContactPrintContext *ctxt, gchar *letter) { PangoLayout *layout; PangoFontDescription *desc; PangoFontMetrics *metrics; gint width, height; cairo_t *cr; desc = ctxt->letter_heading_font; layout = gtk_print_context_create_pango_layout (ctxt->context); /* Make the rectangle thrice the average character width. * XXX Works well for English, what about other locales? */ metrics = pango_context_get_metrics ( pango_layout_get_context (layout), desc, pango_language_get_default ()); width = pango_font_metrics_get_approximate_char_width (metrics) * 3; pango_font_metrics_unref (metrics); pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER); pango_layout_set_font_description (layout, desc); pango_layout_set_text (layout, letter, -1); pango_layout_set_width (layout, width); pango_layout_get_size (layout, NULL, &height); if (ctxt->page_nr == -1 || ctxt->pages != ctxt->page_nr) { /* only calculating number of pages * or on page we do not want to print */ ctxt->y += pango_units_to_double (height); return; } /* Draw white text centered in a black rectangle. */ cr = gtk_print_context_get_cairo_context (ctxt->context); cairo_save (cr); cairo_set_source_rgb (cr, .0, .0, .0); cairo_rectangle ( cr, ctxt->x, ctxt->y, pango_units_to_double (width), pango_units_to_double (height)); cairo_fill (cr); cairo_restore (cr); cairo_save (cr); cairo_move_to (cr, ctxt->x, ctxt->y); cairo_set_source_rgb (cr, 1., 1., 1.); pango_cairo_show_layout (cr, layout); cairo_restore (cr); ctxt->y += pango_units_to_double (height); }
/** * pango_matrix_transform_rectangle: * @matrix: a #PangoMatrix, or %NULL * @rect: (inout) (allow-none): in/out bounding box in Pango units, or %NULL * * First transforms @rect using @matrix, then calculates the bounding box * of the transformed rectangle. The rectangle should be in Pango units. * * This function is useful for example when you want to draw a rotated * @PangoLayout to an image buffer, and want to know how large the image * should be and how much you should shift the layout when rendering. * * If you have a rectangle in device units (pixels), use * pango_matrix_transform_pixel_rectangle(). * * If you have the rectangle in Pango units and want to convert to * transformed pixel bounding box, it is more accurate to transform it first * (using this function) and pass the result to pango_extents_to_pixels(), * first argument, for an inclusive rounded rectangle. * However, there are valid reasons that you may want to convert * to pixels first and then transform, for example when the transformed * coordinates may overflow in Pango units (large matrix translation for * example). * * Since: 1.16 **/ void pango_matrix_transform_rectangle (const PangoMatrix *matrix, PangoRectangle *rect) { int i; double quad_x[4], quad_y[4]; double dx1, dy1; double dx2, dy2; double min_x, max_x; double min_y, max_y; if (!rect || !matrix) return; quad_x[0] = pango_units_to_double (rect->x); quad_y[0] = pango_units_to_double (rect->y); pango_matrix_transform_point (matrix, &quad_x[0], &quad_y[0]); dx1 = pango_units_to_double (rect->width); dy1 = 0; pango_matrix_transform_distance (matrix, &dx1, &dy1); quad_x[1] = quad_x[0] + dx1; quad_y[1] = quad_y[0] + dy1; dx2 = 0; dy2 = pango_units_to_double (rect->height); pango_matrix_transform_distance (matrix, &dx2, &dy2); quad_x[2] = quad_x[0] + dx2; quad_y[2] = quad_y[0] + dy2; quad_x[3] = quad_x[0] + dx1 + dx2; quad_y[3] = quad_y[0] + dy1 + dy2; min_x = max_x = quad_x[0]; min_y = max_y = quad_y[0]; for (i=1; i < 4; i++) { if (quad_x[i] < min_x) min_x = quad_x[i]; else if (quad_x[i] > max_x) max_x = quad_x[i]; if (quad_y[i] < min_y) min_y = quad_y[i]; else if (quad_y[i] > max_y) max_y = quad_y[i]; } rect->x = pango_units_from_double (min_x); rect->y = pango_units_from_double (min_y); rect->width = pango_units_from_double (max_x) - rect->x; rect->height = pango_units_from_double (max_y) - rect->y; }
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; }
double FontSize(const Pango::FontDescription& dsc) { int sz = dsc.get_size(); if( dsc.get_size_is_absolute() ) return sz * (72./GetDpi()); else return pango_units_to_double(sz); }
int PrintNotesNoteAddin::compute_footer_height(const Glib::RefPtr<Gtk::PrintContext> & context) { Glib::RefPtr<Pango::Layout> layout = create_layout_for_timestamp(context); Pango::Rectangle ink_rect; Pango::Rectangle logical_rect; layout->get_extents(ink_rect, logical_rect); return pango_units_to_double(ink_rect.get_height()) + cm_to_pixel(0.5, context->get_dpi_y()); }
static GObject * ddb_equalizer_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) { GObject * obj; GObjectClass * parent_class; DdbEqualizer * self; parent_class = G_OBJECT_CLASS (ddb_equalizer_parent_class); obj = parent_class->constructor (type, n_construct_properties, construct_properties); self = DDB_EQUALIZER (obj); { self->priv->margin_bottom = (gint) (((pango_units_to_double (pango_font_description_get_size (gtk_widget_get_style ((GtkWidget*) self)->font_desc)) * gdk_screen_get_resolution (gdk_screen_get_default ())) / 72) + 4); self->priv->margin_left = self->priv->margin_bottom * 4; } return obj; }
static void _draw_footer(GtkHTML * html, GtkPrintOperation * operation, GtkPrintContext * context, gint page_nr, PangoRectangle * rec, EDITOR * e) { PangoFontDescription *desc; PangoLayout *layout; gdouble x, y; gint n_pages; gchar *text; cairo_t *cr; g_object_get(operation, "n-pages", &n_pages, NULL); text = g_strdup_printf(_("Page %d of %d"), page_nr + 1, n_pages); desc = pango_font_description_from_string("Sans Regular 10"); 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, rec->width); x = pango_units_to_double(rec->x); y = pango_units_to_double(rec->y); 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); }
static gdouble e_contact_text_height (GtkPrintContext *context, PangoFontDescription *desc, const gchar *text) { PangoLayout *layout; gint width, height; 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, &width, &height); g_object_unref (layout); return pango_units_to_double (height); }
static gdouble get_font_width (GtkPrintContext *context, PangoFontDescription *desc, const gchar *text) { PangoLayout *layout; gint width, height; g_return_val_if_fail (desc, .0); g_return_val_if_fail (text, .0); layout = gtk_print_context_create_pango_layout (context); pango_layout_set_font_description (layout, desc); pango_layout_set_text (layout, text, -1); pango_layout_set_width (layout, -1); pango_layout_set_indent (layout, 0); pango_layout_get_size (layout, &width, &height); g_object_unref (layout); return pango_units_to_double (width); }
int main (int argc, char **argv) { PangoFontMap *fontmap; PangoFontFamily **families; int n_families; int i, j, k; #if !GLIB_CHECK_VERSION (2, 35, 3) g_type_init(); #endif g_set_prgname ("pango-list"); /* Use PangoCairo to get default fontmap so it works on every platform. */ fontmap = pango_cairo_font_map_get_default (); pango_font_map_list_families (fontmap, &families, &n_families); for (i = 0; i < n_families; i++) { PangoFontFace **faces; int n_faces; const char *family_name = pango_font_family_get_name (families[i]); g_print ("%s\n", family_name); pango_font_family_list_faces (families[i], &faces, &n_faces); for (j = 0; j < n_faces; j++) { const char *face_name = pango_font_face_get_face_name (faces[j]); gboolean is_synth = pango_font_face_is_synthesized (faces[j]); const char *synth_str = is_synth ? "*" : ""; g_print (" %s%s\n", synth_str, face_name); if (0) { int *sizes; int n_sizes; pango_font_face_list_sizes (faces[j], &sizes, &n_sizes); if (n_sizes) { g_print (" {"); for (k = 0; k < n_sizes; k++) { if (k) g_print (", "); g_print ("%g", pango_units_to_double (sizes[k])); } g_print ("}\n"); } g_free (sizes); } if (1) { PangoFontDescription *desc = pango_font_face_describe (faces[j]); char *desc_str = pango_font_description_to_string (desc); g_print (" \"%s\"\n", desc_str); g_free (desc_str); pango_font_description_free (desc); } } g_free (faces); } g_free (families); g_object_unref (fontmap); return 0; }
void ttext::recalculate(const bool force) const { if(calculation_dirty_ || force) { assert(layout_); calculation_dirty_ = false; surface_dirty_ = true; tfont font(get_font_families(font_class_), font_size_, font_style_); pango_layout_set_font_description(layout_, font.get()); if(font_style_ & ttext::STYLE_UNDERLINE) { PangoAttrList *attribute_list = pango_attr_list_new(); pango_attr_list_insert(attribute_list , pango_attr_underline_new(PANGO_UNDERLINE_SINGLE)); pango_layout_set_attributes (layout_, attribute_list); pango_attr_list_unref(attribute_list); } int maximum_width = 0; if(characters_per_line_ != 0) { PangoFont* f = pango_font_map_load_font( pango_cairo_font_map_get_default() , context_ , font.get()); PangoFontMetrics* m = pango_font_get_metrics(f, nullptr); int w = pango_font_metrics_get_approximate_char_width(m); w *= characters_per_line_; maximum_width = ceil(pango_units_to_double(w)); } else { maximum_width = maximum_width_; } if(maximum_width_ != -1) { maximum_width = std::min(maximum_width, maximum_width_); } /* * See set_maximum_width for some more background info as well. * In order to fix the problem first set a width which seems to render * correctly then lower it to fit. For the campaigns the 4 does "the * right thing" for the terrain labels it should use the value 0 to set * the ellipse properly. Need to see whether this is a bug in pango or * a bug in my understanding of the pango api. */ int hack = 4; do { pango_layout_set_width(layout_, maximum_width == -1 ? -1 : (maximum_width + hack) * PANGO_SCALE); pango_layout_get_pixel_extents(layout_, nullptr, &rect_); DBG_GUI_L << "ttext::" << __func__ << " text '" << gui2::debug_truncate(text_) << "' maximum_width " << maximum_width << " hack " << hack << " width " << rect_.x + rect_.width << ".\n"; --hack; } while(maximum_width != -1 && hack >= 0 && rect_.x + rect_.width > maximum_width); DBG_GUI_L << "ttext::" << __func__ << " text '" << gui2::debug_truncate(text_) << "' font_size " << font_size_ << " markedup_text " << markedup_text_ << " font_style " << std::hex << font_style_ << std::dec << " maximum_width " << maximum_width << " maximum_height " << maximum_height_ << " result " << rect_ << ".\n"; if(maximum_width != -1 && rect_.x + rect_.width > maximum_width) { DBG_GUI_L << "ttext::" << __func__ << " text '" << gui2::debug_truncate(text_) << " ' width " << rect_.x + rect_.width << " greater as the wanted maximum of " << maximum_width << ".\n"; } } }
void PrintNotesNoteAddin::on_draw_page(const Glib::RefPtr<Gtk::PrintContext>& context, guint page_nr) { Cairo::RefPtr<Cairo::Context> cr = context->get_cairo_context(); cr->move_to (m_margin_left, m_margin_top); PageBreak start; if (page_nr != 0) { start = m_page_breaks [page_nr - 1]; } PageBreak end(-1, -1); if (m_page_breaks.size() > page_nr) { end = m_page_breaks [page_nr]; } Gtk::TextIter position; Gtk::TextIter end_iter; get_buffer()->get_bounds (position, end_iter); // Fast-forward to the starting line while (position.get_line() < start.get_paragraph()) { position.forward_line (); } bool done = position.compare (end_iter) >= 0; while (!done) { Gtk::TextIter line_end = position; if (!line_end.ends_line ()) { line_end.forward_to_line_end (); } int paragraph_number = position.get_line(); int indentation; { Glib::RefPtr<Pango::Layout> layout = create_layout_for_paragraph (context,position, line_end, indentation); for(int line_number = 0; line_number < layout->get_line_count() && !done; line_number++) { // Skip the lines up to the starting line in the // first paragraph on this page if ((paragraph_number == start.get_paragraph()) && (line_number < start.get_line())) { continue; } // Break as soon as we hit the end line if ((paragraph_number == end.get_paragraph()) && (line_number == end.get_line())) { done = true; break; } Glib::RefPtr<Pango::LayoutLine> line = layout->get_line(line_number); Pango::Rectangle ink_rect; Pango::Rectangle logical_rect; line->get_extents (ink_rect, logical_rect); double curX, curY; cr->get_current_point(curX, curY); cr->move_to (m_margin_left + indentation, curY); int line_height = pango_units_to_double(logical_rect.get_height()); double x, y; x = m_margin_left + indentation; cr->get_current_point(curX, curY); y = curY + line_height; pango_cairo_show_layout_line(cr->cobj(), line->gobj()); cr->move_to(x, y); } } position.forward_line (); done = done || (position.compare (end_iter) >= 0); } // Print the footer int total_height = context->get_height(); int total_width = context->get_width(); int footer_height = 0; double footer_anchor_x, footer_anchor_y; { Glib::RefPtr<Pango::Layout> pages_footer = create_layout_for_pagenumbers (context, page_nr + 1, m_page_breaks.size() + 1); Pango::Rectangle ink_footer_rect; Pango::Rectangle logical_footer_rect; pages_footer->get_extents(ink_footer_rect, logical_footer_rect); footer_anchor_x = cm_to_pixel(0.5, context->get_dpi_x()); footer_anchor_y = total_height - m_margin_bottom; footer_height = pango_units_to_double(logical_footer_rect.get_height()); cr->move_to(total_width - pango_units_to_double(logical_footer_rect.get_width()) - cm_to_pixel(0.5, context->get_dpi_x()), footer_anchor_y); pango_cairo_show_layout_line(cr->cobj(), (pages_footer->get_line(0))->gobj()); } cr->move_to(footer_anchor_x, footer_anchor_y); pango_cairo_show_layout_line(cr->cobj(), (m_timestamp_footer->get_line(0))->gobj()); cr->move_to(cm_to_pixel(0.5, context->get_dpi_x()), total_height - m_margin_bottom - footer_height); cr->line_to(total_width - cm_to_pixel(0.5, context->get_dpi_x()), total_height - m_margin_bottom - footer_height); cr->stroke(); }
#include "view_private.h" #include "image.h" #include "common.h" #include <glob.h> #include <stdlib.h> #include <string.h> inline void pango_rect_to_view_rect (const PangoRectangle * restrict p_rect, view_rectangle_t * restrict v_rect) { v_rect->x = pango_units_to_double(p_rect->x); v_rect->y = pango_units_to_double(p_rect->y); v_rect->width = pango_units_to_double(p_rect->width); v_rect->height = pango_units_to_double(p_rect->height); } static void setup_background (cairo_t *cr, view_t *v, options_t *opts, const char *fn) { cairo_surface_t *background_im; int back_im_w, back_im_h; double w_scale, h_scale; const option_data_t *data; option_type_t type; cairo_save (cr); data = get_option_data (opts, "background_color", &type); cairo_set_source_rgb (cr, data->color.r, data->color.g, data->color.b); cairo_fill (cr);
static gdouble get_font_height (PangoFontDescription *desc) { return pango_units_to_double ( pango_font_description_get_size (desc)); }
static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose* event) { DdbEqualizer * self; gboolean result = FALSE; GdkColor _tmp0_ = {0}; GdkColor fore_bright_color; GdkColor c1; GdkColor _tmp1_ = {0}; GdkColor c2; GdkColor fore_dark_color; gint width; gint height; GdkDrawable* d; GdkGCValues _tmp2_ = {0}; GdkGCValues _tmp3_; GdkGC* gc; double step; gint i = 0; double vstep; PangoLayout* l; PangoContext* ctx; PangoFontDescription* fd; gint fontsize; gboolean _tmp7_ = FALSE; char* tmp; double val; const char* _tmp9_; char* _tmp10_; const char* _tmp11_; char* _tmp12_; GdkRectangle _tmp13_ = {0}; GdkRectangle _tmp14_; gint count; GdkRectangle _tmp16_ = {0}; GdkRectangle _tmp17_; gint bar_w; GdkRectangle _tmp22_ = {0}; GdkRectangle _tmp23_; self = (DdbEqualizer*) base; fore_bright_color = (gtkui_get_bar_foreground_color (&_tmp0_), _tmp0_); c1 = fore_bright_color; c2 = (gtkui_get_bar_background_color (&_tmp1_), _tmp1_); fore_dark_color = c2; fore_dark_color.red = fore_dark_color.red + ((guint16) ((gint16) ((c1.red - c2.red) * 0.5))); fore_dark_color.green = fore_dark_color.green + ((guint16) ((gint16) ((c1.green - c2.green) * 0.5))); fore_dark_color.blue = fore_dark_color.blue + ((guint16) ((gint16) ((c1.blue - c2.blue) * 0.5))); width = ((GtkWidget*) self)->allocation.width; height = ((GtkWidget*) self)->allocation.height; d = _g_object_ref0 ((GdkDrawable*) gtk_widget_get_window ((GtkWidget*) self)); gc = _g_object_ref0 (GDK_DRAWABLE_GET_CLASS (d)->create_gc (d, (_tmp3_ = (memset (&_tmp2_, 0, sizeof (GdkGCValues)), _tmp2_), &_tmp3_), 0)); gdk_gc_set_rgb_fg_color (gc, &c2); gdk_draw_rectangle (d, gc, TRUE, 0, 0, width, height); gdk_gc_set_rgb_fg_color (gc, &fore_dark_color); step = ((double) (width - self->priv->margin_left)) / ((double) (DDB_EQUALIZER_bands + 1)); { gboolean _tmp4_; i = 0; _tmp4_ = TRUE; while (TRUE) { if (!_tmp4_) { i++; } _tmp4_ = FALSE; if (!(i < DDB_EQUALIZER_bands)) { break; } gdk_draw_line (d, gc, ((gint) ((i + 1) * step)) + self->priv->margin_left, 0, ((gint) ((i + 1) * step)) + self->priv->margin_left, height - self->priv->margin_bottom); } } vstep = (double) (height - self->priv->margin_bottom); { double di; di = (double) 0; { gboolean _tmp5_; _tmp5_ = TRUE; while (TRUE) { if (!_tmp5_) { di = di + 0.25; } _tmp5_ = FALSE; if (!(di < 2)) { break; } gdk_draw_line (d, gc, self->priv->margin_left, (gint) ((di - self->priv->preamp) * vstep), width, (gint) ((di - self->priv->preamp) * vstep)); } } } gdk_gc_set_rgb_fg_color (gc, &fore_bright_color); l = gtk_widget_create_pango_layout ((GtkWidget*) self, NULL); ctx = _g_object_ref0 (pango_layout_get_context (l)); fd = pango_font_description_copy (gtk_widget_get_style ((GtkWidget*) self)->font_desc); pango_font_description_set_size (fd, (gint) (pango_font_description_get_size (gtk_widget_get_style ((GtkWidget*) self)->font_desc) * 0.7)); pango_context_set_font_description (ctx, fd); { gboolean _tmp6_; i = 0; _tmp6_ = TRUE; while (TRUE) { PangoRectangle ink = {0}; PangoRectangle log = {0}; gint offs; if (!_tmp6_) { i++; } _tmp6_ = FALSE; if (!(i < DDB_EQUALIZER_bands)) { break; } pango_layout_set_text (l, freqs[i], (gint) g_utf8_strlen (freqs[i], -1)); pango_layout_get_pixel_extents (l, &ink, &log); offs = 2; if ((i % 2) != 0) { offs = offs + 2; } gdk_draw_layout (d, gc, (((gint) ((i + 1) * step)) + self->priv->margin_left) - (ink.width / 2), (height - self->priv->margin_bottom) + offs, l); } } pango_font_description_set_size (fd, (gint) pango_font_description_get_size (gtk_widget_get_style ((GtkWidget*) self)->font_desc)); pango_context_set_font_description (ctx, fd); pango_layout_set_width (l, self->priv->margin_left - 1); pango_layout_set_alignment (l, PANGO_ALIGN_RIGHT); fontsize = (gint) ((pango_units_to_double (pango_font_description_get_size (fd)) * gdk_screen_get_resolution (gdk_screen_get_default ())) / 72); if (self->priv->mouse_y >= 0) { _tmp7_ = self->priv->mouse_y < (height - self->priv->margin_bottom); } else { _tmp7_ = FALSE; } if (_tmp7_) { double db; const char* _tmp8_; char* tmp; db = ddb_equalizer_scale (self, ((double) (self->priv->mouse_y - 1)) / ((double) ((height - self->priv->margin_bottom) - 2))); _tmp8_ = NULL; if (db > 0) { _tmp8_ = "+"; } else { _tmp8_ = ""; } tmp = g_strdup_printf ("%s%.1fdB", _tmp8_, db); pango_layout_set_text (l, tmp, (gint) g_utf8_strlen (tmp, -1)); gdk_draw_layout (d, gc, self->priv->margin_left - 1, self->priv->mouse_y - 3, l); _g_free0 (tmp); } tmp = NULL; val = ddb_equalizer_scale (self, (double) 1); _tmp9_ = NULL; if (val > 0) { _tmp9_ = "+"; } else { _tmp9_ = ""; } tmp = (_tmp10_ = g_strdup_printf ("%s%.1fdB", _tmp9_, val), _g_free0 (tmp), _tmp10_); pango_layout_set_text (l, tmp, (gint) g_utf8_strlen (tmp, -1)); gdk_draw_layout (d, gc, self->priv->margin_left - 1, (height - self->priv->margin_bottom) - fontsize, l); val = ddb_equalizer_scale (self, (double) 0); _tmp11_ = NULL; if (val > 0) { _tmp11_ = "+"; } else { _tmp11_ = ""; } tmp = (_tmp12_ = g_strdup_printf ("%s%.1fdB", _tmp11_, val), _g_free0 (tmp), _tmp12_); pango_layout_set_text (l, tmp, (gint) g_utf8_strlen (tmp, -1)); gdk_draw_layout (d, gc, self->priv->margin_left - 1, 1, l); pango_layout_set_text (l, "+0dB", 4); gdk_draw_layout (d, gc, self->priv->margin_left - 1, ((gint) ((1 - self->priv->preamp) * (height - self->priv->margin_bottom))) - (fontsize / 2), l); pango_layout_set_text (l, "preamp", 6); pango_layout_set_alignment (l, PANGO_ALIGN_LEFT); gdk_draw_layout (d, gc, 1, (height - self->priv->margin_bottom) + 2, l); gdk_draw_rectangle (d, gc, FALSE, self->priv->margin_left, 0, (width - self->priv->margin_left) - 1, (height - self->priv->margin_bottom) - 1); gdk_gc_set_line_attributes (gc, 2, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER); gdk_gc_set_clip_rectangle (gc, (_tmp14_ = (_tmp13_.x = 0, _tmp13_.y = (gint) (self->priv->preamp * (height - self->priv->margin_bottom)), _tmp13_.width = 11, _tmp13_.height = height, _tmp13_), &_tmp14_)); gdk_gc_set_rgb_fg_color (gc, &fore_bright_color); count = ((gint) ((height - self->priv->margin_bottom) / 6)) + 1; { gint j; j = 0; { gboolean _tmp15_; _tmp15_ = TRUE; while (TRUE) { if (!_tmp15_) { j++; } _tmp15_ = FALSE; if (!(j < count)) { break; } gdk_draw_rectangle (d, gc, TRUE, 1, ((height - self->priv->margin_bottom) - (j * 6)) - 6, 11, 4); } } } gdk_gc_set_clip_rectangle (gc, (_tmp17_ = (_tmp16_.x = self->priv->margin_left + 1, _tmp16_.y = 1, _tmp16_.width = (width - self->priv->margin_left) - 2, _tmp16_.height = (height - self->priv->margin_bottom) - 2, _tmp16_), &_tmp17_)); gdk_gc_set_rgb_fg_color (gc, &fore_bright_color); bar_w = 11; if (step < bar_w) { bar_w = ((gint) step) - 1; } { gboolean _tmp18_; i = 0; _tmp18_ = TRUE; while (TRUE) { GdkRectangle _tmp19_ = {0}; GdkRectangle _tmp20_; if (!_tmp18_) { i++; } _tmp18_ = FALSE; if (!(i < DDB_EQUALIZER_bands)) { break; } gdk_gc_set_clip_rectangle (gc, (_tmp20_ = (_tmp19_.x = (((gint) ((i + 1) * step)) + self->priv->margin_left) - (bar_w / 2), _tmp19_.y = (gint) (self->priv->values[i] * (height - self->priv->margin_bottom)), _tmp19_.width = 11, _tmp19_.height = height, _tmp19_), &_tmp20_)); count = ((gint) (((height - self->priv->margin_bottom) * (1 - self->priv->values[i])) / 6)) + 1; { gint j; j = 0; { gboolean _tmp21_; _tmp21_ = TRUE; while (TRUE) { if (!_tmp21_) { j++; } _tmp21_ = FALSE; if (!(j < count)) { break; } gdk_draw_rectangle (d, gc, TRUE, (((gint) ((i + 1) * step)) + self->priv->margin_left) - (bar_w / 2), ((height - self->priv->margin_bottom) - (j * 6)) - 6, bar_w, 4); } } } } } gdk_gc_set_clip_rectangle (gc, (_tmp23_ = (_tmp22_.x = 0, _tmp22_.y = 0, _tmp22_.width = width, _tmp22_.height = height, _tmp22_), &_tmp23_)); gdk_gc_set_line_attributes (gc, 1, GDK_LINE_ON_OFF_DASH, GDK_CAP_NOT_LAST, GDK_JOIN_MITER); gdk_draw_line (d, gc, self->priv->margin_left + 1, self->priv->mouse_y, width, self->priv->mouse_y); result = FALSE; _g_free0 (tmp); _pango_font_description_free0 (fd); _g_object_unref0 (ctx); _g_object_unref0 (l); _g_object_unref0 (gc); _g_object_unref0 (d); return result; }