LayoutWrapper.st
author Claus Gittinger <cg@exept.de>
Fri, 19 Jul 1996 19:21:29 +0200
changeset 321 6421da8810e2
parent 292 60fbf13dfc8c
child 323 ee2f4da361a6
permissions -rw-r--r--
more view mimicri; renamed #superViewChangedSize to #containerChangedSize, #superViewMapped to #containerMapped and #superViewUnmapped to #containerUnmapped
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
278
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
TranslatingWrapper subclass:#LayoutWrapper
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
	instanceVariableNames:'layout'
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
	classVariableNames:''
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
	poolDictionaries:''
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
	category:'Graphics-Display Objects'
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
!
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
321
6421da8810e2 more view mimicri;
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
     8
!LayoutWrapper  class methodsFor:'documentation'!
292
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
     9
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    10
examples
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    11
"
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    12
                                                                        [exBegin]
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    13
    |t view wrapper|
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    14
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    15
    t := StandardSystemView extent:200@200.
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    16
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    17
    view := View new.
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    18
    view viewBackground:Color red.
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    19
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    20
    wrapper := LayoutWrapper new.
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    21
    wrapper layout:(LayoutFrame new
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    22
                        leftFraction:0.2;
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    23
                        rightFraction:0.8;
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    24
                        topFraction:0.2;
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    25
                        bottomFraction:0.8).
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    26
    wrapper component:view.
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    27
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    28
    t addComponent:wrapper.
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    29
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    30
    t open
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    31
                                                                        [exEnd]
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    32
"
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    33
! !
278
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
321
6421da8810e2 more view mimicri;
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
    35
!LayoutWrapper  class methodsFor:'instance creation'!
278
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
on:aComponent in:aLayout
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
    "create and return a layoutWrapper, which controls
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
     aComponent bounds using aLayout.
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
     The layout argument may be:
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
        nil       - no constraint
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
        Point     - origin shift
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
        Rectangle - origin shift & extent
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
        Layout    - full control"
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
    ^ (self on:aComponent) layout:aLayout
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
    "Created: 26.5.1996 / 16:18:44 / cg"
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
    "Modified: 26.5.1996 / 16:34:04 / cg"
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
! !
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
!LayoutWrapper methodsFor:'accessing'!
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
layout
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
    "return layout"
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
    ^ layout
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
    "Created: 26.5.1996 / 16:18:11 / cg"
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
!
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
layout:something
292
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    63
    "set the layout"
278
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
    layout := something.
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
    "Created: 26.5.1996 / 16:18:11 / cg"
292
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    68
    "Modified: 5.6.1996 / 13:58:55 / cg"
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    69
! !
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    70
321
6421da8810e2 more view mimicri;
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
    71
!LayoutWrapper methodsFor:'queries'!
6421da8810e2 more view mimicri;
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
    72
6421da8810e2 more view mimicri;
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
    73
isLayoutWrapper
6421da8810e2 more view mimicri;
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
    74
     ^ true
6421da8810e2 more view mimicri;
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
    75
6421da8810e2 more view mimicri;
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
    76
    "Created: 19.7.1996 / 17:51:16 / cg"
6421da8810e2 more view mimicri;
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
    77
! !
6421da8810e2 more view mimicri;
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
    78
292
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    79
!LayoutWrapper methodsFor:'view protocol mimicri'!
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    80
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    81
containerChangedSize
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    82
    "my container changed its size.
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    83
     Resize my component according the layout spec"
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    84
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    85
    layout notNil ifTrue:[
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    86
        self bounds:(layout rectangleRelativeTo:(container viewRectangle)
321
6421da8810e2 more view mimicri;
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
    87
                                      preferred:(self preferredBounds)) rounded.
6421da8810e2 more view mimicri;
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
    88
        component containerChangedSize
292
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    89
    ]
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    90
321
6421da8810e2 more view mimicri;
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
    91
    "Modified: 19.7.1996 / 17:47:54 / cg"
278
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
! !
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
321
6421da8810e2 more view mimicri;
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
    94
!LayoutWrapper  class methodsFor:'documentation'!
278
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
version
321
6421da8810e2 more view mimicri;
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
    97
    ^ '$Header: /cvs/stx/stx/libview2/LayoutWrapper.st,v 1.3 1996-07-19 17:21:29 cg Exp $'
278
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
! !