Colors, key_presses, and PNGs
- From: katre <katre mousetrap c64 org>
- To: gtk-list redhat com
- Subject: Colors, key_presses, and PNGs
- Date: Tue, 9 Mar 1999 08:14:45 -0500 (EST)
Okay, I got a lot of coding done this weekend, and ran into a few problems I
can't make heads or tails of. So it's time for a lot of dumb questions to be
sent to the list. :)
Background: I'm writing a frontend for an interpreter. The front end needs to
open a window, write text into that window at any point, in any of 9 fonts and
in any of 12 colors. I need to be able to erase parts of the screen to the
background color, display a PNG image, and accept input. After looking at
what's out there (GtkText, GtkConsole), and realizing none did what I want,
I've gone on to write my own widget, which will do some things, and not do
others. My problems are :
1) Colors - Here's what I've been doing.
GdkColor *fg, *bg;
GdkGC *gc;
GdkPixmap *pm;
fg = malloc(sizeof(GdkColor));
bg = malloc(sizeof(GdkColor));
gdk_color_parse("red", &fg);
gdk_color_parse("blue", &bg);
gc = gdk_gc_new (widget->window);
gdk_gc_set_foreground (gc, fg);
gdk_gc_set_background (gc, bg);
gdk_draw_text (pm, font, gc, 0, 0, "Hello world!", strlen("Hello world"));
gdk_draw_pixmap (widget->window, gc, pm, 0, 0, 0, 0, width, height);
This appears to be what is done in the scribble example, but instead of
drawing in the colors I want, this will give me an entirely black window. Can
anyone tell what I'm doing wrong?
2) key_press - I have given my widget a widget_class->key_press entry, and set
the event mask in widget_realize to be gtk_get_events() | GDK_EXPOSURE_MASK |
GDK_KEY_PRESS_MASK. What else do I need to do to receive key presses?
3) PNG - The png files that this interpreter will use are packaged in a
resource file with the interpreted program and some other data. I can read in
the PNG data, but the only way I've found to draw it is to write it to a
temporary file, then let gdk_imlib open the file. Can I get gdk_imlib to work
with a chunk of data in memory? Or is this not possible?
Thanks you all for reading this, and thank you more if you see any solutions.
John 'katre' Cater
katre@mousetrap.c64.org
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]