Parent document is top of "Motif FAQ (Part 4 of 9)"
Previous document is "103) How can I best add a large piece of text to a scrolled text"
Next document is "105) How can I highlight text in the Text widget?"

104)+ How can I get the correct colors for scrolled text widget

scrollbars (Sun only)?

[Last modified: Nov 97]

Answer:  Michael Hall <mhall@semy.com> writes:

I have found a fix to a bug which is common on SUN platforms.  The problem is
that the scroll bars on scrolled text widgets are not colored or shaded
correctly.


    scrolledWindowText2 = XtVaCreateManagedWidget("scrolledWindowText2",
            xmScrolledWindowWidgetClass,
            form1,
            XmNscrollBarDisplayPolicy, XmSTATIC,
            NULL );

    runValuesText = XtVaCreateManagedWidget("runValuesText",
            xmTextWidgetClass,
            scrolledWindowText2,
            XmNeditMode, XmMULTI_LINE_EDIT ,
            XmNeditable, FALSE,
            NULL );

    /* workaround a Motif bug - text widget scroll bars are wrong color,
       and not shaded. */
    /* by Michael Hall */

    /* just to get background */
    junkScroll = XmCreateScrollBar(form1, "junkScroll", NULL, 0);
    XtVaGetValues(junkScroll,
            XmNbackground, &junkPixel,
            NULL);
    XtVaGetValues(XtParent(runValuesText),
            XmNchildren, &kids,
            XmNnumChildren, &numkids,
            NULL);
    for (n=0;n<numkids;n++)
    {
       if (XmIsScrollBar(kids[n]))
       {
         XtVaSetValues(kids[n],
           XmNbackground, junkPixel,
           XmNshadowThickness, 30,
           XmNwidth, 200,
           XmNheight, 200,
           NULL);
         XmChangeColor(kids[n], junkPixel);
       }
    }

Parent document is top of "Motif FAQ (Part 4 of 9)"
Previous document is "103) How can I best add a large piece of text to a scrolled text"
Next document is "105) How can I highlight text in the Text widget?"