Пример #1
0
gint
wgra_configure(GtkWidget *widget,GdkEventConfigure *ee,gpointer data)
{
  GdkGC *mygc;
  int x,y,cx,xs;
  int i,v;
  long max;
  float fac;
  GdkFont *fn;

  if (wcanvas!=NULL)
    gdk_pixmap_unref(wcanvas);

  mygc=gdk_gc_new(widget->window);

  wcanvas=gdk_pixmap_new(widget->window,x=widget->allocation.width,
			 y=widget->allocation.height,-1);
  gdk_draw_rectangle(wcanvas,widget->style->white_gc,TRUE,0,0,x,y);
  gdk_draw_rectangle(wcanvas,widget->style->black_gc,FALSE,0,0,x-1,y-1);

  max=0;
  for(i=0;i<7;i++)
    if (weekly[i]>max)
      max=weekly[i];

  if (!max) max=1;
  fac=((float)(y-18-16))/((float)max);

  cx=1;
  xs=(x-2)/7;
  fn=gdk_font_load("-*-helvetica-medium-r-*-*-8-*-*-*-*-*-*-*");
  for (i=0;i<7;i++) {
    v=(int)(((float)weekly[i])*fac);
    gdk_rgb_gc_set_foreground(mygc,0xc0c0c0);
    gdk_draw_line(wcanvas,mygc,cx,1,cx,y-2);
    gdk_rgb_gc_set_foreground(mygc,0x004080);
    gdk_draw_rectangle(wcanvas,mygc,TRUE,cx,y-18-v,xs,v);
    gdk_rgb_gc_set_foreground(mygc,0x000000);
    gdk_draw_string(wcanvas,fn,mygc,cx,y-6,wdays[i]);
    cx+=xs;
  }

  gdk_draw_line(wcanvas,widget->style->black_gc,0,y-18,x-1,y-18);

  gdk_rgb_gc_set_foreground(mygc,0xffffff);
  gdk_draw_rectangle(wcanvas,mygc,TRUE,0,0,23*4,13);
  gdk_rgb_gc_set_foreground(mygc,0x000000);
  gdk_draw_rectangle(wcanvas,mygc,FALSE,0,0,23*4,13);

  gdk_font_unref(fn);
  fn=gdk_font_load("-*-helvetica-medium-r-*-*-10-*-*-*-*-*-*-*");

  gdk_draw_string(wcanvas,fn,mygc,5,10,"weekday summary");

  gdk_font_unref(fn);
  gdk_gc_destroy(mygc);

  return FALSE;
}
Пример #2
0
gint init(GtkWidget *widget)
{
  if (gtk_gl_area_make_current(GTK_GL_AREA(widget))) {
    GdkFont *font;

    /* set viewport */
    glViewport(0,0, widget->allocation.width, widget->allocation.height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0,widget->allocation.width, 0,widget->allocation.height, -1.0, 1.0);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    /* generate font display lists */
    fontbase = glGenLists( 128 );
    font = gdk_font_load(fontname);
    if (!font) {
      g_print("Can't load font '%s'\n", fontname);
      gtk_exit(1);
    }

    gdk_gl_use_gdk_font(font, 0, 128, fontbase);
    fontheight = font->ascent+font->descent;
    gdk_font_unref(font);

  }
  return TRUE;
}
Пример #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");
    }
}
Пример #4
0
/* Loads a fontset.
 *
 * Currently, this function will always return a new font, however, in the future,
 * it may be changed to look up the font in a cache. You should make no assumptions
 * about the initial reference count.

 fontset_name : a comma-separated list of XLFDs describing the
 		component fonts of the fontset to load.
 */
int
clip_GDK_FONTSETLOAD(ClipMachine * cm)
{
	ClipVar *cv = _clip_spar(cm,1);
	const gchar *font_name = _clip_parc(cm,2);
	GdkFont *font;
	C_object *cfont;
	CHECKOPT(1,MAP_t); CHECKARG(2,CHARACTER_t);
	font = gdk_fontset_load(font_name);
	if (font)
	{
//		gdk_font_ref(font);
		cfont = _register_object(cm,font,GDK_OBJECT_FONT,cv,
			(coDestructor)gdk_object_font_destructor);
		if (cfont)
		{
                	cfont->ref_count = 1;
			_clip_mclone(cm,RETPTR(cm),&cfont->obj);
                }
                else
                	gdk_font_unref(font);
	}
	return 0;
err:
	return 1;
}
Пример #5
0
CLIP_DLLEXPORT int
gdk_object_font_destructor(ClipMachine *cm, C_object *cfont)
{
	if (cfont && GDK_IS_FONT(cfont) && cfont->ref_count>=0)
        	gdk_font_unref(GDK_FONT(cfont->object));
        return 0;
}
Пример #6
0
void playlist_list_set_font(char *font)
{
	if (playlist_list_font)
		gdk_font_unref(playlist_list_font);

	playlist_list_font = util_font_load(font);
}
Пример #7
0
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);
}
Пример #8
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);
}
Пример #9
0
void wxFontRefData::ClearGdkFonts()
{
    for ( wxScaledFontList::iterator i = m_scaled_xfonts.begin();
          i != m_scaled_xfonts.end();
          ++i )
    {
        GdkFont *font = i->second;
        gdk_font_unref( font );
    }

    m_scaled_xfonts.clear();
}
Пример #10
0
static void
gtk_finalize_font_instance (struct Lisp_Font_Instance *f)
{
  if (f->data)
    {
      if (DEVICE_LIVE_P (XDEVICE (f->device)))
	{
	    gdk_font_unref (FONT_INSTANCE_GTK_FONT (f));
	}
      xfree (f->data);
      f->data = 0;
    }
}
Пример #11
0
static void
gtk_hex_entry_finalize (GtkObject *object)
{
	g_return_if_fail (object != NULL);
	g_return_if_fail (GTK_IS_HEX_ENTRY (object));

	if (GTK_HEX_ENTRY (object)->pixmap)
		gdk_pixmap_unref (GTK_HEX_ENTRY (object)->pixmap);

	gdk_font_unref (GTK_HEX_ENTRY (object)->font);

	GTK_OBJECT_CLASS (parent_class)->finalize (object);
}
Пример #12
0
/* Decrease the reference count of a count by one. If the result is zero,
   destroys the font. */
int
clip_GDK_FONTUNREF(ClipMachine * cm)
{
	C_object *cfont = _fetch_co_arg(cm);
	CHECKCOBJ(cfont,GDK_IS_FONT(cfont));
       	cfont->ref_count--;
        if (cfont->ref_count > 0)
		gdk_font_unref(GDK_FONT(cfont->object));
        else
        	destroy_c_object(cfont);
	return 0;
err:
	return 1;
}
Пример #13
0
/**
 * Perform deinicialization and deallocation of list status view structure.
 *
 * \param specificData pointer to list status view structure
 * \return OK on success
 */
RCode view_lsv_destroy(ViewListStatus *specificData) {

	ASSERT( NULL != specificData );

	if ( NULL != specificData->font ) {
		gdk_font_unref(specificData->font);
		specificData->font = NULL;
	}

	if ( NULL != specificData->buffer ) {
		g_free( (gpointer) specificData->buffer );
	}

	g_free( (gpointer)specificData );

	return OK;
}
Пример #14
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;
}
Пример #15
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);
	}
    }
}
Пример #16
0
gint init(GtkWidget *widget)
{
  /* OpenGL functions can be called only if makecurrent returns true */
  if (gtk_gl_area_make_current(GTK_GL_AREA(widget))) {
#if !defined(WIN32)
    GdkFont *font;
#endif

    /* set viewport */
    glViewport(0,0, widget->allocation.width, widget->allocation.height);

#if !defined(WIN32)
    /* generate font display lists */
    font = gdk_font_load("-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*");
    if (font) {
      fontbase = glGenLists( 128 );
      gdk_gl_use_gdk_font(font, 0, 128, fontbase);
      gdk_font_unref(font);
    }
#endif
  }
  return TRUE;
}
Пример #17
0
GtkWidget *
ghack_init_status_window()
{
    GtkWidget *horizSep0, *horizSep1, *horizSep2, *horizSep3;
    GtkWidget *statsHBox, *strVBox, *dexVBox, *intVBox, *statHBox;
    GtkWidget *wisVBox, *conVBox, *chaVBox;
    GtkWidget *alignVBox, *hungerVBox, *sickVBox, *blindVBox;
    GtkWidget *stunVBox, *halluVBox, *confuVBox, *encumbVBox;

    /* Set up a (ridiculous) initial state */
    lastDepth = 9999;
    lastStr = 9999;
    lastInt = 9999;
    lastWis = 9999;
    lastDex = 9999;
    lastCon = 9999;
    lastCha = 9999;
    lastAu = 9999;
    lastHP = 9999;
    lastMHP = 9999;
    lastLevel = 9999;
    lastPOW = 9999;
    lastMPOW = 9999;
    lastAC = 9999;
    lastExp = 9999;
    lastAlignment = A_NEUTRAL; /* start off guessing neutral */
    lastHungr = 9999;
    lastConf = 9999;
    lastBlind = 9999;
    lastStun = 9999;
    lastHalu = 9999;
    lastSick = 9999;
    lastEncumb = 9999;

    statTable = gtk_table_new(10, 8, FALSE);
    gtk_table_set_row_spacings(GTK_TABLE(statTable), 1);
    gtk_table_set_col_spacings(GTK_TABLE(statTable), 1);

    /* Begin the first row of the table -- the title */
    titleLabel = gtk_label_new(_("GnomeHack!"));
    gtk_table_attach(GTK_TABLE(statTable), titleLabel, 0, 8, 0, 1, GTK_FILL,
                     0, 0, 0);
    if (!normalStyle)
        normalStyle =
            gtk_style_copy(gtk_widget_get_style(GTK_WIDGET(titleLabel)));

    /* Set up some styles to draw stuff with */
    if (!redStyle) {
        g_assert(greenStyle == NULL);
        g_assert(bigStyle == NULL);
        g_assert(bigRedStyle == NULL);
        g_assert(bigGreenStyle == NULL);

        greenStyle = gtk_style_copy(normalStyle);
        redStyle = gtk_style_copy(normalStyle);
        bigRedStyle = gtk_style_copy(normalStyle);
        bigGreenStyle = gtk_style_copy(normalStyle);
        bigStyle = gtk_style_copy(normalStyle);

        greenStyle->fg[GTK_STATE_NORMAL] = color_green;
        redStyle->fg[GTK_STATE_NORMAL] = color_red;
        bigRedStyle->fg[GTK_STATE_NORMAL] = color_red;
        bigGreenStyle->fg[GTK_STATE_NORMAL] = color_green;

        gdk_font_unref(bigRedStyle->font);
        gdk_font_unref(bigGreenStyle->font);
        bigRedStyle->font =
            gdk_font_load("-misc-fixed-*-*-*-*-20-*-*-*-*-*-*-*");
        bigGreenStyle->font =
            gdk_font_load("-misc-fixed-*-*-*-*-20-*-*-*-*-*-*-*");

        gdk_font_unref(bigStyle->font);
        bigStyle->font =
            gdk_font_load("-misc-fixed-*-*-*-*-20-*-*-*-*-*-*-*");
    }
    gtk_widget_set_style(GTK_WIDGET(titleLabel), bigStyle);

    /* Begin the second row */
    dgnLevelLabel = gtk_label_new(_("Nethack for Gnome"));
    gtk_table_attach(GTK_TABLE(statTable), dgnLevelLabel, 0, 8, 1, 2,
                     GTK_FILL, 0, 0, 0);
    gtk_widget_set_style(GTK_WIDGET(dgnLevelLabel), bigStyle);

    /* Begin the third row */
    horizSep0 = gtk_hseparator_new();
    gtk_table_attach(GTK_TABLE(statTable), horizSep0, 0, 8, 2, 3, GTK_FILL,
                     GTK_FILL, 0, 0);

    /* Begin the fourth row */
    statsHBox = gtk_hbox_new(TRUE, 0);

    strVBox = gtk_vbox_new(FALSE, 0);
    strPix = gnome_pixmap_new_from_xpm_d(str_xpm);
    strLabel = gtk_label_new("STR: ");
    gtk_box_pack_start(GTK_BOX(strVBox), strPix, TRUE, TRUE, 2);
    gtk_box_pack_start(GTK_BOX(strVBox), strLabel, TRUE, TRUE, 2);
    gtk_box_pack_start(GTK_BOX(statsHBox), GTK_WIDGET(strVBox), TRUE, TRUE,
                       2);

    dexVBox = gtk_vbox_new(FALSE, 0);
    dexPix = gnome_pixmap_new_from_xpm_d(dex_xpm);
    dexLabel = gtk_label_new("DEX: ");
    gtk_box_pack_start(GTK_BOX(dexVBox), dexPix, TRUE, TRUE, 2);
    gtk_box_pack_start(GTK_BOX(dexVBox), dexLabel, TRUE, TRUE, 2);
    gtk_box_pack_start(GTK_BOX(statsHBox), GTK_WIDGET(dexVBox), TRUE, TRUE,
                       2);

    conVBox = gtk_vbox_new(FALSE, 0);
    conPix = gnome_pixmap_new_from_xpm_d(cns_xpm);
    conLabel = gtk_label_new("CON: ");
    gtk_box_pack_start(GTK_BOX(conVBox), conPix, TRUE, TRUE, 2);
    gtk_box_pack_start(GTK_BOX(conVBox), conLabel, TRUE, TRUE, 2);
    gtk_box_pack_start(GTK_BOX(statsHBox), GTK_WIDGET(conVBox), TRUE, TRUE,
                       2);

    intVBox = gtk_vbox_new(FALSE, 0);
    intPix = gnome_pixmap_new_from_xpm_d(int_xpm);
    intLabel = gtk_label_new("INT: ");
    gtk_box_pack_start(GTK_BOX(intVBox), intPix, TRUE, TRUE, 2);
    gtk_box_pack_start(GTK_BOX(intVBox), intLabel, TRUE, TRUE, 2);
    gtk_box_pack_start(GTK_BOX(statsHBox), GTK_WIDGET(intVBox), TRUE, TRUE,
                       2);

    wisVBox = gtk_vbox_new(FALSE, 0);
    wisPix = gnome_pixmap_new_from_xpm_d(wis_xpm);
    wisLabel = gtk_label_new("WIS: ");
    gtk_box_pack_start(GTK_BOX(wisVBox), wisPix, TRUE, TRUE, 2);
    gtk_box_pack_start(GTK_BOX(wisVBox), wisLabel, TRUE, TRUE, 2);
    gtk_box_pack_start(GTK_BOX(statsHBox), GTK_WIDGET(wisVBox), TRUE, TRUE,
                       2);

    chaVBox = gtk_vbox_new(FALSE, 0);
    chaPix = gnome_pixmap_new_from_xpm_d(cha_xpm);
    chaLabel = gtk_label_new("CHA: ");
    gtk_box_pack_start(GTK_BOX(chaVBox), chaPix, TRUE, TRUE, 2);
    gtk_box_pack_start(GTK_BOX(chaVBox), chaLabel, TRUE, TRUE, 2);
    gtk_box_pack_start(GTK_BOX(statsHBox), GTK_WIDGET(chaVBox), TRUE, TRUE,
                       2);

    gtk_table_attach(GTK_TABLE(statTable), GTK_WIDGET(statsHBox), 0, 8, 3, 4,
                     GTK_FILL, 0, 0, 0);

    /* Begin the fifth row */
    horizSep1 = gtk_hseparator_new();
    gtk_table_attach(GTK_TABLE(statTable), horizSep1, 0, 8, 4, 5, GTK_FILL,
                     GTK_FILL, 0, 0);

    /* Begin the sixth row */
    hpLabel = gtk_label_new("HP: ");
    gtk_table_attach(GTK_TABLE(statTable), hpLabel, 0, 1, 5, 6, GTK_FILL, 0,
                     0, 0);

    acLabel = gtk_label_new("AC: ");
    gtk_table_attach(GTK_TABLE(statTable), acLabel, 2, 3, 5, 6, GTK_FILL, 0,
                     0, 0);

    powLabel = gtk_label_new("Power: ");
    gtk_table_attach(GTK_TABLE(statTable), powLabel, 4, 5, 5, 6, GTK_FILL, 0,
                     0, 0);

    goldLabel = gtk_label_new("Au: ");
    gtk_table_attach(GTK_TABLE(statTable), goldLabel, 6, 7, 5, 6, GTK_FILL, 0,
                     0, 0);

    /* Begin the seventh row */
    horizSep2 = gtk_hseparator_new();
    gtk_table_attach(GTK_TABLE(statTable), horizSep2, 0, 8, 6, 7, GTK_FILL,
                     GTK_FILL, 0, 0);

    /* Begin the eigth row */
    levlLabel = gtk_label_new("Level: ");
    gtk_table_attach(GTK_TABLE(statTable), levlLabel, 0, 1, 7, 8, GTK_FILL, 0,
                     0, 0);

    expLabel = gtk_label_new("Exp: ");
    gtk_table_attach(GTK_TABLE(statTable), expLabel, 2, 3, 7, 8, GTK_FILL, 0,
                     0, 0);

    timeLabel = gtk_label_new("Time: ");
    gtk_table_attach(GTK_TABLE(statTable), timeLabel, 4, 5, 7, 8, GTK_FILL, 0,
                     0, 0);

    scoreLabel = gtk_label_new("Score: ");
    gtk_table_attach(GTK_TABLE(statTable), scoreLabel, 6, 7, 7, 8, GTK_FILL,
                     0, 0, 0);

    /* Begin the ninth row */
    horizSep3 = gtk_hseparator_new();
    gtk_table_attach(GTK_TABLE(statTable), horizSep3, 0, 8, 8, 9, GTK_FILL,
                     GTK_FILL, 0, 0);

    /* Begin the tenth and last row */
    statHBox = gtk_hbox_new(FALSE, 0);

    alignVBox = gtk_vbox_new(FALSE, 0);
    alignPix = gnome_pixmap_new_from_xpm_d(neutral_xpm);
    alignLabel = gtk_label_new("Neutral");
    gtk_box_pack_start(GTK_BOX(alignVBox), alignPix, TRUE, TRUE, 2);
    gtk_box_pack_start(GTK_BOX(alignVBox), alignLabel, TRUE, TRUE, 2);
    gtk_box_pack_start(GTK_BOX(statHBox), GTK_WIDGET(alignVBox), TRUE, FALSE,
                       2);

    hungerVBox = gtk_vbox_new(FALSE, 0);
    hungerPix = gnome_pixmap_new_from_xpm_d(hungry_xpm);
    hungerLabel = gtk_label_new("Hungry");
    gtk_box_pack_start(GTK_BOX(hungerVBox), hungerPix, TRUE, TRUE, 2);
    gtk_box_pack_start(GTK_BOX(hungerVBox), hungerLabel, TRUE, TRUE, 2);
    gtk_box_pack_start(GTK_BOX(statHBox), GTK_WIDGET(hungerVBox), TRUE, FALSE,
                       2);

    sickVBox = gtk_vbox_new(FALSE, 0);
    sickPix = gnome_pixmap_new_from_xpm_d(sick_fp_xpm);
    sickLabel = gtk_label_new("FoodPois");
    gtk_box_pack_start(GTK_BOX(sickVBox), sickPix, TRUE, TRUE, 2);
    gtk_box_pack_start(GTK_BOX(sickVBox), sickLabel, TRUE, TRUE, 2);
    gtk_box_pack_start(GTK_BOX(statHBox), GTK_WIDGET(sickVBox), TRUE, FALSE,
                       2);

    blindVBox = gtk_vbox_new(FALSE, 0);
    blindPix = gnome_pixmap_new_from_xpm_d(blind_xpm);
    blindLabel = gtk_label_new("Blind");
    gtk_box_pack_start(GTK_BOX(blindVBox), blindPix, TRUE, TRUE, 2);
    gtk_box_pack_start(GTK_BOX(blindVBox), blindLabel, TRUE, TRUE, 2);
    gtk_box_pack_start(GTK_BOX(statHBox), GTK_WIDGET(blindVBox), TRUE, FALSE,
                       2);

    stunVBox = gtk_vbox_new(FALSE, 0);
    stunPix = gnome_pixmap_new_from_xpm_d(stunned_xpm);
    stunLabel = gtk_label_new("Stun");
    gtk_box_pack_start(GTK_BOX(stunVBox), stunPix, TRUE, TRUE, 2);
    gtk_box_pack_start(GTK_BOX(stunVBox), stunLabel, TRUE, TRUE, 2);
    gtk_box_pack_start(GTK_BOX(statHBox), GTK_WIDGET(stunVBox), TRUE, FALSE,
                       2);

    confuVBox = gtk_vbox_new(FALSE, 0);
    confuPix = gnome_pixmap_new_from_xpm_d(confused_xpm);
    confuLabel = gtk_label_new("Confused");
    gtk_box_pack_start(GTK_BOX(confuVBox), confuPix, TRUE, TRUE, 2);
    gtk_box_pack_start(GTK_BOX(confuVBox), confuLabel, TRUE, TRUE, 2);
    gtk_box_pack_start(GTK_BOX(statHBox), GTK_WIDGET(confuVBox), TRUE, FALSE,
                       2);

    halluVBox = gtk_vbox_new(FALSE, 0);
    halluPix = gnome_pixmap_new_from_xpm_d(hallu_xpm);
    halluLabel = gtk_label_new("Hallu");
    gtk_box_pack_start(GTK_BOX(halluVBox), halluPix, TRUE, TRUE, 2);
    gtk_box_pack_start(GTK_BOX(halluVBox), halluLabel, TRUE, TRUE, 2);
    gtk_box_pack_start(GTK_BOX(statHBox), GTK_WIDGET(halluVBox), TRUE, FALSE,
                       2);

    encumbVBox = gtk_vbox_new(FALSE, 0);
    encumbPix = gnome_pixmap_new_from_xpm_d(slt_enc_xpm);
    encumbLabel = gtk_label_new("Burdened");
    gtk_box_pack_start(GTK_BOX(encumbVBox), encumbPix, TRUE, TRUE, 2);
    gtk_box_pack_start(GTK_BOX(encumbVBox), encumbLabel, TRUE, TRUE, 2);
    gtk_box_pack_start(GTK_BOX(statHBox), GTK_WIDGET(encumbVBox), TRUE, FALSE,
                       2);

    gtk_table_attach(GTK_TABLE(statTable), GTK_WIDGET(statHBox), 0, 8, 9, 10,
                     GTK_FILL, GTK_FILL, 0, 0);

    /* Set up the necessary signals */
    gtk_signal_connect(GTK_OBJECT(statTable), "ghack_fade_highlight",
                       GTK_SIGNAL_FUNC(ghack_fade_highlighting), NULL);

    gtk_signal_connect(GTK_OBJECT(statTable), "ghack_putstr",
                       GTK_SIGNAL_FUNC(ghack_status_window_put_string), NULL);

    gtk_signal_connect(GTK_OBJECT(statTable), "ghack_clear",
                       GTK_SIGNAL_FUNC(ghack_status_window_clear), NULL);

    gtk_signal_connect(GTK_OBJECT(statTable), "ghack_curs",
                       GTK_SIGNAL_FUNC(ghack_status_window_cursor_to), NULL);
    gtk_signal_connect(GTK_OBJECT(statTable), "gnome_delay_output",
                       GTK_SIGNAL_FUNC(ghack_delay), NULL);

    /* Lastly, show the status window and everything in it */
    gtk_widget_show_all(statTable);

    return GTK_WIDGET(statTable);
}
Пример #18
0
/*
 * Create GDISP+ sampled symbol list.
 */
void
gdisp_createSampledSymbolList ( Kernel_T  *kernel,
				GtkWidget *parent )
{

  GtkWidget    *sFrame         =    (GtkWidget*)NULL;
  GtkWidget    *scrolledWindow =    (GtkWidget*)NULL;
  GtkWidget    *cTree          =    (GtkWidget*)NULL;
  GtkCTreeNode *pNode          = (GtkCTreeNode*)NULL;
  GtkCTreeNode *sNode          = (GtkCTreeNode*)NULL;
  GdkFont      *selectedFont   =      (GdkFont*)NULL;
  GdkFont      *unselectedFont =      (GdkFont*)NULL;

  GList        *providerItem   =        (GList*)NULL;
  Provider_T   *provider       =   (Provider_T*)NULL;

  PopupMenu_T  *popupMenu      = (PopupMenu_T*)NULL;


  /* ------------------------ FRAME WITH LABEL ------------------------ */

  /*
   * Create a Frame that will contain a scrolled window for sampled symbols.
   * Align the label at the left of the frame.
   * Set the style of the frame.
   */
  sFrame = gtk_frame_new(" Sampled Symbols ");
  gtk_frame_set_label_align(GTK_FRAME(sFrame),0.1,0.0);
  gtk_frame_set_shadow_type(GTK_FRAME(sFrame),GTK_SHADOW_ETCHED_IN);

  gtk_container_add(GTK_CONTAINER(parent),sFrame);
  gtk_widget_show(sFrame);


  /* ------- SCROLLED WINDOW FOR THE LIST OF SAMPLED SYMBOLS --------- */

  /*
   * This is the scrolled window to put the List widget inside.
   */
  scrolledWindow = gtk_scrolled_window_new(NULL /* H Adjustment */,
					   NULL /* V Adjustment */);
  gtk_container_border_width(GTK_CONTAINER(scrolledWindow),5);
  gtk_container_add(GTK_CONTAINER(sFrame),scrolledWindow); 
  gtk_widget_show(scrolledWindow);

  kernel->widgets.sampledSymbolScrolledWindow = scrolledWindow;


  /* --------- HIERARCHICAL TREE FOR HANDLING ALL PROVIDERS --------- */

  cTree = gdisp_createHierarchicalTree(kernel);
  gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolledWindow),
					cTree);
  kernel->widgets.sampledSymbolHTree = cTree;


  /* ---------------------- DYNAMIC POPUP MENU ---------------------*/

  /*
   * Create the dynamic menu.
   */
  popupMenu = gdisp_createMenu(kernel,
			       cTree,
			       gdisp_popupMenuHandler,
			       (gpointer)cTree);

  gdisp_addMenuItem(popupMenu,
		    GD_POPUP_TITLE,
		    "Sampled Symbol Tree",
		    (gpointer)NULL);

  gdisp_addMenuItem(popupMenu,
		    GD_POPUP_ITEM,
		    "Expand All",
		    (gpointer)GUINT_TO_POINTER(1));

  gdisp_addMenuItem(popupMenu,
		    GD_POPUP_ITEM,
		    "Collapse All",
		    (gpointer)GUINT_TO_POINTER(0));


  /* ------------------------ NODE PIXMAPS --------------------- */

  /*
   * Create expanded/collapsed node pixmap & mask.
   */
  kernel->widgets.expandedNodePixmap =
    gdisp_getPixmapById(kernel,
			GD_PIX_expandedNode,
			GTK_WIDGET(scrolledWindow));

  kernel->widgets.collapsedNodePixmap =
    gdisp_getPixmapById(kernel,
			GD_PIX_collapseNode,
			GTK_WIDGET(scrolledWindow));

  /* ------------------------ PER PROVIDER ---------------------- */

  providerItem = g_list_first(kernel->providerList);
  while (providerItem != (GList*)NULL) {

    provider = (Provider_T*)providerItem->data;

    /* ----------------- PROVIDER NODE CREATION ------------------ */

    /*
     * Create a node that will contain all provider information.
     */
    gdisp_createProviderNode(kernel,
			     scrolledWindow,
			     cTree,
			     provider,
			     &pNode,
			     &sNode);

    /*
     * Next provider.
     */
    providerItem = g_list_next(providerItem);

  }


  /*
   * Create the styles that contain the correct font
   * for node selection / unselection.
   */
#define GD_SELECTED_FONT   "-adobe-helvetica-bold-r-normal--12-*-*-*-*-*-*-*"
#define GD_UNSELECTED_FONT "-adobe-helvetica-medium-r-normal--12-*-*-*-*-*-*-*"

  selectedFont   = gdk_font_load(GD_SELECTED_FONT);
  unselectedFont = gdk_font_load(GD_UNSELECTED_FONT);

  if (selectedFont == (GdkFont*)NULL || unselectedFont == (GdkFont*)NULL) {

    if (selectedFont != (GdkFont*)NULL) {
      gdk_font_unref(selectedFont);
      selectedFont = (GdkFont*)NULL;
    }

    if (unselectedFont != (GdkFont*)NULL) {
      gdk_font_unref(unselectedFont);
      unselectedFont = (GdkFont*)NULL;
    }

  }
  else {

    kernel->widgets.selectedNodeStyle =
      gtk_style_copy(gtk_widget_get_default_style());
    
    kernel->widgets.selectedNodeStyle =
      gtk_style_ref(kernel->widgets.selectedNodeStyle);

    kernel->widgets.selectedNodeStyle->font = selectedFont;

    kernel->widgets.selectedNodeStyle->fg[GTK_STATE_NORMAL] =
      kernel->colors[_BLUE_];

    kernel->widgets.unselectedNodeStyle =
      gtk_style_copy(gtk_widget_get_default_style());

    kernel->widgets.unselectedNodeStyle =
      gtk_style_ref(kernel->widgets.unselectedNodeStyle);

    kernel->widgets.unselectedNodeStyle->font = unselectedFont;

    kernel->widgets.unselectedNodeStyle->fg[GTK_STATE_NORMAL] =
      kernel->colors[_BLACK_];

  }

  /*
   * Finalise.
   */
  gdisp_finaliseHierarchicalTree(kernel,
				 cTree);

}
Пример #19
0
void 
ghack_menu_window_add_menu( GtkWidget *menuWin, gpointer menu_item,
			    gpointer data)
{
    GHackMenuItem*  item;
    GtkWidget	    *clist;
    gchar buf[BUFSZ]="", accelBuf[BUFSZ]="";
    gchar *pbuf;
    char *text[4] = { buf, NULL, NULL, NULL };
    gint nCurrentRow = -1, numItems = -1;
    MenuWinType isMenu;
    GtkStyle *bigStyle = NULL;
    gboolean item_selectable;
    GdkImlibImage* image;
    static gboolean special;

    g_assert (menu_item != NULL);
    item = (GHackMenuItem*) menu_item;
    item_selectable = ( item->identifier->a_int == 0)? FALSE : TRUE;
    isMenu = (MenuWinType) GPOINTER_TO_INT
    	(gtk_object_get_data (GTK_OBJECT (menuWin), "isMenu"));

    clist = GTK_WIDGET (gtk_object_get_data (GTK_OBJECT (menuWin), "clist"));
    g_assert (clist != NULL);
    /* This is a special kludge to make the special hidden help menu item work as designed */ 
    if ( special==TRUE ) {
	special=FALSE;
	item_selectable=TRUE;
    }
    if ( ! strcmp( item->str, "The NetHack license.")) {
	special=TRUE;
    }
    
    if (item->str) {

	/* First, make a new blank entry in the clist */
	nCurrentRow = gtk_clist_append (GTK_CLIST (clist), text);

	if (item->glyph != NO_GLYPH) {
	    image = ghack_image_from_glyph( item->glyph, FALSE);
	    if (image==NULL || image->pixmap==NULL) {
		g_warning("Bummer -- having to force rendering for glyph %d!", item->glyph);
		/* wierd -- pixmap is NULL so retry rendering it */
		image = ghack_image_from_glyph( item->glyph, TRUE);
	    }
	    if (image==NULL || image->pixmap==NULL) {
		    g_error("Aiiee! glyph is still NULL for item\n\"%s\"", 
			    item->str);
	    }
	    else 
		gtk_clist_set_pixmap (GTK_CLIST (clist), 
			nCurrentRow, 1, 
			gdk_imlib_move_image( image), 
			gdk_imlib_move_mask( image));
	}
	if (item->accelerator) {
	    /* FIXME: handle accelerator, */
	    g_snprintf(accelBuf, sizeof(accelBuf), "%c ", item->accelerator);
	    gtk_clist_set_text (GTK_CLIST (clist), nCurrentRow, 0, accelBuf);
	    g_snprintf(buf, sizeof(buf), "%s", item->str);
	    gtk_clist_set_text (GTK_CLIST (clist), nCurrentRow, 2, buf);
	} else {
	    if (item->group_accel) {
		/* FIXME: maybe some day I should try to handle 
		 * group accelerators... */
	    }
	    if (( (item->attr == 0) && (item->identifier->a_int != 0)) || (special ==TRUE) ) {
		numItems = GPOINTER_TO_INT( gtk_object_get_data(
			    GTK_OBJECT(clist), "numItems") )+1;

		/* Ok, now invent a unique accelerator */
		if (  ('a'+numItems) <= 'z' ) {
		    g_snprintf(accelBuf, sizeof(accelBuf), "%c ", 'a'+numItems);
		    gtk_clist_set_text(GTK_CLIST(clist), nCurrentRow, 0, accelBuf);
		}
		else if ( ('A'+numItems-26)<='Z') {
		    g_snprintf(accelBuf, sizeof(accelBuf), "%c ", 'A'+numItems-26); 
		    gtk_clist_set_text(GTK_CLIST(clist), nCurrentRow, 0, accelBuf);
		} else {
		    accelBuf[0] = buf[0] = 0;
		}
		g_snprintf(buf, sizeof(buf), "%s", item->str);
		gtk_clist_set_text (GTK_CLIST (clist), nCurrentRow, 2, buf);
		gtk_object_set_data (GTK_OBJECT (clist), "numItems",
					GINT_TO_POINTER (numItems));

		/* This junk is to specially handle the options menu */
		pbuf = strstr( buf, " [");
		if (pbuf == NULL) {
		    pbuf = strstr( buf, "\t[");
		}
		if (pbuf != NULL) {
		    *pbuf=0;
		    pbuf++;
		    gtk_clist_set_text (GTK_CLIST (clist), nCurrentRow, 3, pbuf);
		}
	    }
	    /* FIXME: handle more than 26*2 accelerators (but how?
	     * since I only have so many keys to work with???)
	    else
	    {
		foo();
	    }
	    */
	    else {
		g_snprintf(buf, sizeof(buf), "%s", item->str);
		pbuf = strstr( buf, " [");
		if (pbuf == NULL) {
		    pbuf = strstr( buf, "\t[");
		}
		if (pbuf != NULL) {
		    *pbuf=0;
		    pbuf++;
		    gtk_clist_set_text (GTK_CLIST (clist), nCurrentRow, 3, pbuf);
		}
		gtk_clist_set_text (GTK_CLIST (clist), nCurrentRow, 2, buf);
		
	    }
	}

	if (item->attr) {
	    switch(item->attr) {
		case ATR_ULINE:
		case ATR_BOLD:
		case ATR_BLINK:
		case ATR_INVERSE:
		    bigStyle = gtk_style_copy (GTK_WIDGET (clist)->style);
		    g_assert (bigStyle != NULL);
		    gdk_font_unref (bigStyle->font);
		    bigStyle->font = gdk_font_load (
				"-misc-fixed-*-*-*-*-20-*-*-*-*-*-*-*");
		    bigStyle->fg[GTK_STATE_NORMAL] = color_blue;
		    gtk_clist_set_cell_style (GTK_CLIST (clist), 
			    nCurrentRow, 2, bigStyle);
		    item_selectable = FALSE;
	    }
	}


	g_assert (nCurrentRow >= 0);
	gtk_clist_set_selectable (GTK_CLIST (clist), nCurrentRow,
			      item_selectable);

	if ( item_selectable==TRUE && item->presel== TRUE) {
	    /* pre-select this item */
	    gtk_clist_select_row( GTK_CLIST (clist), nCurrentRow, 0);
	}
	
	gtk_object_set_data (GTK_OBJECT (clist), "numRows",
		                GINT_TO_POINTER (nCurrentRow));
        
	/* We have to allocate memory here, since the menu_item currently
	 * lives on the stack, and will otherwise go to the great bit bucket 
	 * in the sky as soon as this function exits, which would leave a 
	 * pointer to crap in the row_data.  Use g_memdup to make a private, 
	 * persistant copy of the item identifier.
	 *
	 * We need to arrange to blow away this memory somewhere (like 
	 * ghack_menu_destroy and ghack_menu_window_clear for example).
	 *
	 *  -Erik
	 */
	{
	    menuItem newItem;
	    menuItem *pNewItem;
	    
	    newItem.identifier = *item->identifier;
	    newItem.itemNumber=nCurrentRow;
	    newItem.selected=FALSE;
	    newItem.accelerator[0]=0;
	    /* only copy 1 char, since accel keys are by definition 1 char */
	    if (accelBuf[0]) {
		strncpy(newItem.accelerator, accelBuf, 1);
	    }
	    newItem.accelerator[1]=0;

	    pNewItem = g_memdup(&newItem, sizeof( menuItem));
	    gtk_clist_set_row_data (GTK_CLIST (clist), nCurrentRow,
				    (gpointer) pNewItem);
	}
    }
    /* Now adjust the column widths to match the contents */
    gtk_clist_columns_autosize (GTK_CLIST (clist));
}
Пример #20
0
void
menu_about (GtkWidget * wid, gpointer sess)
{
	GtkWidget *vbox, *label, *hbox;
	GtkStyle *about_style;
	GtkStyle *head_style;
	char buf[512];

	if (about)
	{
		gdk_window_show (about->window);
		return;
	}
	head_style = gtk_style_new ();
#ifndef WIN32
	gdk_font_unref (head_style->font);
	head_style->font = gdk_font_load ("-*-times-bold-i-*-*-*-240-*");
	if (!head_style->font)
		head_style->font = gdk_font_load ("fixed");
#endif
	head_style->fg[GTK_STATE_NORMAL] = colors[2];

	about_style = gtk_style_new ();
	gdk_font_unref (about_style->font);
	about_style->font = gdk_font_load ("fixed");

	about = gtk_window_new (GTK_WINDOW_DIALOG);
	gtk_window_position (GTK_WINDOW (about), GTK_WIN_POS_CENTER);
	gtk_window_set_title (GTK_WINDOW (about), _("About X-Chat"));
	gtk_container_set_border_width (GTK_CONTAINER (about), 6);
	gtk_signal_connect (GTK_OBJECT (about), "destroy",
							  GTK_SIGNAL_FUNC (about_close), 0);
	gtk_widget_realize (about);

	vbox = gtk_vbox_new (0, 2);
	gtk_container_add (GTK_CONTAINER (about), vbox);
	/*gtk_widget_show (vbox);*/

	label = gtk_entry_new ();
	gtk_entry_set_editable (GTK_ENTRY (label), FALSE);
	gtk_entry_set_text (GTK_ENTRY (label), "X-Chat " VERSION);
	gtk_widget_set_style (label, head_style);
	gtk_style_unref (head_style);
	gtk_container_add (GTK_CONTAINER (vbox), label);

	snprintf (buf, sizeof (buf),
				 _("(C) 1998-2001 Peter Zelezny <*****@*****.**>\n\n"
				 "An IRC Client for UNIX.\n\n"
				 "This binary was compiled on "__DATE__"\n"
				 "Using GTK %d.%d.%d X %d\n"
				 "Running on %s\n"),
				 gtk_major_version, gtk_minor_version, gtk_micro_version,
#ifdef USE_XLIB
				VendorRelease (GDK_DISPLAY ()), get_cpu_str());
#else
				666, get_cpu_str());
#endif

	label = gtk_label_new (buf);
	gtk_container_add (GTK_CONTAINER (vbox), label);
	gtk_widget_set_style (label, about_style);
	gtk_style_unref (about_style);
	gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);

	wid = gtk_hseparator_new ();
	gtk_container_add (GTK_CONTAINER (vbox), wid);

	hbox = gtk_hbox_new (0, 2);
	gtk_container_add (GTK_CONTAINER (vbox), hbox);

	wid = gtk_button_new_with_label ("  Continue  ");
	gtk_container_set_border_width (GTK_CONTAINER (hbox), 2);
	GTK_WIDGET_SET_FLAGS (GTK_WIDGET (wid), GTK_CAN_DEFAULT);
	gtk_box_pack_end (GTK_BOX (hbox), wid, 0, 0, 0);
	gtk_widget_grab_default (wid);
	gtk_signal_connect (GTK_OBJECT (wid), "clicked",
							  GTK_SIGNAL_FUNC (gtkutil_destroy), about);

	gtk_widget_show_all (about);
}
Пример #21
0
 inline void wxFreeFont(wxNativeFont font)
 {
     gdk_font_unref(font);
 }
Пример #22
0
void dessiner(file_opener *donnees)
{
    GdkDrawable* cartew=donnees->carte->window;
    donnees->gc = gdk_gc_new (cartew);
    // On initialise la police et la couleur
    donnees->font=gdk_font_load("6x9");//6x9 - 10x20
int j;
char text[5];

couleur(donnees->gc,donnees->c,-2);
// On trace les parallèles
for(j=35;j<=60;j+=5)
{
sprintf(text,"%d",j);
gdk_draw_line(cartew,donnees->gc,0,conversion_lat(j,donnees)*donnees->ycarte,donnees->xcarte*3,conversion_lat(j,donnees)*donnees->ycarte);
gdk_draw_string(cartew,donnees->font,donnees->gc,3,conversion_lat(j,donnees)*donnees->ycarte-5,text);
}

// Puis les méridiens
for(j=-15;j<=20;j+=5)
{
sprintf(text,"%d",j);
gdk_draw_line(cartew,donnees->gc,conversion_longitude(j,donnees)*donnees->xcarte,0,conversion_longitude(j,donnees)*donnees->xcarte,donnees->ycarte*3);
gdk_draw_string(cartew,donnees->font,donnees->gc,conversion_longitude(j,donnees)*donnees->xcarte+5,8,text);
}
couleur(donnees->gc,donnees->c,10);

 /* ----------------------------------  CONTOUR FRANCE -------------------------------------- */


    {
        double x1,x2,y1,y2;
        // On ouvre le fichier contenant les points
        FILE *f = fopen("contour_france.csv", "rb");
        //printf("f=%p\n", f);
        if(f)
        {
            char buffer[1024];

            while(fgets(buffer, sizeof(buffer), f))
            {
            //  On charge et on converti les points.
                sscanf(buffer, "%lf;%lf", &x1, &y1);
                x1 = conversion_longitude(x1, donnees);
                y1 = conversion_lat(y1, donnees);
                while(fgets(buffer, sizeof(buffer), f))
                {
                //  Si la ligne est "BREAK" on empeche de tracer la ligne afin de retirer les traits entre les iles
                    if(!strcmp(buffer, "BREAK\n"))
                    {
                        break;
                    }

                    sscanf(buffer, "%lf;%lf", &x2, &y2);
                    x2=conversion_longitude(x2, donnees);
                    y2=conversion_lat(y2, donnees);
                    gdk_draw_line(cartew, donnees->gc, x1*donnees->xcarte,y1*donnees->ycarte,x2*donnees->xcarte,y2*donnees->ycarte);
                    x1=x2;
                    y1=y2;
                }
            }
            fclose(f);
        }
    }

 // ----------------------------------  AERODROMES --------------------------------------
// Si des aérodromes sont chargé on commence l'affichage
   if(donnees->debutaero!=NULL)
    {

        aerodrome* pt_aero=donnees->debutaero;
        // Boucle pour parcourir tous les aérodromes
        while(pt_aero->ptsuiv!=NULL)
        {
            dessiner_aerodromes(pt_aero,donnees);
            pt_aero = pt_aero->ptsuiv;
        }
    }

 // ----------------------------------  BALISES --------------------------------------
// La structure est semblable à celle des aérodromes
    if(donnees->debutbalises!=NULL)
    {
        balise* pt_balise=donnees->debutbalises;

        while(pt_balise->ptsuiv!=NULL)
        {
            dessiner_balise(pt_balise,donnees);
            pt_balise = pt_balise->ptsuiv;
        }
    }




 // ----------------------------------  PLAN DE VOL --------------------------------------
// On initialise la couleur à 0 pour donner une couleur à chaque plan de vol
donnees->couleur_avion=0;

    if(donnees->debutpdv!=NULL) // Rentre si un plan de vol est chargé
    {
    pdv * pt_pdv_current=donnees->debutpdv;

        while(pt_pdv_current!=NULL) // Parcours tous les plans de vol
        {
            dessiner_pdv(pt_pdv_current,donnees);
            pt_pdv_current=pt_pdv_current->ptsuiv;
            donnees->couleur_avion+=1;
        }
    }

/* ------------------------------------ CONFLITS  ---------------------------------------- */

// Si il y a des conflits
    if(donnees->deb_conflits!=NULL)
    {
    // On passe en couleur rouge
    couleur(donnees->gc,donnees->c,-3);
    conflit* conflit_current = donnees->deb_conflits;
    // Variable d'affichage si reste nul à la fin de la boucle pas de conflit
    int conflit_affiche = 0;
    //  On parcours les conflits
        while(conflit_current->ptsuiv != NULL)
        {
        pdv* avion1 = conflit_current->pdv1;
        pdv* avion2 = conflit_current->pdv2;

            // On se situe entre le temps de début et de fin de conflit
            if(donnees->temps > conflit_current->temps_deb && donnees->temps < conflit_current->temps_fin)
            {
                position c0; // position au temps t
                if(avion1->affichage && avion2->affichage) // Les deux avions sont affichés
                {
                // Conflits affiché conflit_affiche est différent de 0
                    conflit_affiche++;

                //  On met un gros carré rouge sur la position de l'avion
                    get_position_avion(&c0,avion1,donnees->temps);
                    gdk_draw_rectangle(cartew,donnees->gc,TRUE,conversion_longitude(c0.x,donnees)*donnees->xcarte-3,conversion_lat(c0.y,donnees)*donnees->ycarte-3,7,7);

                    get_position_avion(&c0,avion2,donnees->temps);
                    gdk_draw_rectangle(cartew,donnees->gc,TRUE,conversion_longitude(c0.x,donnees)*donnees->xcarte-3,conversion_lat(c0.y,donnees)*donnees->ycarte-3,7,7);

                //  On change le label de conflit
                    char *markup;
                    markup = g_markup_printf_escaped ("<span foreground=\"#A00000\">%s</span>", "Conflit.");
                    gtk_label_set_markup (GTK_LABEL (donnees->Msg_conflit), markup);
                    g_free (markup);
                }
            }
        conflit_current = conflit_current->ptsuiv;
        }
// Si aucun conflit n'est affiché on passe au label pas de conflit
    if(conflit_affiche==0)
    {
        char *markup;
        markup = g_markup_printf_escaped ("<span foreground=\"#00A000\">%s</span>", "Pas de conflit\n actuellement.");
        gtk_label_set_markup (GTK_LABEL (donnees->Msg_conflit), markup);
        g_free (markup);
    }
    // On remet en noir
    couleur(donnees->gc,donnees->c,10);
    }
    gdk_font_unref(donnees->font);
    g_object_unref (donnees->gc);
}
Пример #23
0
void
cheat_sheet_dialog (void)
{
    GtkWidget *mainbox, *scrolled_window, *text, *hbox, *thing;
    GdkFont *font;

    if(cheat_sheet_window != NULL) {
        gdk_window_raise(cheat_sheet_window->window);
        return;
    }

#ifdef USE_GNOME
    cheat_sheet_window = gnome_app_new("SoundTracker", _("XM Effects Cheat Sheet"));
#else
    cheat_sheet_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(cheat_sheet_window), _("XM Effects Cheat Sheet"));
#endif
    g_signal_connect (GTK_OBJECT (cheat_sheet_window), "delete_event",
                      GTK_SIGNAL_FUNC (cheat_sheet_close_requested), NULL);

    mainbox = gtk_vbox_new(FALSE, 2);
    gtk_container_border_width(GTK_CONTAINER(mainbox), 4);
#ifdef USE_GNOME
    gnome_app_set_contents(GNOME_APP(cheat_sheet_window), mainbox);
#else
    gtk_container_add(GTK_CONTAINER(cheat_sheet_window), mainbox);
#endif
    gtk_widget_show(mainbox);

    scrolled_window = gtk_scrolled_window_new (NULL, NULL);
    gtk_box_pack_start (GTK_BOX (mainbox), scrolled_window, TRUE, TRUE, 0);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
                                    GTK_POLICY_NEVER,
                                    GTK_POLICY_ALWAYS);
    gtk_widget_show (scrolled_window);

    /* Close button */
    thing = gtk_hseparator_new();
    gtk_widget_show(thing);
    gtk_box_pack_start(GTK_BOX(mainbox), thing, FALSE, TRUE, 0);

    hbox = gtk_hbutton_box_new ();
    gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbox), 4);
    gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_END);
    gtk_box_pack_start (GTK_BOX (mainbox), hbox,
                        FALSE, FALSE, 0);
    gtk_widget_show (hbox);

    thing = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
    GTK_WIDGET_SET_FLAGS(thing, GTK_CAN_DEFAULT);
    gtk_window_set_default(GTK_WINDOW(cheat_sheet_window), thing);
    g_signal_connect (GTK_OBJECT (thing), "clicked",
                      GTK_SIGNAL_FUNC (cheat_sheet_close_requested), NULL);
    gtk_box_pack_start (GTK_BOX (hbox), thing, FALSE, FALSE, 0);
    gtk_widget_show (thing);

    text = gtk_text_new (NULL, NULL);
    gtk_text_set_editable (GTK_TEXT (text), FALSE);
    gtk_text_set_word_wrap (GTK_TEXT (text), FALSE);
    gtk_container_add (GTK_CONTAINER (scrolled_window), text);
    gtk_widget_grab_focus (text);
    gtk_widget_show (text);
    gtk_widget_set_usize(text, 42 * 12, 46 * 12);

    font = gdk_font_load ("-adobe-courier-medium-r-normal--*-120-*-*-*-*-*-*");

    gtk_text_insert(GTK_TEXT(text), font, NULL, NULL, cheat_sheet_string, -1);

    /* The Text widget will reference count the font, so we
     * unreference it here
     */
    gdk_font_unref (font);

    gtk_widget_show (cheat_sheet_window);
}
Пример #24
0
int main(int argc, char *argv[])
{
	int ret = 1;

	g_main_window=NULL;	/* for UpdateMenuLink (check "first call") */
	g_quality_dialog = NULL;	/* for UpdateMenuLink (check "first call") */

	bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR);
	bind_textdomain_codeset( PACKAGE, "UTF-8" );
	textdomain(PACKAGE);

	gtk_set_locale();

	// Set gtk resource file.
	SetGtkResourceFile();

	gtk_init(&argc, &argv);

#ifdef	USE_LIB_GLADE
	// Initialize the glade library.
	glade_init();
#endif

	// Parse options.
	InitOption(argc, argv);

	// Set the directory name for storing keytext files.
	SetKeyTextDir(PACKAGE_DATA_DIR);

#ifndef	USE_LIB_GLADE
	// Set the directory name for storing xpm files.
	SetPixmapDir(PACKAGE_DATA_DIR);
#endif

	// Load fontset.
	//g_main_font = LoadFontSet();
	g_main_font = NULL;

	// Initialize signal control level.
	InitSignal();

	// Load the glade and keytext file.
	if( LoadResources() )
	{
		// Initialize databases.
		InitDataBase(g_model_name);

		// Initialize printint type table.
		InitPrintingType();

		// Create main dialog, and realize it.
		g_main_window = CreateMainWindow();
		gtk_widget_realize(UI_DIALOG(g_main_window)->window);

		// Create dialogs.
		CreateDialogs();

		// Connect signal handlers.
		ConnectSignalHandlers();

		// Update widgets.
		DisableSignal();
		UpdateWidgets(UI_DIALOG(g_main_window)->window, NULL);
		EnableSignal();

		// Set window title.
		snprintf(g_window_title, sizeof(g_window_title), "Canon %s", GetDispModelName());	//Ver.2.90(s)

		gtk_window_set_title(
			GTK_WINDOW(UI_DIALOG(g_main_window)->window), g_window_title);

		// Show widgets depend on model.
		ShowModelDependWidgets(g_main_window);

		gtk_widget_show(UI_DIALOG(g_main_window)->window);
		gtk_main();

		ret = 0;

		// Dispose dialogs.
		DisposeDialogs();

		// Dispose main dialog.
		DisposeDialog(UI_DIALOG(g_main_window));

		// Free databases.
		FreeDataBase();

		// Free resources.
		FreeResources();
	}
	// Free Gdk resource.
	if( g_main_font )
		gdk_font_unref(g_main_font);

	// Free option strings.
	FreeOption();

	return ret;
}
Пример #25
0
static void 
gtk_plot_gdk_draw_string                        (GtkPlotPC *pc,
                                                gint tx, gint ty,
                                                gint angle,
                                                const GdkColor *fg,
                                                const GdkColor *bg,
                                                gboolean transparent,
                                                gint border,
                                                gint border_space,
                                                gint border_width,
                                                gint shadow_width,
                                                const gchar *font_name,
                                                gint font_height,
                                                GtkJustification just,
                                                const gchar *text)
{
  GdkBitmap *text_bitmap;
  GdkPixmap *text_pixmap;
  GdkBitmap *text_mask;
  GdkImage *image;
  GdkGC *gc, *bitmap_gc;
  GdkColormap *colormap;
  GdkColor white, black, mask_color;
  GList *family = NULL;
  gint y0;
  gint old_width, old_height;
  gboolean bold, italic;
  gint fontsize;
  gint ascent, descent;
  gint numf;
  gint xp = 0, yp = 0;
  gint width, height;
  gint x, y;
  gint i;
  GdkFont *font, *latin_font, *dfont;
  GtkPSFont *psfont, *base_psfont, *latin_psfont;
  gchar subs[2], insert_char;
  GdkWChar *aux, *wtext, *lastchar = NULL, *xaux;
  gchar num[4];

  if(!GTK_PLOT_GDK(pc)->drawable) return;
  if(!GTK_PLOT_GDK(pc)->window) return;
  if(!GTK_PLOT_GDK(pc)->gc) return;
  if(!text || strlen(text) == 0) return;

  colormap = gdk_colormap_get_system ();
  gc = GTK_PLOT_GDK(pc)->gc;

  if(!gc) return;

  gtk_plot_text_get_size(text, angle, font_name, font_height, &width, &height, &ascent, &descent);

  if(height == 0 || width == 0) return;

  old_width = width;
  old_height = height;
  if(angle == 90 || angle == 270)
    {
      old_width = height;
      old_height = width;
    }

  gtk_psfont_get_families(&family, &numf);
  font = gtk_psfont_get_gdkfont(font_name, font_height);
  base_psfont = psfont = gtk_psfont_get_font(font_name);
  italic = psfont->italic;
  bold = psfont->bold;
  fontsize = font_height;
  x = 0;
  y0 = y = ascent;

  if (psfont->i18n_latinfamily) {
    latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily, italic,
					     bold);
    latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname, fontsize);
  } else {
    latin_psfont = NULL;
    latin_font = NULL;
  }

  i = strlen(text) + 2;
  aux = wtext = g_malloc0(sizeof(GdkWChar) * i);
  gdk_mbstowcs(wtext, text, i - 1);

  /* initializing text bitmap - ajd */
  text_bitmap = gdk_pixmap_new(GTK_PLOT_GDK(pc)->window,
                              old_width, old_height, 1);
  bitmap_gc = gdk_gc_new(text_bitmap);
  gdk_color_white (colormap, &white);
  gdk_gc_set_foreground(bitmap_gc, &white);
  gdk_draw_rectangle(text_bitmap, bitmap_gc, TRUE,
                     0, 0, -1, -1);
  gdk_color_black (colormap, &black);
  gdk_gc_set_foreground(bitmap_gc, &black);

  while(aux && *aux != '\0' && *aux != '\n'){
   if(*aux == '\\'){
     aux++;
     switch(*aux){
       case '0': case '1': case '2': case '3':
       case '4': case '5': case '6': case '7': case '9':
           psfont = gtk_psfont_find_by_family((gchar *)g_list_nth_data(family, *aux-'0'), italic, bold);
           gdk_font_unref(font);
           font = gtk_psfont_get_gdkfont(psfont->psname, fontsize);
	   if (latin_font) {
	     gdk_font_unref(latin_font);
	     latin_font = NULL;
	   }
           aux++;
           break;
       case '8': case 'g':
           psfont = gtk_psfont_find_by_family("Symbol", italic, bold);
           gdk_font_unref(font);
           font = gtk_psfont_get_gdkfont(psfont->psname, fontsize);
	   if (latin_font) {
	     gdk_font_unref(latin_font);
	     latin_font = NULL;
	   }
           aux++;
           break;
       case 'B':
           bold = TRUE;
           psfont = gtk_psfont_find_by_family(psfont->family, italic, bold);
           gdk_font_unref(font);
           font = gtk_psfont_get_gdkfont(psfont->psname, fontsize);
	   if (latin_font) {
	     gdk_font_unref(latin_font);
	     latin_font = NULL;
	   }
	   if (psfont->i18n_latinfamily) {
	     latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily,
						      italic, bold);
	     latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname,
						 fontsize);
	   }
           aux++;
           break;
       case 'x':
           xaux = aux + 1;
           for (i=0; i<3; i++){
            if (xaux[i] >= '0' && xaux[i] <= '9')
              num[i] = xaux[i];
            else
              break;
           }
           if (i < 3){
              aux++;
              break;
           }
           num[3] = '\0';
           insert_char = (gchar)atoi(num);
           subs[0] = insert_char;
           subs[1] = '\0';
	   /* \xNNN is always outputted with latin fonts. */
	   dfont = (psfont->i18n_latinfamily != NULL) ? latin_font : font;
           gdk_draw_string (text_bitmap, dfont,
                            bitmap_gc,
                            x, y,
                            subs);

           x += gdk_char_width(font, insert_char);
           aux += 4;
           lastchar = aux - 1;
           break;
       case 'i':
           italic = TRUE;
           psfont = gtk_psfont_find_by_family(psfont->family, italic, bold);
           gdk_font_unref(font);
           font = gtk_psfont_get_gdkfont(psfont->psname, fontsize);
	   if (latin_font) {
	     gdk_font_unref(latin_font);
	     latin_font = NULL;
	   }
	   if (psfont->i18n_latinfamily) {
	     latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily,
						      italic, bold);
	     latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname,
						 fontsize);
	   }
           aux++;
           break;
       case 'S': case '^':
           fontsize = (int)((gdouble)fontsize * 0.6 + 0.5);
           gdk_font_unref(font);
           font = gtk_psfont_get_gdkfont(psfont->psname, fontsize);
           y -= font->ascent;
	   if (latin_font) {
	     gdk_font_unref(latin_font);
	     latin_font = NULL;
	   }
	   if (psfont->i18n_latinfamily) {
	     latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily,
						      italic, bold);
	     latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname,
						 fontsize);
	   }
           aux++;
           break;
       case 's': case '_':
           fontsize = (int)((gdouble)fontsize * 0.6 + 0.5);
           gdk_font_unref(font);
           font = gtk_psfont_get_gdkfont(psfont->psname, fontsize);
           y += font->descent;
	   if (latin_font) {
	     gdk_font_unref(latin_font);
	     latin_font = NULL;
	   }
	   if (psfont->i18n_latinfamily) {
	     latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily,
						      italic, bold);
	     latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname,
						 fontsize);
	   }
           aux++;
           break;
       case '+':
           fontsize += 3;
           gdk_font_unref(font);
           font = gtk_psfont_get_gdkfont(psfont->psname, fontsize);
	   if (latin_font) {
	     gdk_font_unref(latin_font);
	     latin_font = NULL;
	   }
	   if (psfont->i18n_latinfamily) {
	     latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily,
						      italic, bold);
	     latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname,
						 fontsize);
	   }
           aux++;
           break;
       case '-':
           fontsize -= 3;
           gdk_font_unref(font);
           font = gtk_psfont_get_gdkfont(psfont->psname, fontsize);
	   if (latin_font) {
	     gdk_font_unref(latin_font);
	     latin_font = NULL;
	   }
	   if (psfont->i18n_latinfamily) {
	     latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily,
						      italic, bold);
	     latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname,
						 fontsize);
	   }
           aux++;
           break;
       case 'N':
	   psfont = base_psfont;
           gdk_font_unref(font);
           fontsize = font_height;
           font = gtk_psfont_get_gdkfont(psfont->psname, fontsize);
           y = y0;
           italic = psfont->italic;
           bold = psfont->bold;
	   if (latin_font) {
	     gdk_font_unref(latin_font);
	     latin_font = NULL;
	   }
	   if (psfont->i18n_latinfamily) {
	     latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily,
						      italic, bold);
	     latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname,
						 fontsize);
	   }
           aux++;
           break;
       case 'b':
	   if (lastchar) {
	     gtk_psfont_get_char_size(psfont, font, latin_font, *lastchar, &i,
				    NULL, NULL);
	     x -= i;

	     if (lastchar == wtext)
	       lastchar = NULL;
	     else
	       lastchar--;
	   } else {
	     gtk_psfont_get_char_size(psfont, font, latin_font, 'X', &i, NULL,
				    NULL);
	     x -= i;
	   }
           aux++;
           break;
       default:
           if(aux && *aux != '\0' && *aux !='\n'){
	     x += drawstring(pc, text_bitmap, bitmap_gc, &black, &white, x, y,
			     psfont, font, latin_font, *aux);
	     lastchar = aux;
	     aux++;
	   }
	   break;
     }
   } else {
     if(aux && *aux != '\0' && *aux !='\n'){
       x += drawstring(pc, text_bitmap, bitmap_gc, &black, &white, x, y,
		       psfont, font, latin_font, *aux);
       lastchar = aux;
       aux++;
     }
   }
  }

  g_free(wtext);

  /* initializing clip mask bitmap - ajd */
  text_mask = gdk_pixmap_new(GTK_PLOT_GDK(pc)->window, width, height, 1);
  mask_color = white;
  mask_color.pixel = 0;
  gdk_gc_set_foreground(bitmap_gc, &mask_color);
  gdk_draw_rectangle(text_mask, bitmap_gc, TRUE, 0, 0, -1, -1);
  mask_color = black;
  mask_color.pixel = 1;
  gdk_gc_set_foreground(bitmap_gc, &mask_color);

  /* performing text rotation and saving it onto clip mask bitmap - ajd */
  image = gdk_image_get(text_bitmap, 0, 0, old_width, old_height);
  for(y = 0; y < old_height; y++)
      for(x = 0; x < old_width; x++)
         {
           if( black.pixel == gdk_image_get_pixel(image, x, y) ){
           switch(angle){
            case 0:
                xp = x;
                yp = y;
                break;
            case 90:
                xp = y;
                yp = old_width - x;
                break;
            case 180:
                xp = old_width - x;
                yp = old_height - y;
                break;
            case 270:
                xp = old_height - y;
                yp = x;
                break;
            }
            gdk_draw_point(text_mask, bitmap_gc, xp, yp);
           }
         }
  gdk_image_destroy(image);


  /* initializing text pixmap - ajd */
  text_pixmap = gdk_pixmap_new(GTK_PLOT_GDK(pc)->window, width, height, -1);
  gdk_gc_set_foreground(gc, (GdkColor *) bg);
  gdk_draw_rectangle(text_pixmap, gc, TRUE, 0, 0, -1, -1);
  gdk_gc_set_foreground(gc, (GdkColor *) fg);

  /* copying clip mask bitmap onto text pixmap - ajd */
  gdk_gc_set_clip_mask(gc, text_mask);
  gdk_gc_set_clip_origin(gc, 0, 0);
  gdk_draw_rectangle(text_pixmap, gc, TRUE, 0, 0, -1, -1);
  gdk_gc_set_clip_mask(gc, NULL);

  gtk_plot_text_get_area(text, angle, just, font_name, font_height,
                         &x, &y, &width, &height);
  tx += x;
  ty += y;

  if(transparent){
    gdk_gc_set_clip_mask (gc, text_mask);
    gdk_gc_set_clip_origin (gc, tx, ty);
  } else {
    gdk_gc_set_foreground(gc, (GdkColor *) bg);
    gtk_plot_pc_draw_rectangle(pc,
   		         TRUE, 
                         tx - border_space, ty - border_space, 
                         width + 2*border_space, height + 2*border_space);
  }

  gdk_draw_pixmap(GTK_PLOT_GDK(pc)->drawable, gc,
                  text_pixmap, 0, 0,
                  tx, ty, -1, -1);
  gdk_gc_set_clip_mask(gc, NULL);

  gdk_pixmap_unref(text_pixmap);
  gdk_bitmap_unref(text_mask);
  gdk_font_unref(font);
  if (latin_font) gdk_font_unref(latin_font);
  gdk_gc_unref(bitmap_gc);
  gdk_pixmap_unref(text_bitmap);


/* border */

  gdk_gc_set_foreground(gc, (GdkColor *) fg);
  gtk_plot_pc_set_dash(pc, 0, NULL, 0);
  gtk_plot_pc_set_lineattr(pc, border_width, 0, 0, 0);
  switch(border){
    case GTK_PLOT_BORDER_SHADOW: 
      gtk_plot_pc_draw_rectangle(pc,
   		         TRUE, 
                         tx - border_space + shadow_width, 
                         ty + height + border_space, 
                         width + 2 * border_space, shadow_width);
      gtk_plot_pc_draw_rectangle(pc,
   		         TRUE, 
                         tx + width + border_space, 
                         ty - border_space + shadow_width, 
                         shadow_width, height + 2 * border_space);
    case GTK_PLOT_BORDER_LINE: 
      gtk_plot_pc_draw_rectangle(pc,
   		         FALSE, 
                         tx - border_space, ty - border_space, 
                         width + 2*border_space, height + 2*border_space);
    case GTK_PLOT_BORDER_NONE: 
    default:
	break; 
  }

  return;
}