[comp.windows.x.motif] Problem with Text widget and scrollbars

bmeyer@wilkins.iaims.bcm.tmc.edu (Barry Meyer) (03/21/91)

Hello!

I am having a problem getting the Motif Text widget to do
what I want it to do and have decided to post this to the
group for help. What I would like to do is as follows:

  I would like to have a simple text editor (multi line edit)
  that uses word-wrap. The editor would only display a 
  vertical scrollbar when needed (as the user entered more
  text).

I have tried to implement the above in two ways but it seems
that I can't have my cake and eat it too:

  1. First, I tried using XmCreateScrolledText to create
     the text window. I specified the following resources:

     XmNwidth,300
     XmNheight,300
     XmNeditMode,XmMULTI_LINE_EDIT
     XmNwordWrap,True
     XmNscrollHorizontal,False

     In this case, the vertical scrollbar just stays on (managed)
     all the time. From the manaul, I gathered that the Scrolled
     window is set for APPLICATION_DEINED and thus the scrollbar
     display policy is XmSTATIC. I only want the scrollbar to 
     come on when it is needed.

  2. My second attempt was to place a XmText widget into a
     scrolled window. But, this caused a different set of problems.
     When I resize my application window (i.e. the scrolled window),
     the clip window (viewport) stays a fixed size. So the text
     editor does not track with the resizing of the scrolled window.
     In (1.) above, the text editor resizes nicely when the application
     window is resized.

My main questions are:

Q: Can I implement the functionality I need using XmCreateScrolledText
   by modifying a resource (translation: Am I doing something stupid?).

Q: Or will I have to use the ScrolledWindow widget in an application
   defined mode, create my own scrollbar, and manage it (turn it on 
   and off)?

Barry Meyer        bmeyer@bcm.tmc.edu