MultiColumnPanelView.st
author Claus Gittinger <cg@exept.de>
Wed, 02 Feb 2011 13:29:16 +0100
changeset 4222 53a2a6433f59
parent 4019 bf57f58f13a8
child 4564 0a0d41148e11
permissions -rw-r--r--
changed: #addLabelledField:label:adjust:tabable:from:to:separateAtX:nameAs:foregroundColor:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3518
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
	      All Rights Reserved
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libwidg' }"
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
PanelView subclass:#MultiColumnPanelView
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
	instanceVariableNames:'columnWidths'
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	classVariableNames:''
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	category:'Views-Layout'
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!MultiColumnPanelView class methodsFor:'documentation'!
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
copyright
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
"
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
 COPYRIGHT (c) 1989 by Claus Gittinger
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
	      All Rights Reserved
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
 This software is furnished under a license and may be used
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 only in accordance with the terms of that license and with the
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 be provided or otherwise made available to, or used by, any
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 other person.  No title to or ownership of the software is
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 hereby transferred.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
"
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
!
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
documentation
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
"
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
    a View which arranges its child-views in a vertical column.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
    All real work is done in PanelView - except the layout computation is
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    redefined here.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    The layout is controlled by the instance variables: 
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
	horizontalLayout and verticalLayout
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    in addition to 
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
	horizontalSpace and verticalSpace.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
    The vertical layout can be any of:
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
	#top            arrange elements at the top
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
	#topSpace       arrange elements at the top, start with spacing
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
	#bottom         arrange elements at the bottom
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
	#bottomSpace    arrange elements at the bottom, start with spacing
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
	#center         arrange elements in the center; ignore verticalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
	#spread         spread elements evenly; ignore verticalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
	#spreadSpace    spread elements evenly with spacing at ends; ignore verticalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
	#fit            like #spread, but resize elements for tight packing; ignore verticalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
	#fitSpace       like #fit, with spacing; ignore verticalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
	#topFit         like #top, but resize the last element to fit
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
	#topSpaceFit    like #topSpace, but resize the last element to fit
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
	#bottomFit      like #bottom, but resize the first element to fit
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
	#bottomSpaceFit like #bottomSpace, but resize the first element to fit
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
    the horizontal layout can be:
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
	#left           place element at the left
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
	#leftSpace      place element at the left, offset by horizontalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
	#center         place elements horizontally centered; ignore horizontalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
	#right          place it at the right
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
	#rightSpace     place it at the right, offset by horizontalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
	#fit            resize elements horizontally to fit this panel; ignore horizontalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
	#fitSpace       like #fit, but add spacing; ignore horizontalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
	#leftMax        like #left, but resize elements to max of them
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
	#leftSpaceMax   like #leftSpace, but resize elements
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
	#centerMax      like #center, but resize elements
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
	#rightMax       like #right, but resize elements to max of them
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
	#rightSpaceMax  like #rightSpace, but resize elements
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    The defaults is #center for both directions.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
    The layout is changed by the messages #verticalLayout: and #horizontalLayout:.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
    For backward compatibility (to times, where only vLayout existed), the simple
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
    #layout: does the same as #verticalLayout:. Do not use this old method.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    The panel assumes, that the elements do not resize themselfes, after it
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
    became visible. This is not true for all widgets (buttons or labels may
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    like to change). If you have changing elements, tell this to the panel
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    with 'aPanel elementsChangeSize:true'. In that case, the panel will react
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
    to size changes, and reorganize things.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
    If none of these layout/space combinations is exactly what you need in
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    your application, create a subclass, and redefine the setChildPositions method.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
    CAVEAT: this class started with #top and no horizontal alignments;
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    as time went by, more layouts were added and the setup should be changed
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
    to use different selectors for space, max-resize and alignment
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
    (i.e. having more and more layout symbols makes things a bit confusing ...)
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    [see also:]
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
	HorizontalPanelView
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
	VariableVerticalPanel VariableHorizontalPanel
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
	Label
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
    [author:]
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
	Claus Gittinger
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
"
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
!
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
examples
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
"
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    These examples demonstrate the effect of different layout
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    settings.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
    You should try more examples, combining spacing and different
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
    verticalLayout:/horizontalLayout: combinations.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
    example: default layout (centered)
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
                                                                        [exBegin]
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
        |v p b1 b2 b3 l1 l2 l3|
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
        v := StandardSystemView new.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
        v label:'center (default)'.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
        p := MultiColumnPanelView in:v.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
        p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
        p columnWidths:#(0.3 0.7).
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
        l1 := Label label:'label1' in:p.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
        b1 := Button label:'button1' in:p.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
        l2 := Label label:'l2' in:p.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
        b2 := Button label:'b2' in:p.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
        l3 := Label label:'lab3' in:p.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
        b3 := Button label:'butt3' in:p.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
        v extent:100 @ 300.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
        v open
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
                                                                        [exEnd]
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
"
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
! !
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
!MultiColumnPanelView methodsFor:'accessing'!
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
columnWidths:something
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
    something ~= columnWidths ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
        columnWidths := something.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
        self layoutChanged
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
    ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
!
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
horizontalLayout
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
    "return the horizontal layout as symbol.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
     the returned value is one of
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
	#left           place element at the left
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
	#leftSpace      place element at the left, offset by horizontalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
	#center         place elements horizontally centered; ignore horizontalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
	#right          place it at the right
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
	#rightSpace     place it at the right, offset by horizontalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
	#fit            resize elements horizontally to fit this panel; ignore horizontalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
	#fitSpace       like #fit, but add spacing; ignore horizontalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
	#leftMax        like #left, but resize elements to max of them
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
	#leftSpaceMax   like #leftSpace, but resize elements
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
	#centerMax      like #center, but resize elements
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
	#rightMax       like #right, but resize elements to max of them
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
	#rightSpaceMax  like #rightSpace, but resize elements
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
      the default is #centered
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
    "
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
    ^ hLayout
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
!
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
horizontalLayout:aSymbol
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
    "change the horizontal layout as symbol.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
     The argument, aSymbol must be one of:
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
	#left           place element at the left
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
	#leftSpace      place element at the left, offset by horizontalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
	#center         place elements horizontally centered; ignore horizontalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
	#right          place it at the right
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
	#rightSpace     place it at the right, offset by horizontalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
	#fit            resize elements horizontally to fit this panel; ignore horizontalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
	#fitSpace       like #fit, but add spacing; ignore horizontalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
	#leftMax        like #left, but resize elements to max of them
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
	#leftSpaceMax   like #leftSpace, but resize elements
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
	#centerMax      like #center, but resize elements
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
	#rightMax       like #right, but resize elements to max of them
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
	#rightSpaceMax  like #rightSpace, but resize elements
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
      the default (if never changed) is #centered
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
    "
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
    (hLayout ~~ aSymbol) ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
	hLayout := aSymbol.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
	self layoutChanged
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
    ]
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
!
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
layout:something
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
    "OBSOLETE compatibility interface. Will vanish.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
     leftover for historic reasons - do not use any more.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
     In the meantime, try to figure out what is meant ... a kludge"
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
    <resource:#obsolete>
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
    something isLayout ifTrue:[^ super layout:something].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
    self obsoleteMethodWarning:'use #verticalLayout:'.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
    ^ self verticalLayout:something
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
    "Modified: 31.8.1995 / 23:08:54 / claus"
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
!
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
verticalLayout
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
    "return the vertical layout as a symbol.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
     the returned value is one of
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
	#top            arrange elements at the top
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
	#topSpace       arrange elements at the top, start with spacing
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
	#bottom         arrange elements at the bottom
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
	#bottomSpace    arrange elements at the bottom, start with spacing
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
	#center         arrange elements in the center; ignore verticalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
	#spread         spread elements evenly; ignore verticalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
	#spreadSpace    spread elements evenly with spacing at ends; ignore verticalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
	#fit            like #spread, but resize elements for tight packing; ignore verticalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
	#fitSpace       like #fit, with spacing; ignore verticalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
	#topFit         like #top, but resize the last element to fit
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
	#topSpaceFit    like #topSpace, but resize the last element to fit
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
	#bottomFit      like #bottom, but resize the first element to fit
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
	#bottomSpaceFit like #bottomSpace, but extend the first element to fit
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
      the default is #centered
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
    "
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
    ^ vLayout
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
    "Modified: 17.8.1997 / 15:20:13 / cg"
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
!
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
verticalLayout:aSymbol
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
    "change the vertical layout as a symbol.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
     The argument, aSymbol must be one of:
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
	#top            arrange elements at the top
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
	#topSpace       arrange elements at the top, start with spacing
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
	#bottom         arrange elements at the bottom
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
	#bottomSpace    arrange elements at the bottom, start with spacing
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
	#center         arrange elements in the center; ignore verticalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
	#spread         spread elements evenly; ignore verticalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
	#spreadSpace    spread elements evenly with spacing at ends; ignore verticalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
	#fit            like #spread, but resize elements for tight packing; ignore verticalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
	#fitSpace       like #fit, with spacing; ignore verticalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
	#topFit         like #top, but resize the last element to fit
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
	#topSpaceFit    like #topSpace, but resize the last element to fit
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
	#bottomFit      like #bottom, but resize the first element to fit
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
	#bottomSpaceFit like #bottomSpace, but extend the first element to fit
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
      the default (if never changed) is #centered
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
    "
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
    (vLayout ~~ aSymbol) ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
	vLayout := aSymbol.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
	self layoutChanged
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
    ]
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
    "Modified: 17.8.1997 / 15:19:58 / cg"
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
! !
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
!MultiColumnPanelView methodsFor:'initialization'!
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
initialize
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
    super initialize.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
    hLayout := #fit.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
    vLayout := #top.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
    columnWidths := #(0.5 0.5).
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
! !
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
!MultiColumnPanelView methodsFor:'layout'!
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
setChildPositions
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
    "(re)compute position of every child"
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
    |xpos ypos space sumOfHeights numChilds l hEach hInside hL vL
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
     maxWidth maxHeight resizeToMaxV resizeToMaxH m2 subViews restHeight
4019
bf57f58f13a8 no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents: 3760
diff changeset
   278
     rowsPerCol maxWidthPerCol col numCols cX cY bw|
3518
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
    subViews := self subViewsToConsider.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
    subViews size == 0 ifTrue:[^ self].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
"/    self extentChangedFlag ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
"/        ext := self computeExtent.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
"/        width := ext x.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
"/        height := ext y.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
"/    ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
    space := verticalSpace.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
    numChilds := subViews size.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
    numCols := columnWidths size max:1.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
4019
bf57f58f13a8 no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents: 3760
diff changeset
   293
    bw := self borderWidth.
3518
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
    m2 := margin * 2.
4019
bf57f58f13a8 no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents: 3760
diff changeset
   295
    hInside := height - m2 + (bw*2) - subViews last borderWidth.
3518
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
    hL := hLayout.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
    vL := vLayout.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
    rowsPerCol := Array new:numCols withAll:0.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
    maxWidthPerCol := Array new:numCols withAll:0.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
    maxHeight := 0.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
    col := 1.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
    subViews do:[:child |
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
        |childsW childsH|
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
        childsW := child widthIncludingBorder.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
        childsH := child heightIncludingBorder.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
        maxHeight := maxHeight max:childsH.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
        maxWidthPerCol at:col put:((maxWidthPerCol at:col) max:childsW).
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
        rowsPerCol at:col put:(rowsPerCol at:col)+1.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
        col := col + 1.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
        col > numCols ifTrue:[ col := 1 ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
    ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
"/ new
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
    xpos := 0.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
    ypos := 0.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
    col := 1.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
    subViews do:[:child |
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
        col == numCols ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
            cX := width.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
        ] ifFalse:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
            cX := xpos + (width // numCols).
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
        ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
        cY := ypos + maxHeight.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
        child origin:(xpos@ypos)"corner:(cX @ cY)".
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
        hLayout == #fit ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
            child width:(cX - xpos + 1).
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
        ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   332
        col := col + 1.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   333
        col > numCols ifTrue:[ 
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
            col := 1.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
            xpos := 0.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
            ypos := cY + verticalSpace.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
        ] ifFalse:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
            xpos := cX + horizontalSpace.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
        ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
    ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
    ^ self.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
"/ old
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
    resizeToMaxV := false.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
    (vL endsWith:'Max') ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
        resizeToMaxV := true.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
        hEach := maxHeight := subViews inject:0 into:[:maxSoFar :child | maxSoFar max:child heightIncludingBorder].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
        vL := (vL copyWithoutLast:3) asSymbol.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
    ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
    numChilds == 1 ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
        (vL == #topFit or:[vL == #bottomFit]) ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
            vL := #fit
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
        ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
        (vL == #topSpaceFit or:[vL == #bottomSpaceFit]) ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
            vL := #fitSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   358
        ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
    ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
    vL == #fitSpace ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
        "
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
         adjust childs extents and set origins.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
         Be careful to avoid accumulation of rounding errors
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
        "
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
        hEach := (hInside - ((numChilds + 1) * space)) / numChilds.
4019
bf57f58f13a8 no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents: 3760
diff changeset
   367
        ypos := space + margin - bw.
3518
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   368
    ] ifFalse:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   369
        vL == #fit ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
            "
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
             adjust childs extents and set origins.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
             Be careful to avoid accumulation of rounding errors
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
            "
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
            hEach := (hInside - ((numChilds - 1) * space)) / numChilds.
4019
bf57f58f13a8 no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents: 3760
diff changeset
   375
            ypos := margin - bw.
3518
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
        ] ifFalse:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
            l := vL.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
            "
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
             compute net height needed
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
            "
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
            resizeToMaxV ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
                sumOfHeights := subViews inject:0 into:[:sumSoFar :child | sumSoFar + maxHeight + (child borderWidth*2)].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
            ] ifFalse:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
                sumOfHeights := subViews inject:0 into:[:sumSoFar :child | sumSoFar + child heightIncludingBorder].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
                "/ adjust - do not include height of last(first) element if doing a fit
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
                (vL == #topFit or:[vL == #topSpaceFit]) ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
                    sumOfHeights := sumOfHeights - subViews last heightIncludingBorder.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
                ] ifFalse:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
                    (vL == #bottomFit or:[vL == #bottomSpaceFit]) ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
                        sumOfHeights := sumOfHeights - subViews first heightIncludingBorder.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
                    ]
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
                ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
            ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
            restHeight := height - sumOfHeights - ((numChilds-1)*space).
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
            ((l == #center) and:[numChilds == 1]) ifTrue:[l := #spread].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
            (l == #spread and:[numChilds == 1]) ifTrue:[l := #spreadSpace].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
            "
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
             compute position of topmost subview and space between them;
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
             if they do hardly fit, leave no space between them 
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
            "
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
            ((sumOfHeights >= (height - m2))
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
            and:[l ~~ #fixTopSpace and:[l ~~ #fixTop]]) ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
                "
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
                 if we have not enough space for all the elements, 
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   410
                 fill them tight, and show what can be shown (at least)
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
                "
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   412
                ypos := margin.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
                space := 0
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   414
            ] ifFalse:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   415
                l == #fixTopSpace ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
                    l := #topSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   417
                ] ifFalse:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   418
                    l == #fixTop ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   419
                        l := #top 
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
                    ]
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   421
                ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   422
                ((l == #bottom) or:[l == #bottomSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   423
                or:[l == #bottomFit or:[l == #bottomSpaceFit]]]) ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   424
                    ypos := restHeight - (space * (numChilds - 1)).
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   425
"/
4019
bf57f58f13a8 no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents: 3760
diff changeset
   426
"/                    bw == 0 ifTrue:[
3518
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
"/                        ypos := ypos + space 
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   428
"/                    ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   429
"/           
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   430
                    (l == #bottomSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   431
                    or:[l == #bottomSpaceFit]) ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   432
                        ypos >= space ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   433
                            ypos := ypos - space
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   434
                        ]
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   435
                    ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   436
                    ypos := ypos - margin.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   437
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   438
                    ypos < 0 ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   439
                        space := space min:(restHeight // (numChilds + 1)).
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   440
                        ypos := restHeight - (space * numChilds).
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   441
                    ]
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
                ] ifFalse: [
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   443
                    (l == #spread) ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   444
                        space := (restHeight - m2) // (numChilds - 1).
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   445
                        ypos := margin.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   446
                        (space == 0) ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   447
                            ypos := restHeight // 2
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   448
                        ]
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   449
                    ] ifFalse: [
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   450
                      (l == #spreadSpace) ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
                        space := (restHeight - m2) // (numChilds + 1).
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   452
                        ypos := space + margin.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
                        (space == 0) ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   454
                            ypos := restHeight // 2
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
                        ]
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   456
                      ] ifFalse: [
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
                        ((l == #top) or:[l == #topSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   458
                        or:[l == #topFit or:[l == #topSpaceFit]]]) ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   459
                            space := space min:(restHeight - m2) // (numChilds + 1).
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   460
                            (vL == #fixTop or:[vL == #fixTopSpace]) ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   461
                                space := space max:verticalSpace.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   462
                            ] ifFalse:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   463
                                space := space max:0.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   464
                            ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   465
                            (l == #topSpace or:[l == #topSpaceFit]) ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
                                ypos := space + margin.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   467
                            ] ifFalse:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   468
                                "/
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   469
                                "/ if the very first view has a 0-level AND
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   470
                                "/ my level is non-zero, begin with margin
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   471
                                "/
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   472
                                true "(margin ~~ 0 and:[subViews first level == 0])" ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   473
                                    ypos := margin
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   474
                                ] ifFalse:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   475
                                    ypos := 0
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   476
                                ]
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   477
                            ]
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   478
                        ] ifFalse:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   479
                            "center"
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   480
                            ypos := (restHeight - ((numChilds - 1) * space)) // 2.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   481
                            ypos < 0 ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   482
                                space := restHeight // (numChilds + 1).
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   483
                                ypos := (restHeight - ((numChilds - 1) * space)) // 2.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   484
                            ]
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   485
                        ]
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   486
                      ]
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   487
                    ]
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   488
                ]
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   489
            ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   490
        ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   491
    ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   492
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   493
    resizeToMaxH := false.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   494
    (hL endsWith:'Max') ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   495
        resizeToMaxH := true.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   496
        maxWidth := subViews inject:0 into:[:maxSoFar :child | maxSoFar max:child widthIncludingBorder].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   497
        hL := (hL copyWithoutLast:3) asSymbol.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   498
    ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   499
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   500
    "
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   501
     now set positions
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   502
    "
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   503
    subViews keysAndValuesDo:[:index :child |
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   504
        |xpos advance bwChild wChild newWChild x2|
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   505
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   506
        wChild := child widthIncludingBorder.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   507
        bwChild := child borderWidth.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   508
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   509
        elementsChangeSize ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   510
            "to avoid a recursion when we change the elements size"
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   511
            child removeDependent:self.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   512
        ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   513
        resizeToMaxH ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   514
            child width:(wChild := maxWidth - (bwChild  * 2)).
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   515
        ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   516
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   517
        hL == #left ifTrue:[
4019
bf57f58f13a8 no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents: 3760
diff changeset
   518
            xpos := 0 - bw + margin.
3518
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   519
        ] ifFalse:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   520
            hL == #leftSpace ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   521
                xpos := horizontalSpace + margin
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   522
            ] ifFalse:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   523
                hL == #right ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   524
                    xpos := width - wChild - margin
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   525
                ] ifFalse:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   526
                    hL == #rightSpace ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   527
                        xpos := width - horizontalSpace - wChild - margin.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   528
                    ] ifFalse:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   529
                        hL == #fitSpace ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   530
                            xpos := horizontalSpace + margin.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   531
                            newWChild := width - m2 - ((horizontalSpace + bwChild) * 2)
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   532
                        ] ifFalse:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   533
                            hL == #fit ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   534
                                newWChild := width "- (bwChild * 2)".
4019
bf57f58f13a8 no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents: 3760
diff changeset
   535
                                bw == 0 ifTrue:[
3518
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   536
                                    newWChild :=  newWChild - (bwChild * 2)
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   537
                                ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   538
                                true "child level == 0" ifTrue:[
4019
bf57f58f13a8 no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents: 3760
diff changeset
   539
                                    xpos := margin - bw.
3518
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   540
                                    newWChild := newWChild - m2
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   541
                                ] ifFalse:[
4019
bf57f58f13a8 no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents: 3760
diff changeset
   542
                                    xpos := 0 - bw. 
3518
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   543
                                ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   544
                            ] ifFalse:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   545
                                "centered"
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   546
                                 xpos := margin + ((width - m2 - wChild) // 2).
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   547
                            ]
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   548
                        ]
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   549
                    ]
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   550
                ]
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   551
            ]
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   552
        ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   553
        newWChild notNil ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   554
            child width:newWChild
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   555
        ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   556
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   557
"/        (xpos < 0) ifTrue:[ xpos := 0 ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   558
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   559
        x2 := xpos + child width - 1.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   560
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   561
        (vL == #fit 
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   562
        or:[vL == #fitSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   563
        or:[resizeToMaxV]]) ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   564
            child origin:(xpos @ (ypos rounded))
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   565
                  corner:(x2 @ (ypos + hEach - bwChild - 1) rounded).
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   566
            advance := hEach
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   567
        ] ifFalse:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   568
            child origin:(xpos@ypos).
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   569
            advance := child heightIncludingBorder
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   570
        ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   571
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   572
        index == numChilds ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   573
            |y|
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   574
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   575
            (vL == #topFit or:[vL == #topSpaceFit]) ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   576
                y := height - margin - 1.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   577
                vL == #topSpaceFit ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   578
                    y := y - space
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   579
                ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   580
                child corner:x2 @ y
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   581
            ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   582
        ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   583
        index == 1 ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   584
            (vL == #bottomFit or:[vL == #bottomSpaceFit]) ifTrue:[
4019
bf57f58f13a8 no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents: 3760
diff changeset
   585
                ypos := margin + 0 + (child borderWidth * 2) - bw.
3518
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   586
                vL == #bottomSpaceFit ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   587
                    ypos := ypos + space
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   588
                ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   589
                advance := restHeight.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   590
                child origin:((child origin x) @ ypos)
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   591
                      corner:((child corner x) @ (ypos+advance))
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   592
            ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   593
        ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   594
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   595
        ypos := ypos + advance + space.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   596
        elementsChangeSize ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   597
            "reinstall dependency that we removed above"
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   598
            child addDependent:self.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   599
        ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   600
    ]
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   601
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   602
    "Modified: / 04-09-1995 / 18:43:29 / claus"
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   603
    "Modified: / 10-10-2007 / 13:47:56 / cg"
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   604
! !
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   605
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   606
!MultiColumnPanelView methodsFor:'queries'!
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   607
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   608
preferredExtent
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   609
    "return a good extent, one that makes subviews fit"
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   610
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   611
    |maxHeight maxWidth maxWidthPerCol w m2 subViews col numCols rowsPerCol|
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   612
3760
96d214ff4395 changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3518
diff changeset
   613
    "/ If I have an explicit preferredExtent..
96d214ff4395 changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3518
diff changeset
   614
    explicitExtent notNil ifTrue:[
96d214ff4395 changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3518
diff changeset
   615
        ^ explicitExtent
96d214ff4395 changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3518
diff changeset
   616
    ].
3518
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   617
3760
96d214ff4395 changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3518
diff changeset
   618
    "/ If I have a cached preferredExtent value..
3518
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   619
    preferredExtent notNil ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   620
        ^ preferredExtent
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   621
    ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   622
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   623
    subViews := self subViewsToConsider.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   624
    (subViews size == 0) ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   625
        ^ super preferredExtent.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   626
    ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   627
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   628
    "compute net height needed"
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   629
    numCols := columnWidths size.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   630
    rowsPerCol := Array new:numCols withAll:0.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   631
    maxWidthPerCol := Array new:numCols withAll:0.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   632
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   633
    maxHeight := 0.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   634
    col := 1.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   635
    subViews do:[:child |
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   636
        |childsPreference|
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   637
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   638
        childsPreference := child preferredExtent.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   639
        maxHeight := maxHeight max:childsPreference y.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   640
        maxWidthPerCol at:col put:((maxWidthPerCol at:col) max:childsPreference y).
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   641
        rowsPerCol at:col put:(rowsPerCol at:col)+1.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   642
        col := col + 1.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   643
        col > numCols ifTrue:[ col := 1 ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   644
    ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   645
4019
bf57f58f13a8 no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents: 3760
diff changeset
   646
    self borderWidth ~~ 0 ifTrue:[
3518
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   647
        maxWidth := maxWidth + (horizontalSpace * 2).
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   648
    ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   649
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   650
"/    sumOfHeights := sumOfHeights + ((subViews size - 1) * verticalSpace).
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   651
"/    ((vLayout == #topSpace) or:[vLayout == #bottomSpace]) ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   652
"/        sumOfHeights := sumOfHeights + verticalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   653
"/    ] ifFalse:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   654
"/        ((vLayout == #center) or:[vLayout == #spread]) ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   655
"/            sumOfHeights := sumOfHeights + (verticalSpace * 2)
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   656
"/        ]
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   657
"/    ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   658
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   659
"/    ((hLayout == #leftSpace) or:[hLayout == #rightSpace]) ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   660
"/        maxWidth := maxWidth + horizontalSpace
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   661
"/    ] ifFalse:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   662
"/        ((hLayout == #fitSpace) or:[hLayout == #center]) ifTrue:[
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   663
"/            maxWidth := maxWidth + (horizontalSpace * 2)
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   664
"/        ]        
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   665
"/    ].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   666
    m2 := margin * 2.
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   667
"/    ^ (maxWidth + m2) @ (sumOfHeights + m2)
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   668
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   669
    w := maxWidthPerCol inject:0 into:[:sumSoFar :thisWidth | sumSoFar + thisWidth].
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   670
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   671
    ^ (w+m2) @ (rowsPerCol max * maxHeight) + m2
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   672
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   673
    "Modified: / 17.1.1998 / 00:18:16 / cg"
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   674
! !
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   675
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   676
!MultiColumnPanelView class methodsFor:'documentation'!
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   677
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   678
version
4019
bf57f58f13a8 no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents: 3760
diff changeset
   679
    ^ '$Header: /cvs/stx/stx/libwidg/MultiColumnPanelView.st,v 1.3 2009-10-23 15:22:19 cg Exp $'
bf57f58f13a8 no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents: 3760
diff changeset
   680
!
bf57f58f13a8 no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents: 3760
diff changeset
   681
bf57f58f13a8 no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents: 3760
diff changeset
   682
version_CVS
bf57f58f13a8 no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents: 3760
diff changeset
   683
    ^ '$Header: /cvs/stx/stx/libwidg/MultiColumnPanelView.st,v 1.3 2009-10-23 15:22:19 cg Exp $'
3518
61cde5384831 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   684
! !