Re: RE : RE : drawing and erasing text



Hi Dominique,

Do yourself a favour and take the time to get rid of the use of XOR for
drawing and erasing. You'll have to keep a backing store of your data and
restore it when erasing. I've done the same thing for creating a rubber band
distance measuring tool in my image viewer giv. (Look at giv-backstore.cc
and giv-backstore.h(*)). Even better use of existing canvas frameworks, e.g.
goocanvas, that does all the job for you. The only reason I can think of for
not using the canvas is if you have huge data sets and you can't afford the
time and space overhead of the canvas frameworks.

Regarding XOR, besides being ugly, you'll suffer because you can't use cairo
and pango for a modern anti-aliasing, as well as easy exporting and
printing.

(*) The backstore class is still suffering from flickering because it erases
the old rubber band line by restoring the background, and only after the
background has been restored, does it paint the new rubberband line. I've
been planning to take care of this, but never got around to it.

Regards,
Dov

2009/2/24 POULAIN DOMINIQUE (AREVA TA) <dominique poulain1 areva com>

Hello Tor,

I know that the gdk_font family functions and gdk_draw_string are
deprecated, I use them because it was  easier for me when I translate my
XWindows plotting part on my sotfware to Gdk (in order to port the entire
software from Linux to Windows). Using Pango layout and gtk_draw_layout
leads to same problem : the text is not drawn in Xor mode (we can see also
that the colour is not the same for the lines and text).

The Xor mode is a smart and easy way to erase some drawing (more than
saving and restoring the original plot under each text notes, each axe's
tics... we must calculate the involved region, and what to do when a note to
erase is near a another one we want to keep). I will be sorry if I dont find
a solution !

The CbExpose callback was called repeated over and over by the use in the
sample program of gtk_widget_modify_bg. I replace it by
 gdk_window_set_background that doesn't change the background ! and at last
I use gtk_draw_rectangle to paint the entire drawing area in the background
colour I want.

In the XWindows, I use a XChangeWindowAttributes to set the backing store
which prevents to have to redraw the plot when another window comes over a
part of the drawing. With the backing store, no expose event is send in
these cases. Is there a way to obtain the same beahivior with Gdk ?  If not,
I will use a pixmap to save and restore quickly the plot rather than
redrawing billion of points on each expose event.

The use of setlocale is for trying to have the buttons from stock in
French. In fact, the problem is when I distribute my software on Windows,
Gtk seems to not find the .../share/locale/fr/LC_MESSAGES/gtk20.mo and the
button are in English. Is there a path to set ?

The last problem is about the tree view with multiple selection. On
Windows, when I use Ctrl or Shift keys and left click to select multiple
items, it works fine until I select three or four items : suddenly the tree
is collapsed. It seems to be the same with demo program of GTK.

Thank you for your answer.


-----Message d'origine-----
De : tlillqvist gmail com [mailto:tlillqvist gmail com] De la part de Tor
Lillqvist
Envoyé : lundi 23 février 2009 15:59
À : POULAIN DOMINIQUE (AREVA TA)
Cc : gtk-app-devel-list gnome org
Objet : Re: RE : drawing and erasing text

Hmm, do you know that the gdk_font_* and gdk_draw_string() APIs are
deprecated and de facto unmaintained? Whether some aspect of it works
fully or not on Windows is hardly interesting at this point.

When I run your program both in Linux and Windows, the CbExpose
callback is called repeatedly over and over. Does that happen for you,
too? I wonder why that happens.

By the way, the XLFD you pass to gdk_font_load_for_display,
"-adobe-helvetica-medium-r-normal--10-100-75-75-p-56-iso8859-1" is way
too specific and probably works only on the distro and combination of
package versions you happen to be using. No matching font was found on
openSUSE 11.1, for instance. (Instead, I just used
"-*-fixed-medium-r-normal--*-100-*-*-c-*-iso8859-1")  (But as I said,
using the XLFD-based font API is deprecated anyway.)

You call  setlocale(LC_ALL, "fr"). Note that the setlocale() function
in the Microsoft C library used on Windows in general does not accept
locale names in the form commonly used on Unixes, using ISO639
language codes and ISO3166 country codes. But just out of luck, for
"fr" it happens to work apparently, but not in general for locale
codes like "fr_CA", "sv" or "de" for instance.

--tml

_______________________________________________
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]