Exemplo n.º 1
0
// this is also used from toolbar.cpp and tooltip.cpp, hence extern
extern GdkFont *GtkGetDefaultGuiFont()
{
    if (!g_systemDefaultGuiFont)
    {
        GtkWidget *widget = gtk_button_new();
        GtkStyle *def = gtk_rc_get_style( widget );
        if (def)
        {
            g_systemDefaultGuiFont = gdk_font_ref( def->font );
        }
        else
        {
            def = gtk_widget_get_default_style();
            if (def)
                g_systemDefaultGuiFont = gdk_font_ref( def->font );
        }
        gtk_widget_destroy( widget );
    }
    else
    {
        // already have it, but ref it once more before returning
        gdk_font_ref(g_systemDefaultGuiFont);
    }

    return g_systemDefaultGuiFont;
}
Exemplo n.º 2
0
Arquivo: ascii.c Projeto: dimkr/xchat
void
ascii_open (void)
{
	int do_unref = TRUE;
	int i, j, val;
	unsigned char name[2], num[4];
	GtkWidget *wid, *but, *hbox, *vbox, *win;
	GtkStyle *style;

	style = gtk_style_new ();
	gdk_font_unref (style->font);
	if (menu_sess && menu_sess->type == SESS_DIALOG)
	{
      style->font = dialog_font_normal;
		gdk_font_ref (dialog_font_normal);
	} else
	{
		style->font = font_normal;
		gdk_font_ref (font_normal);
	}

	win = maingui_window ("asciichart", _("Ascii Chart"), TRUE, TRUE, NULL,
									NULL, 0, 0, NULL);
	vbox = wins_get_vbox (win);

	name[1] = 0;

	for (i = 0; i < 16; i++)
	{
		hbox = gtk_hbox_new (0, 0);
		sprintf (num, "%03d", i * 16);
		wid = gtk_label_new (num);
		gtk_widget_set_usize (wid, 36, 20);
		gtk_container_add (GTK_CONTAINER (hbox), wid);
		gtk_widget_show (wid);
		for (j = 0; j < 16; j++)
		{
			val = j + (i * 16);
			name[0] = val;
			but = gtk_button_new_with_label (name);
			gtk_widget_set_style (GTK_BIN (but)->child, style);
			if (do_unref)
			{
				do_unref = FALSE;
				gtk_style_unref (style);
			}
			gtk_signal_connect (GTK_OBJECT (but), "clicked",
					    GTK_SIGNAL_FUNC (ascii_click), GINT_TO_POINTER (val));
			gtk_widget_set_usize (but, 24, 20);
			gtk_container_add (GTK_CONTAINER (hbox), but);
			gtk_widget_show (but);
		}
		gtk_container_add (GTK_CONTAINER (vbox), hbox);
		gtk_widget_show (hbox);
	}

	gtk_widget_show (win);
}
Exemplo n.º 3
0
void
zune_font_replace (GdkFont **font, STRPTR fontname)
{
/*  g_print("replacing preset %ld with font %s\n", preset, fontname); */

    if (*font)
	gdk_font_unref(*font);
    if (fontname != NULL && strlen(fontname) > 0)
    {
	*font = gdk_font_load(fontname);
	if (*font)
	{
/*  	    g_print("font loaded\n"); */
	    return;
	}
/*  	g_print("cannot load font\n"); */
    }
    if (__zprefs.fonts[-MUIV_Font_Normal])
    {
	if (fontname != NULL && strlen(fontname) > 0)
	    g_warning("Cannot load font '%s', fallback to window font\n",
		      fontname);
	*font = gdk_font_ref(__zprefs.fonts[-MUIV_Font_Normal]);
    }
    else
    {
	g_warning("Cannot load font '%s', trying 'fixed'\n", fontname);
	*font = gdk_font_load("fixed");
    }
}
Exemplo n.º 4
0
/* Sets the font for a graphics context.
 * (Note that all text-drawing functions in GDK take a font argument;
 * the value set here is used when that argument is NULL.) */
int
clip_GDK_GCSETFONT(ClipMachine * cm)
{
	C_object      *cgc = _fetch_co_arg(cm);
	ClipVar *c;
	GdkFont *font = 0; C_object *cfont;

	CHECKCOBJ(cgc,GDK_IS_GC(cgc)); CHECKARG3(2,CHARACTER_t,MAP_t,NUMERIC_t);
	switch ( _clip_parinfo(cm,2) )
	{
		case CHARACTER_t:
			c = _clip_spar(cm,2);
			font = gdk_font_load(c->s.str.buf);
			break;
		case MAP_t:
		case NUMERIC_t:
			cfont = _fetch_cobject(cm,_clip_spar(cm,2));
			if (cfont)
			{
				font = (GdkFont*)cfont->object;
				cfont->ref_count++;
			}
			break;
		default:
			break;
	}
	if (font)
	{
		gdk_gc_set_font(GDK_GC(cgc->object), font);
		gdk_font_ref (font);
	}
	return 0;
err:
	return 1;
}
Exemplo n.º 5
0
/* Increase the reference count of a count by one. */
int
clip_GDK_FONTREF(ClipMachine * cm)
{
	C_object *cfont = _fetch_co_arg(cm);
	CHECKCOBJ(cfont,GDK_IS_FONT(cfont));
	gdk_font_ref(GDK_FONT(cfont->object));
       	cfont->ref_count++;
	return 0;
err:
	return 1;
}
Exemplo n.º 6
0
static void
set_font(GtkWidget *w, GdkFont *font)
{
    GtkStyle *style;
    
    style = gtk_style_copy(gtk_widget_get_style(w));
    gdk_font_unref(style->font);
    gdk_font_ref(font);
    style->font = font;
    gtk_widget_set_style(w, style);
    gtk_style_unref(style);
}
Exemplo n.º 7
0
GtkStyle *
create_inputgad_style (void)
{
    GtkStyle *style;

    style = gtk_style_new ();

    gdk_font_unref (style->font);
    gdk_font_ref (font_normal);
    style->font = font_normal;

    style->base[GTK_STATE_NORMAL] = colors[19];
    style->bg[GTK_STATE_NORMAL] = colors[19];
    style->fg[GTK_STATE_NORMAL] = colors[18];

    return style;
}
Exemplo n.º 8
0
void calendar_font_selection_ok( GtkWidget    *button,
                                 CalendarData *calendar )
{
  GtkStyle *style;
  GdkFont  *font;

  calendar->font = gtk_font_selection_dialog_get_font_name(
			GTK_FONT_SELECTION_DIALOG (calendar->font_dialog));
  if (calendar->window)
    {
      font = gtk_font_selection_dialog_get_font(GTK_FONT_SELECTION_DIALOG(calendar->font_dialog));
      if (font) 
	{
	  style = gtk_style_copy (gtk_widget_get_style (calendar->window));
	  gdk_font_unref (style->font);
	  style->font = font;
	  gdk_font_ref (style->font);
	  gtk_widget_set_style (calendar->window, style);
	}
    }
}
Exemplo n.º 9
0
/* The GdkGCValues structure holds a set of values used to create or
   modify a graphics context.
GdkColor foreground;	the foreground color.
GdkColor background;	the background color.
GdkFont *font;		the default font..
GdkFunction function;	the bitwise operation used when drawing.
GdkFill fill;		the fill style.
GdkPixmap *tile;	the tile pixmap.
GdkPixmap *stipple;	the stipple bitmap.
GdkPixmap *clip_mask;	the clip mask bitmap.
GdkSubwindowMode subwindow_mode; the subwindow mode.
gint ts_x_origin;	the x origin of the tile or stipple.
gint ts_y_origin;	the y origin of the tile or stipple.
gint clip_x_origin;	the x origin of the clip mask.
gint clip_y_origin;	the y origin of the clip mask.
gint graphics_exposures; whether graphics exposures are enabled.
gint line_width;	the line width
GdkLineStyle line_style; the way dashed lines are drawn
GdkCapStyle cap_style;	the way the ends of lines are drawn
GdkJoinStyle join_style; the way joins between lines are drawn
*/
int
clip_GDK_GCNEWWITHVALUES(ClipMachine * cm)
{
	ClipVar    *cv = _clip_spar(cm,1);
	C_widget *cwid = _fetch_cwidget(cm,_clip_spar(cm,2));
	ClipVar  *cval = _clip_spar(cm,3);
	long      mask = _clip_parnl(cm,4);
	GdkGC *gc;
	GdkGCValues gcv;
	GdkFont *font = 0;
	C_object *cgc, *cfont;
	ClipVar *c;
	C_widget *cw;
	double d;
	CHECKOPT(1,MAP_t); CHECKARG2(2,NUMERIC_t,MAP_t);
	CHECKARG(3,MAP_t); CHECKARG(4,NUMERIC_t);

	/* the foreground color. */
	if ( (c = _clip_mget( cm, cval, HASH_FOREGROUND )) != NULL )
		_map_colors_to_gdk(cm, c, &gcv.foreground);
	/* the background color. */
	if ( (c = _clip_mget( cm, cval, HASH_BACKGROUND )) != NULL )
		_map_colors_to_gdk(cm, c, &gcv.background);
	/* Set default font */
	switch ( _clip_mtype(cm,cval,HASH_FONT) )
	{
		case CHARACTER_t:
			c = _clip_mget(cm,cval,HASH_FONT);
			font = gdk_font_load(c->s.str.buf);
			break;
		case MAP_t:
		case NUMERIC_t:
			cfont = _fetch_cobject(cm,_clip_mget(cm,cval,HASH_FONT));
			if (cfont)
			{
				font = (GdkFont*)cfont->object;
				cfont->ref_count++;
			}
			break;
		default:
			break;
	}
	if (font)
	{
		gcv.font = font;
		gdk_font_ref (gcv.font);
	}
	/* the bitwise operation used when drawing. */
	/* Determines how the bit values for the source pixels are combined with the
	   bit values for destination pixels to produce the final result. The sixteen
	   values here correspond to the 16 different possible 2x2 truth tables. Only
	   a couple of these values are usually useful; for colored images, only
	   GDK_COPY, GDK_XOR and GDK_INVERT are generally useful. For bitmaps, GDK_AND
	   and GDK_OR are also useful. */
	_clip_mgetn(cm,cval,HASH_FUNCTION,&d);
	gcv.function = (GdkFunction)d;
	/* the fill style. */
	_clip_mgetn(cm,cval,HASH_FILL,&d);
	gcv.fill = (GdkFill)d;
	/* the tile pixmap. */
	if ( (c = _clip_mget( cm, cval, HASH_TILE )) != NULL )
	{
		cw = _fetch_cwidget(cm,c);
		gcv.tile = cw ? GTK_PIXMAP(cw->widget)->pixmap : NULL;
	}
	/* the stipple pixmap. */
	if ( (c = _clip_mget( cm, cval, HASH_STIPPLE )) != NULL )
	{
		cw = _fetch_cwidget(cm,c);
		gcv.stipple = cw ? GTK_PIXMAP(cw->widget)->pixmap : NULL;
	}
	/* the clip mask bitmap. */
	if ( (c = _clip_mget( cm, cval, HASH_CLIPMASK )) != NULL )
	{
		cw = _fetch_cwidget(cm,c);
		gcv.clip_mask = cw ? GTK_PIXMAP(cw->widget)->pixmap : NULL;
	}
	/* the subwindow mode. */
	_clip_mgetn(cm,cval,HASH_SUBWINDOWMODE,&d);
	gcv.subwindow_mode = (GdkSubwindowMode)d;
	/* the x origin of the tile or stipple. */
	_clip_mgetn(cm,cval,HASH_TSXORIGIN,&d);
	gcv.ts_x_origin = (gint)d;
	/* the y origin of the tile or stipple. */
	_clip_mgetn(cm,cval,HASH_TSYORIGIN,&d);
	gcv.ts_y_origin = (gint)d;
	/* the x origin of the clip mask. */
	_clip_mgetn(cm,cval,HASH_CLIPXORIGIN,&d);
	gcv.clip_x_origin = (gint)d;
	/* the y origin of the clip mask. */
	_clip_mgetn(cm,cval,HASH_CLIPYORIGIN,&d);
	gcv.clip_y_origin = (gint)d;
	/* whether graphics exposures are enabled. */
	_clip_mgetn(cm,cval,HASH_GRAPHICSEXPOSURES,&d);
	gcv.graphics_exposures = (gint)d;
	/* the line width */
	_clip_mgetn(cm,cval,HASH_LINEWITDH,&d);
	gcv.line_width = (gint)d;
	/* the way dashed lines are drawn */
	_clip_mgetn(cm,cval,HASH_LINESTYLE,&d);
	gcv.line_style = (GdkLineStyle)d;
	/* the way the ends of lines are drawn */
	_clip_mgetn(cm,cval,HASH_CAPSTYLE,&d);
	gcv.cap_style = (GdkCapStyle)d;
	/* the way joins between lines are drawn */
	_clip_mgetn(cm,cval,HASH_JOINSTYLE,&d);
	gcv.join_style = (GdkJoinStyle)d;

	gc = gdk_gc_new_with_values(cwid->widget->window, &gcv, mask);
	if (gc)
	{
//		gdk_gc_ref(gc);
		cgc = _register_object(cm,gc,GDK_OBJECT_GC,cv,
			(coDestructor)gdk_object_gc_destructor);
		if (cgc)
		{
			cgc->ref_count=1;
			_clip_mclone(cm,RETPTR(cm),&cgc->obj);
		}
		else
			gdk_gc_unref(gc);

	}
	return 0;
err:
	return 1;
}