PanelView.st
author ca
Fri, 21 Feb 1997 20:27:43 +0100
changeset 1036 5958cde90d09
parent 980 6079922a5519
child 1042 5914ecc423e1
permissions -rw-r--r--
added dummy access to hLayout and vLayout.
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
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   124
horizontalSpace:numberOfPixels
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   125
    "set the horizontal space between elements on pixels (default is 1mm)"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   126
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   127
    horizontalSpace ~= numberOfPixels ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   128
	horizontalSpace := numberOfPixels.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   129
	self layoutChanged
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   130
    ]
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   131
!
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
space:numberOfPixels
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   134
    "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
   135
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   136
    (verticalSpace ~= numberOfPixels 
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   137
    or:[horizontalSpace ~= numberOfPixels]) ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   138
	horizontalSpace := numberOfPixels.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   139
	verticalSpace := numberOfPixels.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   140
	self layoutChanged
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
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   143
1036
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   144
verticalLayout
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   145
    "not supported by this view"
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   146
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   147
    ^ nil
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   148
!
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   149
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   150
verticalLayout:aLayoutSymbol
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
!
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   154
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   155
verticalSpace:numberOfPixels
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   156
    "set the vertical space between elements (in pixels).
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   157
     The default is computed for 1mm spacing."
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   158
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   159
    verticalSpace ~= numberOfPixels ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   160
	verticalSpace := numberOfPixels.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   161
	self layoutChanged
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   162
    ]
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   163
! !
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   164
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   165
!PanelView methodsFor:'adding & removing subviews'!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   166
980
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   167
addComponent:aComponent
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   168
    "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
   169
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   170
    super addComponent:aComponent.
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   171
    self addedView:aComponent
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   172
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   173
    "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
   174
!
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   175
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   176
addSubView:aView
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   177
    "redefined to recompute layout when a subview is added"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   178
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   179
    super addSubView:aView.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   180
    self addedView:aView
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   181
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   182
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   183
addSubView:newView after:aView
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   184
    "redefined to recompute layout when a subview is added"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   185
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   186
    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
   187
    self addedView:newView
c568dfd06f11 recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   188
c568dfd06f11 recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   189
    "Modified: 15.7.1996 / 10:15:04 / cg"
202
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
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   192
addSubView:newView before:aView
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   193
    "redefined to recompute layout when a subview is added"
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
    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
   196
    self addedView:newView
c568dfd06f11 recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   197
c568dfd06f11 recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   198
    "Modified: 15.7.1996 / 10:14:39 / cg"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   199
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   200
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   201
removeSubView:aView
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   202
    "redefined to recompute layout when a subview is removed"
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
    super removeSubView:aView.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   205
    aView removeDependent:self.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   206
    self layoutChanged
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 15
diff changeset
   207
! !
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   208
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   209
!PanelView methodsFor:'event processing'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   210
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   211
sizeChanged:how
119
claus
parents: 63
diff changeset
   212
    "my size has changed - must rearrange elements"
claus
parents: 63
diff changeset
   213
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   214
    super sizeChanged:how.
60
f3c738c24ce6 mostly style
claus
parents: 38
diff changeset
   215
    self layoutChanged
125
claus
parents: 119
diff changeset
   216
!
claus
parents: 119
diff changeset
   217
claus
parents: 119
diff changeset
   218
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
   219
    "an element changed its size"
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   220
125
claus
parents: 119
diff changeset
   221
    something == #sizeOfView ifTrue:[
980
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   222
        self layoutChanged.
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   223
        ^ self
125
claus
parents: 119
diff changeset
   224
    ].
claus
parents: 119
diff changeset
   225
    ^ 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
   226
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   227
    "Modified: 28.1.1997 / 17:52:44 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   228
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   229
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   230
!PanelView methodsFor:'initialization'!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   231
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   232
initialize
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   233
    super initialize.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   234
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   235
    hLayout := vLayout := #center.  "/ notice, this is ignored in this class
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   236
				    "/ used by subclasses only
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   237
    verticalSpace := ViewSpacing.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   238
    horizontalSpace := ViewSpacing.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   239
    mustRearrange := elementsChangeSize := false
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   240
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   241
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   242
realize
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   243
    mustRearrange ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   244
	self setChildPositions
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   245
    ].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   246
    super realize
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   247
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   248
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   249
setChildPositionsIfChanged
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   250
    "set all of my child positions - this is usually delayed,
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   251
     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
   252
     elements are to be added) thus avoiding repositioning the elements
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   253
     over and over. However, sometimes it is nescessary, to force positioning
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   254
     the elements, for example, before querying the relative position of
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   255
     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
   256
     pointer)."
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
    mustRearrange ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   259
	self setChildPositions
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
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   262
! !
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   263
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   264
!PanelView methodsFor:'private'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   265
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   266
addedView:aView
980
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   267
    "added a new element - rearrange components"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   268
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   269
    elementsChangeSize ifTrue:[
787
c568dfd06f11 recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   270
        aView addDependent:self
c568dfd06f11 recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   271
    ].
c568dfd06f11 recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   272
    aView resize.
788
653fd742b5b0 extent handling when adding views
Claus Gittinger <cg@exept.de>
parents: 787
diff changeset
   273
"/    explicitExtent ~~ true ifTrue:[
653fd742b5b0 extent handling when adding views
Claus Gittinger <cg@exept.de>
parents: 787
diff changeset
   274
"/        self resize
653fd742b5b0 extent handling when adding views
Claus Gittinger <cg@exept.de>
parents: 787
diff changeset
   275
"/    ].
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   276
    self layoutChanged
787
c568dfd06f11 recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   277
980
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   278
    "Modified: 28.1.1997 / 17:45:10 / cg"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   279
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   280
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   281
layoutChanged
119
claus
parents: 63
diff changeset
   282
    "called whenever repositioning is required. If the panel view is
claus
parents: 63
diff changeset
   283
     already visible, reposition elements right now. Otherwise, remember
claus
parents: 63
diff changeset
   284
     that a repositioning is needed to do so when the view eventually becomes
claus
parents: 63
diff changeset
   285
     visible."
claus
parents: 63
diff changeset
   286
15
0dbce35d3c69 *** empty log message ***
claus
parents: 5
diff changeset
   287
    shown ifTrue:[
60
f3c738c24ce6 mostly style
claus
parents: 38
diff changeset
   288
	self setChildPositions
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   289
    ] ifFalse:[
60
f3c738c24ce6 mostly style
claus
parents: 38
diff changeset
   290
	mustRearrange := true
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   291
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   292
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   293
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   294
setChildPositions
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   295
    "(re)compute position of every child.
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   296
     This method is redefined for different layout characteristics - you may
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   297
     even create subclasses with completely different geometry management."
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   298
980
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   299
    |first xpos ypos maxHeightInRow thisRow subViews|
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   300
980
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   301
    (subViews := self subViews) notNil ifTrue:[
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   302
        xpos := horizontalSpace.
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   303
        ypos := verticalSpace.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   304
980
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   305
        maxHeightInRow := 0.
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   306
        first := true.
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   307
        thisRow := OrderedCollection new.
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   308
        subViews do:[:child |
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   309
            "go to next row, if this subview won't fit"
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   310
            first ifFalse: [
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   311
                (xpos + child widthIncludingBorder + horizontalSpace) > width
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   312
                ifTrue: [
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   313
                    thisRow notEmpty ifTrue:[
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   314
                        thisRow do:[:rowElement |
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   315
                            rowElement heightIncludingBorder < maxHeightInRow ifTrue:[
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   316
                                rowElement top:(rowElement top + (maxHeightInRow - rowElement heightIncludingBorder))
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   317
                            ]
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   318
                        ]
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   319
                    ].
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   320
                    ypos := ypos + verticalSpace + maxHeightInRow.
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   321
                    xpos := horizontalSpace.
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   322
                    maxHeightInRow := 0.
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   323
                    thisRow := OrderedCollection new.
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   324
                ]
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   325
            ].
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   326
            thisRow add:child.
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   327
            child origin:(xpos@ypos).
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   328
            xpos := xpos + (child widthIncludingBorder) + horizontalSpace.
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   329
            (maxHeightInRow < (child heightIncludingBorder)) ifTrue:[
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   330
                maxHeightInRow := child heightIncludingBorder
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   331
            ].
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   332
            first := false
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   333
        ].
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   334
        thisRow notEmpty ifTrue:[
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   335
            thisRow do:[:rowElement |
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   336
                rowElement heightIncludingBorder < maxHeightInRow ifTrue:[
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   337
                    rowElement top:(rowElement top + (maxHeightInRow - rowElement heightIncludingBorder))
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   338
                ]
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   339
            ]
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   340
        ].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   341
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   342
    mustRearrange := false
980
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   343
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   344
    "Modified: 28.1.1997 / 17:51:36 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   345
! !
125
claus
parents: 119
diff changeset
   346
980
6079922a5519 eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   347
!PanelView class methodsFor:'documentation'!
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
   348
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
   349
version
1036
5958cde90d09 added dummy access to hLayout and vLayout.
ca
parents: 980
diff changeset
   350
    ^ '$Header: /cvs/stx/stx/libwidg/PanelView.st,v 1.20 1997-02-21 19:27:43 ca Exp $'
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
   351
! !