Initial position of a SystemWindow (Cuis Smalltalk)

260 views Asked by At

I have made a subclass #Mosaic1 of #SystemWindow and I would like to control the initial position of the window. How do I do that? Class #RealEstateAgent is involved but how? The class comment says

Responsible for real-estate management on the screen, 
which is to say, controlling where new windows appear, 
with what sizes, etc.  5/20/96 sw

So I am asking for an explanation how to configure and use the class #RealEstateAgent.

Notes:

  • #RealEstateAgent is a singleton. It only has class side methods
  • It is only referenced by #SystemWindow
  • A new SystemWindow gets its initial extent from RealEstateAgent class>> standardWindowExtent
1

There are 1 answers

0
z-- On

One solution is to bypass the class #RealEstateAgent and write your own code to handle the initial size and position of a new instance of SystemWindow.

This may be done by overriding SystemWindow>>openInWorld:extent:

openInWorld: aWorld extent: extent
"This msg and its callees result in the window being activeOnlyOnTop"
aWorld addMorph: self.

self morphPosition: 
        (RealEstateAgent initialFrameFor: self world: aWorld) topLeft;
         morphExtent: extent.

aWorld startSteppingSubmorphsOf: self.


"Do it deferred. Was needed for text cursor to start blinking 
    if (Preferences disable: #focusFollowsMouse) "

WorldState addDeferredUIMessage: [ self activate ]

Replace

self morphPosition: 
        (RealEstateAgent initialFrameFor: self world: aWorld) topLeft;
         morphExtent: extent.

Calculate

  • thePositionOfTheWindow
  • theExtentOfTheWindow

Then do

self morphPosition: thePositionOfTheWindow  morphExtent: theExtentOfTheWindow.