Re: right-justify text in entry
- From: Owen Taylor <otaylor redhat com>
- To: Egon Andersen <ean ishoejby dk>
- Cc: gtk-list <gtk-list gnome org>
- Subject: Re: right-justify text in entry
- Date: Mon, 4 Nov 2002 10:44:17 -0500 (EST)
Egon Andersen <ean ishoejby dk> writes:
> Hi,
>
> (GTK+-2.0)
> I'm trying to make text (numbers) right-justified in a GtkEntry, but I
> haven't been able to do it right.
> The best I've got until now is to use:
> gtk_widget_set_direction (entry, GTK_TEXT_DIR_RTL);
> but that is not a good solution, as it is setting the direction the
> text is entered, which is not quite the same as text justification,
> and gives a 'strange' cursor behaviour.
>
> Do anyone have a solution or a hint?
> I'm willing to make my own widget type, if someone can point me in the
> right direction to solve the problem.
Unfortunately, I don't think there is any real alternative to
cut-and-pasting GtkEntry, renaming it, and adding right
justification to it; I believe that basically all that is needed
is in gtk_entry_adjust_scroll():
if (gtk_widget_get_direction (GTK_WIDGET (entry)) == GTK_TEXT_DIR_LTR)
{
min_offset = 0;
max_offset = MAX (min_offset, logical_rect.width / PANGO_SCALE - text_area_width);
}
else
{
max_offset = logical_rect.width / PANGO_SCALE - text_area_width;
min_offset = MIN (0, max_offset);
}
Should be:
if (gtk_widget_get_direction (GTK_WIDGET (entry)) == GTK_TEXT_DIR_LTR &&
!right_justified)
{
...
}
[ Note, if your code isn't [L]GPL, then you'll need to create a separate
library to hold the cut-and-paste of GtkEntry ]
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]