DisplayRootView.st
author Claus Gittinger <cg@exept.de>
Fri, 05 Jul 1996 14:58:04 +0200
changeset 919 47b7aff0f1e4
parent 727 bf23a306b6f2
child 1254 6bb4afe072f1
permissions -rw-r--r--
added #isRootView & #shown queries
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
48194c26a46c Initial revision
claus
parents:
diff changeset
     1
"
6
7ee0cfde237d *** empty log message ***
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1988 by Claus Gittinger
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
     3
	      All Rights Reserved
0
48194c26a46c Initial revision
claus
parents:
diff changeset
     4
48194c26a46c Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
48194c26a46c Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
48194c26a46c Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
48194c26a46c Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
48194c26a46c Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
48194c26a46c Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
48194c26a46c Initial revision
claus
parents:
diff changeset
    11
"
48194c26a46c Initial revision
claus
parents:
diff changeset
    12
727
bf23a306b6f2 renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
    13
DisplaySurface subclass:#DisplayRootView
616
56cf67c82664 documentation
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    14
	instanceVariableNames:''
56cf67c82664 documentation
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    15
	classVariableNames:''
56cf67c82664 documentation
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    16
	poolDictionaries:''
626
9f4a3aa6f8e2 class category changes
Claus Gittinger <cg@exept.de>
parents: 616
diff changeset
    17
	category:'Views-Special'
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    18
!
48194c26a46c Initial revision
claus
parents:
diff changeset
    19
919
47b7aff0f1e4 added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
    20
!DisplayRootView  class methodsFor:'documentation'!
45
d2d5bc481ebb *** empty log message ***
claus
parents: 23
diff changeset
    21
d2d5bc481ebb *** empty log message ***
claus
parents: 23
diff changeset
    22
copyright
d2d5bc481ebb *** empty log message ***
claus
parents: 23
diff changeset
    23
"
d2d5bc481ebb *** empty log message ***
claus
parents: 23
diff changeset
    24
 COPYRIGHT (c) 1988 by Claus Gittinger
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
    25
	      All Rights Reserved
45
d2d5bc481ebb *** empty log message ***
claus
parents: 23
diff changeset
    26
d2d5bc481ebb *** empty log message ***
claus
parents: 23
diff changeset
    27
 This software is furnished under a license and may be used
d2d5bc481ebb *** empty log message ***
claus
parents: 23
diff changeset
    28
 only in accordance with the terms of that license and with the
d2d5bc481ebb *** empty log message ***
claus
parents: 23
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
d2d5bc481ebb *** empty log message ***
claus
parents: 23
diff changeset
    30
 be provided or otherwise made available to, or used by, any
d2d5bc481ebb *** empty log message ***
claus
parents: 23
diff changeset
    31
 other person.  No title to or ownership of the software is
d2d5bc481ebb *** empty log message ***
claus
parents: 23
diff changeset
    32
 hereby transferred.
d2d5bc481ebb *** empty log message ***
claus
parents: 23
diff changeset
    33
"
d2d5bc481ebb *** empty log message ***
claus
parents: 23
diff changeset
    34
!
d2d5bc481ebb *** empty log message ***
claus
parents: 23
diff changeset
    35
d2d5bc481ebb *** empty log message ***
claus
parents: 23
diff changeset
    36
documentation
d2d5bc481ebb *** empty log message ***
claus
parents: 23
diff changeset
    37
"
d2d5bc481ebb *** empty log message ***
claus
parents: 23
diff changeset
    38
    this class describes Xs rootWindow (which is the background window and
180
claus
parents: 134
diff changeset
    39
    can be used for drawing outside of Views i.e. for dragging between Views).
89
ea2bf46eb669 *** empty log message ***
claus
parents: 71
diff changeset
    40
134
claus
parents: 109
diff changeset
    41
    There is one global variable (RootView) which is the Displays rootview.
claus
parents: 109
diff changeset
    42
    (this is the default displays rootView; to access other devices' rootView,
180
claus
parents: 134
diff changeset
    43
     use someDisplay rootView),
claus
parents: 134
diff changeset
    44
claus
parents: 134
diff changeset
    45
    Instances of myself (i.e. these rootViews) are light-weight views; 
claus
parents: 134
diff changeset
    46
    they do not support events, models etc.
claus
parents: 134
diff changeset
    47
    They are pure drawing canvases and should be only used for special
claus
parents: 134
diff changeset
    48
    applications. There may be display systems in which rootViews are not
claus
parents: 134
diff changeset
    49
    supported/allowed implemented. So be VERY careful when using them.
134
claus
parents: 109
diff changeset
    50
claus
parents: 109
diff changeset
    51
    To draw in the (Displays) root window:
89
ea2bf46eb669 *** empty log message ***
claus
parents: 71
diff changeset
    52
616
56cf67c82664 documentation
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    53
        RootView paint:(Color red).
56cf67c82664 documentation
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    54
        RootView fillRectangleX:10 y:10 width:100 height:100.
89
ea2bf46eb669 *** empty log message ***
claus
parents: 71
diff changeset
    55
ea2bf46eb669 *** empty log message ***
claus
parents: 71
diff changeset
    56
    of course, all stuff from View and its superclasses can be used:
ea2bf46eb669 *** empty log message ***
claus
parents: 71
diff changeset
    57
616
56cf67c82664 documentation
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    58
        RootView paint:(Color red).
56cf67c82664 documentation
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    59
        RootView noClipByChildren.
56cf67c82664 documentation
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    60
        RootView fillRectangleX:10 y:10 width:100 height:100.
89
ea2bf46eb669 *** empty log message ***
claus
parents: 71
diff changeset
    61
ea2bf46eb669 *** empty log message ***
claus
parents: 71
diff changeset
    62
    you have to be careful with some window managers, since what you
ea2bf46eb669 *** empty log message ***
claus
parents: 71
diff changeset
    63
    see on the screen is not always really the root window. Some Desktops
ea2bf46eb669 *** empty log message ***
claus
parents: 71
diff changeset
    64
    add their own view in between (although the Xworkstation class does
ea2bf46eb669 *** empty log message ***
claus
parents: 71
diff changeset
    65
    care for this, it seems not to work correctly on all systems).
ea2bf46eb669 *** empty log message ***
claus
parents: 71
diff changeset
    66
    In general, you should never use the RootView for normal applications.
616
56cf67c82664 documentation
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    67
56cf67c82664 documentation
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    68
    [author:]
56cf67c82664 documentation
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    69
        Claus Gittinger
45
d2d5bc481ebb *** empty log message ***
claus
parents: 23
diff changeset
    70
"
d2d5bc481ebb *** empty log message ***
claus
parents: 23
diff changeset
    71
! !
d2d5bc481ebb *** empty log message ***
claus
parents: 23
diff changeset
    72
919
47b7aff0f1e4 added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
    73
!DisplayRootView  class methodsFor:'initialization'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    74
48194c26a46c Initial revision
claus
parents:
diff changeset
    75
initialize
48194c26a46c Initial revision
claus
parents:
diff changeset
    76
    Display isNil ifTrue:[
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
    77
	Workstation initialize
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    78
    ].
48194c26a46c Initial revision
claus
parents:
diff changeset
    79
    super initialize
48194c26a46c Initial revision
claus
parents:
diff changeset
    80
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
    81
919
47b7aff0f1e4 added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
    82
!DisplayRootView  class methodsFor:'instance creation'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    83
134
claus
parents: 109
diff changeset
    84
on:aDisplay
89
ea2bf46eb669 *** empty log message ***
claus
parents: 71
diff changeset
    85
    "since there is only one RootView - catch new and return
ea2bf46eb669 *** empty log message ***
claus
parents: 71
diff changeset
    86
     the one and only rootView."
ea2bf46eb669 *** empty log message ***
claus
parents: 71
diff changeset
    87
134
claus
parents: 109
diff changeset
    88
    aDisplay == Display ifTrue:[
claus
parents: 109
diff changeset
    89
	RootView notNil ifTrue:[^ RootView].
claus
parents: 109
diff changeset
    90
	RootView := super on:aDisplay.
claus
parents: 109
diff changeset
    91
	^ RootView
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    92
    ].
134
claus
parents: 109
diff changeset
    93
    ^ super on:aDisplay
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    94
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
    95
48194c26a46c Initial revision
claus
parents:
diff changeset
    96
!DisplayRootView methodsFor:'accessing'!
48194c26a46c Initial revision
claus
parents:
diff changeset
    97
48194c26a46c Initial revision
claus
parents:
diff changeset
    98
controller
180
claus
parents: 134
diff changeset
    99
    "I have no controller"
claus
parents: 134
diff changeset
   100
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   101
    ^ nil
23
4a7e02de7b72 *** empty log message ***
claus
parents: 6
diff changeset
   102
!
4a7e02de7b72 *** empty log message ***
claus
parents: 6
diff changeset
   103
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   104
name
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   105
    ^ 'RootWindow'
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   106
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   107
23
4a7e02de7b72 *** empty log message ***
claus
parents: 6
diff changeset
   108
sensor
180
claus
parents: 134
diff changeset
   109
    "I have no sensor"
claus
parents: 134
diff changeset
   110
claus
parents: 134
diff changeset
   111
    ^ nil
claus
parents: 134
diff changeset
   112
!
claus
parents: 134
diff changeset
   113
claus
parents: 134
diff changeset
   114
windowGroup
claus
parents: 134
diff changeset
   115
    "I have no windowGroup"
claus
parents: 134
diff changeset
   116
23
4a7e02de7b72 *** empty log message ***
claus
parents: 6
diff changeset
   117
    ^ nil
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   118
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   119
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   120
!DisplayRootView methodsFor:'destroying'!
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   121
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   122
destroy
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   123
    "catch destroy - some windowmanagers get confused if
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   124
     we destroy the rootWindow if its a virtual root window"
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   125
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   126
    ^ self
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   127
! !
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   128
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   129
!DisplayRootView methodsFor:'initialization'!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   130
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   131
initialize
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   132
    super initialize.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   133
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   134
    width := device width.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   135
    height := device height.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   136
    drawableId := device rootWindowFor:self.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   137
    realized := true.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   138
!
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   139
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   140
reinitialize
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   141
    "reinit after snapin"
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   142
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   143
    width := device width.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   144
    height := device height.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   145
    drawableId := device rootWindowFor:self.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   146
    realized := true.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   147
    gcId := nil.
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   148
! !
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   149
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   150
!DisplayRootView methodsFor:'queries'!
48194c26a46c Initial revision
claus
parents:
diff changeset
   151
48194c26a46c Initial revision
claus
parents:
diff changeset
   152
canDrop:anObjectOrCollection
48194c26a46c Initial revision
claus
parents:
diff changeset
   153
    "return true, if anObjectOrCollection can be
48194c26a46c Initial revision
claus
parents:
diff changeset
   154
     dropped in the receiver. This method should be
48194c26a46c Initial revision
claus
parents:
diff changeset
   155
     redefined in views which can take objects"
48194c26a46c Initial revision
claus
parents:
diff changeset
   156
48194c26a46c Initial revision
claus
parents:
diff changeset
   157
    ^ false
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   158
!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   159
919
47b7aff0f1e4 added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   160
isRootView
47b7aff0f1e4 added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   161
    "yes, I am a rootview"
47b7aff0f1e4 added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   162
47b7aff0f1e4 added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   163
    ^ true
47b7aff0f1e4 added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   164
47b7aff0f1e4 added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   165
    "Created: 5.7.1996 / 13:48:24 / cg"
47b7aff0f1e4 added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   166
    "Modified: 5.7.1996 / 14:57:44 / cg"
47b7aff0f1e4 added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   167
!
47b7aff0f1e4 added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   168
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   169
isWindowManagerRunning
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   170
    "answer true, if a window manager is currently running.
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   171
     This is done by performing an action (enabling button events of
23
4a7e02de7b72 *** empty log message ***
claus
parents: 6
diff changeset
   172
     root window), which will fail if a window manager is running."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   173
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   174
    |errorOccured|
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   175
48194c26a46c Initial revision
claus
parents:
diff changeset
   176
    errorOccured := false.
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   177
    device class deviceErrorSignal handle:[:ex |
71
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   178
	errorOccured := true.
6a42b2b115f8 *** empty log message ***
claus
parents: 54
diff changeset
   179
	ex return
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   180
    ] do:[
134
claus
parents: 109
diff changeset
   181
	self enableButtonEvents.
180
claus
parents: 134
diff changeset
   182
	device flush.
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   183
    ].
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   184
    ^ errorOccured
23
4a7e02de7b72 *** empty log message ***
claus
parents: 6
diff changeset
   185
134
claus
parents: 109
diff changeset
   186
    "
claus
parents: 109
diff changeset
   187
     DisplayRootView new
claus
parents: 109
diff changeset
   188
     RootView isWindowManagerRunning
claus
parents: 109
diff changeset
   189
    "
919
47b7aff0f1e4 added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   190
!
47b7aff0f1e4 added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   191
47b7aff0f1e4 added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   192
shown
47b7aff0f1e4 added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   193
    "a rootview is always assumed to be visible"
47b7aff0f1e4 added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   194
47b7aff0f1e4 added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   195
    ^ true
47b7aff0f1e4 added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   196
47b7aff0f1e4 added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   197
    "Created: 5.7.1996 / 13:48:05 / cg"
47b7aff0f1e4 added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   198
    "Modified: 5.7.1996 / 14:57:34 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   199
! !
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   200
919
47b7aff0f1e4 added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   201
!DisplayRootView  class methodsFor:'documentation'!
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   202
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   203
version
919
47b7aff0f1e4 added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   204
    ^ '$Header: /cvs/stx/stx/libview/DisplayRootView.st,v 1.18 1996-07-05 12:58:04 cg Exp $'
269
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   205
! !
ea536bb319a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   206
DisplayRootView initialize!