PanelView.st
author ca
Tue, 04 Mar 1997 17:22:38 +0100
changeset 1095 5cef29109661
parent 1072 79c647d81083
child 1159 856ac1c6046c
permissions -rw-r--r--
only change channel values if there really is a change
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     1
"
5
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
60
f3c738c24ce6 mostly style
claus
parents: 38
diff changeset
     3
	      All Rights Reserved
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     4
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    11
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    12
119
claus
parents: 63
diff changeset
    13
SimpleView subclass:#PanelView
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    14
	instanceVariableNames:'hLayout vLayout verticalSpace horizontalSpace mustRearrange
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    15
		elementsChangeSize'
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    16
	classVariableNames:''
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    17
	poolDictionaries:''
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    18
	category:'Views-Layout'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    19
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    20
980
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
    21
!PanelView class methodsFor:'documentation'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    22
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 15
diff changeset
    23
copyright
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 15
diff changeset
    24
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 15
diff changeset
    25
 COPYRIGHT (c) 1989 by Claus Gittinger
60
f3c738c24ce6 mostly style
claus
parents: 38
diff changeset
    26
	      All Rights Reserved
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    27
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 15
diff changeset
    28
 This software is furnished under a license and may be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 15
diff changeset
    29
 only in accordance with the terms of that license and with the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 15
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 15
diff changeset
    31
 be provided or otherwise made available to, or used by, any
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 15
diff changeset
    32
 other person.  No title to or ownership of the software is
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 15
diff changeset
    33
 hereby transferred.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 15
diff changeset
    34
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 15
diff changeset
    35
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    36
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 15
diff changeset
    37
documentation
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 15
diff changeset
    38
"
127
claus
parents: 125
diff changeset
    39
    this is a view for holding subviews. (layout-widget ?)
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 15
diff changeset
    40
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 15
diff changeset
    41
    Instances of PanelView try to get all their subviews into them,
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 15
diff changeset
    42
    arranging subviews left-to-right, top-to-bottom.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 15
diff changeset
    43
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 15
diff changeset
    44
    If you dont like its layout, define a new subclass or use one of
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 15
diff changeset
    45
    the existing subclasses: HorizontalPanelView and VerticalPanelView.
60
f3c738c24ce6 mostly style
claus
parents: 38
diff changeset
    46
127
claus
parents: 125
diff changeset
    47
    The panel assumes, that the elements do not resize themselfes, after it
claus
parents: 125
diff changeset
    48
    became visible. This is not true for all widgets (buttons or labels may
claus
parents: 125
diff changeset
    49
    like to change). If you have changing elements, tell this to the panel
claus
parents: 125
diff changeset
    50
    with 'aPanel elementsChangeSize:true'. In that case, the panel will react
claus
parents: 125
diff changeset
    51
    to size changes, and reorganize things.
claus
parents: 125
diff changeset
    52
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
    53
    PanelViews normally delay the actual positioning/sizing of their elements,
60
f3c738c24ce6 mostly style
claus
parents: 38
diff changeset
    54
    until actually displayed. This is useful, if more elements are to
f3c738c24ce6 mostly style
claus
parents: 38
diff changeset
    55
    be added, to avoid repeated configuration of the elements.
f3c738c24ce6 mostly style
claus
parents: 38
diff changeset
    56
f3c738c24ce6 mostly style
claus
parents: 38
diff changeset
    57
    If you want to query for the relative position of an element BEFORE
f3c738c24ce6 mostly style
claus
parents: 38
diff changeset
    58
    the view is visible, you have to send #setChildPositionsIfChanged before
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
    59
    doing so (otherwise, you may get invalid origins from the subviews). As
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
    60
    an example, the modalBoxes do so before showing themselfes to ask for the
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
    61
    position of the ok-button relative to the top-left box-origin, in order to
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
    62
    position the ok-button under the mouse-pointer.
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
    63
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    64
    [Instance variables:]
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
    65
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    66
        hLayout         <Symbol>        controls horizontal layout; ignored in this
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    67
                                        class, but used in Horizontal- and
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    68
                                        VerticalPanelViews. See more info there.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
    69
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    70
        vLayout         <Symbol>        controls vertical layout; ignored in this
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    71
                                        class, but used in Horizontal- and
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    72
                                        VerticalPanelViews. See more info there.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
    73
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    74
        horizontalSpace <Integer>       number of pixels to use as space between elements
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    75
                                        defaults to ViewSpacing, which is 1mm
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
    76
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    77
        verticalSpace   <Integer>       number of pixels to use as space between elements
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    78
                                        defaults to ViewSpacing, which is 1mm
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
    79
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    80
        mustRearrange   <Boolean>       internal flag, if rearrangement is needed
125
claus
parents: 119
diff changeset
    81
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    82
        elementsChangeSize   
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    83
                        <Boolean>       if true, the panel takes care of this situation.
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    84
                                        By default, this is false.
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    85
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    86
    [author:]
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    87
        Claus Gittinger
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 15
diff changeset
    88
"
787
c568dfd06f11 recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    89
! !
c568dfd06f11 recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    90
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    91
!PanelView methodsFor:'accessing'!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    92
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    93
elementsChangeSize:aBoolean
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    94
    "tell the panel if elements are to change their size by themselfes
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    95
     (for example, Lables or Buttons may do so if their contents changes).
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    96
     Setting this flag will make the panel reorganize the elements whenever
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    97
     any element changes its size."
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    98
980
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
    99
    |subViews|
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   100
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   101
    elementsChangeSize := aBoolean.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   102
    aBoolean ifTrue:[
980
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   103
        (subViews := self subViews) notNil ifTrue:[
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   104
            subViews do:[:aView |
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   105
                aView addDependent:self
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   106
            ]
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   107
        ]
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   108
    ]
980
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   109
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   110
    "Modified: 28.1.1997 / 17:51:28 / cg"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   111
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   112
1036
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   113
horizontalLayout
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   114
    "not supported by this view"
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   115
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   116
    ^ nil
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   117
!
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   118
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   119
horizontalLayout:aLayoutSymbol
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   120
    "not supported by this view"
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   121
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   122
!
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   123
1072
79c647d81083 checkin from browser
ca
parents: 1042
diff changeset
   124
horizontalSpace
79c647d81083 checkin from browser
ca
parents: 1042
diff changeset
   125
    "return the horizontal space between elements on pixels (default is 1mm)"
79c647d81083 checkin from browser
ca
parents: 1042
diff changeset
   126
79c647d81083 checkin from browser
ca
parents: 1042
diff changeset
   127
    ^ horizontalSpace 
79c647d81083 checkin from browser
ca
parents: 1042
diff changeset
   128
!
79c647d81083 checkin from browser
ca
parents: 1042
diff changeset
   129
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   130
horizontalSpace:numberOfPixels
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   131
    "set the horizontal space between elements on pixels (default is 1mm)"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   132
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   133
    horizontalSpace ~= numberOfPixels ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   134
	horizontalSpace := numberOfPixels.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   135
	self layoutChanged
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   136
    ]
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   137
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   138
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   139
space:numberOfPixels
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   140
    "set the space between elements in pixels (default is 1mm) for both directions"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   141
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   142
    (verticalSpace ~= numberOfPixels 
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   143
    or:[horizontalSpace ~= numberOfPixels]) ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   144
	horizontalSpace := numberOfPixels.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   145
	verticalSpace := numberOfPixels.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   146
	self layoutChanged
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   147
    ]
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   148
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   149
1036
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   150
verticalLayout
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   151
    "not supported by this view"
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   152
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   153
    ^ nil
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   154
!
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   155
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   156
verticalLayout:aLayoutSymbol
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   157
    "not supported by this view"
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   158
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   159
!
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   160
1072
79c647d81083 checkin from browser
ca
parents: 1042
diff changeset
   161
verticalSpace
79c647d81083 checkin from browser
ca
parents: 1042
diff changeset
   162
    "return the vertical space between elements on pixels (default is 1mm)"
79c647d81083 checkin from browser
ca
parents: 1042
diff changeset
   163
79c647d81083 checkin from browser
ca
parents: 1042
diff changeset
   164
    ^ verticalSpace 
79c647d81083 checkin from browser
ca
parents: 1042
diff changeset
   165
!
79c647d81083 checkin from browser
ca
parents: 1042
diff changeset
   166
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   167
verticalSpace:numberOfPixels
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   168
    "set the vertical space between elements (in pixels).
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   169
     The default is computed for 1mm spacing."
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   170
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   171
    verticalSpace ~= numberOfPixels ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   172
	verticalSpace := numberOfPixels.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   173
	self layoutChanged
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   174
    ]
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   175
! !
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   176
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   177
!PanelView methodsFor:'adding & removing subviews'!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   178
980
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   179
addComponent:aComponent
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   180
    "redefined to recompute layout when a component is added"
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   181
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   182
    super addComponent:aComponent.
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   183
    self addedView:aComponent
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   184
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   185
    "Created: 28.1.1997 / 17:44:18 / cg"
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   186
!
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   187
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   188
addSubView:aView
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   189
    "redefined to recompute layout when a subview is added"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   190
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   191
    super addSubView:aView.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   192
    self addedView:aView
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   193
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   194
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   195
addSubView:newView after:aView
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   196
    "redefined to recompute layout when a subview is added"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   197
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   198
    super addSubView:newView after:aView.
787
c568dfd06f11 recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   199
    self addedView:newView
c568dfd06f11 recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   200
c568dfd06f11 recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   201
    "Modified: 15.7.1996 / 10:15:04 / cg"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   202
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   203
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   204
addSubView:newView before:aView
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   205
    "redefined to recompute layout when a subview is added"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   206
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   207
    super addSubView:newView before:aView.
787
c568dfd06f11 recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   208
    self addedView:newView
c568dfd06f11 recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   209
c568dfd06f11 recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   210
    "Modified: 15.7.1996 / 10:14:39 / cg"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   211
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   212
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   213
removeSubView:aView
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   214
    "redefined to recompute layout when a subview is removed"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   215
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   216
    super removeSubView:aView.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   217
    aView removeDependent:self.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   218
    self layoutChanged
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 15
diff changeset
   219
! !
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   220
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   221
!PanelView methodsFor:'event processing'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   222
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   223
sizeChanged:how
119
claus
parents: 63
diff changeset
   224
    "my size has changed - must rearrange elements"
claus
parents: 63
diff changeset
   225
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   226
    super sizeChanged:how.
60
f3c738c24ce6 mostly style
claus
parents: 38
diff changeset
   227
    self layoutChanged
125
claus
parents: 119
diff changeset
   228
!
claus
parents: 119
diff changeset
   229
claus
parents: 119
diff changeset
   230
update:something with:aParameter from:changedObject
980
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   231
    "an element changed its size"
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   232
125
claus
parents: 119
diff changeset
   233
    something == #sizeOfView ifTrue:[
980
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   234
        self layoutChanged.
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   235
        ^ self
125
claus
parents: 119
diff changeset
   236
    ].
claus
parents: 119
diff changeset
   237
    ^ super update:something with:aParameter from:changedObject
980
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   238
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   239
    "Modified: 28.1.1997 / 17:52:44 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   240
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   241
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   242
!PanelView methodsFor:'initialization'!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   243
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   244
initialize
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   245
    super initialize.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   246
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   247
    hLayout := vLayout := #center.  "/ notice, this is ignored in this class
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   248
				    "/ used by subclasses only
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   249
    verticalSpace := ViewSpacing.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   250
    horizontalSpace := ViewSpacing.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   251
    mustRearrange := elementsChangeSize := false
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   252
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   253
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   254
realize
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   255
    mustRearrange ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   256
	self setChildPositions
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   257
    ].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   258
    super realize
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   259
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   260
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   261
setChildPositionsIfChanged
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   262
    "set all of my child positions - this is usually delayed,
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   263
     until the panel is actually shown (since we dont know, if more
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   264
     elements are to be added) thus avoiding repositioning the elements
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   265
     over and over. However, sometimes it is nescessary, to force positioning
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   266
     the elements, for example, before querying the relative position of
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   267
     an element (modalBoxes do so, to position the ok-button under the mouse
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   268
     pointer)."
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   269
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   270
    mustRearrange ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   271
	self setChildPositions
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   272
    ].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   273
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   274
! !
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   275
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   276
!PanelView methodsFor:'private'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   277
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   278
addedView:aView
980
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   279
    "added a new element - rearrange components"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   280
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   281
    elementsChangeSize ifTrue:[
787
c568dfd06f11 recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   282
        aView addDependent:self
c568dfd06f11 recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   283
    ].
c568dfd06f11 recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   284
    aView resize.
788
653fd742b5b0 extent handling when adding views
Claus Gittinger <cg@exept.de>
parents: 787
diff changeset
   285
"/    explicitExtent ~~ true ifTrue:[
653fd742b5b0 extent handling when adding views
Claus Gittinger <cg@exept.de>
parents: 787
diff changeset
   286
"/        self resize
653fd742b5b0 extent handling when adding views
Claus Gittinger <cg@exept.de>
parents: 787
diff changeset
   287
"/    ].
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   288
    self layoutChanged
787
c568dfd06f11 recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   289
980
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   290
    "Modified: 28.1.1997 / 17:45:10 / cg"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   291
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   292
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   293
layoutChanged
119
claus
parents: 63
diff changeset
   294
    "called whenever repositioning is required. If the panel view is
claus
parents: 63
diff changeset
   295
     already visible, reposition elements right now. Otherwise, remember
claus
parents: 63
diff changeset
   296
     that a repositioning is needed to do so when the view eventually becomes
claus
parents: 63
diff changeset
   297
     visible."
claus
parents: 63
diff changeset
   298
15
0dbce35d3c69 *** empty log message ***
claus
parents: 5
diff changeset
   299
    shown ifTrue:[
60
f3c738c24ce6 mostly style
claus
parents: 38
diff changeset
   300
	self setChildPositions
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   301
    ] ifFalse:[
60
f3c738c24ce6 mostly style
claus
parents: 38
diff changeset
   302
	mustRearrange := true
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   303
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   304
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   305
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   306
setChildPositions
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   307
    "(re)compute position of every child.
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   308
     This method is redefined for different layout characteristics - you may
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   309
     even create subclasses with completely different geometry management."
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   310
1042
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   311
    |first xpos ypos maxHeightInRow thisRow subViews ext|
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   312
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   313
    subViews := self subViews.
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   314
    subViews size == 0 ifTrue:[^ self].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   315
1042
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   316
    extentChanged ifTrue:[
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   317
        ext := self computeExtent.
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   318
        width := ext x.
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   319
        height := ext y.
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   320
    ].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   321
1042
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   322
    xpos := horizontalSpace.
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   323
    ypos := verticalSpace.
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   324
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   325
    maxHeightInRow := 0.
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   326
    first := true.
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   327
    thisRow := OrderedCollection new.
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   328
    subViews do:[:child |
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   329
        "go to next row, if this subview won't fit"
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   330
        first ifFalse: [
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   331
            (xpos + child widthIncludingBorder + horizontalSpace) > width
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   332
            ifTrue: [
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   333
                thisRow notEmpty ifTrue:[
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   334
                    thisRow do:[:rowElement |
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   335
                        rowElement heightIncludingBorder < maxHeightInRow ifTrue:[
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   336
                            rowElement top:(rowElement top + (maxHeightInRow - rowElement heightIncludingBorder))
980
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   337
                        ]
1042
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   338
                    ]
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   339
                ].
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   340
                ypos := ypos + verticalSpace + maxHeightInRow.
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   341
                xpos := horizontalSpace.
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   342
                maxHeightInRow := 0.
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   343
                thisRow := OrderedCollection new.
980
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   344
            ]
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   345
        ].
1042
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   346
        thisRow add:child.
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   347
        child origin:(xpos@ypos).
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   348
        xpos := xpos + (child widthIncludingBorder) + horizontalSpace.
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   349
        (maxHeightInRow < (child heightIncludingBorder)) ifTrue:[
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   350
            maxHeightInRow := child heightIncludingBorder
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   351
        ].
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   352
        first := false
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   353
    ].
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   354
    thisRow notEmpty ifTrue:[
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   355
        thisRow do:[:rowElement |
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   356
            rowElement heightIncludingBorder < maxHeightInRow ifTrue:[
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   357
                rowElement top:(rowElement top + (maxHeightInRow - rowElement heightIncludingBorder))
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   358
            ]
5914ecc423e1 care for sizing with no subviews;
ca
parents: 1036
diff changeset
   359
        ]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   360
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   361
    mustRearrange := false
980
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   362
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   363
    "Modified: 28.1.1997 / 17:51:36 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   364
! !
125
claus
parents: 119
diff changeset
   365
980
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   366
!PanelView class methodsFor:'documentation'!
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
   367
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
   368
version
1072
79c647d81083 checkin from browser
ca
parents: 1042
diff changeset
   369
    ^ '$Header: /cvs/stx/stx/libwidg/PanelView.st,v 1.22 1997-02-27 18:17:41 ca Exp $'
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
   370
! !