Re: hello world problem



A window does not immediately appear
when you do the show (lots of reasons,
buffering, involvement of a window manager...)
So, you shouldn't draw into a window until you
know it is visible as GDK does not retain any graphics
for you.  You are notified by an initial expose event
when the window has actually appeared on the screen.
  Also, I think the starting point for draw string is
left corner of the baseline of the string - so a y of 0 is not good!
You might be able to see some of the descenders,
but not the primary text......
  Finally, the default foreground color on a new gc is 0.
Bummer if that's the same as the background color of the
window widget.  Safer to use window's black_gc :-), or set the foreground
color.

HTH,
Donna
----- Original Message -----
From: Martin Eriksen <martin1710 hotmail com>
To: <gtk-app-devel-list gnome org>
Sent: Tuesday, February 27, 2001 10:04 AM
Subject: hello world problem


I am trying to draw some simple text on a widget using gtk_draw_string.
However the string is not displayed;
the window remains empty. Any suggestions as to how to make the string
appear?

#include <gtk/gtk.h>

int main(int argc, char *argv[])
{
  GtkWidget *window;
  GdkGC *gc;
  GdkFont* gfont;
  gtk_init (&argc, &argv);


gfont=gdk_font_load("-adobe-helvetica-bold-r-normal--12-120-75-75-p-70-iso88
59-1"
);
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_show (window);
  gc=gdk_gc_new(window->window);
  gdk_draw_string (window->window, gfont,gc, 0,0,"hello world");
  gtk_widget_draw (window, NULL);
  gtk_main ();
  return(0);
}

Compile-command:
gcc temp.c -o temp `gtk-config --cflags --libs`


_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.


_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]