lindholm@greve.ucs.ubc.ca (George Lindholm) (07/12/90)
How can I calculate the number of lines that will fit in a listWidget? I can't find any information on how to get information on the font currently being used (XtNfont returns something, what I don't know). lindholm@staff.ucs.ubc.ca George_Lindholm@mtsg.ubc.ca USERGNL@UBCMTSG.BITNET University of British Columbia Computing Services (604) 228-4375
dtj@caffeine.cray.com (Dean Johnson) (07/13/90)
#include <std/disclaimers.h> In article <8649@ubc-cs.UUCP> lindholm@greve.ucs.ubc.ca (George Lindholm) writes: >How can I calculate the number of lines that will fit in a listWidget? >I can't find any information on how to get information on the font currently >being used (XtNfont returns something, what I don't know). Something like the following function should give you an good approximation. -Dean -------- cut here ----------- #define FONTHEIGHT(a) ((a)->max_bounds.ascent + (a)->max_bounds.descent) lines_in_widget(w) Widget w; { static Dimension boxHeight; static XFontStruct *font; static Arg getargs[] = {{ XtNheight, (XtArgVal)&boxHeight }, { XtNfont, (XtArgVal)&font }}; XtGetValues(w, getargs, XtNumber(getargs)); return((int) (boxHeight / FONTHEIGHT(font))); }