LayoutWrapper.st
author Claus Gittinger <cg@exept.de>
Wed, 05 Jun 1996 17:28:29 +0200
changeset 292 60fbf13dfc8c
parent 278 f2382bb48850
child 321 6421da8810e2
permissions -rw-r--r--
prepare for view-component integration
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
292
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
     8
!LayoutWrapper class methodsFor:'documentation'!
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
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
!LayoutWrapper class methodsFor:'instance creation'!
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
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    71
!LayoutWrapper methodsFor:'view protocol mimicri'!
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    72
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    73
containerChangedSize
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    74
    "my container changed its size.
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    75
     Resize my component according the layout spec"
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    76
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    77
    layout notNil ifTrue:[
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    78
        self bounds:(layout rectangleRelativeTo:(container viewRectangle)
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    79
                                      preferred:(self preferredBounds)) rounded
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
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    82
    "Modified: 5.6.1996 / 02:32:01 / cg"
278
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
! !
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
!LayoutWrapper class methodsFor:'documentation'!
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
version
292
60fbf13dfc8c prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents: 278
diff changeset
    88
    ^ '$Header: /cvs/stx/stx/libview2/LayoutWrapper.st,v 1.2 1996-06-05 15:28:29 cg Exp $'
278
f2382bb48850 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
! !