VPanelV.st
changeset 125 3ffa271732f7
parent 77 565b052f5277
child 127 462396b08e30
equal deleted inserted replaced
124:7abd3a234296 125:3ffa271732f7
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
    12 
       
    13 'From Smalltalk/X, Version:2.10.5 on 9-may-1995 at 12:07:08 pm'!
       
    14 
    13 PanelView subclass:#VerticalPanelView
    15 PanelView subclass:#VerticalPanelView
    14        instanceVariableNames:''
    16 	 instanceVariableNames:''
    15        classVariableNames:''
    17 	 classVariableNames:''
    16        poolDictionaries:''
    18 	 poolDictionaries:''
    17        category:'Views-Layout'
    19 	 category:'Views-Layout'
    18 !
    20 !
    19 
    21 
    20 VerticalPanelView comment:'
    22 VerticalPanelView comment:'
    21 COPYRIGHT (c) 1989 by Claus Gittinger
    23 COPYRIGHT (c) 1989 by Claus Gittinger
    22 	      All Rights Reserved
    24 	      All Rights Reserved
    23 
    25 
    24 $Header: /cvs/stx/stx/libwidg/Attic/VPanelV.st,v 1.8 1995-02-06 00:53:30 claus Exp $
    26 $Header: /cvs/stx/stx/libwidg/Attic/VPanelV.st,v 1.9 1995-05-09 01:57:00 claus Exp $
    25 '!
    27 '!
    26 
    28 
    27 !VerticalPanelView class methodsFor:'documentation'!
    29 !VerticalPanelView class methodsFor:'documentation'!
    28 
    30 
    29 copyright
    31 copyright
    40 "
    42 "
    41 !
    43 !
    42 
    44 
    43 version
    45 version
    44 "
    46 "
    45 $Header: /cvs/stx/stx/libwidg/Attic/VPanelV.st,v 1.8 1995-02-06 00:53:30 claus Exp $
    47 $Header: /cvs/stx/stx/libwidg/Attic/VPanelV.st,v 1.9 1995-05-09 01:57:00 claus Exp $
    46 "
    48 "
    47 !
    49 !
    48 
    50 
    49 documentation
    51 documentation
    50 "
    52 "
    96     verticalLayout:/horizontalLayout: combinations.
    98     verticalLayout:/horizontalLayout: combinations.
    97 
    99 
    98 
   100 
    99     example: default layout (centered)
   101     example: default layout (centered)
   100 
   102 
   101 	|v p b1 b2 b3|
   103         |v p b1 b2 b3|
   102 
   104 
   103 	v := StandardSystemView new.
   105         v := StandardSystemView new.
   104 	p := VerticalPanelView in:v.
   106         p := VerticalPanelView in:v.
   105 	p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   107         p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   106 	b1 := Button label:'button1' in:p.
   108         b1 := Button label:'button1' in:p.
   107 	b2 := Button label:'button2' in:p.
   109         b2 := Button label:'button2' in:p.
   108 	b3 := Button label:'button3' in:p.
   110         b3 := Button label:'button3' in:p.
   109 	v extent:100 @ 300.
   111         v extent:100 @ 300.
   110 	v open
   112         v open
   111 
   113 
   112 
   114 
   113     example: top-layout
   115     example: top-layout
   114 
   116 
   115 	|v p b1 b2 b3|
   117         |v p b1 b2 b3|
   116 
   118 
   117 	v := StandardSystemView new.
   119         v := StandardSystemView new.
   118 	p := VerticalPanelView in:v.
   120         p := VerticalPanelView in:v.
   119 	p verticalLayout:#top.
   121         p verticalLayout:#top.
   120 	p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   122         p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   121 	b1 := Button label:'button1' in:p.
   123         b1 := Button label:'button1' in:p.
   122 	b2 := Button label:'button2' in:p.
   124         b2 := Button label:'button2' in:p.
   123 	b3 := Button label:'button3' in:p.
   125         b3 := Button label:'button3' in:p.
   124 	v extent:100 @ 300.
   126         v extent:100 @ 300.
   125 	v open
   127         v open
   126 
   128 
   127 
   129 
   128     example: top-layout; horizontal fit
   130     example: top-layout; horizontal fit
   129 
   131 
   130 	|v p b1 b2 b3|
   132         |v p b1 b2 b3|
   131 
   133 
   132 	v := StandardSystemView new.
   134         v := StandardSystemView new.
   133 	p := VerticalPanelView in:v.
   135         p := VerticalPanelView in:v.
   134 	p verticalLayout:#top.
   136         p verticalLayout:#top.
   135 	p horizontalLayout:#fit.
   137         p horizontalLayout:#fit.
   136 	p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   138         p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   137 	b1 := Button label:'button1' in:p.
   139         b1 := Button label:'button1' in:p.
   138 	b2 := Button label:'button2' in:p.
   140         b2 := Button label:'button2' in:p.
   139 	b3 := Button label:'button3' in:p.
   141         b3 := Button label:'button3' in:p.
   140 	v extent:100 @ 300.
   142         v extent:100 @ 300.
   141 	v open
   143         v open
   142 
   144 
   143 
   145 
   144     example: top-layout; horizontal fit with space
   146     example: top-layout; horizontal fit with space
   145 
   147 
   146 	|v p b1 b2 b3|
   148         |v p b1 b2 b3|
   147 
   149 
   148 	v := StandardSystemView new.
   150         v := StandardSystemView new.
   149 	p := VerticalPanelView in:v.
   151         p := VerticalPanelView in:v.
   150 	p verticalLayout:#top.
   152         p verticalLayout:#top.
   151 	p horizontalLayout:#fitSpace.
   153         p horizontalLayout:#fitSpace.
   152 	p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   154         p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   153 	b1 := Button label:'button1' in:p.
   155         b1 := Button label:'button1' in:p.
   154 	b2 := Button label:'button2' in:p.
   156         b2 := Button label:'button2' in:p.
   155 	b3 := Button label:'button3' in:p.
   157         b3 := Button label:'button3' in:p.
   156 	v extent:100 @ 300.
   158         v extent:100 @ 300.
   157 	v open
   159         v open
   158 
   160 
   159 
   161 
   160     example: topSpace-layout
   162     example: topSpace-layout
   161 
   163 
   162 	|v p b1 b2 b3|
   164         |v p b1 b2 b3|
   163 
   165 
   164 	v := StandardSystemView new.
   166         v := StandardSystemView new.
   165 	p := VerticalPanelView in:v.
   167         p := VerticalPanelView in:v.
   166 	p verticalLayout:#topSpace.
   168         p verticalLayout:#topSpace.
   167 	p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   169         p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   168 	b1 := Button label:'button1' in:p.
   170         b1 := Button label:'button1' in:p.
   169 	b2 := Button label:'button2' in:p.
   171         b2 := Button label:'button2' in:p.
   170 	b3 := Button label:'button3' in:p.
   172         b3 := Button label:'button3' in:p.
   171 	v extent:100 @ 300.
   173         v extent:100 @ 300.
   172 	v open
   174         v open
   173 
   175 
   174 
   176 
   175     example: bottom-layout
   177     example: bottom-layout
   176 
   178 
   177 	|v p b1 b2 b3|
   179         |v p b1 b2 b3|
   178 
   180 
   179 	v := StandardSystemView new.
   181         v := StandardSystemView new.
   180 	p := VerticalPanelView in:v.
   182         p := VerticalPanelView in:v.
   181 	p verticalLayout:#bottom.
   183         p verticalLayout:#bottom.
   182 	p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   184         p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   183 	b1 := Button label:'button1' in:p.
   185         b1 := Button label:'button1' in:p.
   184 	b2 := Button label:'button2' in:p.
   186         b2 := Button label:'button2' in:p.
   185 	b3 := Button label:'button3' in:p.
   187         b3 := Button label:'button3' in:p.
   186 	v extent:100 @ 300.
   188         v extent:100 @ 300.
   187 	v open
   189         v open
   188 
   190 
   189 
   191 
   190     example: bottomSpace-layout
   192     example: bottomSpace-layout
   191 
   193 
   192 	|v p b1 b2 b3|
   194         |v p b1 b2 b3|
   193 
   195 
   194 	v := StandardSystemView new.
   196         v := StandardSystemView new.
   195 	p := VerticalPanelView in:v.
   197         p := VerticalPanelView in:v.
   196 	p verticalLayout:#bottomSpace.
   198         p verticalLayout:#bottomSpace.
   197 	p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   199         p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   198 	b1 := Button label:'button1' in:p.
   200         b1 := Button label:'button1' in:p.
   199 	b2 := Button label:'button2' in:p.
   201         b2 := Button label:'button2' in:p.
   200 	b3 := Button label:'button3' in:p.
   202         b3 := Button label:'button3' in:p.
   201 	v extent:100 @ 300.
   203         v extent:100 @ 300.
   202 	v open
   204         v open
   203 
   205 
   204 
   206 
   205     example: spread-layout
   207     example: spread-layout
   206 
   208 
   207 	|v p b1 b2 b3|
   209         |v p b1 b2 b3|
   208 
   210 
   209 	v := StandardSystemView new.
   211         v := StandardSystemView new.
   210 	p := VerticalPanelView in:v.
   212         p := VerticalPanelView in:v.
   211 	p verticalLayout:#spread.
   213         p verticalLayout:#spread.
   212 	p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   214         p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   213 	b1 := Button label:'button1' in:p.
   215         b1 := Button label:'button1' in:p.
   214 	b2 := Button label:'button2' in:p.
   216         b2 := Button label:'button2' in:p.
   215 	b3 := Button label:'button3' in:p.
   217         b3 := Button label:'button3' in:p.
   216 	v extent:100 @ 300.
   218         v extent:100 @ 300.
   217 	v open
   219         v open
   218 
   220 
   219 
   221 
   220     example: spreadSpace-layout
   222     example: spreadSpace-layout
   221 
   223 
   222 	|v p b1 b2 b3|
   224         |v p b1 b2 b3|
   223 
   225 
   224 	v := StandardSystemView new.
   226         v := StandardSystemView new.
   225 	p := VerticalPanelView in:v.
   227         p := VerticalPanelView in:v.
   226 	p verticalLayout:#spreadSpace.
   228         p verticalLayout:#spreadSpace.
   227 	p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   229         p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   228 	b1 := Button label:'button1' in:p.
   230         b1 := Button label:'button1' in:p.
   229 	b2 := Button label:'button2' in:p.
   231         b2 := Button label:'button2' in:p.
   230 	b3 := Button label:'button3' in:p.
   232         b3 := Button label:'button3' in:p.
   231 	v extent:100 @ 300.
   233         v extent:100 @ 300.
   232 	v open
   234         v open
   233 
   235 
   234 
   236 
   235     example: fit-layout
   237     example: fit-layout
   236 
   238 
   237 	|v p b1 b2 b3|
   239         |v p b1 b2 b3|
   238 
   240 
   239 	v := StandardSystemView new.
   241         v := StandardSystemView new.
   240 	p := VerticalPanelView in:v.
   242         p := VerticalPanelView in:v.
   241 	p verticalLayout:#fit.
   243         p verticalLayout:#fit.
   242 	p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   244         p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   243 	b1 := Button label:'button1' in:p.
   245         b1 := Button label:'button1' in:p.
   244 	b2 := Button label:'button2' in:p.
   246         b2 := Button label:'button2' in:p.
   245 	b3 := Button label:'button3' in:p.
   247         b3 := Button label:'button3' in:p.
   246 	v extent:100 @ 300.
   248         v extent:100 @ 300.
   247 	v open
   249         v open
   248 
   250 
   249 
   251 
   250     example: fitSpace-layout
   252     example: fitSpace-layout
   251 
   253 
   252 	|v p b1 b2 b3|
   254         |v p b1 b2 b3|
   253 
   255 
   254 	v := StandardSystemView new.
   256         v := StandardSystemView new.
   255 	p := VerticalPanelView in:v.
   257         p := VerticalPanelView in:v.
   256 	p verticalLayout:#fitSpace.
   258         p verticalLayout:#fitSpace.
   257 	p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   259         p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   258 	b1 := Button label:'button1' in:p.
   260         b1 := Button label:'button1' in:p.
   259 	b2 := Button label:'button2' in:p.
   261         b2 := Button label:'button2' in:p.
   260 	b3 := Button label:'button3' in:p.
   262         b3 := Button label:'button3' in:p.
   261 	v extent:100 @ 300.
   263         v extent:100 @ 300.
   262 	v open
   264         v open
   263 
   265 
   264 
   266 
   265     example: fully fitSpace
   267     example: fully fitSpace
   266 
   268 
   267 	|v p b1 b2 b3|
   269         |v p b1 b2 b3|
   268 
   270 
   269 	v := StandardSystemView new.
   271         v := StandardSystemView new.
   270 	p := VerticalPanelView in:v.
   272         p := VerticalPanelView in:v.
   271 	p verticalLayout:#fitSpace.
   273         p verticalLayout:#fitSpace.
   272 	p horizontalLayout:#fitSpace.
   274         p horizontalLayout:#fitSpace.
   273 	p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   275         p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   274 	b1 := Button label:'button1' in:p.
   276         b1 := Button label:'button1' in:p.
   275 	b2 := Button label:'button2' in:p.
   277         b2 := Button label:'button2' in:p.
   276 	b3 := Button label:'button3' in:p.
   278         b3 := Button label:'button3' in:p.
   277 	v extent:100 @ 300.
   279         v extent:100 @ 300.
   278 	v open
   280         v open
   279 
   281 
   280 
   282 
   281     example: from top, each at left:
   283     example: from top, each at left:
   282 
   284 
   283 	|v p b1 b2 b3|
   285         |v p b1 b2 b3|
   284 
   286 
   285 	v := StandardSystemView new.
   287         v := StandardSystemView new.
   286 	p := VerticalPanelView in:v.
   288         p := VerticalPanelView in:v.
   287 	p verticalLayout:#top.
   289         p verticalLayout:#top.
   288 	p horizontalLayout:#left.
   290         p horizontalLayout:#left.
   289 	p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   291         p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   290 	b1 := Button label:'button1' in:p.
   292         b1 := Button label:'button1' in:p.
   291 	b2 := Button label:'button2' in:p.
   293         b2 := Button label:'button2' in:p.
   292 	b3 := Button label:'button3' in:p.
   294         b3 := Button label:'button3' in:p.
   293 	v extent:100 @ 300.
   295         v extent:100 @ 300.
   294 	v open
   296         v open
   295 
   297 
   296 
   298 
   297     example: centered, right:
   299     example: centered, right:
   298 
   300 
   299 	|v p b1 b2 b3|
   301         |v p b1 b2 b3|
   300 
   302 
   301 	v := StandardSystemView new.
   303         v := StandardSystemView new.
   302 	p := VerticalPanelView in:v.
   304         p := VerticalPanelView in:v.
   303 	p verticalLayout:#centered.
   305         p verticalLayout:#centered.
   304 	p horizontalLayout:#right.
   306         p horizontalLayout:#right.
   305 	p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   307         p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   306 	b1 := Button label:'button1' in:p.
   308         b1 := Button label:'button1' in:p.
   307 	b2 := Button label:'button2' in:p.
   309         b2 := Button label:'button2' in:p.
   308 	b3 := Button label:'button3' in:p.
   310         b3 := Button label:'button3' in:p.
   309 	v extent:100 @ 300.
   311         v extent:100 @ 300.
   310 	v open
   312         v open
   311 
   313 
   312 
   314 
   313     example: a panel in a panel
   315     example: a panel in a panel
   314 
   316 
   315 	|v hp p b1 b2 b3|
   317         |v hp p b1 b2 b3|
   316 
   318 
   317 	v := StandardSystemView new.
   319         v := StandardSystemView new.
   318 
   320 
   319 	hp := HorizontalPanelView in:v.
   321         hp := HorizontalPanelView in:v.
   320 	hp verticalLayout:#fit.
   322         hp verticalLayout:#fit.
   321 	hp horizontalLayout:#fitSpace.
   323         hp horizontalLayout:#fitSpace.
   322 	hp origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   324         hp origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
   323 
   325 
   324 	1 to:3 do:[:i |
   326         1 to:3 do:[:i |
   325 	    p := VerticalPanelView in:hp.
   327             p := VerticalPanelView in:hp.
   326 	    p borderWidth:0.
   328             p borderWidth:0.
   327 	    p verticalLayout:#fitSpace.
   329             p verticalLayout:#fitSpace.
   328 	    p horizontalLayout:#fit.
   330             p horizontalLayout:#fit.
   329 	    b1 := Button label:'button1' in:p.
   331             b1 := Button label:'button1' in:p.
   330 	    b2 := Button label:'button2' in:p.
   332             b2 := Button label:'button2' in:p.
   331 	    b3 := Button label:'button3' in:p.
   333             b3 := Button label:'button3' in:p.
   332 	].
   334         ].
   333 
   335 
   334 	v extent:300 @ 100.
   336         v extent:300 @ 100.
   335 	v open
   337         v open
   336 "
   338 
   337 ! !
   339     example: checkToggles in a panel
   338 
   340 
   339 !VerticalPanelView methodsFor:'accessing'!
   341         |panel|
   340 
   342 
   341 horizontalLayout
   343         panel := VerticalPanelView new.
   342     "return the horizontal layout as symbol.
   344         panel horizontalLayout:#left.
   343      the returned value is one of
   345 
   344 	#left 
   346         panel add:((CheckBox on:true asValue) label:'this is toggle number 1'; resize).
   345 	#leftSpace 
   347         panel add:((CheckBox on:false asValue) label:'nr 2 '; resize).
   346 	#center
   348         panel add:((CheckBox on:true asValue) label:'number 3 '; resize).
   347 	#right 
   349 
   348 	#rightSpace 
   350         panel extent:(panel preferedExtent).
   349 	#fit 
   351         panel open
   350       the default is #centered
   352 "
   351     "
       
   352 
       
   353     ^ hLayout
       
   354 !
       
   355 
       
   356 verticalLayout
       
   357     "return the vertical layout as a symbol.
       
   358      the returned value is one of
       
   359 	#top
       
   360 	#topSpace
       
   361 	#spread
       
   362 	#fit
       
   363 	#center
       
   364 	#bottom
       
   365 	#bottomSpace
       
   366       the default is #centered
       
   367     "
       
   368 
       
   369     ^ vLayout
       
   370 !
       
   371 
       
   372 horizontalLayout:aSymbol
       
   373     "change the horizontal layout as symbol.
       
   374      The argument, aSymbol must be one of:
       
   375 	#left 
       
   376 	#leftSpace 
       
   377 	#center
       
   378 	#right 
       
   379 	#rightSpace 
       
   380 	#fit 
       
   381       the default (if never changed) is #centered
       
   382     "
       
   383 
       
   384     (hLayout ~~ aSymbol) ifTrue:[
       
   385 	hLayout := aSymbol.
       
   386 	self layoutChanged
       
   387     ]
       
   388 !
       
   389 
       
   390 verticalLayout:aSymbol
       
   391     "change the vertical layout as a symbol.
       
   392      The argument, aSymbol must be one of:
       
   393 	#top
       
   394 	#topSpace
       
   395 	#spread
       
   396 	#fit
       
   397 	#center
       
   398 	#bottom
       
   399 	#bottomSpace
       
   400       the default (if never changed) is #centered
       
   401     "
       
   402 
       
   403     (vLayout ~~ aSymbol) ifTrue:[
       
   404 	vLayout := aSymbol.
       
   405 	self layoutChanged
       
   406     ]
       
   407 !
       
   408 
       
   409 layout
       
   410     "leftover for historic reasons - do not use any more"
       
   411 
       
   412     self verticalLayout
       
   413 !
       
   414 
       
   415 layout:aSymbol
       
   416     "leftover for historic reasons - do not use any more"
       
   417 
       
   418     self verticalLayout:aSymbol
       
   419 ! !
       
   420 
       
   421 
       
   422 !VerticalPanelView methodsFor:'queries'!
       
   423 
       
   424 preferedExtent
       
   425     "return a good extent, one that makes subviews fit"
       
   426 
       
   427     |sumOfHeights maxWidth maxHeight|
       
   428 
       
   429     subViews isNil ifTrue:[^ horizontalSpace @ verticalSpace].
       
   430 
       
   431     "compute net height needed"
       
   432 
       
   433     sumOfHeights := 0.
       
   434     maxWidth := 0.
       
   435     maxHeight := 0.
       
   436 
       
   437     subViews do:[:child |
       
   438 	|childsPreference|
       
   439 
       
   440 	childsPreference := child preferedExtent.
       
   441 	sumOfHeights := sumOfHeights + childsPreference y.
       
   442 	maxHeight := maxHeight max:childsPreference y.
       
   443 	maxWidth := maxWidth max:childsPreference x.
       
   444 
       
   445 "/        sumOfHeights := sumOfHeights + child heightIncludingBorder.
       
   446 "/        maxWidth := maxWidth max:(child widthIncludingBorder).
       
   447 "/        maxHeight := maxHeight max:(child heightIncludingBorder).
       
   448     ].
       
   449     borderWidth ~~ 0 ifTrue:[
       
   450 	sumOfHeights := sumOfHeights + (horizontalSpace * 2).
       
   451 	maxWidth := maxWidth + (horizontalSpace * 2).
       
   452     ].
       
   453     (vLayout == #fit or:[vLayout == #fitSpace]) ifTrue:[
       
   454 	sumOfHeights := maxHeight * subViews size.
       
   455 	borderWidth ~~ 0 ifTrue:[
       
   456 	    sumOfHeights := sumOfHeights + (verticalSpace * 2).
       
   457 	]
       
   458     ] ifFalse:[
       
   459 	sumOfHeights := sumOfHeights + ((subViews size - 1) * verticalSpace).
       
   460     ].
       
   461 
       
   462     ((hLayout == #leftSpace) or:[hLayout == #rightSpace]) ifTrue:[
       
   463 	maxWidth := maxWidth + horizontalSpace
       
   464     ] ifFalse:[
       
   465 	((hLayout == #fitSpace) or:[hLayout == #center]) ifTrue:[
       
   466 	    maxWidth := maxWidth + (horizontalSpace * 2)
       
   467 	]        
       
   468     ].
       
   469     ^ maxWidth @ sumOfHeights
       
   470 ! !
   353 ! !
   471 
   354 
   472 !VerticalPanelView methodsFor:'layout'!
   355 !VerticalPanelView methodsFor:'layout'!
   473 
   356 
   474 setChildPositions
   357 setChildPositions
   581 
   464 
   582     "
   465     "
   583      now set positions
   466      now set positions
   584     "
   467     "
   585     subViews do:[:child |
   468     subViews do:[:child |
   586 	|xpos|
   469 	|xpos bwChild wChild|
       
   470 
       
   471 	wChild := child widthIncludingBorder.
       
   472 	bwChild := child borderWidth.
   587 
   473 
   588 	hLayout == #left ifTrue:[
   474 	hLayout == #left ifTrue:[
   589 	    xpos := 0
   475 	    xpos := 0
   590 	] ifFalse:[
   476 	] ifFalse:[
   591 	    hLayout == #leftSpace ifTrue:[
   477 	    hLayout == #leftSpace ifTrue:[
   592 		xpos := horizontalSpace
   478 		xpos := horizontalSpace
   593 	    ] ifFalse:[
   479 	    ] ifFalse:[
   594 		hLayout == #right ifTrue:[
   480 		hLayout == #right ifTrue:[
   595 		    xpos := width - child widthIncludingBorder
   481 		    xpos := width - wChild
   596 		] ifFalse:[
   482 		] ifFalse:[
   597 		    hLayout == #rightSpace ifTrue:[
   483 		    hLayout == #rightSpace ifTrue:[
   598 			xpos := width - horizontalSpace - child widthIncludingBorder.
   484 			xpos := width - horizontalSpace - wChild.
   599 		    ] ifFalse:[
   485 		    ] ifFalse:[
   600 			hLayout == #fitSpace ifTrue:[
   486 			hLayout == #fitSpace ifTrue:[
   601 			    xpos := horizontalSpace.
   487 			    xpos := horizontalSpace.
   602 			    child width:(width - (horizontalSpace + child borderWidth * 2))
   488 			    child width:(width - (horizontalSpace +  bwChild * 2))
   603 			] ifFalse:[
   489 			] ifFalse:[
   604 			    hLayout == #fit ifTrue:[
   490 			    hLayout == #fit ifTrue:[
   605 				xpos := 0.
   491 				xpos := 0.
   606 				child width:(width - (child borderWidth * 2))
   492 				child width:(width - (bwChild  * 2))
   607 			    ] ifFalse:[
   493 			    ] ifFalse:[
   608 			       "centered"
   494 			       "centered"
   609 				xpos := (width - child widthIncludingBorder) // 2.
   495 				xpos := (width - wChild) // 2.
   610 			    ]
   496 			    ]
   611 			]
   497 			]
   612 		    ]
   498 		    ]
   613 		]
   499 		]
   614 	    ]
   500 	    ]
   616 	(xpos < 0) ifTrue:[ xpos := 0 ].
   502 	(xpos < 0) ifTrue:[ xpos := 0 ].
   617 
   503 
   618 	(vLayout == #fit or:[vLayout == #fitSpace]) ifTrue:[
   504 	(vLayout == #fit or:[vLayout == #fitSpace]) ifTrue:[
   619 	    child origin:(xpos @ ypos rounded)
   505 	    child origin:(xpos @ ypos rounded)
   620 		  corner:(xpos + (child width))
   506 		  corner:(xpos + (child width))
   621 			 @ (ypos + hEach - (child borderWidth)) rounded.
   507 			 @ (ypos + hEach - bwChild) rounded.
   622 	    ypos := ypos + hEach + space
   508 	    ypos := ypos + hEach + space
   623 	] ifFalse:[
   509 	] ifFalse:[
   624 	    child origin:(xpos@ypos).
   510 	    child origin:(xpos@ypos).
   625 	    ypos := ypos + (child heightIncludingBorder) + space
   511 	    ypos := ypos + (child heightIncludingBorder) + space
   626 	]
   512 	]
   627     ]
   513     ]
   628 ! !
   514 ! !
       
   515 
       
   516 !VerticalPanelView methodsFor:'accessing'!
       
   517 
       
   518 horizontalLayout
       
   519     "return the horizontal layout as symbol.
       
   520      the returned value is one of
       
   521 	#left 
       
   522 	#leftSpace 
       
   523 	#center
       
   524 	#right 
       
   525 	#rightSpace 
       
   526 	#fit 
       
   527       the default is #centered
       
   528     "
       
   529 
       
   530     ^ hLayout
       
   531 !
       
   532 
       
   533 horizontalLayout:aSymbol
       
   534     "change the horizontal layout as symbol.
       
   535      The argument, aSymbol must be one of:
       
   536 	#left 
       
   537 	#leftSpace 
       
   538 	#center
       
   539 	#right 
       
   540 	#rightSpace 
       
   541 	#fit 
       
   542       the default (if never changed) is #centered
       
   543     "
       
   544 
       
   545     (hLayout ~~ aSymbol) ifTrue:[
       
   546 	hLayout := aSymbol.
       
   547 	self layoutChanged
       
   548     ]
       
   549 !
       
   550 
       
   551 verticalLayout
       
   552     "return the vertical layout as a symbol.
       
   553      the returned value is one of
       
   554 	#top
       
   555 	#topSpace
       
   556 	#spread
       
   557 	#fit
       
   558 	#center
       
   559 	#bottom
       
   560 	#bottomSpace
       
   561       the default is #centered
       
   562     "
       
   563 
       
   564     ^ vLayout
       
   565 !
       
   566 
       
   567 verticalLayout:aSymbol
       
   568     "change the vertical layout as a symbol.
       
   569      The argument, aSymbol must be one of:
       
   570 	#top
       
   571 	#topSpace
       
   572 	#spread
       
   573 	#fit
       
   574 	#center
       
   575 	#bottom
       
   576 	#bottomSpace
       
   577       the default (if never changed) is #centered
       
   578     "
       
   579 
       
   580     (vLayout ~~ aSymbol) ifTrue:[
       
   581 	vLayout := aSymbol.
       
   582 	self layoutChanged
       
   583     ]
       
   584 !
       
   585 
       
   586 layout:aSymbol
       
   587     "leftover for historic reasons - do not use any more"
       
   588 
       
   589     self verticalLayout:aSymbol
       
   590 !
       
   591 
       
   592 layout
       
   593     "leftover for historic reasons - do not use any more"
       
   594 
       
   595     self verticalLayout
       
   596 ! !
       
   597 
       
   598 !VerticalPanelView methodsFor:'queries'!
       
   599 
       
   600 preferedExtent
       
   601     "return a good extent, one that makes subviews fit"
       
   602 
       
   603     |sumOfHeights maxWidth maxHeight|
       
   604 
       
   605     subViews isNil ifTrue:[^ horizontalSpace @ verticalSpace].
       
   606 
       
   607     "compute net height needed"
       
   608 
       
   609     sumOfHeights := 0.
       
   610     maxWidth := 0.
       
   611     maxHeight := 0.
       
   612 
       
   613     subViews do:[:child |
       
   614         |childsPreference|
       
   615 
       
   616         childsPreference := child preferedExtent.
       
   617         sumOfHeights := sumOfHeights + childsPreference y.
       
   618         maxHeight := maxHeight max:childsPreference y.
       
   619         maxWidth := maxWidth max:childsPreference x.
       
   620 
       
   621 "/        sumOfHeights := sumOfHeights + child heightIncludingBorder.
       
   622 "/        maxWidth := maxWidth max:(child widthIncludingBorder).
       
   623 "/        maxHeight := maxHeight max:(child heightIncludingBorder).
       
   624     ].
       
   625     borderWidth ~~ 0 ifTrue:[
       
   626         sumOfHeights := sumOfHeights + (horizontalSpace * 2).
       
   627         maxWidth := maxWidth + (horizontalSpace * 2).
       
   628     ].
       
   629     (vLayout == #fit or:[vLayout == #fitSpace]) ifTrue:[
       
   630         sumOfHeights := maxHeight * subViews size.
       
   631         borderWidth ~~ 0 ifTrue:[
       
   632             sumOfHeights := sumOfHeights + (verticalSpace * 2).
       
   633         ]
       
   634     ] ifFalse:[
       
   635         sumOfHeights := sumOfHeights + ((subViews size - 1) * verticalSpace).
       
   636     ].
       
   637 
       
   638     ((hLayout == #leftSpace) or:[hLayout == #rightSpace]) ifTrue:[
       
   639         maxWidth := maxWidth + horizontalSpace
       
   640     ] ifFalse:[
       
   641         ((hLayout == #fitSpace) or:[hLayout == #center]) ifTrue:[
       
   642             maxWidth := maxWidth + (horizontalSpace * 2)
       
   643         ]        
       
   644     ].
       
   645     ^ maxWidth @ sumOfHeights
       
   646 ! !
       
   647