Re: GtkEntry right aligned/justified (and Solution)
- From: Steffen Gutmann <gutmann ieee org>
- To: Olexiy Avramchenko <olexiy irtech cn ua>
- Cc: gtk-list gnome org
- Subject: Re: GtkEntry right aligned/justified (and Solution)
- Date: Mon, 23 Feb 2004 12:08:30 +0900
Hello Olexiy!
I tried your 'solution' for obtaining right-aligned GtkEntries. Thanks
for the modified entry example, it compiled and run without problems.
[...] I solve this with connecting to GtkEntry' "expose-event" :
static gboolean set_layout_align(GtkEntry *entry)
{
PangoLayout *pl;
pl = gtk_entry_get_layout(entry);
pango_layout_set_width(pl,
GTK_WIDGET(entry)->allocation.width*PANGO_SCALE);
pango_layout_set_alignment(pl, PANGO_ALIGN_RIGHT);
return FALSE;
}
It sets layout width equal width of GtkEntry every time before real
expose handler pops up.
Modified "entry" sample from GTK+ tarball coming attached.
However, there are a few odd things when using this method:
1) text gets clipped at the right end. This is because there are
additional borders at the left and right end which you didn't consider.
This could be fixed though.
2) Mouse clicks still believe the entry is left aligned and you get a
strange behavior.
3) When the text is larger than the allocation can hold, you get a
strange behavior, too.
After all, I think, your solution is more like a 'hack' that needs more
tuning for making it really work. But it is a good start and it made me
spent a few hours looking into the source code of gtk+-2.2.2 and writing
a new version of GtkEntry.
I modified the original gtkentry.[ch] source and added two functions
void gtk_entry_set_justify(GtkEntry *entry, GtkJustification jtype);
GtkJustification gtk_entry_get_justify(GtkEntry *entry);
I went through major parts of the source and made sure, mouse clicks,
drag'n drop, text selection, etc. are handled correctly. So far I didn't
experience any problems so I would like to open my solution to other
developers. I put my replacments here:
http://www.informatik.uni-freiburg.de/~gutmann/gtk/gtkentry.h
http://www.informatik.uni-freiburg.de/~gutmann/gtk/gtkentry.c
and if you do a diff to the original version, you will find out they
only differ at a few places.
Ideally, I would like to see these changes in a future version of gtk.
Are the developers of gtk reading this list, or should I send another
message to the developer list?
Kind regards,
Steffen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]