[comp.windows.x.motif] how do I determine the width of a XmText widget?

jollyc@HPWARF.HP.COM (Jolly Chen) (08/16/90)

How do I determine the current width of a XmText widget in terms of
character spaces?  For example, if my XmText widget is inside a form and
the form is resized, I want to know how many characters are actually
being displayed.  The XmNcolumns resource is only the initial width,
right?  Also, how can I can determine what is currently displayed in the
text widget?  Note that this is different from the value inside the text
widget because of scrolling (even in single_line_edit mode) or resizing.
For example, if I have a 100 character string in my text widget and
only 10 characters are visible at a time, how do I find out which 10 are
being displayed?  I even looked at some of the fields in the internal
XmText structures but I didn't find the appropriate ones.

- Jolly Chen


Jolly Chen
Clinical Information Systems
Hewlett-Packard
Waltham, MA

jollyc@hpwarf.hp.com

mikey@eukanuba.wpd.sgi.com (Mike Yang) (08/18/90)

In article <9008161545.AA12056@hpwarf.HP.COM>, jollyc@HPWARF.HP.COM
(Jolly Chen) writes:
|> 
|> How do I determine the current width of a XmText widget in terms of
|> character spaces?  For example, if my XmText widget is inside a form
and
|> the form is resized, I want to know how many characters are actually
|> being displayed.  The XmNcolumns resource is only the initial width,
|> right?

No, this is updated to reflect the current state.  Note that XmNcolumns
has CSG access.

|> Also, how can I can determine what is currently displayed in the
|> text widget?  Note that this is different from the value inside the
text
|> widget because of scrolling (even in single_line_edit mode) or
resizing.

In Motif 1.1, check out XmTextXYToPos and XmTextPosToXY.  One problem
is that XmTextXYToPos doesn't seem to work correctly when there is
word wrap.  I found that XmTextPosToXY works okay.

These routines may or may not help you, depending on why you want to
know exactly what's displayed.  If you just want to know if there's
more to scroll to, XmTextPosToXY will do the trick since you can call
it with the last position in the text and see if it succeeds.

-----------------------------------------------------------------------
                 Mike Yang        Silicon Graphics, Inc.
               mikey@sgi.com           415/335-1786