[comp.windows.x] resource lookup problem

john@cluster.cs.su.oz.au (John Mackin) (10/03/90)

We are running X11R3 on some machines and X11R4 (at fix-12) on others.
I have the following resource loaded into my RESOURCE_MANAGER:

*Scrollbar.Translations:        <Btn1Down>: StartScroll(Backward) \n\
 <Btn2Down>: StartScroll(Continuous) MoveThumb() NotifyThumb() \n\
 <Btn3Down>: StartScroll(Forward) \n\
 <Btn2Motion>: MoveThumb() NotifyThumb() \n\
 <BtnUp>: NotifyScroll(Proportional) EndScroll()

(I want to reverse the functions of button 1 and button 3.)

This works perfectly under the X11R3 and X11R4 xterms; however, I
recently started trying to use the X11R4 xman, and found that the
scrollbars worked in reverse to what I wanted.  I eventually found
that I could work around it by specifying the names of the scrollbars
instead of the class:

xman*scrollbar.Translations:    <Btn1Down>: StartScroll(Backward) \n\
 <Btn2Down>: StartScroll(Continuous) MoveThumb() NotifyThumb() \n\
 <Btn3Down>: StartScroll(Forward) \n\
 <Btn2Motion>: MoveThumb() NotifyThumb() \n\
 <BtnUp>: NotifyScroll(Proportional) EndScroll()
xman*vertical.Translations:     <Btn1Down>: StartScroll(Backward) \n\
 <Btn2Down>: StartScroll(Continuous) MoveThumb() NotifyThumb() \n\
 <Btn3Down>: StartScroll(Forward) \n\
 <Btn2Motion>: MoveThumb() NotifyThumb() \n\
 <BtnUp>: NotifyScroll(Proportional) EndScroll()

But surely this should not be necessary.  Can anyone tell me what I am
doing wrong?  Thanks in advance.

-- 
John Mackin, Basser Department of Computer Science,
	     University of Sydney, Sydney, Australia; <john@cs.su.oz.AU>
``Reading your standard output doesn't sound like a very good idea to me.''

aw@cellar.bae.bellcore.com (Andrew Wason) (10/04/90)

In article <1239@cluster.cs.su.oz.au>,
 john@cluster.cs.su.oz.au (John Mackin) writes:
> I have the following resource loaded into my RESOURCE_MANAGER:
> 
> *Scrollbar.Translations:        <Btn1Down>: StartScroll(Backward) \n\
>  <Btn2Down>: StartScroll(Continuous) MoveThumb() NotifyThumb() \n\
>  <Btn3Down>: StartScroll(Forward) \n\
>  <Btn2Motion>: MoveThumb() NotifyThumb() \n\
>  <BtnUp>: NotifyScroll(Proportional) EndScroll()
> 
> This works perfectly under the X11R3 and X11R4 xterms; however, I
> recently started trying to use the X11R4 xman, and found that the
> scrollbars worked in reverse to what I wanted.  I eventually found
> that I could work around it by specifying the names of the scrollbars
> instead of the class:
> 
> xman*scrollbar.Translations:    <Btn1Down>: StartScroll(Backward) \n\
>  <Btn2Down>: StartScroll(Continuous) MoveThumb() NotifyThumb() \n\
>  <Btn3Down>: StartScroll(Forward) \n\
>  <Btn2Motion>: MoveThumb() NotifyThumb() \n\
>  <BtnUp>: NotifyScroll(Proportional) EndScroll()
> xman*vertical.Translations:     <Btn1Down>: StartScroll(Backward) \n\
       ^^^^^^^^
I couldn't find any widgets/subwidgets named vertical in xman.

>  <Btn2Down>: StartScroll(Continuous) MoveThumb() NotifyThumb() \n\
>  <Btn3Down>: StartScroll(Forward) \n\
>  <Btn2Motion>: MoveThumb() NotifyThumb() \n\
>  <BtnUp>: NotifyScroll(Proportional) EndScroll()


The scrollbar in xman is actually a subwidget of a compound widget
called ScrollByLineWidget.  According to OReilly Vol. 4,
you can't directly set the resources of a compound widgets subwidget.

However, I tried the following variations of setting the
scrollbar subwidgets resources:


All four of these worked:
   xman -xrm "*Scrollbar.foreground: green"
   xman -xrm "*scrollbar.foreground: green"
   xman -xrm "xman*scrollbar.foreground: green"
   xman -xrm "xman*Scrollbar.foreground: green"


Neither of these worked:
   xman -xrm "*Scrollbar.Translations: <Btn3Down>: StartScroll(Forward) \n\
        <BtnUp>: NotifyScroll(Proportional) EndScroll()"
   xman -xrm "*scrollbar.Translations: <Btn3Down>: StartScroll(Forward) \n\
         <BtnUp>: NotifyScroll(Proportional) EndScroll()"


Both of these worked:
   xman -xrm "xman*Scrollbar.Translations: <Btn3Down>: StartScroll(Forward) \n\
         <BtnUp>: NotifyScroll(Proportional) EndScroll()"
   xman -xrm "xman*scrollbar.Translations: <Btn3Down>: StartScroll(Forward) \n\
         <BtnUp>: NotifyScroll(Proportional) EndScroll()"


So, if you aren't allowed to directly access a subwidgets resources,
why did all four of the "foreground" resource settings work?
Also, why does setting "Translations" work when you specify
xman as part of the resource, and fail when you don't?

Is there a section of the MIT R4 docs that discusses compound widgets?
All I could find was a small section (11.5) in OReilly Vol. 4.


Thanks,
Andrew

--------------------------------------------------------------------------------
Andrew Wason                                        Bell Communications Research
aw@cellar.bae.bellcore.com                          Piscataway, NJ
bellcore!cellar!aw

brossard@sasun1.epfl.ch (Alain Brossard EPFL-SIC/SII) (10/04/90)

In article <27499@bellcore.bellcore.com>, aw@cellar.bae.bellcore.com (Andrew Wason) writes:
] In article <1239@cluster.cs.su.oz.au>,
]  john@cluster.cs.su.oz.au (John Mackin) writes:
] > I have the following resource loaded into my RESOURCE_MANAGER:

> Neither of these worked:
>    xman -xrm "*Scrollbar.Translations: <Btn3Down>: StartScroll(Forward) \n\
>         <BtnUp>: NotifyScroll(Proportional) EndScroll()"
>    xman -xrm "*scrollbar.Translations: <Btn3Down>: StartScroll(Forward) \n\
>          <BtnUp>: NotifyScroll(Proportional) EndScroll()"
> 
> 
> Both of these worked:
>    xman -xrm "xman*Scrollbar.Translations: <Btn3Down>: StartScroll(Forward) \n\
>          <BtnUp>: NotifyScroll(Proportional) EndScroll()"
>    xman -xrm "xman*scrollbar.Translations: <Btn3Down>: StartScroll(Forward) \n\
>          <BtnUp>: NotifyScroll(Proportional) EndScroll()"
> 
> 
  I can add that the following never worked for me, but I think
that it should:
Xman*translations:  #override \
        <Key>Q: Quit() \n\
        <Key>F8: Quit() \n\
        <Key>/: PopupSearch()

-- 

Alain Brossard, Ecole Polytechnique Federale de Lausanne,
	SIC/SII, EL-Ecublens, CH-1015 Lausanne, Suisse
brossard@sasun1.epfl.ch

rlh2@ukc.ac.uk (Richard Hesketh) (10/04/90)

In article <27499@bellcore.bellcore.com> aw@cellar.bae.bellcore.com writes:
>In article <1239@cluster.cs.su.oz.au>,

>> xman*vertical.Translations:     <Btn1Down>: StartScroll(Backward) \n\
>       ^^^^^^^^
>I couldn't find any widgets/subwidgets named vertical in xman.

"vertical" is a sub-widget instance of a Scrollbar in the Viewport
widget class.

>The scrollbar in xman is actually a subwidget of a compound widget
>called ScrollByLineWidget.  According to OReilly Vol. 4,
>you can't directly set the resources of a compound widgets subwidget.

You can in resource files but not "directly" in applications unless you
know the widget id.  Some widget classes have resources which are the widget
id.s of their sub-objects or have convenience routines to return these ids.
Once you have the id. you can *try* setting resource values using a call
to XtSetValues().  However the compound widget will normally have final say
over which resources can be changed (i.e. refusal of geometry changes).

You may also *never* be able to change resources even using the resource
database because the compound widget creates its sub-objects with hard-wired
resource values given as arguments to XtCreate{Managed}Widget().
Widget programmers ought to be discouraged from hard-wiring-in sub-object
resource settings, however the Xt Intrinsics currently does not have any real
support for "Widget Class Defaults" for setting overridable defaults on
sub-objects, (R5 wish?).

>However, I tried the following variations of setting the
>scrollbar subwidgets resources:
>
	[ deleted ]
>
>So, if you aren't allowed to directly access a subwidgets resources,
>why did all four of the "foreground" resource settings work?
>Also, why does setting "Translations" work when you specify
>xman as part of the resource, and fail when you don't?

Setting resources via entries in a user defaults database requires that
these entries override any similar entries given in application and user
*Class* defaults files.  To override a default the entry must have a resource
name binding that is the same as or "tighter" than the one given in the
app-defaults file.  If you examine the Xman defaults file (normally installed
in somewhere like /usr/lib/X11/app-defaults/Xman), you will see that it sets
translations for quite a few widgets.

The Xman defaults file has "Xman" prepended to all the resource entries,
this is a bit of overkill and isn't really necessary.  It is probably also
the reason why adding "xman" to your resource entries makes them work ..
(hint: instance names have a tighter binding than class names).

>Thanks,
>Andrew

Moral: text editors aren't resource editors; you need to know too much 8-}

Richard Hesketh   :   @nsfnet-relay.ac.uk:rlh2@ukc.ac.uk
		  :   rlh2@ukc.ac.uk    ..!{mcsun|mcvax}!ukc!rlh2
Computing Officer, Computing Lab., University of Kent at Canterbury,
Canterbury, Kent, CT2 7NF, United Kingdom.
        Tel: +44 227 764000 ext 7620/7590      Fax: +44 227 762811