Makefile for GTK2 programs?

2010-08-18 Thread Juhana Sadeharju

What CFLAGS and LIBS I should use in Makefiles?
I installed GTK2 to home directory, and thus I won't use lddconfig.
My programs should take all from ~/gtk2/, and nothing from
/usr/include/gtk-1.2/ and nothing gtk-related from /usr/lib/.

GTK2 does not have gtk-config program. It made things easier
in gtk1.2:

  CC=gcc -O2 -Wall
  CFLAGS = `gtk-config --cflags`
  LIBS= `gtk-config --libs` -lm -ljpeg -lpng

Is there away to get all CFLAGS and LIBS by checking the pkgconfig file?
  ~/gtk2/lib/pkgconfig/gtk+-2.0.pc

I have now the following in Makefile. Very messy. It does not work;
I get errors: undefined reference to `gtk_text_view_new' and the like.

  CC=gcc -O2 -Wall
  CFLAGS= -I/home/juhana/gtk2/include/glib-2.0 
-I/home/juhana/gtk2/include/gtk-2.0 -I/home/juhana/gtk2/lib/glib-2.0/include 
-I/home/juhana/gtk2/include/cairo -I/home/juhana/gtk2/include/pango-1.0 
-I/home/juhana/gtk2/lib/gtk-2.0/include -I/home/juhana/gtk2/include/atk-1.0
  LIBS= -L/home/juhana/gtk2/lib -lgtk -lgdk -rdynamic -lgmodule -lglib -ldl 
-lXi -lXext -lX11 -lm -ljpeg -lpng

  O_ESPBROWSER=mylib/filesdirs.o mylib/buffer.o mylib/image.o mylib/gsl_taus.o 
mylib/clock.o mylib/mmapfile.o mylib/sprint.o mylib/arrays.o espbrowser.o

  all:: espbrowser

  espbrowser: $(O_ESPBROWSER)
  $(CC) $(CFLAGS) -o espbrowser $(O_ESPBROWSER) $(LIBS)


I use this include command in the C code:
  #include /home/juhana/gtk2/include/gtk-2.0/gtk/gtk.h
I'm afraid it won't help because gtk.h uses
  #include gdk/gdk.h
which may be /usr/include/gtk-1.2/gdk/gdk.h.


How the linked ld works? My programs are simple. Perhaps I could
write a script to compile and link everything explicitly. But this
include file business worries me still.

This is so frustating. I will return to GTK 1.2 soon.
First Ubuntu failed to install GTK2, and now this!

I could start writing my programs under demos/gtk-demo/ and compile
the demo. But then I don't understand how to add my mylib/mmapfile.o
etc. files to the configure system. :-(

Help needed.

___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


GTK2 compilation error / Cairo

2010-08-09 Thread Juhana Sadeharju

What went wrong in this compilation?
Should I search and delete one parenthesis somewhere?

juh...@dante:~/compiled/gtk2/cairo-1.8.10$ make
make  all-recursive
make[1]: Entering directory `/home/juhana/compiled/gtk2/cairo-1.8.10'
Making all in src
make[2]: Entering directory `/home/juhana/compiled/gtk2/cairo-1.8.10/src'
make  all-am
make[3]: Entering directory `/home/juhana/compiled/gtk2/cairo-1.8.10/src'
../doltcompile gcc -DHAVE_CONFIG_H -I. -I..  -I. -I/home/juhana/gtk2/include/pix
man-1  -I/usr/include/freetype2 -I/usr/include/libpng12
-g -O2 -MT cairo-analysis-surface.lo -MD -MP -MF .deps/cairo-analysis-surfac
e.Tpo -c -o cairo-analysis-surface.lo cairo-analysis-surface.c
../doltcompile: 2: Syntax error: ( unexpected
make[3]: *** [cairo-analysis-surface.lo] Error 2
make[3]: Leaving directory `/home/juhana/compiled/gtk2/cairo-1.8.10/src'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/juhana/compiled/gtk2/cairo-1.8.10/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/juhana/compiled/gtk2/cairo-1.8.10'
make: *** [all] Error 2

___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


GUI quickly?

2009-02-10 Thread Juhana Sadeharju

This is related to open source free project, please help.

I have described variables this way:
NPC / Weight, float
NPC / AI Data / Mood, list of choices here

What are possibilities for creating GUI with minimal work?
I may group variables to groups, one per window.
I may group variables to subgroups, one per tab.
I may add widget type IDs if that is not clear.
But, using Glade to built the windows is too time-consuming.

Of course, when a value has been edited in GUI, I should
receive message: NPC / Weight changed to 3.14, etc.

Juhana
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Glade (Re: What widgets in TES Construction Set?)

2008-10-20 Thread Juhana Sadeharju

About Glade. I tried to create something simple (which I don't
remember now) it didn't succeed. The menubar was simple, but
this equally simple thing was too hard. I will check it again
and post to glade lists someday.

It would be nice if there would be complete examples which
could be grabbed and dragged to the project. This equals to
adding complete subgraph of widgets to the project.

For other project, I need an audio waveform display with
callbacks and with overdrawn controls (draggable selection edge)
and displays (playhead time display moving with the pointer).
It would be nice if I could grab an example of this kind of
thing, and then modify it to my taste in Glade.

Such an audio waveform display may require multiple pixmaps.
If waveform is moved forward, only the new revealed waveform
is drawn, and the rest are copied. One pixmap could contain the
waveform and other the controls (which are widgets), the final
rendering then composite of the two pixmaps.
All the code making the framwork work could be part of the Glade
(not the waveform drawing, not the audio reading).

Then if I have an Open File dialog, I would want Glade to generate
me a framework code for opening the audiofile at background
thread, if necessary. If the waveform drawing LOD file is missing
it needs to be generated and that may take time. At meanwhile user
should be able to continue editing of other audio.

Threads etc. are standard part of modern software so they should
be easily available. If Glade searches for means to extends its
cababilities, this would be the way.

Juhana
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Using a key to generate mouse button press?

2008-10-20 Thread Juhana Sadeharju

My software uses Alt modifier but the Alt key is now
blocked by Gnome. A quick solution is to use key presses
for generating mouse button presses.

How to generate them?

A method found from the mail archives is

  win = gdk_window_at_pointer(wx, wy);
  event.type = GDK_BUTTON_PRESS;
  event.button.send_event = True;
  event.button.window = win;
  event.button.x = wx;
  event.button.y = wy;
  event.button.state = 0;
  event.button.button = Button1;
  event.button.source = GDK_SOURCE_MOUSE;
  event.button.x_root = (double)newx;
  event.button.y_root = (double)newy;
  gdk_event_put(event);


Problem 1: I catch key presses at the top window because I could
not get them working with a drawing area. How to get the pointer
position with respect to the drawing area? How to know if the
pointer is in the drawing area? There is no point in sending the
event if pointer is somewhere else.

Problem 2: Why I should fill the pointer position at all?
I just want generate the mouse button press (with modifier Alt),
and to get GTK/GDK in process of doing the rest, like checking the
pointer position, the active window, and widget.

Problem 3: While sending a mouse button press from the code is
interesting, how my application could catch the Alt modifier?
When my software is in use (focus, enter etc.) the Alt modifier
flow should be guided to my software instead of Gnome.

Juhana
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


What widgets in TES Construction Set?

2008-10-18 Thread Juhana Sadeharju

Hello. What GUI items can be seen in these images:
http://www.funet.fi/~kouhia/tescs-objectwindow.png
http://www.funet.fi/~kouhia/tescs-lightwindow.png
http://www.funet.fi/~kouhia/tescs-regionwindow.png

They are from TES Construction Set which is used to modify
the Oblivion game. Note that user may grab and move the
vertical lines in the label row of the spreadsheet, for
revealing or hiding the text.

I tried Glade but soon found that plain GTK is more for my
taste. In Glade, good is that all the widget properties are
listed, no guess work. Bad was that I could not do what
I wanted.

My application includes OpenGL/GPU graphics. Is the gtkglext
preferred choice? Is everything possible with it? I have
no idea how 2D graphics and 3D GPU-graphics are mixed in
gnome/gtk/gtkglext.

Juhana
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GTK+ canvas?

2006-09-18 Thread Juhana Sadeharju
From: Havoc Pennington [EMAIL PROTECTED]

I can't think of more than a short list of layout managers that would be 
widely used. Application-specific layouts could be useful though, e.g. 
put these items in a circle or flow items around this item or 
something like that.

Constraints libraries such as Qoca or Cassowary could be used.

Because I'm up to OpenGL-only GUI, I have also thought of if
game physics/collision libraries such as ODE or Bullet could be
used for layout and other constraints. There is already a Physics
Processing Unit (PSU) in hardware which could manage fairly
large GUIs.

Juhana
-- 
  http://music.columbia.edu/mailman/listinfo/linux-graphics-dev
  for developers of open source graphics software
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: graphics!!

2006-05-08 Thread Juhana Sadeharju

I think you may need to use a canvas. For example:
http://developer.gnome.org/doc/API/2.0/libgnomecanvas/index.html
http://www.dachaplin.dsl.pipex.com/goocanvas/

Do they have a graph widget? Or are they more primitive?

I need such a widget in audio apps:
(1) Envelopes drawn over the audio waveform widget.
(2) Frequency response curves of multiple parametric filters
drawn in one canvas.
(3) Control envelopes.

Much of the stuff what can be seen in VST plugins, in Absynth
(specially envelopes), Waves' plugins, etc. They look nice too
unlike what I most see here.

Does GTK canvases provide transparency? What programs uses the
canvases? I might want see how they look like.

With gtkglext/opengl all seems to be eventually simpler.
Multiple widgets can be combined by using suitable transparency
and depth coordinates. Decorations are done easily, e.g., by
modeling objects in 3D. But then I cannot use the GTK widgets
indistinctly. Interaction with the opengl objects comes a problem
as well, making it tempting to use, e.g., OSG (openscenegraph.org).
But that is a large software and written with C++, which could be
a problem if I want code in C.

How would GTK's Cairo integration help? If at all.

Juhana
-- 
  http://music.columbia.edu/mailman/listinfo/linux-graphics-dev
  for developers of open source graphics software
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


glib suggestions

2006-02-04 Thread Juhana Sadeharju

A few glib suggestions:

1. basename(3) don't accept the suffix removal as does the basename(1).
I have written/cloned basenamesuffix(3) but would like to have one in glib
if not available elsewhere.

2. I have written/cloned date(3) which is equivalent to date(1).
Note that strftime(3) does something similar, but if I remember
correctly, the reason for date(3) was the following use:

 sprintf(s,%i day,daynumber);
 t = date(s,%d%m);   // date(t,s,%d%m) could be of better style

strftime(3) may require exhausting computation for achieving the same.

3. Equivalent for mkdir -p or mkdirhier.

Juhana
-- 
  http://music.columbia.edu/mailman/listinfo/linux-graphics-dev
  for developers of open source graphics software
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: glib / String handling difficult

2006-01-11 Thread Juhana Sadeharju
From: Robert Thorpe [EMAIL PROTECTED]

Why is this needed in a graphical toolkit library?
Surely it's more appropriate to do it outside of GTK+.

glib *is* outside of gtk...?

the regex library in the glibc.

I don't remember now why it failed for me, but I tried.

Juhana
-- 
  http://music.columbia.edu/mailman/listinfo/linux-graphics-dev
  for developers of open source graphics software
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


glib / String handling difficult

2006-01-08 Thread Juhana Sadeharju

Hello. I have always found string handling quite difficult in C.
It also looks like sed, awk, perl etc. cannot handle all of my
simple needs. Glib could be improved.

I need often an extractor which finds something from
an arbitrary data. I have routines file2buffer(), which
loads a file to buffer, and bufferfind(), which searches
for a string in the buffer. The file could be a html page
downloaded with wget or a mixed binary and ascii file.

Now more difficult example. I need to parse 12 pages in
a middle of a html page. For example, sscanf(%i pages,) yields
nothing even there is only one number pages in the file.
Now I first find the pages and move back over the 12 but
this is not simple.

The lexicar scanner in glib is nice, but a similar parser would
be needed as well. A parser to which the rules are feeded at
runtime -- not compiled as with flex/bison.
  p = parser_new();
  parser_add_rule(p,rule : token otherrule, callback);
  parser_add_rule(p,rule : alttoken anotherrule, altcallback);
  etc.
  parser_prepare(p); // converts rules to efficient execution data structure
  parser_input(p,text);

Then in my application, I could mix the bufferfind() with several
miniparsers. And I could define miniparsers as needed in app's
dialog without compiling anything.

Juhana
-- 
  http://music.columbia.edu/mailman/listinfo/linux-graphics-dev
  for developers of open source graphics software
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Drawing 1-bit bitmaps

2005-11-01 Thread Juhana Sadeharju
From: George Williams [EMAIL PROTECTED]

So I continue to believe that gdk does not support 1-bit client side
images. But I keep hoping I'm missing something. 

What library can load 1-bit images to a format GTK understands?
My 1-bit images have been very large, the library should be
able to extract only a rectangle from the image before converting
anything to 24-bit.

What library can handle tiled image formats?

Juhana
-- 
  http://music.columbia.edu/mailman/listinfo/linux-graphics-dev
  for developers of open source graphics software
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: canvas notes

2005-11-01 Thread Juhana Sadeharju

Hello. I did read this nearly two months old discussion.

It would be nice to have one scenegraph. Such scenegraph
can handle both 3D and 2D. See modern game engines how
they handle 3D and 2D renderings.

GTK already has a some sort of scenegraph built-in, because one
can trace all widgets starting from the top window. A code
was (re)posted recently in gtk lists somewhere. A better
scenegraph could be written. (Could openscenegraph, openinventor,
coin3d, etc. be used? 3D comes free.)

Scenegraph is very easy to use if the user operates on the graph
explicitly. Compare Glade and XXL (graph editor) for GUI authoring.
With Glade they suggest to predesign the GUI (on paper?).

Custom widgets can be built using existing nodes, but more
efficient widgets can be hardcoded later. Compare to Csound's
instruments (script) and opcodes (C coding of script).
This gives means to easily test new widget ideas.

Two different zoom modes can be found: one where the whole
rendering is scaled and another where individual objects are
scaled (fonts in Mozilla). In scenegraph, the first means
that the doc's top node is affected, and the second means that
individual objects under the doc's top node are affected.

Resolution-independent font renderings can be nowadays performed
in GPU.


david.bellot wrote:
On the other handl, it is very seducing to think about an underlying
canvas for the whole desktop (evas, display pdf, etc...) but that would
mean we must rewrite almost all GTK lower levels. Not very productive at
all.

Game engine authors have done the same when they switched to
OpenGL or to DirectX. Switch was very productive.


From: Damon Chaplin [EMAIL PROTECTED]
I think you should take it one step at a time, i.e first get a 2D
zoomable, printable, cairo canvas working, then think about 3D.
Otherwise you'll probably spend the next year just discussing what
features should be in it!

Scenegraph is very modular as one may first have a basic set of nodes
and then may later expand the set of nodes. I have always kept 3D
side easier to implement first. Then 2D is programmed with constraints
and/or with special nodes. Openscenegraph etc. have already extensive
3D nodes and some 2D nodes.


From: Gustavo J. A. M. Carneiro [EMAIL PROTECTED]
2. (like Jean Br�©afort says) OpenGL is not printable, and IMHO all
applications should have a print option for any useful data they
produce. (by print I mean either on paper or to PDF file).

I'm not exactly sure what you mean by printable.
The scenegraph is nice in sense that objects may have different
interpretations. How otherwise 3D animators could edit and save
their animations? How otherwise a renderer or a editor could output
alternatively an image or a line drawing?


From: Alexander Larsson [EMAIL PROTECTED]
Interestingly, this is pretty much how Microsoft seem to be handling 3D
in Avalon, as can be seen in this blog entry:
http://blogs.msdn.com/greg_schechter/archive/2004/05/22/139744.aspx

Not all of scenegraph needs to be rendered with one method.
Not every node need to have built-in support for every rendering
architecture. The system may modify the scenegraph for managing
different architectures. All 2D nodes may be moved out of 3D
part if needed. In comparison, GTK now has a fixed scenegraph
built by the application programmer. So, GTK is quite limited.


From: Alexander Larsson [EMAIL PROTECTED]
All programs that exist can be programmed on a universal turing machine.
That is interesting, but doesn't mean that people actually develop on
turing machines. OpenGL as an API is clearly targeted towards drawing of
3D scenes, and is not at all what you want when you're writing a
predominantly 2D graphical user interface, whereas Cairo is an ideal API
for this.

Popular widget system FLTK was earlier programmed with GL.
Then they re-wrote it in X/GTK-way.

Blender uses OpenGL for all rendering. That made Blender very
easy to port to other systems. I'm not exactly sure if 3D and 2D
are all in one scenegraph, but I remember reading such plans
recently.

In fact, the system which Blender uses (scenegraph plus dependency
graph) would be needed in GTK as well. I have already though if
I could use Blender as a GUI for my applications.

Juhana
-- 
  http://music.columbia.edu/mailman/listinfo/linux-graphics-dev
  for developers of open source graphics software
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: Very slow gdk_draw_pixbuf

2005-09-05 Thread Juhana Sadeharju
From: Barry Demchak [EMAIL PROTECTED]

I am trying to use gdk_draw_pixbuf to render a .PNG into a window via a 
pixmap. (Actually, this is a much simplified case of trying to use librsvg 
to render into a window.)
[ ... ]
 pixbuf = gdk_pixbuf_new_from_file((gchar *) mapserv.png, NULL);

How big is this image?
Even the file size would be small, the vector renderings can be huge
in pixels. X falls back to the network connection if the shared memory
is not large enough.

Juhana
-- 
  http://music.columbia.edu/mailman/listinfo/linux-graphics-dev
  for developers of open source graphics software
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Key for screenshots?

2005-04-04 Thread Juhana Sadeharju

Hello. I'm puzzling how to implement the following most conveniently.
Help, anyone?

The screenshot application should take the whole screen screenshot
when I press F1 key. It should work even if my application
would not have focus. In fact, I would be using a web browser
actively when I would take a screenshot. The web browser would
have the pointer and the keyboard focuses. It even could be that
I'm dragging something with the pointer. The screenshot application
GUI would not be even visible; the shots would be saved to numbered
files, they would not be displayed on the screen.

The key used to take screenshots will be one which is not used
in the web browser. The web browser is only an example, and thus
the feature cannot be added to the web browser itself. I could
be using a 3D graphics editor as well.

The screenshot taking code itself should not be the problem because
we already have several screenshot applications. The GTK app could
listen to a pipe for the key events coming from an external keyboard
program. Should I code the keyboard program as GTK app as well?
Can it be done? Can the whole system be coded as a single GTK application?

Juhana
-- 
  http://music.columbia.edu/mailman/listinfo/linux-graphics-dev
  for developers of open source graphics software
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Canvas API proposal

2005-02-15 Thread Juhana Sadeharju

I would agree on the scenegraph as the storage of objects.

Canvas or not, I need a system which both draws objects (e.g.,
polygons) and provides interactive control of the objects.

Perhaps polygons are poor example because they make people
think GtkDrawingArea. What if I want make a slider which is
drawn with OpenGL, probably drawn and moved in 3D (e.g.,
a lever). That lever should have equally simple API as
the GTK slider has; both are widgets.

Consider a moment that the canvas would be an OpenGL only.
The canvas should have a system for simultaneous handling of
3D objects and of 2D GUI objects. Both drawn with OpenGL.
In scenegraph this would probably mean perspective and orthogonal
transformation nodes, and a drawing order node.

Juhana
-- 
  http://music.columbia.edu/mailman/listinfo/linux-graphics-dev
  for developers of open source graphics software
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: GTK+ and Bangla language

2005-02-03 Thread Juhana Sadeharju
From: Gian Mario Tagliaretti [EMAIL PROTECTED]
 
 Here is my complain:
 I cannot type Bangla (Indic language) texts in any GTK depended software.

I don't think is fair to complain on a software that is brougth to you
by volunteers.
Read the licence for further information about the product.

The mailing list software should replace the word complain with
report automatically so that some of us don't understand the
message wrong.

Complain must be extra negative word that it makes people to
see red without reason.

Juhana
-- 
  http://music.columbia.edu/mailman/listinfo/linux-graphics-dev
  for developers of open source graphics software
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: RFC: Part 1 of new GObject tutorial

2004-07-22 Thread Juhana Sadeharju
From: Ryan McDougall [EMAIL PROTECTED]

Therefore I'm asking everyone with some experience to give it a read
over for technical mistakes, or unclear language.

Please place it to a webpage, thanks. It was cutoff from the digest.

Juhana
-- 
  http://music.columbia.edu/mailman/listinfo/linux-graphics-dev
  for developers of open source graphics software
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Proper way to provide gtk+ app with asynchronous data?

2004-07-12 Thread Juhana Sadeharju
From: Dmitry M. Shatrov [EMAIL PROTECTED]

[ ... ]

Here is my suggestion: create the thread, which handles the input and
the critical processing, before initializing GTK. Create a separate
process if necessary. This way you don't need enter/leave pairs.

In an audio level meter, I would create a thread for reading the audio
data from the card. The same thread processes the audio and generates
the level information.

The GUI thread would receive the information in a form which is
suitable for displaying. If data is a stream, then the sample rate
of the information must be lower than the display refresh rate,
e.g., 20 times per second. Lock-free fifos are used. If the data is
not a stream, GUI may read periodically the shared memory variables
for information. Some information may be missed (but nothing important
in the example).

The GUI callback may be launched by sending a wake-up byte to a pipe
which is watched by the GUI. The level information is still read
via shared memory.

The time critical audio thread/process may run with soft-realtime
privileges and the GUI may run normally.

 -*-

I have a similar problem: gtkglext has the shapes.c demo. The display
gets slow because my extended shapes.c draws the bunny. The slowness
is ok, but the pop-up menu raises only after the drawing has ended.
More, I want to process motion notify events while the bunny is
drawn. Does the enter/leave pair help here? How I should place
them in the shapes.c? (gtkglext.sourceforge.net)

Juhana
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Pango offscreen at client side?

2004-07-01 Thread Juhana Sadeharju

Hello. I solved the problem.

I did check pangoft2topgm.c but because installer did not found
the freetype2 in RedHat, I could not use it. If I modify the code to
use X fonts, then there is another problem:
  gdkdisplay = gdk_display_get_default();
  xdisplay = 
  context = pango_x_get_context(xdisplay);
How to get Display as returned by XOpenDisplay()?

The working code is included below. I only added code to clean
the pixmap before the text is drawn on to it. The mailing list
archives have mostly GTK related solutions, but here is now GDK
related code. The font is not pretty, though.

I could not figure out how to free some of the objects. Anyone?

There might not be more inefficient way to get fonts to opengl
application.

Juhana

 == cut ==
// Generates the opengl quad data for the given text.
void glpangofont_new(char *s, int *quads, float **quaddata)
{
  PangoContext *context;
  PangoLanguage *language;
  PangoFontDescription *font_desc;
  PangoLayout *layout;
  int width,height;
  GdkPixmap *pixmap;
  GdkGC *gc;
  GdkColor colorb,colorw;
  GdkImage *image;
  int k,x,y;
  float *q;
  float scale;

  context = gdk_pango_context_get();
  language = gtk_get_default_language();
  pango_context_set_language (context, language);
  pango_context_set_base_dir (context, PANGO_DIRECTION_LTR);

  font_desc = pango_font_description_from_string (courier 12);
  pango_context_set_font_description (context, font_desc);

  layout = pango_layout_new(context);
  pango_layout_set_alignment (layout, PANGO_ALIGN_LEFT);
  pango_layout_set_text (layout, s, -1);
  pango_layout_get_pixel_size (layout, width, height);

  pixmap = gdk_pixmap_new(NULL,width,height,8);
  gc = gdk_gc_new(pixmap);
  colorw.red = 0x; 
  colorw.green = 0x; 
  colorw.blue = 0x; 
  colorb.red = 0x; 
  colorb.green = 0x; 
  colorb.blue = 0x;
  gdk_gc_set_foreground(gc,colorw);
  gdk_gc_set_background(gc,colorw);
  gdk_draw_rectangle (pixmap, gc, TRUE, 0, 0, width, height);
  gdk_gc_set_foreground(gc,colorb);
  gdk_gc_set_background(gc,colorw);
  gdk_draw_layout(pixmap, gc, 0, 0, layout);
  image = gdk_drawable_get_image (pixmap, 0, 0, width, height);

  // Count font pixels.
  k = 0;
  for (y = 0; y  height; y++) {
for (x = 0; x  width; x++) {
  if (gdk_image_get_pixel(image,x,height-1-y) == 0) {
k++;
  }
}
  }

  q = array_float(k*4*2); // One xy xy xy xy makes a quad.

  // Gen quads. Height will be 1.0.
  scale = 1.0/(float)height;
  k = 0;
  for (y = 0; y  height; y++) {
for (x = 0; x  width; x++) {
  if (gdk_image_get_pixel(image,x,height-1-y) == 0) {
q[8*k+0] = (float)x*scale;
q[8*k+1] = (float)y*scale;
q[8*k+2] = (float)x*scale;
q[8*k+3] = (float)(y+1)*scale;
q[8*k+4] = (float)(x+1)*scale;
q[8*k+5] = (float)(y+1)*scale;
q[8*k+6] = (float)(x+1)*scale;
q[8*k+7] = (float)y*scale;
k++;
  }
}
  }

  pango_font_description_free(font_desc);

  *quads = k;
  *quaddata = q;
}

// Renders the opengl quad data.
void glpangofont_draw(int quads, float *quaddata)
{
  int i;
  float x1,x2,x3,x4;
  float y1,y2,y3,y4;

  for (i = 0; i  quads; i++) {
x1 = quaddata[i*8+0];
y1 = quaddata[i*8+1];
x2 = quaddata[i*8+2];
y2 = quaddata[i*8+3];
x3 = quaddata[i*8+4];
y3 = quaddata[i*8+5];
x4 = quaddata[i*8+6];
y4 = quaddata[i*8+7];
glVertex3f(x1,y1,0.0);
glVertex3f(x2,y2,0.0);
glVertex3f(x3,y3,0.0);
glVertex3f(x4,y4,0.0);
  }
}
 == end ==
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Pango offscreen at client side?

2004-06-29 Thread Juhana Sadeharju

How hard it can be? I spend several hours in compiling the following
code from various sources (there seems to be no good standalone
example) and it does not work. The text is corrupted with noise.

  PangoContext *context;
  PangoLanguage *language;
  PangoFontDescription *font_desc;
  PangoLayout *layout;
  GdkPixmap *pixmap;
  GdkImage *image;
  int width,height;

  // context = pango_context_new();
  context = gdk_pango_context_get();
  // language = pango_language_from_string();
  language = gtk_get_default_language();
  pango_context_set_language (context, language);
  pango_context_set_base_dir (context, PANGO_DIRECTION_LTR);

  font_desc = pango_font_description_from_string (courier 12);
  pango_context_set_font_description (context, font_desc);

  layout = pango_layout_new(context);
  pango_layout_set_alignment (layout, PANGO_ALIGN_LEFT);
  pango_layout_set_text (layout, Test, -1);
  pango_layout_get_pixel_size (layout, width, height);

  pixmap = gdk_pixmap_new(NULL,width,height,1); // 1-bit image
  gdk_draw_layout(pixmap, gdk_gc_new(pixmap), 0, 0, layout);
  image = gdk_drawable_get_image (pixmap, 0, 0, width, height);


Then gdk_image_get_pixel(image,x,y) is used to examine the pixel
values. The pixels are incorrect at this point.

Is gdk_gc_new(pixmap) correct way to get the required GC?

I have tested the 8-bit image as well. All results looks like
in the screenshot at http://www.funet.fi/~kouhia/enved4.png;
(texts are i01-i19 in the first column).
Note that the texts in the screenshot are not on a gdk drawable.
All texts together are composed of about 7000 opengl quads in 3D
space. The code above is used to generate the quads.

I wish there would be an easier way to generate texts. Because
modern fonts (Metafont, PostScript) are vector outline fonts,
Pango could give out a polygonal approximation of the outline
easily. The polygon could then be used to draw the texts in opengl.

Juhana
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: draw a 16bpp unindexed image on PC linux

2004-06-19 Thread Juhana Sadeharju
From:  John Cupitt [EMAIL PROTECTED]

gtk+-2.4.x/tests/testrgb

Chose visual type=true color depth=24, image bpp=32, lsb first
Color test time elapsed: 0.82s, 60.8 fps, 15.58 megapixels/s
Grayscale test time elapsed: 0.76s, 65.6 fps, 16.80 megapixels/s
Alpha test time elapsed: 18.28s, 2.7 fps, 0.70 megapixels/s
Alpha test (to pixmap) time elapsed: 18.15s, 2.8 fps, 0.71 megapixels/s

I keep OpenGL in mind. Apparently I have to write an object culling
system and perhaps a clipping system if I use pixbuf. My software
is already starting to look like OpenGL and it is puzzling what I should
implement and what I should leave to OpenGL or to GTK.

Juhana
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: draw a 16bpp unindexed image on PC linux

2004-06-18 Thread Juhana Sadeharju
From: John Cupitt [EMAIL PROTECTED]

http://developer.gnome.org/doc/API/2.0/gdk-pixbuf/index.html

you keep the image in memory as a 24 bit RGB and it will render
it to any display device for you (8, 16, 24, 32 bit etc.). Is that
what you need?

The demo looks great.

I wrote a software with GTK 1.*, but now I changed to GTK 2.0.
I did not change any code and I'm not sure should I change.

I draw to 24-bit RGB rowstrided image which I created with malloc.
I update the drawing area with gdk_draw_rgb_image().
The full update takes 80+ msec -- i.e., max frame rate is as low
as 12 frames per second. Drawing to RGB image takes time as well,
and so the frame rate drops too low. Image size is 900x600.

When little objects moves in the image, the update is not
a problem. How to get the full update faster? Are RGB images
wrong choise for that?

Is it wise to draw lines to RGB image by drawing to drawable
and copying the content to pixbuf? I would not want re-write
drawing routines? Should I use some other drawing library?
gegl? libart? svg something? OpenGL?

Juhana
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: On Click event for an image

2004-06-18 Thread Juhana Sadeharju
From: Russell Shaw [EMAIL PROTECTED]

Chris W wrote:
 I am thinking that the best way to get the look I want for the 
 calculator simulator I want to create is to have one graphic for 
 keyboard.  So I need to respond to clicks and then know where on the 
 image they clicked so I can then figure out what button is at that 
 point.How do you do that?

Read the button-press coordinates from a GtkDrawingArea that has a
picture of the keypad on it. You'll need to manually define where
the hot areas for each button lie.

Have another image of the same size than the calculator keyboard
image. Code the number and operation keys to color codes. Get the
coordinates from GtkDrawingArea and check the color code from the
another image. Convert the color code to key.

If you make the keyboard image with image manipulation software
(like GIMP), it should be easy to select the color codes and
paint over the keys. Select the colors numerically. You may
check the color numbers from the ascii table.

Juhana
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Show and Hide Menu Items

2004-06-10 Thread Juhana Sadeharju
From: Bobby King [EMAIL PROTECTED]

How does one show and hide menu items? At various states of an
application, I want only a specific subset of menu items to be visible
(accessible). Each state is entered by selecting a specific menu item.

That must be a hard problem because I have not seen a good solution to
it. Until I come up with an elegant solution, I don't waste time
for writing messy code like others.

Here is what I have come up so far:

Keep a set of active menu items (and key and mouse operations). Go that
set through and turn on/off menu items (and KMO). For each state, write
a list of allowed menu items (and KMO). You may need to keep a separate
always-active set (like New Window which is always on). You may need to
have different groups, each group having one active state (like
a customable spline editor in two different editors: one group for
editors, another for splines).

Then when updating, make the set of active menu items empty, go through
all active states, and re-build the set of active menu items, and update
the menus.

It is a hierarchical system (main app -- editor -- subeditor).
Active sets could be pushed to a stack, but may need a stack for
each part of the application (like multiple editors in the same
window).

In a webbrowser, the parent script may forbid menu items to appear
in the child window. It might be we also need different set operations:
union, substraction.

It is a hard problem if anyone asks me. A good solution should be
a part of GTK.

The discussion could continue in gtk-devel-list.

Regards,
Juhana
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Displaying Image

2004-06-10 Thread Juhana Sadeharju
From: John Cupitt [EMAIL PROTECTED]

  GtkWidget *image = gtk_image_new_from_file (myfile.png);

But what if I want load the image to memory without creating
the widget? I would later then map/morph the image and display it.

The loaded image should stay at the computer which runs my app,
and not go to the X display computer. What gtk_image_new_from_file()
does in this context?

Is there glib_image_new_from_file()? I would not like to use
any external image library.

Regards,
Juhana
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: GTK+ books

2004-02-08 Thread Juhana Sadeharju
From: Jack Chen [EMAIL PROTECTED]

Hi, I think the official GTK programming tutorial on the official GTK's
site is the best resource for programming GTK I've found.

So, the situation is pretty bad.

I checked drawing area widget page in the tutorial but it is empty.
The drawing area widget is at the top among widgets where I start
wishing better documentation and tools. It is the place where GTK+
ends too soon.

Regards,
Juhana
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: GTK+ books

2004-02-08 Thread Juhana Sadeharju
From:  Sven Neumann [EMAIL PROTECTED]

 I checked drawing area widget page in the tutorial but it is empty.
 The drawing area widget is at the top among widgets where I start
 wishing better documentation and tools. It is the place where GTK+
 ends too soon.

There are the two scribble examples in the GTK+ tutorial that explain
GTK+/GDK drawing pretty well.

I find it difficult to keep up various states of the tools
which I want code.

I have a modification of the original scribble which has a small
rectangle drawing area by default, and more drawing areas can be
added by pressing a button. All drawing areas can be grabbed and
moved, in wich case they raise at front and follow the pointer.
It has a couple of states and tmp variables used when dragging,
but the code looks messy.

Some kind of state graph routines with state variables would be nice.
I have gathered papers on these topics and people have written
some kind of state graph systems. Perhaps similar could be provided
by GTK.

My modified scribble has evolved to software which with I can
paint on large float RGB images. Again the images can be grabbed
and dragged. Now the problem is that I don't anymore have multiple
drawing areas which naturally isolates the events -- now I have to
provide my own routines to maintain the multiple images (because
all events go to one place only: to drawing area).

If the GTK widget system would be extended inside the OpenGL
(see my Widget Portal mail in gtk-app-devel), then I could
create one polygon per image, receive events to polygons, have
callbacks for each polygon. Image rotations and zooms would be
easy now, and they could be painted on.

As said, it all stops to drawing area. Beyond that I have to
start from scratch.

BTW, I'm still looking toward the GIMP rectangle selection tool.
It may take while because I yet again started doing a perfect
job: first a constraint based system, then any vector manipulations
are easier to do. When I grab a selection tool edge or vertex,
I just set up a constraint which forces the rectangle (or part of
it) to follow pointer implicitly. The rectangle tool is simple but
I want save the trouble when I want a more complex tool.

That kind of systems could be part of GTK.

Regards,
Juhana
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list