コード例 #1
0
ファイル: gimpscalecombobox.c プロジェクト: Distrotech/gimp
static void
gimp_scale_combo_box_style_set (GtkWidget *widget,
                                GtkStyle  *prev_style)
{
  GtkWidget  *entry;
  GtkRcStyle *rc_style;
  gint        font_size;
  gdouble     scale;

  GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);

  gtk_widget_style_get (widget, "label-scale", &scale, NULL);

  entry = gtk_bin_get_child (GTK_BIN (widget));

  rc_style = gtk_widget_get_modifier_style (GTK_WIDGET (entry));

  if (! rc_style->font_desc)
    {
      PangoContext         *context;
      PangoFontDescription *font_desc;

      context = gtk_widget_get_pango_context (widget);
      font_desc = pango_context_get_font_description (context);

      rc_style->font_desc = pango_font_description_copy (font_desc);
    }

  font_size = pango_font_description_get_size (rc_style->font_desc);
  pango_font_description_set_size (rc_style->font_desc, scale * font_size);

  gtk_widget_modify_style (GTK_WIDGET (entry), rc_style);
}
コード例 #2
0
ファイル: lib_cairox.c プロジェクト: nicksexton/gui-tools
void pangox_layout_set_font_face(PangoLayout *layout, OutputFontFace face)
{
    if (layout != NULL) {
        const PangoFontDescription *old_font;
        PangoFontDescription *new_font;

        if ((old_font = pango_layout_get_font_description(layout)) == NULL) {
            PangoContext *context = pango_layout_get_context(layout);
            new_font = pango_font_description_copy(pango_context_get_font_description(context));
        }
        else {
            new_font = pango_font_description_copy(old_font);
        }
        switch (face) {
            case PS_FONT_SANS: {
                pango_font_description_set_family(new_font, "Sans");
                break;
            }
            case PS_FONT_SERIF: {
                pango_font_description_set_family(new_font, "Serif");
                break;
            }
            default: {
                pango_font_description_set_family(new_font, "Fixed");
                break;
            }
	}
        pango_layout_set_font_description(layout, new_font);
        pango_font_description_free(new_font);
    }
}
コード例 #3
0
ファイル: HippoCanvas.cpp プロジェクト: nihed/magnetism
static PangoFontDescription *
hippo_canvas_context_win_get_font(HippoCanvasContext *context)
{
    HippoCanvasContextWin *canvas_win = HIPPO_CANVAS_CONTEXT_WIN(context);
    
    return pango_context_get_font_description(canvas_win->pango);
}
コード例 #4
0
ファイル: gwygraphlabel.c プロジェクト: svn2github/gwyddion
/**
 * gwy_graph_label_new:
 *
 * Creates a new graph label.
 *
 * Returns: A new graph label widget as a #GtkWidget.
 **/
GtkWidget*
gwy_graph_label_new()
{
    GwyGraphLabel *label;
    PangoFontDescription *description;
    PangoContext *context;
    gint size;

    gwy_debug("");

    label = g_object_new(GWY_TYPE_GRAPH_LABEL, NULL);

    context = gtk_widget_get_pango_context(GTK_WIDGET(label));
    description = pango_context_get_font_description(context);

    /* Make major font a bit smaller */
    label->font_desc = pango_font_description_copy(description);
    size = pango_font_description_get_size(label->font_desc);
    size = MAX(1, size*10/11);
    pango_font_description_set_size(label->font_desc, size);

    gtk_widget_set_events(GTK_WIDGET(label), 0);

    return GTK_WIDGET(label);
}
コード例 #5
0
static void
apply_values (void)
{
	gchar *utf;
	grg_ctx_set_crypt_algo (gctx, tmp_pref_crypto);
	grg_ctx_set_hash_algo (gctx, tmp_pref_hash);
	grg_ctx_set_comp_algo (gctx, tmp_pref_comp);
	grg_ctx_set_comp_ratio (gctx, tmp_pref_ratio);
	g_free (grg_pref_file);
	grg_pref_file =
		g_strdup (gtk_entry_get_text (GTK_ENTRY (file_entry)));
	utf = g_filename_from_utf8 (grg_pref_file, -1, NULL, NULL, NULL);
	if (!g_file_test (utf, G_FILE_TEST_IS_REGULAR))
	{
		g_free (grg_pref_file);
		grg_pref_file = NULL;
		gtk_entry_set_text (GTK_ENTRY (file_entry), "");
	}
	g_free (utf);

	set_pref_font_string (pango_font_description_to_string
			      (pango_context_get_font_description
			       (gtk_widget_get_pango_context
				(gtk_bin_get_child (GTK_BIN (but_font))))));
	set_editor_font (grg_prefs_editor_font);

	update_saveable (GRG_SAVE_ACTIVE);
	grg_save_prefs ();
}
コード例 #6
0
ファイル: settings.c プロジェクト: nightmorph/LogJam
static void
run_fontsel_settings_dlg(SettingsWidget *sw) {
    GtkWidget *dlg;
    const gchar *newfont;
    gchar *oldfont;

    dlg = gtk_font_selection_dialog_new(_("Select font"));
    gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(dlg),
                                            gtk_label_get_text(GTK_LABEL(sw->widget)));

    if (gtk_dialog_run(GTK_DIALOG(dlg)) == GTK_RESPONSE_OK) {
        gtk_label_set_text(GTK_LABEL(sw->widget),
                           gtk_font_selection_dialog_get_font_name(
                               GTK_FONT_SELECTION_DIALOG(dlg)));
    }


    newfont = gtk_label_get_text(GTK_LABEL(sw->widget));
    oldfont = pango_font_description_to_string(
                  pango_context_get_font_description(
                      gtk_widget_get_pango_context(GTK_WIDGET(sw->data))));

    if (newfont && g_ascii_strcasecmp(oldfont, newfont) != 0) {
        string_replace(sw->conf, g_strdup(newfont));
        jam_widget_set_font(sw->widget, newfont);
        jam_widget_set_font(sw->data, newfont);
    }
    g_free(oldfont);

    gtk_widget_destroy(dlg);
}
コード例 #7
0
ファイル: t_display.c プロジェクト: BackupTheBerlios/gtemp1w
//		Narysowanie zawartosci calego okna (z legenda, opisami osi i charakterystykami)
void t_display_przerysuj(T_Display *w)
{
		int szer, wys ;
		double units_per_pixel_x ;
		//double units_per_pixel_y ;
		
		szer = w->canvas->allocation.width ;
		wys = w->canvas->allocation.height ;
		
		units_per_pixel_x = (double)w->time_range / ((double)szer) ;
		
		//PangoLayout *etykieta = gtk_widget_create_pango_layout (w->canvas, "");									
		PangoContext *pc = gtk_widget_get_pango_context (w->canvas) ;
		PangoFontDescription* pfd = pango_context_get_font_description (pc) ;
		//printf ("czcionka %d\n", pango_font_description_get_size(pfd)) ;
		pango_font_description_set_size (pfd, w->font_size * PANGO_SCALE) ;
		//pango_layout_context_changed(etykieta) ;
		
		
		t_display_draw_legend(w) ;
		t_display_calculate_borders(w) ;
		t_display_rysuj_siatke_czas(w) ;
		t_display_rysuj_siatke_temp(w) ;
		t_display_draw_plots(w) ;
		
} ;
コード例 #8
0
static void
gimp_number_pair_entry_modify_font (GimpNumberPairEntry *entry,
                                    gboolean             italic)
{
  GimpNumberPairEntryPrivate *priv = GIMP_NUMBER_PAIR_ENTRY_GET_PRIVATE (entry);
  GtkRcStyle                 *rc_style;

  if (priv->font_italic == italic)
    return;

  rc_style = gtk_widget_get_modifier_style (GTK_WIDGET (entry));

  if (! rc_style->font_desc)
    {
      PangoContext         *context;
      PangoFontDescription *font_desc;

      context = gtk_widget_get_pango_context (GTK_WIDGET (entry));
      font_desc = pango_context_get_font_description (context);

      rc_style->font_desc = pango_font_description_copy (font_desc);
    }

  pango_font_description_set_style (rc_style->font_desc,
                                    italic ?
                                    PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);

  gtk_widget_modify_style (GTK_WIDGET (entry), rc_style);

  priv->font_italic = italic;
}
コード例 #9
0
ファイル: dcmemory.cpp プロジェクト: Bluehorn/wxPython
void wxMemoryDC::Init()
{
    m_ok = false;

    m_cmap = gtk_widget_get_default_colormap();

    m_context = gdk_pango_context_get();
    // Note: The Sun customised version of Pango shipping with Solaris 10
    // crashes if the language is left NULL (see bug 1374114)
    pango_context_set_language( m_context, gtk_get_default_language() );
    m_layout = pango_layout_new( m_context );
    m_fontdesc = pango_font_description_copy( pango_context_get_font_description( m_context ) );
}
コード例 #10
0
static void
etfci_font_load (ETableFieldChooserItem *etfci)
{
	PangoContext *pango_context;
	GtkWidget *widget;

	if (etfci->font_desc)
		pango_font_description_free (etfci->font_desc);

	widget = GTK_WIDGET (GNOME_CANVAS_ITEM (etfci)->canvas);
	pango_context = gtk_widget_get_pango_context (widget);
	etfci->font_desc = pango_font_description_copy (pango_context_get_font_description (pango_context));
}
コード例 #11
0
int QPushButton::baselinePosition(int height) const
{
    return (int) ((15.0f/20.0f)*(float)height);
#if 0
    GtkWidget *w = getGtkWidget();
    PangoContext *pc= gtk_widget_get_pango_context(w);
    PangoFontDescription *fd = pango_context_get_font_description(pc);
    PangoFontMetrics *fm = pango_context_get_metrics(pc,fd,NULL); //lang=NULL

    float ascender = pango_font_metrics_get_ascent(fm) / PANGO_SCALE;
    float descender =pango_font_metrics_get_descent(fm) / PANGO_SCALE;

    return (int)ceil(- TOP_MARGIN
                     + ((height() + TOP_MARGIN + BOTTOM_MARGIN) - (ascender - descender)) / 2.0
                     + ascender - VERTICAL_FUDGE_FACTOR);
#endif
}
コード例 #12
0
ファイル: lib_cairox.c プロジェクト: nicksexton/gui-tools
void pangox_layout_set_font_size(PangoLayout *layout, int size)
{
    if (layout != NULL) {
        const PangoFontDescription *old_font;
        PangoFontDescription *new_font;

        if ((old_font = pango_layout_get_font_description(layout)) == NULL) {
            PangoContext *context = pango_layout_get_context(layout);
            new_font = pango_font_description_copy(pango_context_get_font_description(context));
        }
        else {
            new_font = pango_font_description_copy(old_font);
        }
        pango_font_description_set_size(new_font, size * PANGO_SCALE * 0.71);
        pango_layout_set_font_description(layout, new_font);
        pango_font_description_free(new_font);
    }
}
コード例 #13
0
ファイル: lib_cairox.c プロジェクト: nicksexton/gui-tools
void pangox_layout_set_font_style(PangoLayout *layout, PangoStyle style)
{
    if (layout != NULL) {
        const PangoFontDescription *old_font;
        PangoFontDescription *new_font;

        if ((old_font = pango_layout_get_font_description(layout)) == NULL) {
            PangoContext *context = pango_layout_get_context(layout);
            new_font = pango_font_description_copy(pango_context_get_font_description(context));
        }
        else {
            new_font = pango_font_description_copy(old_font);
        }
        pango_font_description_set_style(new_font, style);
        pango_layout_set_font_description(layout, new_font);
        pango_font_description_free(new_font);
    }
}
コード例 #14
0
ファイル: lib_cairox.c プロジェクト: nicksexton/gui-tools
int pangox_layout_get_font_height(PangoLayout *layout)
{
    if (layout != NULL) {
        PangoFontMetrics *metric;
        PangoContext *context;
        int h;

        context = pango_layout_get_context(layout);
        metric = pango_context_get_metrics(context, pango_context_get_font_description(context), NULL);
        h = pango_font_metrics_get_ascent(metric) + pango_font_metrics_get_descent(metric);
        pango_font_metrics_unref(metric);

        return(h / PANGO_SCALE);
    }
    else {
        return(0);
    }
}
コード例 #15
0
ファイル: hime-common.c プロジェクト: Explorer09/hime
void set_label_font_size(GtkWidget *label, int size)
{
  if (! GTK_IS_WIDGET(label))
    return;

  PangoContext *pango_context = gtk_widget_get_pango_context (label);
  PangoFontDescription* font=pango_context_get_font_description (pango_context);
#if 0
  pango_font_description_set_family(font, hime_font_name);
  pango_font_description_set_size(font, PANGO_SCALE * size);
#else
  char tt[256];
  sprintf(tt, "%s %d", hime_font_name, size);
  PangoFontDescription* nfont = pango_font_description_from_string(tt);
  pango_font_description_merge(font, nfont, TRUE);
  pango_font_description_free(nfont);
#endif
  gtk_widget_override_font(label, font);
}
コード例 #16
0
ファイル: chewing.c プロジェクト: CarterTsai/hime
static gboolean
gtk_pango_font_pixel_size_get (int *pnFontWidth, int *pnFontHeight)
{
    PangoLayout *pPangoLayout;
    PangoContext *pPangoContext;
    PangoFontDescription *pPangoFontDesc;

    pPangoLayout = gtk_widget_create_pango_layout (g_pWinChewing, "中");
    //pPangoLayout = gtk_widget_create_pango_layout (
    //                   g_pWinChewing,
    //                   (char *)gtk_label_get_text (GTK_LABEL (g_pSeg[g_nCurrentCursorPos].label)));
    pPangoContext = gtk_widget_get_pango_context (g_pWinChewing);
    pPangoFontDesc = pango_context_get_font_description (pPangoContext);

    pango_layout_set_font_description (pPangoLayout, pPangoFontDesc);
    pango_layout_get_pixel_size (pPangoLayout, pnFontWidth, pnFontHeight);

    g_object_unref (pPangoLayout);
    return TRUE;
}
コード例 #17
0
ファイル: tray.c プロジェクト: Explorer09/hime
gboolean create_tray(gpointer data)
{
  if (tray_icon)
    return FALSE;

  destroy_other_tray();

  tray_icon = gtk_status_icon_new();

  g_signal_connect (G_OBJECT (tray_icon), "button-press-event",
                    G_CALLBACK (tray_button_press_event_cb), NULL);

  g_signal_connect (G_OBJECT (tray_icon), "size-changed",
                    G_CALLBACK (tray_size_changed_cb), NULL);

  g_signal_connect (G_OBJECT (tray_icon), "notify::embedded",
                  G_CALLBACK (tray_embedded_cb), NULL);

#if GTK_CHECK_VERSION(2,12,0)
  gtk_status_icon_set_tooltip_text (tray_icon, _("左:中英切換 中:小鍵盤 右:選項"));
#else
  GtkTooltips *tips = gtk_tooltips_new ();
  gtk_status_icon_set_tooltip (GTK_TOOLTIPS (tips), tray_icon, _("左:中英切換 中:小鍵盤 右:選項"), NULL);
#endif

// Initiate Pango for drawing texts from default setting
  GtkWidget *wi = gtk_label_new (NULL); // for reference
  PangoContext *context = gtk_widget_get_pango_context(wi);
  PangoFontDescription* desc = pango_font_description_copy(pango_context_get_font_description(context)); // Copy one from wi for pango
  pango_font_description_set_size(desc, 9 * PANGO_SCALE);
  pango = gtk_widget_create_pango_layout(wi, NULL);
  pango_layout_set_font_description(pango, desc);
 
  gdk_color_parse("red", &red_color_fg);
  gdk_color_parse("blue", &blue_color_fg);

  gtk_widget_destroy(wi);

  load_tray_icon();
  return FALSE;
}
コード例 #18
0
ファイル: tray.c プロジェクト: b4283/hime
gboolean create_tray(gpointer data)
{
  if (da)
    return FALSE;

  destroy_other_tray();

  egg_tray_icon = egg_tray_icon_new ("hime");

  if (!egg_tray_icon)
    return FALSE;

  GtkWidget *event_box = gtk_event_box_new ();
// Do not use this, otherwise tray menu fails
//  gtk_event_box_set_visible_window (event_box, FALSE);
  gtk_container_add (GTK_CONTAINER (egg_tray_icon), event_box);
#if GTK_CHECK_VERSION(2,12,0)
  gtk_widget_set_tooltip_text (event_box, _("左:中英切換 中:小鍵盤 右:選項"));
#else
  GtkTooltips *tips = gtk_tooltips_new ();
  gtk_tooltips_set_tip (GTK_TOOLTIPS (tips), event_box, _("左:中英切換 中:小鍵盤 右:選項"), NULL);
#endif

  g_signal_connect (G_OBJECT (event_box), "button-press-event",
                    G_CALLBACK (tray_button_press_event_cb), NULL);

  GError *err = NULL;
  if (pixbuf)
    g_object_unref(pixbuf);

  char icon_fname[128];
  get_icon_path(HIME_TRAY_PNG, icon_fname);
  pixbuf = gdk_pixbuf_new_from_file(icon_fname, &err);
  int pwidth = gdk_pixbuf_get_width (pixbuf);
  int pheight = gdk_pixbuf_get_height (pixbuf);

  da =  gtk_drawing_area_new();
  g_signal_connect (G_OBJECT (event_box), "destroy",
                    G_CALLBACK (gtk_widget_destroyed), &da);
#if !GTK_CHECK_VERSION(2,91,0)
  g_signal_connect(G_OBJECT(da), "expose-event", G_CALLBACK(cb_expose), NULL);
#else
  g_signal_connect(G_OBJECT(da), "draw", G_CALLBACK(cb_expose), NULL);
#endif

  gtk_container_add (GTK_CONTAINER (event_box), da);
  gtk_widget_set_size_request(GTK_WIDGET(egg_tray_icon), pwidth, pheight);

  gtk_widget_show_all (GTK_WIDGET (egg_tray_icon));
  tray_da_win = gtk_widget_get_window(da);
  // tray window is not ready ??
  if (!tray_da_win || !GTK_WIDGET_DRAWABLE(da)) {
    gtk_widget_destroy(GTK_WIDGET(egg_tray_icon));
    da = NULL;
    return FALSE;
  }

  PangoContext *context=gtk_widget_get_pango_context(da);
  PangoFontDescription* desc=pango_context_get_font_description(context);

//  dbg("zz %s %d\n",  pango_font_description_to_string(desc), PANGO_SCALE);

  pango = gtk_widget_create_pango_layout(da, NULL);
  pango_layout_set_font_description(pango, desc);
#if 1
  // strange bug, why do we need this ?
  desc = (PangoFontDescription *)pango_layout_get_font_description(pango);
#endif
  pango_font_description_set_size(desc, 9 * PANGO_SCALE);

#if 0
  dbg("aa %s\n",  pango_font_description_to_string(desc));
  dbg("context %x %x\n", pango_layout_get_context(pango), context);
  dbg("font %x %x\n",pango_layout_get_font_description(pango), desc);
#endif
#if !GTK_CHECK_VERSION(2,90,6)
  gc = gdk_gc_new (tray_da_win);
#endif
  return FALSE;
}
コード例 #19
0
ファイル: settings.c プロジェクト: nightmorph/LogJam
static GtkWidget*
uisettings(JamWin *jw) {
    SettingsWidget *sw;
    GtkWidget *vbox, *hbox, *button;
    char *fontname = NULL;
    GtkWidget *post, *entry, *misc;

    vbox = gtk_vbox_new(FALSE, 18);
    gtk_container_set_border_width(GTK_CONTAINER(vbox), 10);

    post = groupedbox_new_with_text(_("Posting"));
    gtk_box_pack_start(GTK_BOX(vbox), post, FALSE, FALSE, 0);

    groupedbox_pack(GROUPEDBOX(post),
                    sw_make("ui_revertusejournal"), FALSE);

    sw = sw_lookup("ui_defaultsecurity");
    sw->widget = secmgr_new(FALSE);
    secmgr_security_set(SECMGR(sw->widget), (LJSecurity*)sw->conf);
    g_signal_connect(G_OBJECT(sw->widget), "changed",
                     G_CALLBACK(sec_changed_cb), sw);
    groupedbox_pack(GROUPEDBOX(post), sw_make("ui_defaultsecurity"), FALSE);

#ifdef USE_DOCK
    groupedbox_pack(GROUPEDBOX(post), sw_make("ui_close_when_send"), FALSE);
#endif /* USE_DOCK */

    entry = groupedbox_new_with_text(_("Entries"));
    gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0);

    groupedbox_pack(GROUPEDBOX(entry), sw_make("ui_autosave"), FALSE);

    groupedbox_pack(GROUPEDBOX(entry), sw_make("ui_keepsaveddrafts"), FALSE);

#ifdef HAVE_GTKSPELL
    {
        GtkWidget *toggle = sw_make("ui_spellcheck");
        GtkWidget *label, *box;

        hbox = sw_make("ui_spell_language");
        label = gtk_label_new("        ");
        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
        gtk_box_reorder_child(GTK_BOX(hbox), label, 0);

        sw = sw_lookup("ui_spell_language");
        gtk_entry_set_width_chars(GTK_ENTRY(sw->widget), 5);

        box = gtk_vbox_new(FALSE, 3);
        gtk_box_pack_start(GTK_BOX(box), toggle, FALSE, FALSE, 0);
        gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);

        groupedbox_pack(GROUPEDBOX(entry), box, FALSE);
        toggle_tie_enable(toggle, hbox);
    }
#endif

    groupedbox_pack(GROUPEDBOX(entry), sw_make("ui_showloginhistory"), TRUE);
    groupedbox_pack(GROUPEDBOX(entry),
                    sw_make("ui_smartquotes"), FALSE);

    sw = sw_lookup("ui_font");
    if (conf.uifont == NULL) {
        fontname = pango_font_description_to_string(
                       pango_context_get_font_description(
                           gtk_widget_get_pango_context(jw->view)));
        sw->widget = gtk_label_new(fontname ? fontname : _("[gtk default]"));
        if (fontname)
            jam_widget_set_font(sw->widget, fontname);
        g_free(fontname);
    } else {
        sw->widget = gtk_label_new(conf.uifont);
        jam_widget_set_font(sw->widget, conf.uifont);
    }
    button = gtk_button_new_from_stock(GTK_STOCK_SELECT_FONT);
    sw->data = jw->view;

    hbox = labelled_box_new_expand(_(sw->caption), button, FALSE);
    gtk_box_pack_start(GTK_BOX(hbox), sw->widget, TRUE, TRUE, 0);
    gtk_box_reorder_child(GTK_BOX(hbox), sw->widget, 1);

    groupedbox_pack(GROUPEDBOX(entry), hbox, FALSE);
    g_signal_connect_swapped(G_OBJECT(button), "clicked",
                             G_CALLBACK(run_fontsel_settings_dlg), sw);

    misc = groupedbox_new_with_text(_("Behavior"));
    gtk_box_pack_start(GTK_BOX(vbox), misc, FALSE, FALSE, 0);

    groupedbox_pack(GROUPEDBOX(misc),
                    sw_make("ui_allowmultipleinstances"), FALSE);

#ifdef USE_DOCK
    button = sw_make("ui_docklet");
    g_signal_connect(G_OBJECT(button), "toggled",
                     G_CALLBACK(docklet_change_cb), jw);
    groupedbox_pack(GROUPEDBOX(misc), button, FALSE);
    groupedbox_pack(GROUPEDBOX(misc), sw_make("ui_start_in_dock"), FALSE);
#endif /* USE_DOCK */

    return vbox;
}
コード例 #20
0
ファイル: font-pangoft2.c プロジェクト: inniyah/gtkglext3
static gboolean
draw (GtkWidget *widget,
      cairo_t   *cr,
      gpointer   data)
{
  GtkAllocation allocation;
  GdkGLContext *glcontext = gtk_widget_get_gl_context (widget);
  GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (widget);

  PangoContext *widget_context;
  PangoFontDescription *font_desc;
  PangoLayout *layout;
  PangoRectangle logical_rect;
  GLfloat text_w, text_h;
  GLfloat tangent_h;

  gtk_widget_get_allocation (widget, &allocation);

  /* Font */
  widget_context = gtk_widget_get_pango_context (widget);
  font_desc = pango_context_get_font_description (widget_context);
  pango_font_description_set_size (font_desc, 24 * PANGO_SCALE);
  pango_context_set_font_description (ft2_context, font_desc);

  /* Text layout */
  layout = pango_layout_new (ft2_context);
  pango_layout_set_width (layout, PANGO_SCALE * allocation.width);
  pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
  pango_layout_set_text (layout, text, -1);

  /*** OpenGL BEGIN ***/
  if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext))
    return FALSE;

  glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glCallList (1);

  /* Text color */
  glColor3f (1.0, 0.9, 0.0);

  /* Text position */
  pango_layout_get_extents (layout, NULL, &logical_rect);
  text_w = PANGO_PIXELS (logical_rect.width);
  text_h = PANGO_PIXELS (logical_rect.height);
  /*
   * tangent = Z_NEAR * tan (FOVY_2 * G_PI / 180.0)
   * w = allocation.width
   * h = allocation.height
   *
   * x = -1.0 * (text_w/w) * tangent * (w/h) = -text_w * tangent / h
   * y = -1.0 * (text_h/h) * tangent         = -text_h * tangent / h
   * z = Z_NEAR
   */
  tangent_h = Z_NEAR * tan (FOVY_2 * G_PI / 180.0);
  tangent_h /= allocation.height;
  glRasterPos3f (-text_w * tangent_h,
                 -text_h * tangent_h,
                 Z_NEAR);

  /* Render text */
  gl_pango_ft2_render_layout (layout);

  if (gdk_gl_drawable_is_double_buffered (gldrawable))
    gdk_gl_drawable_swap_buffers (gldrawable);
  else
    glFlush ();

  gdk_gl_drawable_gl_end (gldrawable);
  /*** OpenGL END ***/

  g_object_unref (G_OBJECT (layout));

  return TRUE;
}
コード例 #21
0
ファイル: histodrawing.c プロジェクト: adannis/lttv
/* Redraw the vertical ruler */
static gboolean
histo_expose_vertical_ruler( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
{
  histoDrawing_t *drawing = (histoDrawing_t*)user_data;
  HistoControlFlowData *histo_cfv = drawing->histo_control_flow_data;
  gchar text[255];
  
  PangoContext *context;
  PangoLayout *layout;
  PangoFontDescription *FontDesc;
  PangoRectangle ink_rect;
  gint global_height=0;
  GdkColor foreground = { 0, 0, 0, 0 };
  GdkColor background = { 0, 0xffff, 0xffff, 0xffff };
  GdkColor red ={ 0, 0xFFFF, 0x1E00, 0x1000 };
  //GdkColor magneta ={ 0, 0x8900, 0x0000, 0x8400 };
  g_debug("vertical ruler expose event");
 
  gdk_draw_rectangle (drawing->vertical_ruler->window,
          drawing->vertical_ruler->style->white_gc,
          TRUE,
          event->area.x, event->area.y,
          event->area.width,
          event->area.height);

  gdk_draw_line (drawing->vertical_ruler->window,
                  drawing->ruler_gc_butt,
                  padding_width-1/*event->area.width-1*/,event->area.y,
                  padding_width-1/*event->area.width-1*/,event->area.y + event->area.height);

  snprintf(text, 255, "%.1f", (float)histo_cfv->max_height);

  layout = gtk_widget_create_pango_layout(drawing->drawing_area, NULL);

  context = pango_layout_get_context(layout);
  FontDesc = pango_context_get_font_description(context);

  pango_font_description_set_size(FontDesc, 6*PANGO_SCALE);
  pango_layout_context_changed(layout);

  pango_layout_set_text(layout, text, -1);
  pango_layout_get_pixel_extents(layout, &ink_rect, NULL);
  global_height += ink_rect.height;

  gdk_draw_layout_with_colors(drawing->vertical_ruler->window,
      drawing->ruler_gc_butt,
      1,
      1,
      layout, &foreground, &background);

  gdk_draw_line (drawing->vertical_ruler->window,
                   drawing->ruler_gc_round,
                   drawing->vertical_ruler-> allocation.width-1, 1,
                   drawing->vertical_ruler-> allocation.width-7, 1);


  snprintf(text, 255, "%d", 0);

  pango_layout_set_text(layout, text, -1);
  pango_layout_get_pixel_extents(layout, &ink_rect, NULL);
  global_height += ink_rect.height;

  if(global_height <= drawing->vertical_ruler->allocation.height)
  {
    gdk_draw_layout_with_colors(drawing->vertical_ruler->window,
      drawing->ruler_gc_butt,
      1,
      drawing->vertical_ruler->allocation.height - ink_rect.height-2,
      layout, &foreground, &background);

    gdk_draw_line (drawing->vertical_ruler->window,
                    drawing->ruler_gc_butt,
                    drawing->vertical_ruler-> allocation.width-1,
		    drawing->vertical_ruler->allocation.height-1,
                    drawing->vertical_ruler-> allocation.width-7,
  		    drawing->vertical_ruler->allocation.height-1);
  }


  snprintf(text, 255, "%.1f",(float) histo_cfv->max_height/2.0);

  pango_layout_set_text(layout, text, -1);
  pango_layout_get_pixel_extents(layout, &ink_rect, NULL);
  global_height += ink_rect.height;

  if(global_height <= drawing->vertical_ruler->allocation.height)
  {
    gdk_draw_layout_with_colors(drawing->vertical_ruler->window,
      drawing->ruler_gc_butt,
      1,
      (drawing->vertical_ruler->allocation.height - ink_rect.height)/2,
      layout, &foreground, &background);

    gdk_draw_line (drawing->vertical_ruler->window,
                   drawing->ruler_gc_butt,
                   drawing->vertical_ruler-> allocation.width-1,
		   drawing->vertical_ruler-> allocation.height/2,
                   drawing->vertical_ruler-> allocation.width-7,
		   drawing->vertical_ruler->allocation.height/2);
  }

  //show number of events at current time:
  LttTime current_time = 
      lttvwindow_get_current_time(histo_cfv->tab);
  TimeWindow time_window =
            lttvwindow_get_time_window(histo_cfv->tab);
  LttTime time_begin = time_window.start_time;
  LttTime time_width = time_window.time_width;
  LttTime time_end = ltt_time_add(time_begin, time_width);
  if((ltt_time_compare(current_time, time_begin) >= 0)&&
	(ltt_time_compare(current_time, time_end) <= 0))
  {
     guint *events_at_currenttime;
     guint max_height=histo_cfv ->max_height;
     guint x;
     histo_convert_time_to_pixels(
                    time_window,
                    current_time,
                    drawing->width,
                    &x);
  //   if(x_test<histo_cfv->number_of_process->len)

     {
     	events_at_currenttime = 
		&g_array_index(histo_cfv->number_of_process,guint,x);


	    if((*events_at_currenttime) > max_height)
	    {	
		snprintf(text, 255, "OverFlow!");
	    	pango_layout_set_text(layout, text, -1);
  		pango_layout_get_pixel_extents(layout, &ink_rect, NULL);
  		global_height += ink_rect.height;
		gdk_draw_layout_with_colors(drawing->vertical_ruler->window,
      				drawing->ruler_gc_butt,
      				1,
      				(drawing->vertical_ruler->allocation.height - ink_rect.height)/5, 
      				layout, &red, &background);
	    }else
  	//    if((*events_at_currenttime) <= max_height)
	    {
  		snprintf(text, 255, "%.1f",
			(float) *events_at_currenttime);

  		pango_layout_set_text(layout, text, -1);
  		pango_layout_get_pixel_extents(layout, &ink_rect, NULL);
  		global_height += ink_rect.height;

		if ((*events_at_currenttime) == 0)
		{
  			gdk_draw_layout_with_colors(drawing->vertical_ruler->window,
      				drawing->ruler_gc_butt,
      				1,
      				(drawing->vertical_ruler->allocation.height - ink_rect.height)-2, 
      			layout, &red, &background);
		}
		else if ((*events_at_currenttime) == max_height)
		{
  			gdk_draw_layout_with_colors(drawing->vertical_ruler->window,
      				drawing->ruler_gc_butt,
      				1,
      				1, 
      			layout, &red, &background);
		}
		/*else if ((*events_at_currenttime) == max_height/2) 
		{
  			gdk_draw_layout_with_colors(drawing->vertical_ruler->window,
      				drawing->ruler_gc_butt,
      				1,
      				(drawing->vertical_ruler->allocation.height - ink_rect.height)/2, 
      			layout, &red, &background);
		}*/
		else if ((*events_at_currenttime) > max_height/2) 
        	{
  			gdk_draw_layout_with_colors(drawing->vertical_ruler->window,
      				drawing->ruler_gc_butt,
      				1,
      				(drawing->vertical_ruler->allocation.height - ink_rect.height)/4, 
      			layout, &red, &background);
		}
		else{
			gdk_draw_layout_with_colors(drawing->vertical_ruler->window,
      				drawing->ruler_gc_butt,
      				1,
      				((drawing->vertical_ruler->allocation.height 
					- ink_rect.height)*3)/4, 	
      				layout, &red, &background);
		}
	    }
	    
     	}
   }

  g_object_unref(layout);
   
  return FALSE;
}
コード例 #22
0
ファイル: histodrawing.c プロジェクト: adannis/lttv
/* Redraw the ruler */
static gboolean
histo_expose_ruler( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
{
  histoDrawing_t *drawing = (histoDrawing_t*)user_data;
  TimeWindow time_window = lttvwindow_get_time_window(drawing->histo_control_flow_data->tab);
  gchar text[255];
  
  PangoContext *context;
  PangoLayout *layout;
  PangoFontDescription *FontDesc;
  PangoRectangle ink_rect;
  gint global_width=0;
  GdkColor foreground = { 0, 0, 0, 0 };
  GdkColor background = { 0, 0xffff, 0xffff, 0xffff };

  LttTime window_end = time_window.end_time;
  LttTime half_width =
    ltt_time_div(time_window.time_width,2.0);
  LttTime window_middle =
    ltt_time_add(half_width,
                 time_window.start_time);
  g_debug("ruler expose event");
 
  gdk_draw_rectangle (drawing->ruler->window,
          drawing->ruler->style->white_gc,
          TRUE,
          event->area.x, event->area.y,
          event->area.width,
          event->area.height);

  gdk_draw_line (drawing->ruler->window,
                  drawing->ruler_gc_butt,
                  event->area.x, 1,
                  event->area.x + event->area.width, 1);


  snprintf(text, 255, "%lus\n%luns",
    time_window.start_time.tv_sec,
    time_window.start_time.tv_nsec);

  layout = gtk_widget_create_pango_layout(drawing->drawing_area, NULL);

  context = pango_layout_get_context(layout);
  FontDesc = pango_context_get_font_description(context);

  pango_font_description_set_size(FontDesc, 6*PANGO_SCALE);
  pango_layout_context_changed(layout);

  pango_layout_set_text(layout, text, -1);
  pango_layout_get_pixel_extents(layout, &ink_rect, NULL);
  global_width += ink_rect.width;

  gdk_draw_layout_with_colors(drawing->ruler->window,
      drawing->ruler_gc_butt,
      0,
      6,
      layout, &foreground, &background);

  gdk_draw_line (drawing->ruler->window,
                   drawing->ruler_gc_round,
                   1, 1,
                   1, 7);


  snprintf(text, 255, "%lus\n%luns", window_end.tv_sec,
                                     window_end.tv_nsec);

  pango_layout_set_text(layout, text, -1);
  pango_layout_get_pixel_extents(layout, &ink_rect, NULL);
  global_width += ink_rect.width;

  if(global_width <= drawing->ruler->allocation.width)
  {
    gdk_draw_layout_with_colors(drawing->ruler->window,
      drawing->ruler_gc_butt,
      drawing->ruler->allocation.width - ink_rect.width,
      6,
      layout, &foreground, &background);

    gdk_draw_line (drawing->ruler->window,
                   drawing->ruler_gc_butt,
                   drawing->ruler->allocation.width-1, 1,
                   drawing->ruler->allocation.width-1, 7);
  }


  snprintf(text, 255, "%lus\n%luns", window_middle.tv_sec,
                                     window_middle.tv_nsec);

  pango_layout_set_text(layout, text, -1);
  pango_layout_get_pixel_extents(layout, &ink_rect, NULL);
  global_width += ink_rect.width;

  if(global_width <= drawing->ruler->allocation.width)
  {
    gdk_draw_layout_with_colors(drawing->ruler->window,
      drawing->ruler_gc_butt,
      (drawing->ruler->allocation.width - ink_rect.width)/2,
      6,
      layout, &foreground, &background);

    gdk_draw_line (drawing->ruler->window,
                   drawing->ruler_gc_butt,
                   drawing->ruler->allocation.width/2, 1,
                   drawing->ruler->allocation.width/2, 7);
  }

  g_object_unref(layout);
   
  return FALSE;
}
コード例 #23
0
ファイル: glgdGraph.c プロジェクト: karme/Gauche-gtk2
static GLboolean
glgdGraphNodeDrawLabel(glgdGraph *graph, glgdNode *node)
{
    int                     i;
    GLint                   width;
    GLuint                  texture;
    GLfloat                 s0, s1, t0, t1;
    GLfloat                 a;
    guint32                 alpha, rgb, *t;
    guint8                  *row, *row_end;
    PangoContext            *pangoContext;
    PangoFontDescription    *fontDesc;
    PangoLayout             *layout;
    PangoRectangle          extents;
    FT_Bitmap               bitmap;
    glgdVec2                center, pnt[2];
    glgdStroke              *stroke;
    glgdTexture             *tex;
    
    if (graph && graph->pangoFT2Context)
    {
        stroke = &graph->stroke;
        tex = &graph->textTexture;
        if (tex->width <= 0 || tex->height <= 0)
        {
            glgdTrace(1, "Invalid texture dimension (%d,%d)\n", tex->width,
                tex->height);
                
            return GL_FALSE;
        }

        /* Pango font description */
        width = 10 * _PANGO_SCALE;
        pangoContext = gtk_widget_get_pango_context(graph->gtkWindow);
        fontDesc = pango_context_get_font_description(pangoContext);
        pango_font_description_set_size(fontDesc, PANGO_SCALE * width);
        pango_font_description_set_weight(fontDesc, PANGO_WEIGHT_NORMAL);
        pango_context_set_font_description(graph->pangoFT2Context, fontDesc);
        
        /* Text layout */
        width = (int)graph->dim[0] * _PANGO_SCALE;
        layout = graph->layout;
        pango_layout_set_width(layout, PANGO_SCALE * width);
        pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
        pango_layout_set_text(layout, node->label, -1);
        pango_layout_get_extents(layout, NULL, &extents);
        if (extents.width == 0 || extents.height == 0)
        {
            glgdTrace(1, "Invalid extents (%d,%d)\n", extents.width,
                extents.height);
                
            return GL_FALSE;
        }

        /* Bitmap creation */
        bitmap.rows = PANGO_PIXELS(extents.height);
        bitmap.width = PANGO_PIXELS(extents.width);
        if (bitmap.width > tex->width || bitmap.rows > tex->height)
        {
            return GL_FALSE;
        }

        bitmap.pitch = bitmap.width;
        bitmap.buffer = GLGD_MALLOC(bitmap.rows * bitmap.width);
        bitmap.num_grays = 256;
        bitmap.pixel_mode = ft_pixel_mode_grays;

        memset(bitmap.buffer, 0, bitmap.rows * bitmap.width);
        pango_ft2_render_layout(&bitmap, layout, PANGO_PIXELS(-extents.x), 0);

#if !defined(GL_VERSION_1_2) && G_BYTE_ORDER == G_LITTLE_ENDIAN
        rgb =((guint32)(stroke->col[0] * 255.0))         |
            (((guint32)(stroke->col[1] * 255.0)) << 8)   |
            (((guint32)(stroke->col[2] * 255.0)) << 16);
#else
        rgb =(((guint32)(stroke->col[0] * 255.0)) << 24)    |
            (((guint32)(stroke->col[1] * 255.0)) << 16) |
            (((guint32)(stroke->col[2] * 255.0)) << 8);
#endif

        /* Bitmap transfer to <glgdTexture> */
        a = stroke->col[3];
        alpha = (guint32)(255.0 * a);
        row = bitmap.buffer + bitmap.rows * bitmap.width;
        row_end = bitmap.buffer;
        t = (guint32 *)tex->texels;
        if (graph->flags & GLGDGRAPH_FLAG_PANGOBOLD)
        {
            do
            {
                row -= bitmap.width;
                for (i=0; i<bitmap.width; i++)
                {
#if !defined(GL_VERSION_1_2) && G_BYTE_ORDER == G_LITTLE_ENDIAN
                    if (row[i] > 0)
                        *t++ = rgb | (alpha << 24);
                    else
                        *t++ = rgb;
#else
                    if (row[i] > 0)
                        *t++ = rgb | alpha;
                    else
                        *t++ = rgb;
#endif
                }
            }
            while (row != row_end);
        }
        else
        {
            do
            {
                row -= bitmap.width;
                for (i=0; i<bitmap.width; i++)
                {
#if !defined(GL_VERSION_1_2) && G_BYTE_ORDER == G_LITTLE_ENDIAN
                    *t++ = rgb | ((guint32)(a * row[i]) << 24);
#else
                    *t++ = rgb | (guint32)(a * row[i]);
#endif
                }
            }
            while (row != row_end);
        }

        glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
        glBindTexture(GL_TEXTURE_2D, tex->name);
#if !defined(GL_VERSION_1_2)
        glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, bitmap.width, bitmap.rows,
            GL_RGBA, GL_UNSIGNED_BYTE, tex->texels);
#else
        glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, bitmap.width, bitmap.rows,
            GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, tex->texels);
#endif

        /* <glgdTexture> render */
        s0 = 0.0;
        s1 = (GLdouble)bitmap.width / (GLdouble)tex->width;
        t0 = 0.0;
        t1 = (GLdouble)bitmap.rows / (GLdouble)tex->height;

        center[0] = node->pos[0] + GLGD_HALF(graph->dim[0]);
        center[1] = node->pos[1] + GLGD_HALF(graph->dim[1]);
        pnt[0][0] = center[0] - GLGD_HALF(bitmap.width / _PANGO_SCALE);
        pnt[0][1] = center[1] - GLGD_HALF(bitmap.rows / _PANGO_SCALE);
        pnt[1][0] = center[0] + GLGD_HALF(bitmap.width / _PANGO_SCALE);
        pnt[1][1] = center[1] + GLGD_HALF(bitmap.rows / _PANGO_SCALE);
        GLGD_FREE(bitmap.buffer);

        glColor3d(stroke->col[0], stroke->col[1], stroke->col[2]);
        glEnable(GL_TEXTURE_2D);
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glBindTexture(GL_TEXTURE_2D, tex->name);
        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
        glBegin(GL_QUADS);
            glTexCoord2f(s0, t0);
            glVertex3f(pnt[0][0], pnt[0][1], 0.0);
            
            glTexCoord2f(s0, t1);
            glVertex3f(pnt[0][0], pnt[1][1], 0.0);
            
            glTexCoord2f(s1, t1);
            glVertex3f(pnt[1][0], pnt[1][1], 0.0);
            
            glTexCoord2f(s1, t0);
            glVertex3f(pnt[1][0], pnt[0][1], 0.0);
        glEnd();
        glDisable(GL_BLEND);
        glDisable(GL_TEXTURE_2D);

        return GL_TRUE;
    }
    
    return GL_FALSE;
}
コード例 #24
0
ファイル: html_text_buffer.c プロジェクト: ayttm/ayttm
/*
 * Apply styles to the string based on the tags
 */
gboolean apply_tag(GtkTextView *text_view, tag in_tag, int ignore)
{
	/*
	 * TODO: Create GTK_TAGs for the following tags:
	 * 2) body: All done except for the width=100% portion
	 */

	GtkTextTag *style;
	GtkTextBuffer *buffer = gtk_text_view_get_buffer(text_view);

	/* HEAD */
	if (!g_ascii_strncasecmp(in_tag.name, "head", 4)) {

		GtkTextIter start, end;
		gtk_text_buffer_get_iter_at_mark(buffer, &start,
			&(in_tag.start));
		gtk_text_buffer_get_iter_at_mark(buffer, &end, &(in_tag.end));

		gtk_text_buffer_delete(buffer, &start, &end);

		return TRUE;
	}

	/* HORIZONTAL LINE */
	if (!g_ascii_strncasecmp(in_tag.name, "hr", 4)) {
		GtkTextIter start;
		GtkWidget *line;
		GtkTextChildAnchor *anchor;
		GtkRequisition r;

		gtk_text_buffer_get_iter_at_mark(buffer, &start,
			&(in_tag.start));
		gtk_text_buffer_insert(buffer, &start, "\n", -1);

		/* Reinitialized since the insert invalidates the iter */
		gtk_text_buffer_get_iter_at_mark(buffer, &start,
			&(in_tag.start));
		gtk_text_iter_forward_line(&start);

		line = gtk_hseparator_new();

		anchor = gtk_text_buffer_create_child_anchor(buffer, &start);
		gtk_text_view_add_child_at_anchor(text_view, line, anchor);

		/* FIXME: Need a way to stretch the HR on resize */
		gtk_widget_size_request(GTK_WIDGET(text_view), &r);
		gtk_widget_set_size_request(line, r.width, 2);

		gtk_widget_show(line);

		return TRUE;
	}

	/* BR */
	if (!g_ascii_strncasecmp(in_tag.name, "br", 2)) {

		GtkTextIter start;
		gtk_text_buffer_get_iter_at_mark(buffer, &start,
			&(in_tag.start));
		gtk_text_buffer_insert(buffer, &start, "\n", -1);

		return TRUE;
	}

	/* BODY */
	if (!g_ascii_strncasecmp(in_tag.name, "body", 4)) {
		char *param = NULL;
		char attr_val[255];
		GtkTextIter start, end;

		bzero(attr_val, 255);

		gtk_text_buffer_get_iter_at_mark(buffer, &start,
			&(in_tag.start));
		gtk_text_buffer_get_iter_at_mark(buffer, &end, &(in_tag.end));

		if ((param = ay_strcasestr(in_tag.name, "bgcolor=")) != NULL) {
			param += 8;	/* length of bgcolor= */
			_extract_parameter(param, attr_val, 255);
			style = gtk_text_buffer_create_tag(buffer, in_tag.id,
				"background", attr_val, NULL);

			gtk_text_buffer_apply_tag(buffer, style, &start, &end);
		}

		return TRUE;
	}

	/* BOLD */
	if (!g_ascii_strcasecmp(in_tag.name, "b")) {
		GtkTextIter start, end;

		gtk_text_buffer_get_iter_at_mark(buffer, &start,
			&(in_tag.start));
		gtk_text_buffer_get_iter_at_mark(buffer, &end, &(in_tag.end));

		style = gtk_text_buffer_create_tag(buffer, in_tag.id,
			"weight", PANGO_WEIGHT_BOLD, NULL);
		gtk_text_buffer_apply_tag(buffer, style, &start, &end);
		return TRUE;
	}

	/* UNDERLINE */
	if (!g_ascii_strcasecmp(in_tag.name, "u")) {
		GtkTextIter start, end;

		gtk_text_buffer_get_iter_at_mark(buffer, &start,
			&(in_tag.start));
		gtk_text_buffer_get_iter_at_mark(buffer, &end, &(in_tag.end));

		style = gtk_text_buffer_create_tag(buffer, in_tag.id,
			"underline", PANGO_UNDERLINE_SINGLE, NULL);
		gtk_text_buffer_apply_tag(buffer, style, &start, &end);
		return TRUE;
	}

	/* ITALICS */
	if (!g_ascii_strcasecmp(in_tag.name, "i")) {
		GtkTextIter start, end;

		gtk_text_buffer_get_iter_at_mark(buffer, &start,
			&(in_tag.start));
		gtk_text_buffer_get_iter_at_mark(buffer, &end, &(in_tag.end));

		style = gtk_text_buffer_create_tag(buffer, in_tag.id,
			"style", PANGO_STYLE_ITALIC, NULL);
		gtk_text_buffer_apply_tag(buffer, style, &start, &end);
		return TRUE;
	}

	/* FONT */
	if (!g_ascii_strncasecmp(in_tag.name, "font", 4)) {
		GtkTextIter start, end;
		char *param = NULL;
		char attr_val[255];

		bzero(attr_val, 255);

		gtk_text_buffer_get_iter_at_mark(buffer, &start,
			&(in_tag.start));
		gtk_text_buffer_get_iter_at_mark(buffer, &end, &(in_tag.end));

		style = gtk_text_buffer_create_tag(buffer, in_tag.id, NULL);

		/* Font Face */
		if (!(ignore & HTML_IGNORE_FONT) &&
			(param = ay_strcasestr(in_tag.name, "face=")) != NULL) {
			param += 5;	/* length of face= */
			_extract_parameter(param, attr_val, 255);

			g_object_set(style, "family", attr_val, NULL);
		}

		/* Font color */
		if (!(ignore & HTML_IGNORE_FOREGROUND) &&
			(param = ay_strcasestr(in_tag.name, "color=")) != NULL)
		{
			param += 6;	/* length of color= */
			_extract_parameter(param, attr_val, 255);

			g_object_set(style, "foreground", attr_val, NULL);
		}

		/* Font Size */
		if ((param = ay_strcasestr(in_tag.name, "ptsize=")) != NULL) {
			param += 7;	/*length of ptsize= */
			_extract_parameter(param, attr_val, 255);

			g_object_set(style, "size-points", strtod(attr_val,
					NULL), NULL);
		} else if ((param =
				ay_strcasestr(in_tag.name, "absz=")) != NULL) {
			param += 5;	/*length of absz= */
			_extract_parameter(param, attr_val, 255);

			g_object_set(style, "size-points", strtod(attr_val,
					NULL), NULL);
		} else if ((param =
				ay_strcasestr(in_tag.name, "size=")) != NULL) {
			/* Get the current font size */
			gint cur_size = 0;
			PangoContext *context =
				gtk_widget_get_pango_context(GTK_WIDGET
				(text_view));
			PangoFontDescription *desc =
				pango_context_get_font_description(context);

			param += 5;	/*length of size= */

			cur_size =
				pango_font_description_get_size(desc) /
				PANGO_SCALE;

			_extract_parameter(param, attr_val, 255);

			if (attr_val == NULL) {
				/* Do nothing */
			} else if (*attr_val == '+') {
				int font_size = atoi(attr_val + 1) * 4;
				g_object_set(style, "size-points",
					(double)cur_size + font_size, NULL);
			} else if (*attr_val == '-') {
				int font_size = atoi(attr_val + 1) * 4;
				g_object_set(style, "size-points",
					(double)cur_size - font_size, NULL);
			} else {
				int font_size = atoi(attr_val) * 4;
				g_object_set(style, "size-points",
					(double)font_size, NULL);
			}

		}

		gtk_text_buffer_apply_tag(buffer, style, &start, &end);

		return TRUE;
	}

	/* ANCHOR */
	if (!g_ascii_strncasecmp(in_tag.name, "a ", 2)) {
		GtkTextIter start, end;
		char *param = NULL;
		gchar *attr_val = (gchar *)malloc(1024);

		bzero(attr_val, 1024);

		gtk_text_buffer_get_iter_at_mark(buffer, &start,
			&(in_tag.start));
		gtk_text_buffer_get_iter_at_mark(buffer, &end, &(in_tag.end));

		/* Font Face */
		if ((param = ay_strcasestr(in_tag.name, "href=")) != NULL) {
			param += 5;	/*length of href= */
			_extract_parameter(param, attr_val, 1024);

			style = gtk_text_buffer_create_tag(buffer, in_tag.id,
				"underline", PANGO_UNDERLINE_SINGLE,
				"foreground", "blue", NULL);
			g_object_set_data(G_OBJECT(style), "href", attr_val);

			gtk_text_buffer_apply_tag(buffer, style, &start, &end);
		}
		return TRUE;
	}

	/* SMILEY */
	if (!g_ascii_strncasecmp(in_tag.name, "smiley", 6)) {
		GtkTextIter start;

		char *param = NULL;
		char smiley_name[64];
		char smiley_protocol[64];
		smiley *smile = NULL;
		bzero(smiley_name, 64);
		bzero(smiley_protocol, 64);

		gtk_text_buffer_get_iter_at_mark(buffer, &start,
			&(in_tag.start));

		if ((param = ay_strcasestr(in_tag.name, "name=")) != NULL) {

			param += 5;	/*length of name= */
			_extract_parameter(param, smiley_name, 64);

			if ((param = ay_strcasestr(in_tag.name,
						"protocol=")) != NULL) {
				param += 9;	/*length of protocol= */
				_extract_parameter(param, smiley_protocol, 64);
				smile = get_smiley_by_name_and_service
					(smiley_name, smiley_protocol);
			} else {
				smile = get_smiley_by_name(smiley_name);
			}

			if (smile) {
				insert_xpm_at_iter(text_view, &start,
					smile->pixmap);
			} else if ((param =
					ay_strcasestr(in_tag.name,
						"alt=")) != NULL) {
				param += 4;	/*length of alt= */
				_extract_parameter(param, smiley_name, 64);
				gtk_text_buffer_insert(buffer, &start,
					smiley_name, -1);
			} else {
				insert_xpm_at_iter(text_view, &start,
					no_such_smiley_xpm);
			}
		}

		return TRUE;
	}

	/* IMAGE */
	if (!g_ascii_strncasecmp(in_tag.name, "img", 3)) {
		GtkTextIter start;
		char *param = NULL;
		char img_loc[1024];

		bzero(img_loc, 1024);

		gtk_text_buffer_get_iter_at_mark(buffer, &start,
			&(in_tag.start));

		if ((param = ay_strcasestr(in_tag.name, "src=")) != NULL) {

			param += 4;	/*length of src= */
			_extract_parameter(param, img_loc, 1024);

			if (!strcmp(img_loc, "aol_icon.gif"))
				insert_xpm_at_iter(text_view, &start,
					aol_icon_xpm);
			else if (!strcmp(img_loc, "free_icon.gif"))
				insert_xpm_at_iter(text_view, &start,
					free_icon_xpm);
			else if (!strcmp(img_loc, "dt_icon.gif"))
				insert_xpm_at_iter(text_view, &start,
					dt_icon_xpm);
			else if (!strcmp(img_loc, "admin_icon.gif"))
				insert_xpm_at_iter(text_view, &start,
					admin_icon_xpm);
		}

		return TRUE;
	}

	return FALSE;
}
コード例 #25
0
ファイル: gimptagpopup.c プロジェクト: Amerekanets/gimp-1
static gint
gimp_tag_popup_layout_tags (GimpTagPopup *popup,
                            gint          width)
{
  PangoFontMetrics *font_metrics;
  gint              x;
  gint              y;
  gint              height = 0;
  gint              i;
  gint              line_height;
  gint              space_width;

  x = GIMP_TAG_POPUP_MARGIN;
  y = GIMP_TAG_POPUP_MARGIN;

  font_metrics = pango_context_get_metrics (popup->context,
                                            pango_context_get_font_description (popup->context),
                                            NULL);

  line_height = PANGO_PIXELS ((pango_font_metrics_get_ascent (font_metrics) +
                               pango_font_metrics_get_descent (font_metrics)));
  space_width = PANGO_PIXELS (pango_font_metrics_get_approximate_char_width (font_metrics));

  pango_font_metrics_unref (font_metrics);

  for (i = 0; i < popup->tag_count; i++)
    {
      PopupTagData *tag_data = &popup->tag_data[i];
      gint          w, h;

      pango_layout_set_text (popup->layout,
                             gimp_tag_get_name (tag_data->tag), -1);
      pango_layout_get_pixel_size (popup->layout, &w, &h);

      tag_data->bounds.width  = w + 2 * GIMP_TAG_POPUP_PADDING;
      tag_data->bounds.height = h + 2 * GIMP_TAG_POPUP_PADDING;

      if (x + space_width + tag_data->bounds.width +
          GIMP_TAG_POPUP_MARGIN - 1 > width)
        {
          x = GIMP_TAG_POPUP_MARGIN;
          y += line_height + 2 * GIMP_TAG_POPUP_PADDING + GIMP_TAG_POPUP_LINE_SPACING;
        }

      tag_data->bounds.x = x;
      tag_data->bounds.y = y;

      x += tag_data->bounds.width + space_width;
    }

  if (gtk_widget_get_direction (GTK_WIDGET (popup)) == GTK_TEXT_DIR_RTL)
    {
      for (i = 0; i < popup->tag_count; i++)
        {
          PopupTagData *tag_data = &popup->tag_data[i];

          tag_data->bounds.x = (width -
                                tag_data->bounds.x -
                                tag_data->bounds.width);
        }
    }

  height = y + line_height + GIMP_TAG_POPUP_MARGIN;

  return height;
}
コード例 #26
0
ファイル: rsvg-text.c プロジェクト: chagge/libsvg
static PangoLayout *
rsvg_text_create_layout (RsvgDrawingCtx * ctx,
                         RsvgState * state, const char *text, PangoContext * context)
{
    PangoFontDescription *font_desc;
    PangoLayout *layout;
    PangoAttrList *attr_list;
    PangoAttribute *attribute;

    if (state->lang)
        pango_context_set_language (context, pango_language_from_string (state->lang));

    if (state->unicode_bidi == UNICODE_BIDI_OVERRIDE || state->unicode_bidi == UNICODE_BIDI_EMBED)
        pango_context_set_base_dir (context, state->text_dir);

    font_desc = pango_font_description_copy (pango_context_get_font_description (context));

    if (state->font_family)
        pango_font_description_set_family_static (font_desc, state->font_family);

    pango_font_description_set_style (font_desc, state->font_style);
    pango_font_description_set_variant (font_desc, state->font_variant);
    pango_font_description_set_weight (font_desc, state->font_weight);
    pango_font_description_set_stretch (font_desc, state->font_stretch);
    pango_font_description_set_size (font_desc,
                                     _rsvg_css_normalize_font_size (state, ctx) *
                                     PANGO_SCALE / ctx->dpi_y * 72);

    layout = pango_layout_new (context);
    pango_layout_set_font_description (layout, font_desc);
    pango_font_description_free (font_desc);

    attr_list = pango_attr_list_new ();
    attribute = pango_attr_letter_spacing_new (_rsvg_css_normalize_length (&state->letter_spacing,
                                                                           ctx, 'h') * PANGO_SCALE);
    attribute->start_index = 0;
    attribute->end_index = G_MAXINT;
    pango_attr_list_insert (attr_list, attribute); 

    if (state->has_font_decor && text) {
        if (state->font_decor & TEXT_UNDERLINE) {
            attribute = pango_attr_underline_new (PANGO_UNDERLINE_SINGLE);
            attribute->start_index = 0;
            attribute->end_index = -1;
            pango_attr_list_insert (attr_list, attribute);
        }
	if (state->font_decor & TEXT_STRIKE) {
            attribute = pango_attr_strikethrough_new (TRUE);
            attribute->start_index = 0;
            attribute->end_index = -1;
            pango_attr_list_insert (attr_list, attribute);
	}
    }

    pango_layout_set_attributes (layout, attr_list);
    pango_attr_list_unref (attr_list);

    if (text)
        pango_layout_set_text (layout, text, -1);
    else
        pango_layout_set_text (layout, NULL, 0);

    pango_layout_set_alignment (layout, (state->text_dir == PANGO_DIRECTION_LTR ||
                                         state->text_dir == PANGO_DIRECTION_TTB_LTR) ?
                                PANGO_ALIGN_LEFT : PANGO_ALIGN_RIGHT);

    return layout;
}
コード例 #27
0
ファイル: main.c プロジェクト: gfunkmonk2/mate-games
static void
render_logo (void)
{
  ClutterActor *image;
  ClutterActor *text, *text_shadow;
  ClutterActor *desc, *desc_shadow;
  ClutterColor actor_color = {0xff,0xff,0xff,0xff};
  ClutterColor shadow_color = {0x00, 0x00, 0x00, 0x88};
  ClutterActor *text_group;
  static gint width, height;
  gint size;
  gfloat stage_w, stage_h;
  PangoFontDescription *pfd;
  PangoLayout *layout;
  PangoContext *context;

  gchar *nibbles = _("Nibbles");
  /* Translators: This string will be included in the intro screen, so don't make sure it fits! */
  gchar *description = _("A worm game for MATE.");

  logo = clutter_group_new ();
  text_group = clutter_group_new ();

  if (!logo_pixmap)
    gnibbles_load_logo (properties->tilesize);

  image = gtk_clutter_texture_new_from_pixbuf (logo_pixmap);

  stage_w = board->width * properties->tilesize;
  stage_h = board->height * properties->tilesize;

  clutter_actor_set_size (CLUTTER_ACTOR (image), stage_w, stage_h);

  clutter_actor_set_position (CLUTTER_ACTOR (image), 0, 0);
  clutter_actor_show (image);

  text = clutter_text_new ();
  clutter_text_set_color (CLUTTER_TEXT (text), &actor_color);

  context = gdk_pango_context_get ();
  layout = clutter_text_get_layout (CLUTTER_TEXT (text));
  pfd = pango_context_get_font_description (context);
  size = pango_font_description_get_size (pfd);

  pango_font_description_set_size (pfd, (size * stage_w) / 100);
  pango_font_description_set_family (pfd, "Sans");
  pango_font_description_set_weight(pfd, PANGO_WEIGHT_BOLD);
  pango_layout_set_font_description (layout, pfd);
  pango_layout_set_text (layout, nibbles, -1);
  pango_layout_get_pixel_size (layout, &width, &height);

  text_shadow = clutter_text_new ();
  clutter_text_set_color (CLUTTER_TEXT (text_shadow), &shadow_color);

  layout = clutter_text_get_layout (CLUTTER_TEXT (text_shadow));
  pango_layout_set_font_description (layout, pfd);
  pango_layout_set_text (layout, nibbles, -1);

  clutter_actor_set_position (CLUTTER_ACTOR (text),
                              (stage_w - width) * 0.5 ,
                              stage_h * .72);
  clutter_actor_set_position (CLUTTER_ACTOR (text_shadow),
                              (stage_w - width) * 0.5 + 5,
                              stage_h * .72 + 5);

  desc = clutter_text_new ();
  layout = clutter_text_get_layout (CLUTTER_TEXT (desc));

  clutter_text_set_color (CLUTTER_TEXT (desc), &actor_color);
  pango_font_description_set_size (pfd, (size * stage_w) / 400);
  pango_layout_set_font_description (layout, pfd);
  pango_layout_set_text (layout, description, -1);
  pango_layout_get_pixel_size(layout, &width, &height);

  desc_shadow = clutter_text_new ();
  layout = clutter_text_get_layout (CLUTTER_TEXT (desc_shadow));
  clutter_text_set_color (CLUTTER_TEXT (desc_shadow), &shadow_color);

  pango_font_description_set_size (pfd, (size * stage_w) / 400);
  pango_layout_set_font_description (layout, pfd);
  pango_layout_set_text (layout, description, -1);

  clutter_actor_set_position (CLUTTER_ACTOR (desc),
                              (stage_w - width) * 0.5,
                              stage_h* .93);
  clutter_actor_set_position (CLUTTER_ACTOR (desc_shadow),
                              (stage_w - width) * 0.5 + 3,
                              stage_h * .93 + 3);

  clutter_container_add (CLUTTER_CONTAINER (text_group),
                         CLUTTER_ACTOR (text_shadow),
                         CLUTTER_ACTOR (text),
                         CLUTTER_ACTOR (desc_shadow),
                         CLUTTER_ACTOR (desc),
                         NULL);
  clutter_container_add (CLUTTER_CONTAINER (logo),
                         CLUTTER_ACTOR (image),
                         CLUTTER_ACTOR (text_group),
                         NULL);

  clutter_actor_set_opacity (CLUTTER_ACTOR (text_group), 0);
  clutter_actor_set_scale (CLUTTER_ACTOR (text_group), 0.0, 0.0);
  clutter_actor_animate (text_group, CLUTTER_EASE_OUT_CIRC, 800,
                          "opacity", 0xff,
                          "scale-x", 1.0,
                          "scale-y", 1.0,
                          "fixed::scale-center-y", stage_w / 2,
                          "fixed::scale-center-x", stage_h / 2,
                          NULL);

  clutter_container_add_actor (CLUTTER_CONTAINER (stage),
                               CLUTTER_ACTOR (logo));
}
コード例 #28
0
ファイル: UgtkScheduleForm.c プロジェクト: erdincay/uget2
static gboolean on_draw_callback (GtkWidget* widget, cairo_t* cr, struct UgtkScheduleForm* sform)
{
	gboolean  sensitive;
	gint      y, x;
	gdouble   cy, cx, ox;
	PangoContext*  context;
	PangoLayout*   layout;
	PangoFontDescription*  desc;

	cairo_set_line_width (cr, 1);
	sensitive = gtk_widget_get_sensitive (widget);

	// setup Pango
	context = gtk_widget_get_pango_context (widget);
	desc = pango_context_get_font_description (context);
	layout = pango_cairo_create_layout (cr);
	pango_layout_set_font_description (layout, desc);

	// week days
	// ox = x offset
	for (ox = 0, cy = 0.5, y = 0;  y < 7;  y++, cy+=GRID_HEIGHT_LINE) {
		cairo_move_to (cr, 1, cy);
		pango_layout_set_text (layout, gettext (week_days[y]), -1);
		pango_cairo_update_layout (cr, layout);
		pango_cairo_show_layout (cr, layout);
		pango_layout_get_size (layout, &x, NULL);
		x /= PANGO_SCALE;
		if (x + 4 > ox)
			ox = x + 4;
	}
	g_object_unref (layout);

	if (sform->drawing_offset == 0)
		sform->drawing_offset = ox;
	// draw grid columns
	for (cx = 0.5;  cx <= GRID_WIDTH_ALL;  cx += GRID_WIDTH_LINE) {
		cairo_move_to (cr, ox + cx, 0 + 0.5);
		cairo_line_to (cr, ox + cx, GRID_HEIGHT_ALL - 1.0 + 0.5);
	}
	// draw grid rows
	for (cy = 0.5;  cy <= GRID_HEIGHT_ALL;  cy += GRID_HEIGHT_LINE) {
		cairo_move_to (cr, ox + 0.5, cy);
		cairo_line_to (cr, ox + GRID_WIDTH_ALL - 1.0 + 0.5, cy);
	}
	cairo_stroke (cr);

	// fill grid
	if (sensitive == FALSE) {
		cairo_set_source_rgb (cr,
				COLOR_DISABLE_R,
				COLOR_DISABLE_G,
				COLOR_DISABLE_B);
	}
	for (cy = 1.5, y = 0;  y < 7;  y++, cy+=GRID_HEIGHT_LINE) {
		for (cx = 1.5+ox, x = 0;  x < 24;  x++, cx+=GRID_WIDTH_LINE) {
			if (sensitive) {
				cairo_set_source_rgb (cr,
						colors [sform->state[y][x]][0],
						colors [sform->state[y][x]][1],
						colors [sform->state[y][x]][2]);
			}
			cairo_rectangle (cr,
					cx,
					cy,
					GRID_WIDTH  - 0.5,
					GRID_HEIGHT - 0.5);
			cairo_fill (cr);
		}
	}

	return FALSE;
}
コード例 #29
0
ファイル: gailmisc.c プロジェクト: 3dfxmadscientist/gtk
/**
 * gail_misc_get_default_attributes:
 * @attrib_set: The #AtkAttributeSet to add the attribute to
 * @layout: The PangoLayout from which the attributes will be obtained
 * @widget: The GtkWidget for which the default attributes are required.
 *
 * Adds the default attributes to the specified attribute set.
 *
 * Returns: A pointer to the #AtkAttributeSet.
 **/
AtkAttributeSet* 
gail_misc_get_default_attributes (AtkAttributeSet *attrib_set,
                                  PangoLayout     *layout,
                                  GtkWidget       *widget)
{
  PangoContext *context;
  GtkStyleContext *style_context;
  gint int_value;
  PangoWrapMode mode;
  GdkRGBA color;
  gchar *value;

  attrib_set = gail_misc_add_attribute (attrib_set, 
                                        ATK_TEXT_ATTR_DIRECTION,
     g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_DIRECTION, 
                                        gtk_widget_get_direction (widget))));

  context = pango_layout_get_context (layout);
  if (context)
    {
      PangoLanguage* language;
      PangoFontDescription* font;

      language = pango_context_get_language (context);
      if (language)
        {
          attrib_set = gail_misc_add_attribute (attrib_set,
                                                ATK_TEXT_ATTR_LANGUAGE,
                      g_strdup (pango_language_to_string (language)));
        }
      font = pango_context_get_font_description (context);
      if (font)
        {
          attrib_set = gail_misc_add_attribute (attrib_set,
                                                ATK_TEXT_ATTR_STYLE,
              g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STYLE,
                                   pango_font_description_get_style (font))));
          attrib_set = gail_misc_add_attribute (attrib_set,
                                                ATK_TEXT_ATTR_VARIANT,
              g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_VARIANT,
                                   pango_font_description_get_variant (font))));
          attrib_set = gail_misc_add_attribute (attrib_set,
                                                ATK_TEXT_ATTR_STRETCH,
              g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STRETCH,
                                   pango_font_description_get_stretch (font))));
          attrib_set = gail_misc_add_attribute (attrib_set,
                                                ATK_TEXT_ATTR_FAMILY_NAME,
              g_strdup (pango_font_description_get_family (font)));
          attrib_set = gail_misc_add_attribute (attrib_set,
                                                ATK_TEXT_ATTR_WEIGHT,
                    g_strdup_printf ("%d",
                                   pango_font_description_get_weight (font)));
          attrib_set = gail_misc_add_attribute (attrib_set,
                                                ATK_TEXT_ATTR_SIZE,
                    g_strdup_printf ("%i",
                                   pango_font_description_get_size (font) / PANGO_SCALE));
        }
    }
  if (pango_layout_get_justify (layout))
    {
      int_value = 3;
    }
  else
    {
      PangoAlignment align;

      align = pango_layout_get_alignment (layout);
      if (align == PANGO_ALIGN_LEFT)
        int_value = 0;
      else if (align == PANGO_ALIGN_CENTER)
        int_value = 2;
      else /* if (align == PANGO_ALIGN_RIGHT) */
        int_value = 1;
    }
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_JUSTIFICATION,
              g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_JUSTIFICATION, 
                                                      int_value))); 
  mode = pango_layout_get_wrap (layout);
  if (mode == PANGO_WRAP_WORD)
    int_value = 2;
  else /* if (mode == PANGO_WRAP_CHAR) */
    int_value = 1;
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_WRAP_MODE,
              g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_WRAP_MODE, 
                                                      int_value))); 

  style_context = gtk_widget_get_style_context (widget);

  gtk_style_context_get_background_color (style_context, 0, &color);
  value = g_strdup_printf ("%u,%u,%u",
                           (guint) ceil (color.red * 65536 - color.red),
                           (guint) ceil (color.green * 65536 - color.green),
                           (guint) ceil (color.blue * 65536 - color.blue));
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_BG_COLOR,
                                        value); 

  gtk_style_context_get_color (style_context, 0, &color);
  value = g_strdup_printf ("%u,%u,%u",
                           (guint) ceil (color.red * 65536 - color.red),
                           (guint) ceil (color.green * 65536 - color.green),
                           (guint) ceil (color.blue * 65536 - color.blue));
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_FG_COLOR,
                                        value); 

  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_FG_STIPPLE,
              g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_FG_STIPPLE, 
                                                      0))); 
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_BG_STIPPLE,
              g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_BG_STIPPLE, 
                                                      0))); 
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_STRIKETHROUGH,
              g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STRIKETHROUGH, 
                                                      0))); 
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_UNDERLINE,
              g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_UNDERLINE, 
                                                      0))); 
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_RISE,
                                               g_strdup_printf ("%i", 0));
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_SCALE,
                                               g_strdup_printf ("%g", 1.0));
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_BG_FULL_HEIGHT,
                                               g_strdup_printf ("%i", 0));
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP,
                                               g_strdup_printf ("%i", 0));
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_PIXELS_BELOW_LINES,
                                        g_strdup_printf ("%i", 0));
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_PIXELS_ABOVE_LINES,
                                        g_strdup_printf ("%i", 0));
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_EDITABLE,
              g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_EDITABLE, 
                                                      0))); 
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_INVISIBLE,
              g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_INVISIBLE, 
                                                      0))); 
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_INDENT,
                                        g_strdup_printf ("%i", 0));
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_RIGHT_MARGIN,
                                        g_strdup_printf ("%i", 0));
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_LEFT_MARGIN,
                                        g_strdup_printf ("%i", 0));
  return attrib_set;
}
コード例 #30
0
ファイル: uiutil.c プロジェクト: Arthaey/fontforge
static void CreateErrorWindow(void) {
    GtkWidget *hbox5;
    GtkWidget *view;
    GtkWidget *vscrollbar2;
    GdkPixbuf *Warning_icon_pixbuf;
    PangoContext *context;
    PangoFont *font;
    PangoFontMetrics *fm;
    int as, ds;
    GtkRequisition desired;

    errdata.gw = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_widget_set_name (errdata.gw, "Warnings");
    gtk_widget_set_events (errdata.gw, GDK_EXPOSURE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_PROPERTY_CHANGE_MASK);
    gtk_window_set_title (GTK_WINDOW (errdata.gw), _("Warnings"));
    Warning_icon_pixbuf = create_pixbuf ("fontview2.xbm");
    if (Warning_icon_pixbuf) {
	gtk_window_set_icon (GTK_WINDOW (errdata.gw), Warning_icon_pixbuf);
	gdk_pixbuf_unref (Warning_icon_pixbuf);
    }

    hbox5 = gtk_hbox_new (FALSE, 0);
    gtk_widget_set_name (hbox5, "hbox5");
    gtk_widget_show (hbox5);
    gtk_container_add (GTK_CONTAINER (errdata.gw), hbox5);

    view = gtk_drawing_area_new ();
    gtk_widget_set_name (view, "view");
    gtk_widget_show (view);
    gtk_box_pack_start (GTK_BOX (hbox5), view, TRUE, TRUE, 0);
    gtk_widget_set_size_request (view, 16*24+1, 4*24+1);

    vscrollbar2 = gtk_vscrollbar_new (GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, 0, 0, 0, 0)));
    gtk_widget_set_name (vscrollbar2, "vscrollbar2");
    gtk_widget_show (vscrollbar2);
    gtk_box_pack_start (GTK_BOX (hbox5), vscrollbar2, FALSE, TRUE, 0);

    g_signal_connect ((gpointer) errdata.gw, "delete_event",
		      G_CALLBACK (Warning_Hide),
		      NULL);
    g_signal_connect ((gpointer) vscrollbar2, "value_changed",
		      G_CALLBACK (Warning_VScroll),
		      NULL);

    g_signal_connect ((gpointer) view, "configure_event",
		      G_CALLBACK (Warning_Resize),
		      NULL);
    g_signal_connect ((gpointer) view, "expose_event",
		      G_CALLBACK (Warning_Expose),
		      NULL);

    errdata.v   = view;
    errdata.vsb = vscrollbar2;
    errdata.layout = gtk_widget_create_pango_layout( view, NULL );
    pango_layout_set_width(errdata.layout, -1);		/* Don't wrap long lines */

    context = gtk_widget_get_pango_context( view );
    font = pango_context_load_font( context, pango_context_get_font_description(context));
    fm = pango_font_get_metrics(font,NULL);
    as = pango_font_metrics_get_ascent(fm);
    ds = pango_font_metrics_get_descent(fm);
    errdata.as = as / PANGO_SCALE;
    errdata.fh = (as+ds) / PANGO_SCALE;

    gtk_widget_set_size_request(view, 40*errdata.fh, 5*errdata.fh );

    gtk_widget_size_request(errdata.gw,&desired);
    /* This function is deprecated, but I can find no other way to position */
    /*  a window in the bottom right corner (or at all). So I use it */
    gtk_widget_set_uposition(errdata.gw,
	    gdk_screen_get_width(gdk_screen_get_default())-desired.width-5,
	    gdk_screen_get_height(gdk_screen_get_default())-desired.height-errdata.fh-5);

    errdata.linecnt = 5;

    gtk_widget_show(errdata.gw);
}