Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!sdd.hp.com!ucsd!ucbvax!KITCHEN.BELLCORE.COM!aw From: aw@KITCHEN.BELLCORE.COM (Andrew Wason, aw@cellar.bae.bellcore.com) Newsgroups: comp.windows.x.motif Subject: Re: Resizing with an XmScrolledWindow Message-ID: <9010311757.AA03169@bellcore.bellcore.com> Date: 31 Oct 90 16:07:36 GMT References: <3659@stl.stc.co.uk> Sender: daemon@ucbvax.BERKELEY.EDU Distribution: inet Organization: The Internet Lines: 71 mcsun!ukc!stl!tap@uunet.uu.net writes: > I am trying to get an XmScrolledWindow to size itself correctly to > a given child widget. What I mean by correctly is :- > > 1) if only vertical scrolling enabled, size the clip window to > the width of the child widget. Leave the clip window height > to whatever default is set. > > 2) if only horizontal scrolling enabled, size the clip window > to the height of the child widget. Leave the width alone > > 3) if scrolling in both directions is enabled, set the width > and height of the clip window to some specified value I don't know what you mean by "enabled". If your XmNscrollBarDisplayPolicy is XmAS_NEEDED (see below) then the scrollbars will only be displayed if your work area widget is too big. When using XmAUTOMATIC mode, you don't explicitly enable/disable the scrollbars - they get enabled/disabled depending on the size of the work area child. > [...] > static Arg ViewportArgs[] = { > {XmNscrollBarPlacement,XmTOP_LEFT}, > {XmNspacing,0}, > {XmNscrollingPolicy,XmAUTOMATIC}, > {XmNscrollBarDisplayPolicy,XmSTATIC}, > {XmNvisualPolicy,XmCONSTANT} > }; XmNscrollBarDisplayPolicy should be XmAS_NEEDED or else the scrollbars will always be displayed. For your item #1, you want only the vertical scrollbar, so you must set the width of the XmScrolledWindow to be the width of the work area. Since you must take into account the width of the vertical scrollbar too, it is best to use XtQueryGeometry as the manual suggests: intended.request_mode = CWHeight | XtCWQueryOnly; intended.height = 75; XtQueryGeometry(scrolledWin, &intended, &preferred); XtVaSetValues(scrolledWin, XmNwidth, preferred.width, NULL); The XtQueryGeometry will cause scrolledWin to return the correct width in preferred.width (this is the width which will cause the horizontal scrollbar to disappear). For your item #2, you want only the horizontal scrollbar. You need to do basically the same thing as above, but set the height of the scrolledWin: intended.request_mode = CWWidth | XtCWQueryOnly; intended.width = 75; XtQueryGeometry(scrolledWin, &intended, &preferred); XtVaSetValues(scrolledWin, XmNheight, preferred.height, NULL); For item #3, you want both scrollbars, so just set the width/height of scrolledWin to be less than the width/height of your work area child. Andrew -------------------------------------------------------------------------------- Andrew Wason Bell Communications Research aw@cellar.bae.bellcore.com Piscataway, NJ bellcore!cellar!aw