ScrView.st
changeset 2009 853cece96ee7
parent 2008 1d02c2e994b6
child 2010 ca8dcc8723dc
equal deleted inserted replaced
2008:1d02c2e994b6 2009:853cece96ee7
     1 "
       
     2  COPYRIGHT (c) 1989 by Claus Gittinger
       
     3 	      All Rights Reserved
       
     4 
       
     5  This software is furnished under a license and may be used
       
     6  only in accordance with the terms of that license and with the
       
     7  inclusion of the above copyright notice.   This software may not
       
     8  be provided or otherwise made available to, or used by, any
       
     9  other person.  No title to or ownership of the software is
       
    10  hereby transferred.
       
    11 "
       
    12 
       
    13 SimpleView subclass:#ScrollableView
       
    14 	instanceVariableNames:'scrolledView vScrollBar hScrollBar scrollBarPosition lockUpdates
       
    15 		hideVScrollBar hideHScrollBar hasHorizontalScrollBar
       
    16 		hasVerticalScrollBar horizontalMini verticalMini vScrollBarHidden
       
    17 		hScrollBarHidden'
       
    18 	classVariableNames:'DefaultScrolledViewLevel DefaultScrolledViewMargin
       
    19 		DefaultScrollBarSpacing DefaultScrolledViewBorderWidth
       
    20 		DefaultLevel DefaultScrollBarLevel MyDefaultViewBackgroundColor'
       
    21 	poolDictionaries:''
       
    22 	category:'Views-Basic'
       
    23 !
       
    24 
       
    25 !ScrollableView class methodsFor:'documentation'!
       
    26 
       
    27 copyright
       
    28 "
       
    29  COPYRIGHT (c) 1989 by Claus Gittinger
       
    30 	      All Rights Reserved
       
    31 
       
    32  This software is furnished under a license and may be used
       
    33  only in accordance with the terms of that license and with the
       
    34  inclusion of the above copyright notice.   This software may not
       
    35  be provided or otherwise made available to, or used by, any
       
    36  other person.  No title to or ownership of the software is
       
    37  hereby transferred.
       
    38 "
       
    39 !
       
    40 
       
    41 documentation
       
    42 "
       
    43     a view containing a scrollbar and some other (slave-)view.
       
    44     This view wraps scrollbar(s) around the view to be scrolled.
       
    45     The scrollbars are setup to send scrollUp/scrollDown/scrollVerticalTo
       
    46     and scrollLeft/scrollRight/scrollHorizontalTo- messages whenever moved.
       
    47     The view itself has to implement these (there is a default implementation
       
    48     in the common View class for this - so your widgets usually dont have to
       
    49     care for this).
       
    50 
       
    51     For the scrollbars to know about the full (maximum) size, the view
       
    52     MUST implement #heightOfContents and/or #widthOfContents.
       
    53     The values returned by those methods are used to compute the fraction
       
    54     which is visible (i.e. the scrollers thumb heights).
       
    55 
       
    56     There are three ways to setup a scrollableView:
       
    57     if the type of the view to be scrolled is known in advance,
       
    58     use:
       
    59 	v := ScrollableView for:<ViewClass>
       
    60     or:
       
    61 	v := ScrollableView for:<ViewClass> in:someSuperView
       
    62 
       
    63 
       
    64     otherwise, create an empty scrollableView with:
       
    65 
       
    66 	v := ScrollableView new
       
    67     or:
       
    68 	v := ScrollableView in:someSuperView
       
    69 
       
    70     and define the view later with:
       
    71 
       
    72 	v scrolledView:aViewToBeScrolled
       
    73 
       
    74 
       
    75     Finally, if the view to be scrolled has been already created,
       
    76     use:
       
    77 
       
    78 	v := ScrollableView forView:aViewToBeScrolled
       
    79     or:    
       
    80 	v := ScrollableView forView:aViewToBeScrolled in:someSuperView
       
    81 
       
    82     It is also possible to change the scrolledView later (even multiple times).
       
    83     This may be useful, if different views are needed to display different types
       
    84     of data (see example2) and at creation time, it is not known what type
       
    85     of view is required (multidocument format applications).
       
    86 
       
    87     If you want to scroll a bucnh of other views (instead of a views contents),
       
    88     you need a companion class (ViewScroller). See the documentation there.
       
    89 
       
    90     If you need horizontal scrolling too, use an instance of HVScrollableView.
       
    91 
       
    92     By default, scrollbars are full size scrollbars - for horizontal scrolling
       
    93     (which is less often used), scrollableViews can optionally be created with
       
    94     miniscrollers which take up less screen space.
       
    95 
       
    96     TODO:
       
    97 	this is pretty old and needs a rewrite. There are quite some
       
    98 	historic leftovers found here and things can be done better
       
    99 	(especially in initializeFor...)
       
   100 
       
   101 	Also, it should be rewritten into one class which supports both
       
   102 	Vertical-only, Horizontal-only and HV scrolling.
       
   103 	Currently, horizontal-only scrolling is not available.
       
   104 	(you have to write your own class ...)
       
   105 
       
   106 	Finally, some means to hide scrollbars should be added - this would
       
   107 	give more screenspace to the view when all is visible 
       
   108 	(and therefore, the scrollbars are not needed, anyway)
       
   109 
       
   110 	Expect the above things to be fixed in an upcoming version.
       
   111 
       
   112     Recent changes:
       
   113 	Originally, there where two classes, for vertical-only and
       
   114 	horizontal+vertical scrollability.
       
   115 	These have now been merged into the common ScrollableView class,
       
   116 	and each scrollability can be controlled individually.
       
   117 	The original HVScrollableView class is almost empty, but remains
       
   118 	for backward compatibility (it simply initializes the scrollability
       
   119 	flags for H+V scrollability).
       
   120 
       
   121     [author:]
       
   122 	Claus Gittinger
       
   123 
       
   124     [see also:]
       
   125 	ScrollBar Scroller
       
   126 	 HVScrollableView
       
   127 "
       
   128 !
       
   129 
       
   130 examples
       
   131 "
       
   132   simple scrolled text:
       
   133 									[exBegin]
       
   134 	|top scr txt|
       
   135 
       
   136 	top := StandardSystemView label:'scroll example1'.
       
   137 	top extent:200@100.
       
   138 
       
   139 	scr := ScrollableView for:EditTextView in:top.
       
   140 	scr origin:0.0@0.0 corner:1.0@1.0.
       
   141 	txt := scr scrolledView.
       
   142 
       
   143 	txt list:#('line1'
       
   144 		   'line2'
       
   145 		   'line3'
       
   146 		   'line4'
       
   147 		   'line5'
       
   148 		   'line7'
       
   149 		   'line8'
       
   150 		   'line9'
       
   151 		   'line10'
       
   152 		  ).
       
   153 	top open
       
   154 									[exEnd]
       
   155 
       
   156 
       
   157   changing the scrolledView later:
       
   158 									[exBegin]
       
   159 	|top scr txtView1 txtView2 browserView|
       
   160 
       
   161 	top := StandardSystemView label:'scroll example2'.
       
   162 	top extent:300@100.
       
   163 
       
   164 	scr := ScrollableView in:top.
       
   165 	scr origin:0.0@0.0 corner:1.0@1.0.
       
   166 
       
   167 	top open.
       
   168 
       
   169 	(Delay forSeconds:5) wait.
       
   170 
       
   171 	txtView1 := EditTextView new.
       
   172 	txtView1 list:#(
       
   173 			'wait 5 seconds to see the other text'
       
   174 			'line2'
       
   175 			'line3'
       
   176 			'line4'
       
   177 			'line5'
       
   178 			'line7'
       
   179 			'line8'
       
   180 			'line9'
       
   181 			'line10'
       
   182 		  ).
       
   183 	scr scrolledView:txtView1.
       
   184 
       
   185 	(Delay forSeconds:5) wait.
       
   186 
       
   187 	txtView2 := EditTextView new.
       
   188 	txtView2 list:#('this is the other views text' 
       
   189 			'alternative line2'
       
   190 			'alternative line3'
       
   191 			'alternative line4'
       
   192 			'alternative line5'
       
   193 			'alternative line6').
       
   194 	scr scrolledView:txtView2.
       
   195 									[exEnd]
       
   196 
       
   197 
       
   198 
       
   199 
       
   200   using a miniscroller:
       
   201 									[exBegin]
       
   202 	|top scr txt|
       
   203 
       
   204 	top := StandardSystemView label:'scroll example3'.
       
   205 	top extent:200@100.
       
   206 
       
   207 	scr := ScrollableView for:EditTextView miniScroller:true in:top.
       
   208 	scr origin:0.0@0.0 corner:1.0@1.0.
       
   209 	txt := scr scrolledView.
       
   210 
       
   211 	txt list:#('line1'
       
   212 		   'line2'
       
   213 		   'line3'
       
   214 		   'line4'
       
   215 		   'line5'
       
   216 		   'line7'
       
   217 		   'line8'
       
   218 		   'line9'
       
   219 		   'line10'
       
   220 		  ).
       
   221 	top open
       
   222 									[exEnd]
       
   223 
       
   224 
       
   225 
       
   226   scrolling in both directions:
       
   227     Notice: HVScrollableView remains existent for backward compatibility;
       
   228 	    scrollability can now be controlled in both directions at any
       
   229 	    time (see examples below).
       
   230 									[exBegin]
       
   231 	|top scr txt|
       
   232 
       
   233 	top := StandardSystemView label:'scroll example4'.
       
   234 	top extent:200@100.
       
   235 
       
   236 	scr := HVScrollableView for:EditTextView in:top.
       
   237 	scr origin:0.0@0.0 corner:1.0@1.0.
       
   238 	txt := scr scrolledView.
       
   239 
       
   240 	txt list:#('line1'
       
   241 		   'line2'
       
   242 		   'line3'
       
   243 		   'line4'
       
   244 		   'line5'
       
   245 		   'line7'
       
   246 		   'line8'
       
   247 		   'line9'
       
   248 		   'line10'
       
   249 		  ).
       
   250 	top open
       
   251 									[exEnd]
       
   252 
       
   253 
       
   254 
       
   255   using a full scroller vertically, miniscroller horizontally:
       
   256     Notice: HVScrollableView remains existent for backward compatibility;
       
   257 	    scrollability can now be controlled in both directions at any
       
   258 	    time (see examples below).
       
   259 									[exBegin]
       
   260 	|top scr txt|
       
   261 
       
   262 	top := StandardSystemView label:'scroll example5'.
       
   263 	top extent:200@100.
       
   264 
       
   265 	scr := HVScrollableView for:EditTextView miniScrollerH:true in:top.
       
   266 	scr origin:0.0@0.0 corner:1.0@1.0.
       
   267 	txt := scr scrolledView.
       
   268 
       
   269 	txt list:#('line1'
       
   270 		   'line2'
       
   271 		   'line3'
       
   272 		   'line4'
       
   273 		   'line5'
       
   274 		   'line7'
       
   275 		   'line8'
       
   276 		   'line9'
       
   277 		   'line10'
       
   278 		  ).
       
   279 	top open
       
   280 									[exEnd]
       
   281 
       
   282 
       
   283 
       
   284   using miniscrollers for both directions:
       
   285     Notice: HVScrollableView remains existent for backward compatibility;
       
   286 	    scrollability can now be controlled in both directions at any
       
   287 	    time (see examples below).
       
   288 									[exBegin]
       
   289 	|top scr txt|
       
   290 
       
   291 	top := StandardSystemView label:'scroll example6'.
       
   292 	top extent:200@100.
       
   293 
       
   294 	scr := HVScrollableView for:EditTextView miniScroller:true in:top.
       
   295 	scr origin:0.0@0.0 corner:1.0@1.0.
       
   296 	txt := scr scrolledView.
       
   297 
       
   298 	txt list:#('line1'
       
   299 		   'line2'
       
   300 		   'line3'
       
   301 		   'line4'
       
   302 		   'line5'
       
   303 		   'line7'
       
   304 		   'line8'
       
   305 		   'line9'
       
   306 		   'line10'
       
   307 		  ).
       
   308 	top open
       
   309 									[exEnd]
       
   310   controlling scrollability:
       
   311 									[exBegin]
       
   312 	|top scr txt|
       
   313 
       
   314 	top := StandardSystemView label:'scroll example6'.
       
   315 	top extent:200@100.
       
   316 
       
   317 	txt := EditTextView new.
       
   318         
       
   319 	scr := ScrollableView forView:txt in:top.
       
   320 	scr origin:0.0@0.0 corner:1.0@1.0.
       
   321 	scr horizontalScrollable:true.
       
   322 	scr verticalScrollable:false.
       
   323 
       
   324 	txt list:#('line1'
       
   325 		   'line2'
       
   326 		   'line3'
       
   327 		   'line4'
       
   328 		   'line5'
       
   329 		   'line7'
       
   330 		   'line8'
       
   331 		   'line9'
       
   332 		   'line10'
       
   333 		  ).
       
   334 	top open
       
   335 									[exEnd]
       
   336   controlling scrollability and miniScroller:
       
   337 									[exBegin]
       
   338 	|top scr txt|
       
   339 
       
   340 	top := StandardSystemView label:'scroll example6'.
       
   341 	top extent:200@100.
       
   342 
       
   343 	txt := EditTextView new.
       
   344 
       
   345 	scr := ScrollableView forView:txt in:top.
       
   346 	scr origin:0.0@0.0 corner:1.0@1.0.
       
   347 	scr horizontalScrollable:true; horizontalMini:false.
       
   348 	scr verticalScrollable:true; verticalMini:true.
       
   349 
       
   350 	txt list:#('line1'
       
   351 		   'line2'
       
   352 		   'line3'
       
   353 		   'line4'
       
   354 		   'line5'
       
   355 		   'line7'
       
   356 		   'line8'
       
   357 		   'line9'
       
   358 		   'line10'
       
   359 		  ).
       
   360 	top open
       
   361 									[exEnd]
       
   362   autohiding scrollbars (edit the text to make scrollbars visible/invisible)
       
   363   (NOTICE:
       
   364 	this is controlled by the styleSheet and 
       
   365 	should normally NOT be done by the program):
       
   366 									[exBegin]
       
   367 	|top scr txt|
       
   368 
       
   369 	top := StandardSystemView label:'scroll example6'.
       
   370 	top extent:200@100.
       
   371 
       
   372 	txt := EditTextView new.
       
   373 
       
   374 	scr := ScrollableView forView:txt in:top.
       
   375 	scr origin:0.0@0.0 corner:1.0@1.0.
       
   376 	scr horizontalScrollable:true; horizontalMini:false.
       
   377 	scr verticalScrollable:true; verticalMini:true.
       
   378 	scr autoHideScrollBars:true.
       
   379 
       
   380 	txt list:#('line1'
       
   381 		   'line2'
       
   382 		   'line3'
       
   383 		   'line4'
       
   384 		   'line5'
       
   385 		   'line7'
       
   386 		   'line8'
       
   387 		   'line9'
       
   388 		   'line10'
       
   389 		  ).
       
   390 	top open
       
   391 									[exEnd]
       
   392 "
       
   393 ! !
       
   394 
       
   395 !ScrollableView class methodsFor:'instance creation'!
       
   396 
       
   397 for:aViewClass
       
   398     "return a new scrolling view scrolling an instance of aViewClass.
       
   399      The subview is created here.
       
   400      The view will have full scrollbars."
       
   401 
       
   402     ^ self 
       
   403         for:aViewClass
       
   404         hasHorizontalScrollBar:self defaultHorizontalScrollable
       
   405         hasVerticalScrollBar:self defaultVerticalScrollable
       
   406         miniScrollerH:false 
       
   407         miniScrollerV:false 
       
   408         origin:nil
       
   409         corner:nil 
       
   410         in:nil
       
   411 
       
   412     "Created: 6.3.1997 / 18:06:22 / cg"
       
   413     "Modified: 6.3.1997 / 23:18:32 / cg"
       
   414 !
       
   415 
       
   416 for:aViewClass hasHorizontalScrollBar:hasH hasVerticalScrollBar:hasV miniScrollerH:miniH miniScrollerV:miniV 
       
   417     "return a new scrolling view scrolling an instance of aViewClass.
       
   418      The subview is created here.
       
   419      The view will have full scrollbars if the corresponding miniH/miniV
       
   420      is false, miniscrollers if true."
       
   421 
       
   422     |newView|
       
   423 
       
   424     aViewClass notNil ifTrue:[
       
   425 	newView := aViewClass new.
       
   426     ].
       
   427     ^ self
       
   428 	forView:newView
       
   429 	hasHorizontalScrollBar:hasH 
       
   430 	hasVerticalScrollBar:hasV 
       
   431 	miniScrollerH:miniH 
       
   432 	miniScrollerV:miniV 
       
   433 	origin:nil 
       
   434 	corner:nil 
       
   435 	in:nil
       
   436 
       
   437     "Created: 7.4.1997 / 19:00:14 / cg"
       
   438 !
       
   439 
       
   440 for:aViewClass hasHorizontalScrollBar:hasH hasVerticalScrollBar:hasV miniScrollerH:miniH miniScrollerV:miniV origin:org corner:corn in:aView
       
   441     "return a new scrolling view scrolling an instance of aViewClass.
       
   442      The subview is created here.
       
   443      The view will have full scrollbars if the corresponding miniH/miniV
       
   444      is false, miniscrollers if true."
       
   445 
       
   446     |newView|
       
   447 
       
   448     aViewClass notNil ifTrue:[
       
   449         newView := aViewClass new.
       
   450     ].
       
   451     ^ self
       
   452         forView:newView
       
   453         hasHorizontalScrollBar:hasH 
       
   454         hasVerticalScrollBar:hasV 
       
   455         miniScrollerH:miniH 
       
   456         miniScrollerV:miniV 
       
   457         origin:org 
       
   458         corner:corn 
       
   459         in:aView
       
   460 
       
   461     "
       
   462      |top scr|
       
   463 
       
   464      top := StandardSystemView extent:200@200.
       
   465      scr := ScrollableView for:nil
       
   466                  hasHorizontalScrollBar:true
       
   467                  hasVerticalScrollBar:true
       
   468                  miniScrollerH:false
       
   469                  miniScrollerV:false
       
   470                  origin:0.0@0.0
       
   471                  corner:1.0@1.0
       
   472                  in:top.
       
   473      top open
       
   474     "
       
   475 
       
   476     "Modified: 6.3.1997 / 18:36:01 / cg"
       
   477 !
       
   478 
       
   479 for:aViewClass in:aView
       
   480     "return a new scrolling view scrolling an instance of aViewClass.
       
   481      The subview is created here.
       
   482      The view will have full scrollbars."
       
   483 
       
   484     ^ self 
       
   485         for:aViewClass
       
   486         hasHorizontalScrollBar:self defaultHorizontalScrollable
       
   487         hasVerticalScrollBar:self defaultVerticalScrollable
       
   488         miniScrollerH:false 
       
   489         miniScrollerV:false 
       
   490         origin:nil
       
   491         corner:nil 
       
   492         in:aView
       
   493 
       
   494     "Modified: 6.3.1997 / 23:18:41 / cg"
       
   495 !
       
   496 
       
   497 for:aViewClass miniScroller:mini
       
   498     "return a new scrolling view scrolling an instance of aViewClass.
       
   499      The subview is created here.
       
   500      The view will have full scrollbars if mini is false, miniscrollers
       
   501      if true."
       
   502 
       
   503     ^ self 
       
   504         for:aViewClass
       
   505         hasHorizontalScrollBar:self defaultHorizontalScrollable
       
   506         hasVerticalScrollBar:self defaultVerticalScrollable
       
   507         miniScrollerH:mini 
       
   508         miniScrollerV:mini 
       
   509         origin:nil
       
   510         corner:nil 
       
   511         in:nil
       
   512 
       
   513     "Modified: 6.3.1997 / 23:18:45 / cg"
       
   514 !
       
   515 
       
   516 for:aViewClass miniScroller:mini in:aView
       
   517     "return a new scrolling view scrolling an instance of aViewClass.
       
   518      The subview is created here.
       
   519      The view will have full scrollbars if mini is false, miniscrollers
       
   520      if true."
       
   521 
       
   522     ^ self 
       
   523         for:aViewClass
       
   524         hasHorizontalScrollBar:self defaultHorizontalScrollable
       
   525         hasVerticalScrollBar:self defaultVerticalScrollable
       
   526         miniScrollerH:mini 
       
   527         miniScrollerV:mini 
       
   528         origin:nil
       
   529         corner:nil 
       
   530         in:aView
       
   531 
       
   532     "Modified: 6.3.1997 / 23:18:50 / cg"
       
   533 !
       
   534 
       
   535 for:aViewClass miniScroller:mini origin:org corner:corn in:aView
       
   536     "return a new scrolling view scrolling an instance of aViewClass.
       
   537      The subview is created here.
       
   538      The view will have full scrollbars if mini is false, miniscrollers
       
   539      if true."
       
   540 
       
   541     ^ self 
       
   542         for:aViewClass
       
   543         hasHorizontalScrollBar:self defaultHorizontalScrollable
       
   544         hasVerticalScrollBar:self defaultVerticalScrollable
       
   545         miniScrollerH:mini 
       
   546         miniScrollerV:mini 
       
   547         origin:org
       
   548         corner:corn 
       
   549         in:aView
       
   550 
       
   551     "Modified: 6.3.1997 / 23:18:53 / cg"
       
   552 !
       
   553 
       
   554 for:aViewClass miniScrollerH:miniH
       
   555     "return a new scrolling view scrolling an instance of aViewClass.
       
   556      The subview is created here.
       
   557      The view will have full scrollbars if miniH is false, 
       
   558      and a horizontal miniscroller if true."
       
   559 
       
   560      ^ self 
       
   561 	for:aViewClass
       
   562 	hasHorizontalScrollBar:true
       
   563 	hasVerticalScrollBar:true
       
   564 	miniScrollerH:miniH 
       
   565 	miniScrollerV:false
       
   566 	origin:nil
       
   567 	corner:nil 
       
   568 	in:nil
       
   569 
       
   570     "Modified: 6.3.1997 / 18:30:15 / cg"
       
   571 !
       
   572 
       
   573 for:aViewClass miniScrollerH:miniH in:aView
       
   574     "return a new scrolling view scrolling an instance of aViewClass.
       
   575      The subview is created here.
       
   576      The view will have full scrollbars if the corresponding miniH/miniV
       
   577      is false, miniscrollers if true."
       
   578 
       
   579      ^ self 
       
   580 	for:aViewClass
       
   581 	hasHorizontalScrollBar:true
       
   582 	hasVerticalScrollBar:true
       
   583 	miniScrollerH:miniH 
       
   584 	miniScrollerV:false
       
   585 	origin:nil
       
   586 	corner:nil 
       
   587 	in:aView
       
   588 
       
   589     "Modified: 6.3.1997 / 18:30:31 / cg"
       
   590 !
       
   591 
       
   592 for:aViewClass miniScrollerH:miniH miniScrollerV:miniV
       
   593     "return a new scrolling view scrolling an instance of aViewClass.
       
   594      The subview is created here.
       
   595      The view will have full scrollbars if the corresponding miniH/miniV
       
   596      is false, miniscrollers if true."
       
   597 
       
   598      ^ self 
       
   599 	for:aViewClass
       
   600 	hasHorizontalScrollBar:true
       
   601 	hasVerticalScrollBar:true
       
   602 	miniScrollerH:miniH 
       
   603 	miniScrollerV:miniV
       
   604 	origin:nil
       
   605 	corner:nil 
       
   606 	in:nil
       
   607 
       
   608     "Modified: 6.3.1997 / 18:30:47 / cg"
       
   609 !
       
   610 
       
   611 for:aViewClass miniScrollerH:miniH miniScrollerV:miniV in:aView
       
   612     "return a new scrolling view scrolling an instance of aViewClass.
       
   613      The subview is created here.
       
   614      The view will have full scrollbars if the corresponding miniH/miniV
       
   615      is false, miniscrollers if true."
       
   616 
       
   617      ^ self 
       
   618 	for:aViewClass
       
   619 	hasHorizontalScrollBar:true
       
   620 	hasVerticalScrollBar:true
       
   621 	miniScrollerH:miniH 
       
   622 	miniScrollerV:miniV
       
   623 	origin:nil
       
   624 	corner:nil 
       
   625 	in:aView
       
   626 
       
   627     "Modified: 6.3.1997 / 18:31:02 / cg"
       
   628 !
       
   629 
       
   630 for:aViewClass miniScrollerH:miniH miniScrollerV:miniV origin:org corner:corn in:aView
       
   631     "return a new scrolling view scrolling an instance of aViewClass.
       
   632      The subview is created here.
       
   633      The view will have full scrollbars if the corresponding miniH/miniV
       
   634      is false, miniscrollers if true."
       
   635 
       
   636      ^ self 
       
   637 	for:aViewClass
       
   638 	hasHorizontalScrollBar:true
       
   639 	hasVerticalScrollBar:true
       
   640 	miniScrollerH:miniH 
       
   641 	miniScrollerV:miniV
       
   642 	origin:org
       
   643 	corner:corn 
       
   644 	in:aView
       
   645 
       
   646     "Modified: 6.3.1997 / 18:31:17 / cg"
       
   647 !
       
   648 
       
   649 for:aViewClass miniScrollerH:miniH origin:org corner:corn in:aView
       
   650     "return a new scrolling view scrolling an instance of aViewClass.
       
   651      The subview is created here.
       
   652      The view will have a full horizontal scrollbar if miniH is false,
       
   653      a miniscroller if true."
       
   654 
       
   655      ^ self 
       
   656 	for:aViewClass
       
   657 	hasHorizontalScrollBar:true
       
   658 	hasVerticalScrollBar:true
       
   659 	miniScrollerH:miniH 
       
   660 	miniScrollerV:false
       
   661 	origin:org
       
   662 	corner:corn 
       
   663 	in:aView
       
   664 
       
   665     "Modified: 6.3.1997 / 18:31:28 / cg"
       
   666 !
       
   667 
       
   668 for:aViewClass miniScrollerV:miniV origin:org corner:corn in:aView
       
   669     "return a new scrolling view scrolling an instance of aViewClass.
       
   670      The subview is created here.
       
   671      The view will have a full vertical scrollbar if miniV is false,
       
   672      a miniscroller if true."
       
   673 
       
   674      ^ self 
       
   675 	for:aViewClass
       
   676 	hasHorizontalScrollBar:true
       
   677 	hasVerticalScrollBar:true
       
   678 	miniScrollerH:false 
       
   679 	miniScrollerV:miniV
       
   680 	origin:org
       
   681 	corner:corn 
       
   682 	in:aView
       
   683 
       
   684     "Modified: 6.3.1997 / 18:31:41 / cg"
       
   685 !
       
   686 
       
   687 for:aViewClass origin:org corner:corner in:aView
       
   688     "return a new scrolling view scrolling an instance of aViewClass.
       
   689      The subview is created here.
       
   690      The view will have full scrollbars."
       
   691 
       
   692      ^ self 
       
   693         for:aViewClass
       
   694         hasHorizontalScrollBar:self defaultHorizontalScrollable
       
   695         hasVerticalScrollBar:self defaultVerticalScrollable
       
   696         miniScrollerH:false 
       
   697         miniScrollerV:false
       
   698         origin:org
       
   699         corner:corner 
       
   700         in:aView
       
   701 
       
   702     "Modified: 6.3.1997 / 23:19:05 / cg"
       
   703 !
       
   704 
       
   705 forView:aView
       
   706     "return a new scrolling view scrolling aView.
       
   707      The view will have full scrollbars."
       
   708 
       
   709      ^ self 
       
   710         forView:aView
       
   711         hasHorizontalScrollBar:self defaultHorizontalScrollable
       
   712         hasVerticalScrollBar:self defaultVerticalScrollable
       
   713         miniScrollerH:false 
       
   714         miniScrollerV:false
       
   715         origin:nil
       
   716         corner:nil 
       
   717         in:nil
       
   718 
       
   719     "Modified: 6.3.1997 / 23:19:08 / cg"
       
   720 !
       
   721 
       
   722 forView:aScrolledView hasHorizontalScrollBar:hasH hasVerticalScrollBar:hasV miniScrollerH:miniH miniScrollerV:miniV origin:org corner:corn in:aView
       
   723     "return a new scrolling view scrolling an instance of aViewClass.
       
   724      The subview is created here.
       
   725      The view will have full scrollbars if the corresponding miniH/miniV
       
   726      is false, miniscrollers if true."
       
   727 
       
   728     |newView dev|
       
   729 
       
   730     aView notNil ifTrue:[
       
   731         dev := aView graphicsDevice
       
   732     ] ifFalse:[ 
       
   733         dev := Screen current
       
   734     ].
       
   735     newView := self basicNew device:dev.
       
   736     newView initialize.
       
   737     newView setupVertical:hasV mini:miniV horizontal:hasH mini:miniH.
       
   738 
       
   739     aScrolledView notNil ifTrue:[
       
   740         newView scrolledView:aScrolledView.
       
   741     ].
       
   742 
       
   743     org notNil ifTrue:[
       
   744         newView origin:org
       
   745     ].
       
   746     corn notNil ifTrue:[
       
   747         newView corner:corn
       
   748     ].
       
   749 
       
   750     aView notNil ifTrue:[
       
   751         aView addSubView:newView
       
   752     ].
       
   753     ^ newView
       
   754 
       
   755     "
       
   756      |top scr|
       
   757 
       
   758      top := StandardSystemView extent:200@200.
       
   759      scr := ScrollableView 
       
   760                  forView:(TextView new)
       
   761                  hasHorizontalScrollBar:true
       
   762                  hasVerticalScrollBar:true
       
   763                  miniScrollerH:false
       
   764                  miniScrollerV:false
       
   765                  origin:0.0@0.0
       
   766                  corner:1.0@1.0
       
   767                  in:top.
       
   768      top open
       
   769     "
       
   770     "
       
   771      |top scr|
       
   772 
       
   773      top := StandardSystemView extent:200@200.
       
   774      scr := ScrollableView 
       
   775                  forView:(TextView new)
       
   776                  hasHorizontalScrollBar:false
       
   777                  hasVerticalScrollBar:true
       
   778                  miniScrollerH:false
       
   779                  miniScrollerV:false
       
   780                  origin:0.0@0.0
       
   781                  corner:1.0@1.0
       
   782                  in:top.
       
   783      top open
       
   784     "
       
   785 
       
   786     "Modified: 6.3.1997 / 18:42:40 / cg"
       
   787     "Modified: 19.3.1997 / 15:32:51 / stefan"
       
   788 !
       
   789 
       
   790 forView:aView in:aSuperView
       
   791     "return a new scrolling view scrolling aView.
       
   792      The view will have full scrollbars."
       
   793 
       
   794      ^ self 
       
   795         forView:aView
       
   796         hasHorizontalScrollBar:self defaultHorizontalScrollable
       
   797         hasVerticalScrollBar:self defaultVerticalScrollable
       
   798         miniScrollerH:false 
       
   799         miniScrollerV:false
       
   800         origin:nil
       
   801         corner:nil 
       
   802         in:aSuperView
       
   803 
       
   804     "Modified: 6.3.1997 / 23:19:12 / cg"
       
   805 !
       
   806 
       
   807 forView:aView miniScrollerH:mini
       
   808     "return a new scrolling view scrolling aView.
       
   809      The view will have a full vertical scrollbar and a horizontal
       
   810      miniScroller if mini is true."
       
   811 
       
   812      ^ self 
       
   813 	forView:aView
       
   814 	hasHorizontalScrollBar:true
       
   815 	hasVerticalScrollBar:true
       
   816 	miniScrollerH:mini 
       
   817 	miniScrollerV:false
       
   818 	origin:nil
       
   819 	corner:nil 
       
   820 	in:nil
       
   821 
       
   822     "Modified: 6.3.1997 / 18:32:58 / cg"
       
   823 !
       
   824 
       
   825 forView:scrolledView miniScrollerH:miniH miniScrollerV:miniV in:aView
       
   826     "return a new scrolling view, scrolling aView.
       
   827      The view will have full scrollbars if the corresponding miniH/miniV
       
   828      is false, miniscrollers if true."
       
   829 
       
   830      ^ self 
       
   831 	forView:scrolledView
       
   832 	hasHorizontalScrollBar:true
       
   833 	hasVerticalScrollBar:true
       
   834 	miniScrollerH:miniH 
       
   835 	miniScrollerV:miniV
       
   836 	origin:nil
       
   837 	corner:nil 
       
   838 	in:aView
       
   839 
       
   840     "Modified: 6.3.1997 / 18:33:20 / cg"
       
   841 !
       
   842 
       
   843 in:aView
       
   844     "return a new scrolling view to be contained in aView.
       
   845      There is no slave view now - this has to be set later via
       
   846      the scrolledView: method.
       
   847      The view will have full scrollbars."
       
   848 
       
   849      ^ self 
       
   850         forView:nil
       
   851         hasHorizontalScrollBar:self defaultHorizontalScrollable
       
   852         hasVerticalScrollBar:self defaultVerticalScrollable
       
   853         miniScrollerH:false 
       
   854         miniScrollerV:false
       
   855         origin:nil
       
   856         corner:nil 
       
   857         in:aView
       
   858 
       
   859     "Modified: 6.3.1997 / 23:19:19 / cg"
       
   860 !
       
   861 
       
   862 miniScroller:mini
       
   863     "return a new scrolling view. The subview will be created later.
       
   864      The view will have full scrollbars if mini is false, 
       
   865      miniscrollers if true."
       
   866 
       
   867      ^ self 
       
   868         forView:nil
       
   869         hasHorizontalScrollBar:self defaultHorizontalScrollable
       
   870         hasVerticalScrollBar:self defaultVerticalScrollable
       
   871         miniScrollerH:mini 
       
   872         miniScrollerV:mini
       
   873         origin:nil
       
   874         corner:nil 
       
   875         in:nil
       
   876 
       
   877     "Modified: 6.3.1997 / 23:19:21 / cg"
       
   878 !
       
   879 
       
   880 miniScrollerH:miniH
       
   881     "return a new scrolling view. The subview will be created later.
       
   882      The view will have full scrollbars if miniH is false, 
       
   883      and a horizontal miniscroller if true."
       
   884 
       
   885      ^ self 
       
   886 	forView:nil
       
   887 	hasHorizontalScrollBar:true
       
   888 	hasVerticalScrollBar:true
       
   889 	miniScrollerH:miniH 
       
   890 	miniScrollerV:false
       
   891 	origin:nil
       
   892 	corner:nil 
       
   893 	in:nil
       
   894 
       
   895     "Modified: 6.3.1997 / 18:34:06 / cg"
       
   896 !
       
   897 
       
   898 miniScrollerH:miniH miniScrollerV:miniV
       
   899     "return a new scrolling view. The subview will be created later.
       
   900      The view will have full scrollbars if the corresponding miniH/miniV
       
   901      is false, miniscrollers if true."
       
   902 
       
   903      ^ self 
       
   904 	forView:nil
       
   905 	hasHorizontalScrollBar:true
       
   906 	hasVerticalScrollBar:true
       
   907 	miniScrollerH:miniH 
       
   908 	miniScrollerV:miniV
       
   909 	origin:nil
       
   910 	corner:nil 
       
   911 	in:nil
       
   912 
       
   913     "Modified: 6.3.1997 / 18:34:16 / cg"
       
   914 !
       
   915 
       
   916 new
       
   917     "return a new scrolling view.
       
   918      There is no slave view now - this has to be set later via
       
   919      the scrolledView: method.
       
   920      The view will have full scrollbars."
       
   921 
       
   922      ^ self in:nil
       
   923 
       
   924     "Modified: / 12.11.1998 / 14:55:54 / cg"
       
   925 ! !
       
   926 
       
   927 !ScrollableView class methodsFor:'defaults'!
       
   928 
       
   929 defaultHorizontalScrollable
       
   930     ^ false
       
   931 !
       
   932 
       
   933 defaultScrollBarPosition
       
   934     "return the default position of the scrollBar.
       
   935      (max be of interest to panels, to make the handlePosition alike)"
       
   936 
       
   937     <resource: #style (#'scrollBar.position')>
       
   938 
       
   939     ^ StyleSheet at:#'scrollBar.position' default:#left.
       
   940 
       
   941     "
       
   942      self defaultScrollBarPosition
       
   943     "
       
   944 
       
   945     "Modified: / 31.10.1997 / 12:58:15 / cg"
       
   946 !
       
   947 
       
   948 defaultVerticalScrollable
       
   949     ^ true
       
   950 !
       
   951 
       
   952 updateStyleCache
       
   953     "extract values from the styleSheet and cache them in class variables"
       
   954 
       
   955     <resource: #style (#'scrolledView.level' #'scrolledView.margin'
       
   956 		       #'scrolledView.borderWidth'
       
   957 		       #'scrollBar.spacing' #'scrollBar.level'
       
   958 		       #'scrollableView.level' #'scrollableView.backgroundColor' )>
       
   959 
       
   960     |defLevel defMargin defSpacing|
       
   961 
       
   962     StyleSheet is3D ifTrue:[
       
   963 	defLevel := -1.
       
   964 	defMargin := ViewSpacing // 2.
       
   965 	defSpacing := defMargin.
       
   966     ] ifFalse:[
       
   967 	defLevel := 0.
       
   968 	defMargin := 0.
       
   969 	defSpacing := 0
       
   970     ].
       
   971     DefaultScrolledViewLevel := StyleSheet at:#'scrolledView.level' default:defLevel.
       
   972     DefaultScrolledViewBorderWidth := StyleSheet at:#'scrolledView.borderWidth' default:nil.
       
   973     DefaultScrolledViewMargin := StyleSheet at:#'scrolledView.margin' default:defMargin.
       
   974     DefaultScrollBarSpacing := StyleSheet at:#'scrollBar.spacing' default:defSpacing.
       
   975     DefaultLevel := StyleSheet at:#'scrollableView.level' default:nil.
       
   976     DefaultScrollBarLevel := StyleSheet at:#'scrollBar.level' default:nil.
       
   977     MyDefaultViewBackgroundColor := StyleSheet at:#'scrollableView.backgroundColor' default:DefaultViewBackgroundColor.
       
   978 
       
   979     "
       
   980      self updateStyleCache
       
   981     "
       
   982 
       
   983     "Modified: / 31.10.1997 / 20:57:10 / cg"
       
   984 ! !
       
   985 
       
   986 !ScrollableView methodsFor:'accessing-behavior'!
       
   987 
       
   988 autoHideHorizontalScrollBar:aBoolean
       
   989     "set/clear the flag which controls if the horizontal scrollBar should
       
   990      be made invisible dynamically, if there is nothing to scroll
       
   991      (and shown if there is). 
       
   992      This flags setting is normally controlled by the styleSheet."
       
   993 
       
   994     hideHScrollBar := aBoolean.
       
   995 
       
   996     "Modified: 19.3.1997 / 16:28:42 / cg"
       
   997     "Created: 19.3.1997 / 17:24:39 / cg"
       
   998 !
       
   999 
       
  1000 autoHideScrollBars:aBoolean
       
  1001     "set/clear the flag which controls if scrollBars should
       
  1002      be made invisible dynamically, if there is nothing to scroll
       
  1003      (and shown if there is). 
       
  1004      This flags setting is normally controlled by the styleSheet."
       
  1005 
       
  1006     hideVScrollBar := hideHScrollBar := aBoolean.
       
  1007 
       
  1008     "Modified: 19.3.1997 / 16:28:42 / cg"
       
  1009     "Created: 19.3.1997 / 17:24:39 / cg"
       
  1010 !
       
  1011 
       
  1012 autoHideVerticalScrollBar:aBoolean
       
  1013     "set/clear the flag which controls if the vertical scrollBar should
       
  1014      be made invisible dynamically, if there is nothing to scroll
       
  1015      (and shown if there is). 
       
  1016      This flags setting is normally controlled by the styleSheet."
       
  1017 
       
  1018     hideVScrollBar := aBoolean.
       
  1019 
       
  1020     "Modified: 19.3.1997 / 16:28:42 / cg"
       
  1021     "Created: 19.3.1997 / 17:24:39 / cg"
       
  1022 ! !
       
  1023 
       
  1024 !ScrollableView methodsFor:'accessing-components'!
       
  1025 
       
  1026 horizontalScrollBar
       
  1027     "return the horizontal scrollbar (or nil, if there is none)"
       
  1028 
       
  1029 "/    hScrollBar isNil ifTrue:[
       
  1030 "/        self horizontalScrollable:true.
       
  1031 "/    ].
       
  1032     ^ hScrollBar
       
  1033 
       
  1034     "Created: / 6.3.1997 / 18:06:23 / cg"
       
  1035     "Modified: / 25.5.1998 / 12:53:58 / cg"
       
  1036 !
       
  1037 
       
  1038 removeSubView:aView
       
  1039     super removeSubView:aView.
       
  1040     aView == scrolledView ifTrue:[
       
  1041         scrolledView := nil
       
  1042     ].
       
  1043     aView == vScrollBar ifTrue:[
       
  1044         vScrollBar := nil
       
  1045     ].
       
  1046     aView == hScrollBar ifTrue:[
       
  1047         hScrollBar := nil
       
  1048     ].
       
  1049 
       
  1050 
       
  1051 
       
  1052 
       
  1053 !
       
  1054 
       
  1055 scrollBar
       
  1056     "return the vertical scrollbar (or nil, if there is none)"
       
  1057 
       
  1058 "/    vScrollBar isNil ifTrue:[
       
  1059 "/        self verticalScrollable:true.
       
  1060 "/    ].
       
  1061     ^ vScrollBar
       
  1062 
       
  1063     "Created: / 6.3.1997 / 18:06:23 / cg"
       
  1064     "Modified: / 25.5.1998 / 12:54:06 / cg"
       
  1065 !
       
  1066 
       
  1067 scrolledView
       
  1068     "return the scrolled view (or nil, if there is none)"
       
  1069 
       
  1070     ^ scrolledView
       
  1071 
       
  1072     "Modified: 6.3.1997 / 16:48:09 / cg"
       
  1073     "Created: 6.3.1997 / 18:06:23 / cg"
       
  1074 !
       
  1075 
       
  1076 scrolledView:aView
       
  1077     "set the view to scroll"
       
  1078 
       
  1079     scrolledView notNil ifTrue:[
       
  1080 	scrolledView removeDependent:self.
       
  1081 	scrolledView destroy.
       
  1082 	scrolledView := nil.
       
  1083     ].
       
  1084 
       
  1085     scrolledView := aView.
       
  1086 
       
  1087     super addSubViewFirst:aView.
       
  1088     scrolledView notNil ifTrue:[
       
  1089 	self setScrollActions.
       
  1090 
       
  1091 	realized ifTrue:[
       
  1092 	    self setupDimensionsConfigureScrolledView:true.
       
  1093 	    self sizeChanged:nil.
       
  1094 	    scrolledView realize
       
  1095 	].
       
  1096     ]
       
  1097 
       
  1098     "Modified: / 19.3.1997 / 15:32:37 / stefan"
       
  1099     "Modified: / 21.5.1998 / 00:48:57 / cg"
       
  1100 !
       
  1101 
       
  1102 verticalScrollBar
       
  1103     "return the vertical scrollbar (or nil, if there is none)"
       
  1104 
       
  1105 "/    vScrollBar isNil ifTrue:[
       
  1106 "/        self verticalScrollable:true.
       
  1107 "/    ].
       
  1108     ^ vScrollBar
       
  1109 
       
  1110     "Modified: 6.3.1997 / 16:59:24 / cg"
       
  1111     "Created: 6.3.1997 / 18:06:23 / cg"
       
  1112 !
       
  1113 
       
  1114 widget
       
  1115     "for ST80 compatibility (where a wrapper returns its wrapped
       
  1116      widget), return the scrolledView here"
       
  1117 
       
  1118     ^ scrolledView
       
  1119 
       
  1120     "Created: 20.6.1997 / 14:45:16 / cg"
       
  1121 ! !
       
  1122 
       
  1123 !ScrollableView methodsFor:'accessing-look'!
       
  1124 
       
  1125 horizontalMini:aBoolean
       
  1126     "control the horizontal scrollBar to be either a miniScroller,
       
  1127      or a full scrollBar."
       
  1128 
       
  1129     horizontalMini ~~ aBoolean ifTrue:[
       
  1130         horizontalMini := aBoolean.
       
  1131         (styleSheet at:#'scrollBar.neverMini' default:false) == true ifTrue:[
       
  1132             horizontalMini := false.
       
  1133         ].
       
  1134         self setupViews.
       
  1135         shown ifTrue:[
       
  1136             self setupDimensionsConfigureScrolledView:false.
       
  1137         ]
       
  1138     ].
       
  1139 
       
  1140     "Created: / 7.3.1997 / 21:57:02 / cg"
       
  1141     "Modified: / 22.4.1998 / 22:42:25 / ca"
       
  1142     "Modified: / 21.5.1998 / 00:48:25 / cg"
       
  1143 !
       
  1144 
       
  1145 horizontalScrollable:aBoolean
       
  1146     "enable/disable horizontal scrollability.
       
  1147      If disabled, the horizontal scrollBar is made invisible."
       
  1148 
       
  1149     hasHorizontalScrollBar ~~ aBoolean ifTrue:[
       
  1150         hasHorizontalScrollBar := aBoolean.
       
  1151         hScrollBarHidden := false.
       
  1152         self setupViews.
       
  1153         shown ifTrue:[
       
  1154             self setupDimensionsConfigureScrolledView:false.
       
  1155         ]
       
  1156     ].
       
  1157 
       
  1158     "Created: / 7.3.1997 / 21:56:28 / cg"
       
  1159     "Modified: / 21.5.1998 / 00:48:44 / cg"
       
  1160 !
       
  1161 
       
  1162 verticalMini:aBoolean
       
  1163     "control the vertical scrollBar to be either a miniScroller,
       
  1164      or a full scrollBar."
       
  1165 
       
  1166     verticalMini ~~ aBoolean ifTrue:[
       
  1167         verticalMini := aBoolean.
       
  1168         (styleSheet at:#'scrollBar.neverMini' default:false) == true ifTrue:[
       
  1169             verticalMini := false.
       
  1170         ].
       
  1171         self setupViews.
       
  1172         shown ifTrue:[
       
  1173             self setupDimensionsConfigureScrolledView:false.
       
  1174         ]
       
  1175     ]
       
  1176 
       
  1177     "Created: / 7.3.1997 / 21:56:57 / cg"
       
  1178     "Modified: / 22.4.1998 / 22:42:32 / ca"
       
  1179     "Modified: / 21.5.1998 / 00:49:10 / cg"
       
  1180 !
       
  1181 
       
  1182 verticalScrollable:aBoolean
       
  1183     "enable/disable vertical scrollability.
       
  1184      If disabled, the vertical scrollBar is made invisible."
       
  1185 
       
  1186     hasVerticalScrollBar ~~ aBoolean ifTrue:[
       
  1187 	hasVerticalScrollBar := aBoolean.
       
  1188 	vScrollBarHidden := false.
       
  1189 	self setupViews.
       
  1190 	shown ifTrue:[
       
  1191 	    self setupDimensionsConfigureScrolledView:false.
       
  1192 	]
       
  1193     ]
       
  1194 
       
  1195     "Created: / 7.3.1997 / 21:56:39 / cg"
       
  1196     "Modified: / 21.5.1998 / 00:49:16 / cg"
       
  1197 ! !
       
  1198 
       
  1199 !ScrollableView methodsFor:'changes '!
       
  1200 
       
  1201 update:something with:argument from:changedObject
       
  1202     "whenever the scrolledView changes its contents, the scroller(s) must
       
  1203      be updated as well"
       
  1204 
       
  1205     |doUpdate|
       
  1206 
       
  1207     doUpdate := false.
       
  1208     changedObject == scrolledView ifTrue:[
       
  1209         something == #sizeOfContents ifTrue:[
       
  1210             vScrollBar notNil ifTrue:[
       
  1211                 vScrollBar setThumbFor:scrolledView.
       
  1212                 doUpdate := true
       
  1213             ].
       
  1214             hScrollBar notNil ifTrue:[
       
  1215                 hScrollBar setThumbFor:scrolledView.
       
  1216                 doUpdate := true
       
  1217             ].
       
  1218         ] ifFalse:[
       
  1219             something == #originOfContents ifTrue:[
       
  1220                 lockUpdates ifFalse:[
       
  1221                     vScrollBar notNil ifTrue:[
       
  1222                         vScrollBar setThumbOriginFor:scrolledView.
       
  1223                         doUpdate := true
       
  1224                     ].
       
  1225                     hScrollBar notNil ifTrue:[
       
  1226                         hScrollBar setThumbOriginFor:scrolledView.
       
  1227                         doUpdate := true
       
  1228                     ].
       
  1229                 ].
       
  1230             ].
       
  1231         ].
       
  1232 
       
  1233         doUpdate ifTrue:[
       
  1234             self updateScrollBarVisibility
       
  1235         ]
       
  1236     ].
       
  1237 
       
  1238 !
       
  1239 
       
  1240 updateScrollBarVisibility
       
  1241     "check if any scrollbar needs to be hidden or shown"
       
  1242 
       
  1243     |anyChange hide|
       
  1244 
       
  1245     anyChange := false.
       
  1246 
       
  1247     hideVScrollBar ~~ false ifTrue:[
       
  1248         vScrollBar notNil ifTrue:[
       
  1249             hide := vScrollBar thumbHeight >= 100.
       
  1250             hide ~~ vScrollBarHidden ifTrue:[
       
  1251                 vScrollBarHidden := hide.
       
  1252                 hide ifTrue:[vScrollBar beInvisible] ifFalse:[vScrollBar beVisible].
       
  1253                 anyChange := true.
       
  1254             ]
       
  1255         ].
       
  1256     ].
       
  1257 
       
  1258     hideHScrollBar ~~ false ifTrue:[
       
  1259         hScrollBar notNil ifTrue:[
       
  1260             hide := hScrollBar thumbHeight >= 100.
       
  1261             hide ~~ hScrollBarHidden ifTrue:[
       
  1262                 hScrollBarHidden :=  hide.
       
  1263                 hide ifTrue:[hScrollBar beInvisible] ifFalse:[hScrollBar beVisible].
       
  1264                 anyChange := true.
       
  1265             ] 
       
  1266         ].
       
  1267     ].
       
  1268 
       
  1269     anyChange ifTrue:[
       
  1270         self setupDimensionsConfigureScrolledView:false.
       
  1271 
       
  1272         "/ force him to recompute its dimension ...
       
  1273         scrolledView notNil ifTrue:[
       
  1274             vScrollBar notNil ifTrue:[
       
  1275                 vScrollBar setThumbFor:scrolledView.
       
  1276             ].
       
  1277             hScrollBar notNil ifTrue:[
       
  1278                 hScrollBar setThumbFor:scrolledView.
       
  1279             ].
       
  1280         ].
       
  1281 
       
  1282         "/ stupid - showing one may need the other ...
       
  1283         "/ and vice versa; do it again.
       
  1284 
       
  1285         anyChange := false.
       
  1286 
       
  1287         hideVScrollBar ~~ false ifTrue:[
       
  1288             vScrollBar notNil ifTrue:[
       
  1289                 hide := vScrollBar thumbHeight >= 100.
       
  1290                 hide ~~ vScrollBarHidden ifTrue:[
       
  1291                     vScrollBarHidden := hide.
       
  1292                     hide ifTrue:[vScrollBar beInvisible] ifFalse:[vScrollBar beVisible].
       
  1293                     anyChange := true.
       
  1294                 ]
       
  1295             ].
       
  1296         ].
       
  1297 
       
  1298         hideHScrollBar ~~ false ifTrue:[
       
  1299             hScrollBar notNil ifTrue:[
       
  1300                 hide := hScrollBar thumbHeight >= 100.
       
  1301                 hide ~~ hScrollBarHidden ifTrue:[
       
  1302                     hScrollBarHidden := hide.
       
  1303                     hide ifTrue:[hScrollBar beInvisible] ifFalse:[hScrollBar beVisible].
       
  1304                     anyChange := true.
       
  1305                 ]
       
  1306             ].
       
  1307         ].
       
  1308 
       
  1309         anyChange ifTrue:[
       
  1310             self setupDimensionsConfigureScrolledView:false.
       
  1311         ].
       
  1312     ].
       
  1313 
       
  1314     "Modified: / 19.3.1997 / 15:33:36 / stefan"
       
  1315     "Modified: / 21.5.1998 / 00:49:05 / cg"
       
  1316 ! !
       
  1317 
       
  1318 !ScrollableView methodsFor:'event processing'!
       
  1319 
       
  1320 keyPress:key x:x y:y
       
  1321     "a key was pressed - handle page-keys here"
       
  1322 
       
  1323     <resource: #keyboard ( #Prior #Next ) >
       
  1324 
       
  1325     (key == #Prior)    ifTrue: [^ self pageUp].
       
  1326     (key == #Next)     ifTrue: [^ self pageDown].
       
  1327 
       
  1328     super keyPress:key x:x y:y
       
  1329 
       
  1330     "Created: 6.3.1997 / 18:06:23 / cg"
       
  1331 !
       
  1332 
       
  1333 sizeChanged:how
       
  1334     "handle size changes - this may change any scrollBars visibility"
       
  1335 
       
  1336     |orgX orgY thV thH scrollH scrollV|
       
  1337 
       
  1338     "/ resize components manually, in an order which is optimal
       
  1339 
       
  1340     how == #smaller ifTrue:[
       
  1341         "/ first resize the horizontalScrollBar,
       
  1342 
       
  1343         scrolledView notNil ifTrue:[
       
  1344             scrolledView containerChangedSize
       
  1345         ].
       
  1346         hScrollBar notNil ifTrue:[
       
  1347             hScrollBar containerChangedSize
       
  1348         ].
       
  1349         vScrollBar notNil ifTrue:[
       
  1350             vScrollBar containerChangedSize
       
  1351         ].
       
  1352     ] ifFalse:[
       
  1353         hScrollBar notNil ifTrue:[
       
  1354             hScrollBar containerChangedSize
       
  1355         ].
       
  1356         vScrollBar notNil ifTrue:[
       
  1357             vScrollBar containerChangedSize
       
  1358         ].
       
  1359         scrolledView notNil ifTrue:[
       
  1360             scrolledView containerChangedSize
       
  1361         ].
       
  1362     ].
       
  1363 
       
  1364     scrolledView isNil ifTrue:[^ self].
       
  1365     (hScrollBar isNil and:[vScrollBar isNil]) ifTrue:[
       
  1366         ^ self
       
  1367     ].
       
  1368 
       
  1369     vScrollBar notNil ifTrue:[
       
  1370         vScrollBar setThumbFor:scrolledView.
       
  1371         orgY := vScrollBar thumbOrigin.
       
  1372         thV := vScrollBar thumbHeight.
       
  1373     ].
       
  1374     hScrollBar notNil ifTrue:[
       
  1375         hScrollBar setThumbFor:scrolledView.
       
  1376         orgX := hScrollBar thumbOrigin.
       
  1377         thH := hScrollBar thumbHeight.
       
  1378     ].
       
  1379 
       
  1380     "/ splitted, since there are optimized scrollProcedures for each case ...
       
  1381 
       
  1382     hScrollBar isNil ifTrue:[
       
  1383         "/ only care for vertical ...
       
  1384         orgY + thV >= 100 ifTrue:[
       
  1385             vScrollBar thumbOrigin:(100 - thV).
       
  1386             scrolledView scrollVerticalToPercent:vScrollBar thumbOrigin.
       
  1387         ].
       
  1388     ] ifFalse:[
       
  1389         vScrollBar isNil ifTrue:[
       
  1390             "/ only care for horizontal ...
       
  1391             orgX + thH >= 100 ifTrue:[
       
  1392                 hScrollBar thumbOrigin:(100 - thH).
       
  1393                 scrolledView scrollHorizontalToPercent:hScrollBar thumbOrigin.
       
  1394             ].
       
  1395         ] ifFalse:[
       
  1396             "/ care for both ...
       
  1397 
       
  1398             scrollH := scrollV := false.
       
  1399 
       
  1400             orgY + thV >= 100 ifTrue:[
       
  1401                 vScrollBar thumbOrigin:(100 - thV).
       
  1402                 orgY := vScrollBar thumbOrigin.
       
  1403                 scrollV := true.
       
  1404             ].
       
  1405             orgX + thH >= 100 ifTrue:[
       
  1406                 hScrollBar thumbOrigin:(100 - thH).
       
  1407                 orgX := hScrollBar thumbOrigin.
       
  1408                 scrollH := true.
       
  1409             ].
       
  1410             scrollV ifTrue:[
       
  1411                 scrollH ifTrue:[
       
  1412                     scrolledView scrollToPercent:(orgX@orgY).
       
  1413                 ] ifFalse:[
       
  1414                     scrolledView scrollVerticalToPercent:orgY.
       
  1415                 ]
       
  1416             ] ifFalse:[
       
  1417                 scrollH ifTrue:[
       
  1418                     scrolledView scrollHorizontalToPercent:orgX.
       
  1419                 ]
       
  1420             ]
       
  1421         ]
       
  1422     ].
       
  1423     self updateScrollBarVisibility.
       
  1424 
       
  1425     "Modified: 28.3.1997 / 17:25:38 / cg"
       
  1426 ! !
       
  1427 
       
  1428 !ScrollableView methodsFor:'forced scroll'!
       
  1429 
       
  1430 pageDown
       
  1431     "page down - but only if there is a vertical scrollbar"
       
  1432 
       
  1433     vScrollBar notNil ifTrue:[
       
  1434 	vScrollBar pageDown
       
  1435     ]
       
  1436 
       
  1437     "Created: 6.3.1997 / 18:06:23 / cg"
       
  1438     "Modified: 19.3.1997 / 16:32:34 / cg"
       
  1439 !
       
  1440 
       
  1441 pageLeft
       
  1442     "page left - but only if there is a horizontal scrollbar"
       
  1443 
       
  1444     hScrollBar notNil ifTrue:[
       
  1445 	hScrollBar pageDown
       
  1446     ]
       
  1447 
       
  1448     "Created: 19.3.1997 / 16:32:14 / cg"
       
  1449     "Modified: 19.3.1997 / 16:32:44 / cg"
       
  1450 !
       
  1451 
       
  1452 pageRight
       
  1453     "page right - but only if there is a horizontal scrollbar"
       
  1454 
       
  1455     hScrollBar notNil ifTrue:[
       
  1456 	hScrollBar pageUp
       
  1457     ]
       
  1458 
       
  1459     "Created: 19.3.1997 / 16:32:22 / cg"
       
  1460     "Modified: 19.3.1997 / 16:32:48 / cg"
       
  1461 !
       
  1462 
       
  1463 pageUp
       
  1464     "page up - but only if there is a vertical scrollbar"
       
  1465 
       
  1466     vScrollBar notNil ifTrue:[
       
  1467 	vScrollBar pageUp
       
  1468     ]
       
  1469 
       
  1470     "Created: 6.3.1997 / 18:06:23 / cg"
       
  1471     "Modified: 19.3.1997 / 16:32:38 / cg"
       
  1472 ! !
       
  1473 
       
  1474 !ScrollableView methodsFor:'initialization'!
       
  1475 
       
  1476 initStyle
       
  1477     "initialize style specifics"
       
  1478 
       
  1479     <resource: #style (#'scrollBar.position' #'scrollBar.hiding')>
       
  1480 
       
  1481     super initStyle.
       
  1482 
       
  1483     viewBackground := MyDefaultViewBackgroundColor. 
       
  1484     scrollBarPosition := styleSheet at:#'scrollBar.position' default:#left.
       
  1485     hideHScrollBar := hideVScrollBar := styleSheet at:#'scrollBar.hiding' default:false.
       
  1486     DefaultLevel notNil ifTrue:[self level:DefaultLevel].
       
  1487 
       
  1488     "Created: / 6.3.1997 / 18:06:23 / cg"
       
  1489     "Modified: / 21.5.1998 / 00:52:26 / cg"
       
  1490 !
       
  1491 
       
  1492 initialize
       
  1493     "setup some default"
       
  1494 
       
  1495     verticalMini := horizontalMini := false.
       
  1496     hasVerticalScrollBar := hasHorizontalScrollBar := false.
       
  1497     vScrollBarHidden := hScrollBarHidden := true.
       
  1498     super initialize.
       
  1499 !
       
  1500 
       
  1501 realize
       
  1502     "realize (i.e. make me visible).
       
  1503      Since scrolledView may have done something to its contents
       
  1504      during init-time we had no chance yet to catch contents-
       
  1505      changes; do it now"
       
  1506 
       
  1507     self setupDimensionsConfigureScrolledView:true.
       
  1508     super realize.
       
  1509 
       
  1510     scrolledView notNil ifTrue:[
       
  1511         vScrollBar notNil ifTrue:[
       
  1512             vScrollBar setThumbFor:scrolledView
       
  1513         ].
       
  1514         hScrollBar notNil ifTrue:[
       
  1515             hScrollBar setThumbFor:scrolledView
       
  1516         ].
       
  1517         self updateScrollBarVisibility.
       
  1518     ].
       
  1519 
       
  1520     "Modified: / 21.5.1998 / 00:52:18 / cg"
       
  1521 !
       
  1522 
       
  1523 releaseHorizontalScrollBar
       
  1524     "destroy any horizontal scrollBar"
       
  1525 
       
  1526     hScrollBar notNil ifTrue:[
       
  1527 	hScrollBar destroy.
       
  1528 	hScrollBar := nil
       
  1529     ].
       
  1530 
       
  1531     "Modified: 6.3.1997 / 17:43:20 / cg"
       
  1532     "Created: 6.3.1997 / 18:06:23 / cg"
       
  1533 !
       
  1534 
       
  1535 releaseVerticalScrollBar
       
  1536     "destroy any vertical scrollBar"
       
  1537 
       
  1538     vScrollBar notNil ifTrue:[
       
  1539 	vScrollBar destroy.
       
  1540 	vScrollBar := nil
       
  1541     ].
       
  1542 
       
  1543     "Created: 6.3.1997 / 18:06:23 / cg"
       
  1544 !
       
  1545 
       
  1546 setScrollActions
       
  1547     "lock prevents repositioning the scroller to the
       
  1548      actual (often rounded) position while scrolling,
       
  1549      and keeps it instead at the pointer position.
       
  1550 
       
  1551      (this avoids run-away scroller when scrolling
       
  1552       textviews, when the text is aligned line-wise).
       
  1553       Consider this as a kludge."
       
  1554 
       
  1555     lockUpdates := false.
       
  1556 
       
  1557     vScrollBar notNil ifTrue:[
       
  1558         vScrollBar scrollAction:[:position |
       
  1559             lockUpdates := true.
       
  1560             scrolledView scrollVerticalToPercent:position.
       
  1561             lockUpdates := false
       
  1562         ].
       
  1563         vScrollBar 
       
  1564             scrollUpAction:[|sensor|
       
  1565                             ((sensor := self sensor) notNil
       
  1566                             and:[sensor shiftDown or:[sensor ctrlDown]]) ifTrue:[
       
  1567                                 scrolledView scrollToTop
       
  1568                             ] ifFalse:[
       
  1569                                 scrolledView scrollUp
       
  1570                             ]
       
  1571                            ].
       
  1572         vScrollBar 
       
  1573             scrollDownAction:[|sensor|
       
  1574                             ((sensor := self sensor) notNil
       
  1575                             and:[sensor shiftDown or:[sensor ctrlDown]]) ifTrue:[
       
  1576                                 scrolledView scrollToBottom
       
  1577                             ] ifFalse:[
       
  1578                                 scrolledView scrollDown
       
  1579                             ]
       
  1580                            ].
       
  1581     ].
       
  1582     hScrollBar notNil ifTrue:[
       
  1583         hScrollBar scrollAction:[:position |
       
  1584             lockUpdates := true.
       
  1585             scrolledView scrollHorizontalToPercent:position.
       
  1586             lockUpdates := false
       
  1587         ].
       
  1588         hScrollBar 
       
  1589             scrollUpAction:[|sensor|
       
  1590                             ((sensor := self sensor) notNil
       
  1591                             and:[sensor shiftDown or:[sensor ctrlDown]]) ifTrue:[
       
  1592                                 scrolledView scrollToLeft
       
  1593                             ] ifFalse:[
       
  1594                                 scrolledView scrollLeft
       
  1595                             ]
       
  1596                            ].
       
  1597         hScrollBar 
       
  1598             scrollDownAction:[|sensor|
       
  1599                             ((sensor := self sensor) notNil
       
  1600                             and:[sensor shiftDown or:[sensor ctrlDown]]) ifTrue:[
       
  1601                                 scrolledView scrollToRight
       
  1602                             ] ifFalse:[
       
  1603                                 scrolledView scrollRight
       
  1604                             ]
       
  1605                              ].
       
  1606     ].
       
  1607 
       
  1608     scrolledView addDependent:self.
       
  1609 
       
  1610     "
       
  1611      pass my keyboard input (and other subviews input) 
       
  1612      to the scrolled view ...
       
  1613     "
       
  1614     self delegate:(KeyboardForwarder toView:scrolledView).
       
  1615 
       
  1616     "Modified: 6.3.1997 / 17:03:43 / cg"
       
  1617     "Created: 6.3.1997 / 18:06:23 / cg"
       
  1618 !
       
  1619 
       
  1620 setupDimensionsConfigureScrolledView:configureScrolledView
       
  1621     "set the components dimensions (i.e. layouts) according to
       
  1622      the scrollability and hidden settings.
       
  1623      This may heavily move around the parts ..."
       
  1624 
       
  1625     |scrolledViewMargin scrollBarSpacing hasV hasH
       
  1626      scrolledViewLayout hScrollBarLayout vScrollBarLayout
       
  1627      vBd         "{ Class: SmallInteger }"
       
  1628      hBd         "{ Class: SmallInteger }"
       
  1629      sBd         "{ Class: SmallInteger }"
       
  1630      wVScroll    "{ Class: SmallInteger }"
       
  1631      hHScroll    "{ Class: SmallInteger }"
       
  1632      hLeftOffs   "{ Class: SmallInteger }"
       
  1633      hRightOffs  "{ Class: SmallInteger }"
       
  1634      hTopOffs    "{ Class: SmallInteger }"
       
  1635      hBottomOffs "{ Class: SmallInteger }"
       
  1636      sLeftOffs   "{ Class: SmallInteger }"
       
  1637      sRightOffs  "{ Class: SmallInteger }"
       
  1638      sTopOffs    "{ Class: SmallInteger }"
       
  1639      sBottomOffs "{ Class: SmallInteger }"
       
  1640      vLeftOffs   "{ Class: SmallInteger }"
       
  1641      vRightOffs  "{ Class: SmallInteger }"
       
  1642      vTopOffs    "{ Class: SmallInteger }"
       
  1643      vBottomOffs "{ Class: SmallInteger }"
       
  1644      addMargin   "{ Class: SmallInteger }"|
       
  1645 
       
  1646     sBd := 0.
       
  1647     DefaultScrolledViewBorderWidth notNil ifTrue:[
       
  1648         sBd := DefaultScrolledViewBorderWidth.
       
  1649         scrolledView notNil ifTrue:[
       
  1650             scrolledView borderWidth:DefaultScrolledViewBorderWidth.
       
  1651         ]
       
  1652     ] ifFalse:[
       
  1653         scrolledView notNil ifTrue:[
       
  1654             sBd := scrolledView borderWidth
       
  1655         ]
       
  1656     ].
       
  1657 
       
  1658     (hasV := (vScrollBar notNil and:[vScrollBarHidden not])) ifTrue:[
       
  1659         vBd := vScrollBar borderWidth.
       
  1660         wVScroll := vScrollBar widthIncludingBorder.
       
  1661     ] ifFalse:[
       
  1662         vBd := wVScroll := 0.
       
  1663     ].
       
  1664 
       
  1665     (hasH := (hScrollBar notNil and:[hScrollBarHidden not])) ifTrue:[
       
  1666         hBd := hScrollBar borderWidth.
       
  1667         hHScroll := hScrollBar heightIncludingBorder.
       
  1668     ] ifFalse:[
       
  1669         hBd := hHScroll := 0.
       
  1670     ].
       
  1671 
       
  1672     "/ the raw layout ...
       
  1673 
       
  1674     scrolledViewLayout := ((0.0 @ 0.0) corner:(1.0@1.0)) asLayout.
       
  1675     hScrollBarLayout := ((0.0 @ 1.0) corner:(1.0@1.0)) asLayout.
       
  1676 
       
  1677     "/ the painful details; mostly complicated for 2D styles,
       
  1678     "/ where the positions are setUp to overlay borders ...
       
  1679     "/ (well, with 3D styles, a single pixel error will not be noticed;
       
  1680     "/  but 2D styles are very sensitive to those;
       
  1681     "/  the code below may not work correctly with different borderWidths).
       
  1682 
       
  1683     scrolledViewMargin := DefaultScrolledViewMargin.
       
  1684     scrollBarSpacing := DefaultScrollBarSpacing.
       
  1685 
       
  1686     vTopOffs := 0 - vBd + scrolledViewMargin + margin.
       
  1687 
       
  1688     scrolledViewMargin == 0 ifTrue:[
       
  1689         vBottomOffs := vBd - scrolledViewMargin - sBd.
       
  1690     ] ifFalse:[
       
  1691         vBottomOffs := vBd - scrolledViewMargin + sBd.
       
  1692     ].
       
  1693 
       
  1694     hLeftOffs := 0 - hBd + scrolledViewMargin + margin.
       
  1695     hRightOffs := hBd - scrolledViewMargin - sBd.
       
  1696 
       
  1697     sLeftOffs := 0 - hBd + scrolledViewMargin + margin.
       
  1698     sRightOffs := hBd - scrolledViewMargin - sBd - sBd - sBd.
       
  1699 
       
  1700     scrolledViewMargin == 0 ifTrue:[
       
  1701         sTopOffs := 0 - sBd + margin.
       
  1702         sBottomOffs := sBd - sBd.
       
  1703     ] ifFalse:[
       
  1704         sTopOffs := 0 + scrolledViewMargin + margin.
       
  1705         sBottomOffs := sBd - scrolledViewMargin - sBd - sBd - sBd.
       
  1706     ].
       
  1707 
       
  1708 "/ kludge - for now
       
  1709 styleSheet name == #win95 ifTrue:[
       
  1710     vTopOffs := 0.
       
  1711     hLeftOffs := 0.
       
  1712     sLeftOffs := 0.
       
  1713     sTopOffs := 0.
       
  1714 ].
       
  1715 
       
  1716     addMargin := 0.
       
  1717 "/    DefaultScrollBarLevel == DefaultScrolledViewLevel
       
  1718 "/        addMargin := 1.
       
  1719 "/    ].
       
  1720 
       
  1721     hasV ifTrue:[
       
  1722         scrollBarPosition == #right ifTrue:[
       
  1723             "/ right/bottom
       
  1724             vScrollBarLayout := ((1.0 @ 0.0) corner:(1.0@1.0)) asLayout.
       
  1725 
       
  1726             vRightOffs := 0 - scrolledViewMargin + margin "???".
       
  1727             vLeftOffs := vRightOffs - wVScroll.
       
  1728 
       
  1729             sRightOffs := sRightOffs - scrollBarSpacing - wVScroll + sBd.
       
  1730 
       
  1731             hRightOffs := hRightOffs - wVScroll - scrollBarSpacing - sBd.
       
  1732 
       
  1733             sRightOffs := sRightOffs - addMargin
       
  1734         ] ifFalse:[
       
  1735             "/ left/bottom
       
  1736             vScrollBarLayout := ((0.0 @ 0.0) corner:(0.0@1.0)) asLayout.
       
  1737 
       
  1738             vLeftOffs := 0 - vBd + scrolledViewMargin + margin.
       
  1739             vRightOffs := vLeftOffs + wVScroll + margin.
       
  1740 
       
  1741             sLeftOffs := wVScroll + scrolledViewMargin + scrollBarSpacing + margin.
       
  1742             sRightOffs := 0 - scrolledViewMargin - margin.
       
  1743             hLeftOffs := hLeftOffs + wVScroll + vBd + scrollBarSpacing.
       
  1744 
       
  1745             sLeftOffs := sLeftOffs + addMargin
       
  1746         ].
       
  1747     ].
       
  1748 
       
  1749     hasH ifTrue:[
       
  1750         hBottomOffs := 0 - scrolledViewMargin - hBd + margin "???".
       
  1751         hTopOffs := hBottomOffs - hHScroll.
       
  1752         scrolledViewMargin == 0 ifTrue:[
       
  1753             hTopOffs := hTopOffs + sBd + sBd
       
  1754         ].
       
  1755         sBottomOffs := sBottomOffs - scrollBarSpacing - hHScroll.
       
  1756         (vScrollBar notNil and:[vScrollBarHidden not]) ifTrue:[
       
  1757             vBottomOffs := vBottomOffs - scrollBarSpacing - hHScroll.
       
  1758         ].
       
  1759 
       
  1760         sBottomOffs := sBottomOffs - addMargin.
       
  1761         hRightOffs := hRightOffs - addMargin.
       
  1762     ].
       
  1763 
       
  1764     (hScrollBar notNil
       
  1765      and:[ hScrollBar borderWidth == 0 
       
  1766      and:[sBd ~~ 0
       
  1767      and:[scrollBarPosition == #right]]]) ifTrue:[
       
  1768         hRightOffs := hRightOffs + sBd + sBd.
       
  1769     ].
       
  1770 
       
  1771     scrolledView notNil ifTrue:[
       
  1772         scrolledViewLayout leftOffset:sLeftOffs.
       
  1773         scrolledViewLayout rightOffset:sRightOffs.
       
  1774         scrolledViewLayout topOffset:sTopOffs.
       
  1775         scrolledViewLayout bottomOffset:sBottomOffs.
       
  1776 
       
  1777         configureScrolledView ifTrue:[
       
  1778             ((hideVScrollBar or:[hideHScrollBar]) not
       
  1779             and:[(hScrollBar isNil or:[hScrollBarHidden])
       
  1780             and:[(vScrollBar isNil or:[vScrollBarHidden])]]) ifTrue:[
       
  1781                 scrolledView level:0
       
  1782             ] ifFalse:[
       
  1783                 scrolledView level:DefaultScrolledViewLevel.
       
  1784             ].
       
  1785         ].
       
  1786         scrolledView layout:scrolledViewLayout.
       
  1787     ].
       
  1788     hasH ifTrue:[
       
  1789         hScrollBarLayout leftOffset:hLeftOffs.
       
  1790         hScrollBarLayout rightOffset:hRightOffs.
       
  1791         hScrollBarLayout topOffset:hTopOffs.
       
  1792         hScrollBarLayout bottomOffset:hBottomOffs.
       
  1793 
       
  1794         hScrollBar level:DefaultScrollBarLevel.
       
  1795         hScrollBar layout:hScrollBarLayout.
       
  1796 
       
  1797 "/        scrollBarPosition == #right ifTrue:[
       
  1798 "/            "/ right/bottom
       
  1799 "/            hScrollBar viewGravity:#SouthWest.
       
  1800 "/        ] ifFalse:[
       
  1801 "/            hScrollBar viewGravity:#NorthWest.
       
  1802 "/        ]
       
  1803     ].
       
  1804     (vScrollBar notNil and:[vScrollBarHidden not]) ifTrue:[
       
  1805         vScrollBarLayout leftOffset:vLeftOffs.
       
  1806         vScrollBarLayout rightOffset:vRightOffs.
       
  1807         vScrollBarLayout topOffset:vTopOffs.
       
  1808         vScrollBarLayout bottomOffset:vBottomOffs.
       
  1809 
       
  1810         vScrollBar level:DefaultScrollBarLevel.
       
  1811         vScrollBar layout:vScrollBarLayout.
       
  1812 
       
  1813 "/        scrollBarPosition == #right ifTrue:[
       
  1814 "/            "/ right/bottom
       
  1815 "/            vScrollBar viewGravity:#NorthEast.
       
  1816 "/        ] ifFalse:[
       
  1817 "/            vScrollBar viewGravity:#NorthWest.
       
  1818 "/        ]
       
  1819     ].
       
  1820 
       
  1821     "Created: / 21.5.1998 / 00:48:35 / cg"
       
  1822     "Modified: / 9.9.1998 / 18:57:35 / cg"
       
  1823 !
       
  1824 
       
  1825 setupVertical:isVertical mini:miniV horizontal:isHorizontal mini:miniH 
       
  1826     "setup scrollbars as specified in the arguments"
       
  1827 
       
  1828     |noMiniScrollers|
       
  1829 
       
  1830     vScrollBarHidden := hScrollBarHidden := false.
       
  1831 
       
  1832     hasVerticalScrollBar := isVertical.
       
  1833     hasHorizontalScrollBar := isHorizontal.
       
  1834 
       
  1835     noMiniScrollers := styleSheet at:#'scrollBar.neverMini' default:false.
       
  1836     verticalMini := miniV.
       
  1837     horizontalMini := miniH.
       
  1838 
       
  1839     noMiniScrollers == true ifTrue:[
       
  1840         verticalMini := false.
       
  1841         horizontalMini := false.
       
  1842     ].
       
  1843 
       
  1844     self setupViews.
       
  1845 
       
  1846     "Modified: 7.3.1997 / 22:09:12 / cg"
       
  1847 !
       
  1848 
       
  1849 setupViews 
       
  1850     "setup scrollbars as specified in the arguments"
       
  1851 
       
  1852     |cls|
       
  1853 
       
  1854     hasVerticalScrollBar ifTrue:[
       
  1855         cls := ScrollBar. 
       
  1856         verticalMini ifTrue:[
       
  1857             cls := MiniScroller
       
  1858         ].
       
  1859         (vScrollBar notNil
       
  1860         and:[vScrollBar class ~~ cls]) ifTrue:[
       
  1861             self releaseVerticalScrollBar
       
  1862         ].
       
  1863         vScrollBar isNil ifTrue:[
       
  1864             vScrollBar := cls in:self.
       
  1865             realized ifTrue:[
       
  1866                 vScrollBar realize "/ beVisible
       
  1867             ]
       
  1868         ].
       
  1869         vScrollBar thumbOrigin:0 thumbHeight:100.
       
  1870     ] ifFalse:[
       
  1871         vScrollBar notNil ifTrue:[
       
  1872             self releaseVerticalScrollBar
       
  1873         ]
       
  1874     ].
       
  1875 
       
  1876     hasHorizontalScrollBar ifTrue:[
       
  1877         cls := HorizontalScrollBar. 
       
  1878         horizontalMini ifTrue:[
       
  1879             cls := HorizontalMiniScroller
       
  1880         ].
       
  1881         (hScrollBar notNil
       
  1882         and:[hScrollBar class ~~ cls]) ifTrue:[
       
  1883             self releaseHorizontalScrollBar
       
  1884         ].
       
  1885         hScrollBar isNil ifTrue:[
       
  1886             hScrollBar := cls in:self.
       
  1887             realized ifTrue:[
       
  1888                 hScrollBar realize "/ beVisible
       
  1889             ]
       
  1890         ].
       
  1891         hScrollBar thumbOrigin:0 thumbHeight:100.
       
  1892     ] ifFalse:[
       
  1893         hScrollBar notNil ifTrue:[
       
  1894             self releaseHorizontalScrollBar
       
  1895         ]
       
  1896     ].
       
  1897 
       
  1898     scrolledView notNil ifTrue:[
       
  1899         self setScrollActions.
       
  1900     ]
       
  1901 
       
  1902     "Created: 6.3.1997 / 18:06:23 / cg"
       
  1903     "Modified: 8.4.1997 / 00:44:33 / cg"
       
  1904 ! !
       
  1905 
       
  1906 !ScrollableView methodsFor:'queries'!
       
  1907 
       
  1908 isHorizontalScrollable
       
  1909     "return true if I am horizontally scrollable"
       
  1910 
       
  1911     ^ hScrollBar notNil
       
  1912 
       
  1913     "Modified: 6.3.1997 / 17:03:49 / cg"
       
  1914     "Created: 6.3.1997 / 18:06:23 / cg"
       
  1915 !
       
  1916 
       
  1917 isScrollWrapper
       
  1918      ^ true
       
  1919 
       
  1920     "Created: / 20.6.1998 / 14:15:42 / cg"
       
  1921 !
       
  1922 
       
  1923 isVerticalScrollable
       
  1924     "return true if I am vertically scrollable"
       
  1925 
       
  1926     ^ vScrollBar notNil
       
  1927 
       
  1928     "Modified: 6.3.1997 / 17:03:52 / cg"
       
  1929     "Created: 6.3.1997 / 18:06:23 / cg"
       
  1930 !
       
  1931 
       
  1932 preferredExtent
       
  1933     "return my preferredExtent from the scrolledViews prefExtent
       
  1934      plus the size of the scrollBar"
       
  1935 
       
  1936     |slavesPref prefX prefY margin|
       
  1937 
       
  1938     "/ If I have an explicit preferredExtent ..
       
  1939 
       
  1940     preferredExtent notNil ifTrue:[
       
  1941         ^ preferredExtent
       
  1942     ].
       
  1943 
       
  1944     scrolledView notNil ifTrue:[ 
       
  1945         slavesPref := scrolledView preferredExtent.
       
  1946         prefX := slavesPref x.
       
  1947         prefY := slavesPref y.
       
  1948         margin := (DefaultScrolledViewMargin * 2) + DefaultScrollBarSpacing.
       
  1949         vScrollBar notNil ifTrue:[
       
  1950             prefX := prefX + vScrollBar width + margin.
       
  1951         ].
       
  1952         hScrollBar notNil ifTrue:[
       
  1953             prefY := prefY + hScrollBar height + margin.
       
  1954         ].
       
  1955 
       
  1956         ^ prefX @ prefY.
       
  1957     ].
       
  1958 
       
  1959     ^ super preferredExtent.
       
  1960 
       
  1961     "Created: 6.3.1997 / 18:06:24 / cg"
       
  1962     "Modified: 6.3.1997 / 22:34:09 / cg"
       
  1963 !
       
  1964 
       
  1965 preferredExtentForLines:numLines cols:numCols
       
  1966     "return my preferredExtent from the scrolledViews prefExtent
       
  1967      plus the size of the scrollBar"
       
  1968 
       
  1969     |slavesPref prefX prefY|
       
  1970 
       
  1971     "/ If I have an explicit preferredExtent ..
       
  1972 
       
  1973     preferredExtent notNil ifTrue:[
       
  1974 	^ preferredExtent
       
  1975     ].
       
  1976 
       
  1977     scrolledView notNil ifTrue:[ 
       
  1978 	slavesPref := scrolledView preferredExtentForLines:numLines cols:numCols.
       
  1979 	prefX := slavesPref x.
       
  1980 	prefY := slavesPref y.
       
  1981 	vScrollBar notNil ifTrue:[
       
  1982 	    prefX := prefX + vScrollBar width + (DefaultScrolledViewMargin * 2) + DefaultScrollBarSpacing.
       
  1983 	].
       
  1984 	hScrollBar notNil ifTrue:[
       
  1985 	    prefY := prefY + hScrollBar height + (DefaultScrolledViewMargin * 2) + DefaultScrollBarSpacing.
       
  1986 	].
       
  1987 
       
  1988 	^ prefX @ prefY.
       
  1989     ].
       
  1990 
       
  1991     ^ super preferredExtent.
       
  1992 
       
  1993     "Created: 6.3.1997 / 18:06:24 / cg"
       
  1994     "Modified: 6.3.1997 / 22:34:30 / cg"
       
  1995 !
       
  1996 
       
  1997 specClass
       
  1998     "redefined, since my subclasses also want ScrollableViewSpecs"
       
  1999 
       
  2000     ^ ScrollableViewSpec
       
  2001 
       
  2002     "Modified: / 31.10.1997 / 19:48:48 / cg"
       
  2003 ! !
       
  2004 
       
  2005 !ScrollableView methodsFor:'slave-view messages'!
       
  2006 
       
  2007 clear
       
  2008     "convenient method: forward this to the scrolledView"
       
  2009 
       
  2010     scrolledView notNil ifTrue:[scrolledView clear]
       
  2011 
       
  2012     "Created: 6.3.1997 / 18:06:24 / cg"
       
  2013     "Modified: 19.3.1997 / 16:34:19 / cg"
       
  2014 !
       
  2015 
       
  2016 doesNotUnderstand:aMessage
       
  2017     "this is funny: all message we do not understand, are passed
       
  2018      on to the scrolledView - so we do not have to care for all
       
  2019      possible messages ...(thanks to the Message class)"
       
  2020 
       
  2021      scrolledView isNil ifFalse:[
       
  2022 	 ^ scrolledView perform:(aMessage selector)
       
  2023 		  withArguments:(aMessage arguments)
       
  2024      ].
       
  2025      ^ super doesNotUnderstand:aMessage
       
  2026 
       
  2027     "Created: 6.3.1997 / 18:06:24 / cg"
       
  2028     "Modified: 6.3.1997 / 18:38:54 / cg"
       
  2029 !
       
  2030 
       
  2031 leftButtonMenu
       
  2032     "return scrolledViews leftbuttonmenu"
       
  2033 
       
  2034     scrolledView isNil ifTrue:[^ nil].
       
  2035     ^ scrolledView leftButtonMenu
       
  2036 
       
  2037     "Created: 6.3.1997 / 18:06:24 / cg"
       
  2038 !
       
  2039 
       
  2040 leftButtonMenu:aMenu
       
  2041     "pass on leftbuttonmenu to scrolledView"
       
  2042 
       
  2043     scrolledView leftButtonMenu:aMenu
       
  2044 
       
  2045     "Created: 6.3.1997 / 18:06:24 / cg"
       
  2046 !
       
  2047 
       
  2048 middleButtonMenu
       
  2049     "return scrolledViews middlebuttonmenu"
       
  2050 
       
  2051     scrolledView isNil ifTrue:[^ nil].
       
  2052     ^ scrolledView middleButtonMenu
       
  2053 
       
  2054     "Created: 6.3.1997 / 18:06:24 / cg"
       
  2055 !
       
  2056 
       
  2057 middleButtonMenu:aMenu
       
  2058     "pass on middlebuttonmenu to scrolledView"
       
  2059 
       
  2060     scrolledView middleButtonMenu:aMenu
       
  2061 
       
  2062     "Created: 6.3.1997 / 18:06:24 / cg"
       
  2063 !
       
  2064 
       
  2065 model
       
  2066     "return my scrolledViews model"
       
  2067 
       
  2068     scrolledView isNil ifTrue:[^ nil].
       
  2069     ^ scrolledView model
       
  2070 
       
  2071     "Modified: 1.3.1997 / 01:38:07 / cg"
       
  2072     "Created: 6.3.1997 / 18:06:24 / cg"
       
  2073 !
       
  2074 
       
  2075 model:aModel
       
  2076     "forward model change to my scrolledViews"
       
  2077 
       
  2078     ^ scrolledView model:aModel
       
  2079 
       
  2080     "Modified: 5.6.1996 / 17:09:50 / cg"
       
  2081     "Created: 6.3.1997 / 18:06:24 / cg"
       
  2082 !
       
  2083 
       
  2084 requestFocus
       
  2085     ^ scrolledView requestFocus
       
  2086 !
       
  2087 
       
  2088 rightButtonMenu
       
  2089     "return scrolledViews rightbuttonmenu"
       
  2090 
       
  2091     scrolledView isNil ifTrue:[^ nil].
       
  2092     ^ scrolledView rightButtonMenu
       
  2093 
       
  2094     "Created: 6.3.1997 / 18:06:24 / cg"
       
  2095 !
       
  2096 
       
  2097 rightButtonMenu:aMenu
       
  2098     "pass on rightbuttonmenu to scrolledView"
       
  2099 
       
  2100     scrolledView rightButtonMenu:aMenu
       
  2101 
       
  2102     "Created: 6.3.1997 / 18:06:24 / cg"
       
  2103 ! !
       
  2104 
       
  2105 !ScrollableView class methodsFor:'documentation'!
       
  2106 
       
  2107 version
       
  2108     ^ '$Header: /cvs/stx/stx/libwidg/Attic/ScrView.st,v 1.100 1999-08-17 10:59:01 cg Exp $'
       
  2109 ! !