DisplayRootView.st
author Claus Gittinger <cg@exept.de>
Mon, 27 Nov 1995 23:31:52 +0100
changeset 269 ea536bb319a6
parent 219 9ff0660f447f
child 616 56cf67c82664
permissions -rw-r--r--
checkin from browser

"
 COPYRIGHT (c) 1988 by Claus Gittinger
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"

PseudoView subclass:#DisplayRootView
	 instanceVariableNames:''
	 classVariableNames:''
	 poolDictionaries:''
	 category:'Views-Basic'
!

!DisplayRootView class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1988 by Claus Gittinger
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
!

documentation
"
    this class describes Xs rootWindow (which is the background window and
    can be used for drawing outside of Views i.e. for dragging between Views).

    There is one global variable (RootView) which is the Displays rootview.
    (this is the default displays rootView; to access other devices' rootView,
     use someDisplay rootView),

    Instances of myself (i.e. these rootViews) are light-weight views; 
    they do not support events, models etc.
    They are pure drawing canvases and should be only used for special
    applications. There may be display systems in which rootViews are not
    supported/allowed implemented. So be VERY careful when using them.

    To draw in the (Displays) root window:

	RootView paint:(Color red).
	RootView fillRectangleX:10 y:10 width:100 height:100.

    of course, all stuff from View and its superclasses can be used:

	RootView paint:(Color red).
	RootView noClipByChildren.
	RootView fillRectangleX:10 y:10 width:100 height:100.

    you have to be careful with some window managers, since what you
    see on the screen is not always really the root window. Some Desktops
    add their own view in between (although the Xworkstation class does
    care for this, it seems not to work correctly on all systems).
    In general, you should never use the RootView for normal applications.
"
! !

!DisplayRootView class methodsFor:'initialization'!

initialize
    Display isNil ifTrue:[
	Workstation initialize
    ].
    super initialize
! !

!DisplayRootView class methodsFor:'instance creation'!

on:aDisplay
    "since there is only one RootView - catch new and return
     the one and only rootView."

    aDisplay == Display ifTrue:[
	RootView notNil ifTrue:[^ RootView].
	RootView := super on:aDisplay.
	^ RootView
    ].
    ^ super on:aDisplay
! !

!DisplayRootView methodsFor:'accessing'!

controller
    "I have no controller"

    ^ nil
!

name
    ^ 'RootWindow'
!

sensor
    "I have no sensor"

    ^ nil
!

windowGroup
    "I have no windowGroup"

    ^ nil
! !

!DisplayRootView methodsFor:'destroying'!

destroy
    "catch destroy - some windowmanagers get confused if
     we destroy the rootWindow if its a virtual root window"

    ^ self
! !

!DisplayRootView methodsFor:'initialization'!

initialize
    super initialize.

    width := device width.
    height := device height.
    drawableId := device rootWindowFor:self.
    realized := true.
!

reinitialize
    "reinit after snapin"

    width := device width.
    height := device height.
    drawableId := device rootWindowFor:self.
    realized := true.
    gcId := nil.
! !

!DisplayRootView methodsFor:'queries'!

canDrop:anObjectOrCollection
    "return true, if anObjectOrCollection can be
     dropped in the receiver. This method should be
     redefined in views which can take objects"

    ^ false
!

isWindowManagerRunning
    "answer true, if a window manager is currently running.
     This is done by performing an action (enabling button events of
     root window), which will fail if a window manager is running."

    |errorOccured|

    errorOccured := false.
    device class deviceErrorSignal handle:[:ex |
	errorOccured := true.
	ex return
    ] do:[
	self enableButtonEvents.
	device flush.
    ].
    ^ errorOccured

    "
     DisplayRootView new
     RootView isWindowManagerRunning
    "
! !

!DisplayRootView class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libview/DisplayRootView.st,v 1.14 1995-11-27 22:27:35 cg Exp $'
! !
DisplayRootView initialize!