[Fwd: Re: Newbie Q: What to use ...]
- From: Soren Kuula <dongfang bitplanet net>
- To: gtk-list gnome org
- Subject: [Fwd: Re: Newbie Q: What to use ...]
- Date: Sun, 04 Jul 2004 14:20:59 +0200
--- Begin Message ---
- From: Soren Kuula <dongfang bitplanet net>
- To: Jan-Marek Glogowski <glogow fbihome de>
- Subject: Re: Newbie Q: What to use ...
- Date: Sun, 04 Jul 2004 09:32:33 +0200
Jan-Marek Glogowski wrote:
Hi
From my first impression I think you can simply use a GtkDrawingArea and
GdkPixmap(s).
Look at GDK Docs -> Drawing Primitives, if you want to move from X to GDK.
 
Thank you, I have done that.
I think what confused me into thinking that GDK was not suitable, was 
those graphics contexts and color maps. Somehow, I got into thinking I 
could not easily define my own colors, but use some predefined sets. 
Meanwhile I have realized that is wrong :)
1) Stick with Xlib primitives for displaying ants ? OK, but I can't see
which kind of widget that will allow
   me to use XLib drawing primitives on it, or how to somehow extract
an XWindow from a widget
   
GDK Docs -> X Window System Interaction
 
I will look once more. As far as I can see, it will generally give me 
handles for GDK components if I have some for X components. I wanted to 
go the other way - build a GTK UI, and then just "pick" out some 
underlying X components, and draw on those.
Anyway, it seems GDK is much more suitable, and I will avoid messing 
around at levels of my GUI where I have nothing to do. And easier too :)
'
As long as you don't have [moving] objects (like sprites), you want to
handle like GtkObjects (signals, ...), GnomeCanvas may be overkill.
 
As for the Gnome canvas: I think the GDK below is just fine for me.
3) Use GDK primitives ? But I need to be able to control the color of
the ants directly. Can I somehow
   set the drawing foreground color in RGB directly ? Seems to me that
GDK was made for drawing
   widgets, not much more.
   
Any drawing is done using GDK Graphics Contexts (GdkGC)
gdk_gc_set_foreground( GdkGC, GdkColor ), with
struct GdkColor {
 guint32 pixel;
 guint16 red;
 guint16 green;
 guint16 blue;
};
Simply create some GC with you required colors after widget realization,
if you just need some, and free them at unrealization.
 
Rrrrrrright.
Now my whole UI window will consist of
- a widget (Drawable) with the battlefield map, in whatever colors the 
ants request
- the usual bunch og GTK widgets
I have seen some general advice that one should use the same color map 
for all widgets in an UI. But I suppose that in this case it will be 
perfectly all right to install my special "ant" color map on only the 
battlefield widget ?
How do you want to handle window resize?
 
For the battlefield view: Verboten and meaningless anyway.
The game's logic does, however, resize the battlefield for each game in 
a tournament - I suppose if I carefully scrap and re-initialize the 
backing pixbuf in a configure event, everything should be handled 
automatically for me.'
The debugger view could be resizeable. The view is a magnified version 
of a small area of the battlefield - each pixel is boosted to 30x30 or 
so, and decorated with diagnostics information and widgets to control 
breakpoints, and display even more diagnostics info. That could be made 
resizeable. I suppose a resize could be translated into resizing the 
area magnified (luxury, elegance :) ), and that I can do that by just 
throwing out all data and rebuilding from scratch.
Do you want to support scrolling a larger image?
 
Not a must. Are there any viewport widgets that handle that 
automatically ? (Ok I really should look for myself).
Thanks a lot for the effort ! I solved part of it myself already, but 
confirmation is nice.
You can see the game at
www.myrekrig.dk
It's written by a Ph.D. student here some years ago, and as you can see 
(download, at software tab) the code is quite ugly. But the idea is 
brilliant !
The ant BayiMayi is my work.
Cheers,
Soren
--- End Message ---
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]