RE: [gtk-list] Entry widget default size
- From: "Olivier Nenert" <onenert condumex com mx>
- To: <gtk-list redhat com>
- Subject: RE: [gtk-list] Entry widget default size
- Date: Tue, 25 Jan 2000 10:14:49 -0600
I'm not sure this could be the correct answer,
but still...
I don't think you can actually specify a size in characters, as this size
will depend on the
text, if you don't use a fixed font. maybe you could just find the max size,
for the widest chars..
say, if you want 6 chars, you would evaluate the size of string "MMMMMM".
then to know its size in pixels, you can obtain the style from the entry,
then the font from the entry,
then the width in pixels from the entry....
so you would have a function like this:
/*
* take size in chars, and return max size in pixels
*
*/
guint my_entry_get_size_chars(GtkEntry *entry, guint num_chars)
{
gchar *string;
int i;
guint size;
g_return_val_if_fail(entry!=NULL, 0);
g_return_if_fail(GTK_IS_ENTRY(entry), 0);
string=g_new(gchar, num_chars+1)
for(i=0;i<num_chars;i++)
string[i]='M';
string[i]='\0';
size=gdk_string_width(GTK_WIDGET(entry)->style->font, string);
/* so far, there wasno need for the entry to actually BE an entry :) */
/* size+= whatever_additional_space_required_by_entry */
/* should have a look at gtkentry.c to find out what paddingis used, or
whatever... */
g_free(string);
return(size);
}
correct me if I'm wrong..
hoppe this helps...
cheers
Olivier.
-----Mensaje original-----
De: Timothy M. Shead <tshead@k-3d.com>
Para: gtk-list@redhat.com <gtk-list@redhat.com>
Fecha: Martes, 25 de Enero de 2000 06:00 a.m.
Asunto: [gtk-list] Entry widget default size
>I'm creating a scrollbar next to an entry widget, within an hbox:
>
>_______________________________
>| |
>| GtkHBox |
>|________________ ___________ |
>|| | | ||
>|| GtkHScrollbar | | GtkEntry ||
>||_______________| |__________||
>|______________________________|
>
>
>The problem is that the entry "wants" to be too wide. Ideally, the entry
>should be a fixed width, wide enough for 6-7 characters, with remaining
room
>going to the scrollbar. The only way I've been able to accomplish this
>behaviour is to force the entry size using gtk_widget_set_usize;
>unfortunately this sets the size in pixels, which I'm assuming could be a
>problem, depending on the users' fonts/themes/etc. Is there any way to set
>the width of an entry box in characters?
>
>Thanks in advance,
>Timothy M. Shead
>tshead@k-3d.com
>
>--
>To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]