TransparentBox.st
author sr
Mon, 13 May 2019 16:23:44 +0200
changeset 4262 b69be50550bb
parent 4255 e8e9d68d5a5f
permissions -rw-r--r--
#BUGFIX by Stefan Reise class: ActiveHelp changed: #basicHelpTextFor:at: care for nil in #aDevicePointOrNil
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4255
e8e9d68d5a5f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3621
diff changeset
     1
"{ Encoding: utf8 }"
e8e9d68d5a5f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3621
diff changeset
     2
2377
4a5d442f4a2b copyright
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
     3
"
4a5d442f4a2b copyright
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
     4
 COPYRIGHT (c) 2004 by eXept Software AG
4a5d442f4a2b copyright
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
     5
              All Rights Reserved
4a5d442f4a2b copyright
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
     6
4a5d442f4a2b copyright
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
     7
 This software is furnished under a license and may be used
4a5d442f4a2b copyright
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
     8
 only in accordance with the terms of that license and with the
4a5d442f4a2b copyright
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
4a5d442f4a2b copyright
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    10
 be provided or otherwise made available to, or used by, any
4a5d442f4a2b copyright
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    11
 other person.  No title to or ownership of the software is
4a5d442f4a2b copyright
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    12
 hereby transferred.
4a5d442f4a2b copyright
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    13
"
1975
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
"{ Package: 'stx:libview2' }"
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
3621
63e942161951 device access
Claus Gittinger <cg@exept.de>
parents: 3289
diff changeset
    16
"{ NameSpace: Smalltalk }"
63e942161951 device access
Claus Gittinger <cg@exept.de>
parents: 3289
diff changeset
    17
1975
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
View subclass:#TransparentBox
2003
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    19
	instanceVariableNames:'shapeForm'
1975
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	classVariableNames:''
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	poolDictionaries:''
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
	category:'Views-Basic'
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
2003
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    25
!TransparentBox class methodsFor:'documentation'!
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    26
2377
4a5d442f4a2b copyright
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    27
copyright
4a5d442f4a2b copyright
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    28
"
4a5d442f4a2b copyright
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    29
 COPYRIGHT (c) 2004 by eXept Software AG
4a5d442f4a2b copyright
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    30
              All Rights Reserved
4a5d442f4a2b copyright
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    31
4a5d442f4a2b copyright
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    32
 This software is furnished under a license and may be used
4a5d442f4a2b copyright
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    33
 only in accordance with the terms of that license and with the
4a5d442f4a2b copyright
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
4a5d442f4a2b copyright
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    35
 be provided or otherwise made available to, or used by, any
4a5d442f4a2b copyright
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    36
 other person.  No title to or ownership of the software is
4a5d442f4a2b copyright
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    37
 hereby transferred.
4a5d442f4a2b copyright
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    38
"
4a5d442f4a2b copyright
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    39
!
4a5d442f4a2b copyright
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    40
4255
e8e9d68d5a5f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3621
diff changeset
    41
documentation
e8e9d68d5a5f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3621
diff changeset
    42
"
e8e9d68d5a5f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3621
diff changeset
    43
    sorry, but currently this works only on X-displays.
e8e9d68d5a5f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3621
diff changeset
    44
    i.e. on Windows, a non-transparent regular view is shown
e8e9d68d5a5f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3621
diff changeset
    45
"
e8e9d68d5a5f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3621
diff changeset
    46
!
e8e9d68d5a5f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3621
diff changeset
    47
2003
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    48
examples
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    49
"
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    50
    | tv b1 b2 |
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    51
2004
a0245a3e8cdc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2003
diff changeset
    52
    b1 := Button label:'close'.
a0245a3e8cdc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2003
diff changeset
    53
    b1 action:[ tv close ].
2003
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    54
    b1 origin:10@10.
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    55
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    56
    b2 := Button label:'hello'.
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    57
    b2 origin:100@100.
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    58
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    59
    tv := self new.
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    60
    tv extent:200@200.
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    61
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    62
    tv addSubView:b1.
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    63
    tv addSubView:b2.
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    64
    tv open
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    65
"
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    66
! !
1975
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
!TransparentBox methodsFor:'events'!
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
sizeChanged:how
2003
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    71
    shapeForm notNil ifTrue:[
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    72
        self computeShape.
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    73
    ].
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    74
    ^ super sizeChanged: how.
1975
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
! !
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
!TransparentBox methodsFor:'initialization'!
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
2003
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    79
realize
1975
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    self computeShape.
2003
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    81
    super realize.
1975
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
! !
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
!TransparentBox methodsFor:'queries'!
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
isTransparentBox
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    ^true
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
!
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
specClass
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
    ^ TransparentBoxSpec
2003
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    93
!
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    94
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    95
windowStyle
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
    96
    ^ #undecorated
1975
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
! !
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
!TransparentBox methodsFor:'shape computation'!
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
2003
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
   101
addSubView:aView
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
   102
    super addSubView:aView.
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
   103
    shapeForm notNil ifTrue:[
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
   104
        self computeShape
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
   105
    ].
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
   106
!
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
   107
1975
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
computeShape
2003
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
   109
    | subViews w h |
1975
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
3621
63e942161951 device access
Claus Gittinger <cg@exept.de>
parents: 3289
diff changeset
   111
    device supportsArbitraryShapedViews ifFalse:[^self].
1975
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    w := self extent x.
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
    h := self extent y.
2003
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
   115
    shapeForm := Form width:w height:h.
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
   116
    shapeForm fill:(Color colorId:0).
1975
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
2003
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
   118
    shapeForm foreground:(Color colorId:1).
1975
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
    subViews := self subViews.
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
    subViews isEmptyOrNil ifTrue:[
2003
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
   122
       self fillFormWithBorderShape:shapeForm.
1975
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
    ] ifFalse:[
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
        subViews do:[:aSubView|
2003
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
   125
            aSubView fillFormWithBorderShape:shapeForm.
1975
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
        ]
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    ].
2003
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
   128
    "/ self viewShape:shapeForm.
196bdcaf1859 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1975
diff changeset
   129
    self borderShape:shapeForm.
1975
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
! !
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
!TransparentBox class methodsFor:'documentation'!
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
version
3621
63e942161951 device access
Claus Gittinger <cg@exept.de>
parents: 3289
diff changeset
   135
    ^ '$Header$'
1975
3901166c295e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
! !
3289
3dff9f4efe99 class: TransparentBox
Stefan Vogel <sv@exept.de>
parents: 2377
diff changeset
   137