2

#SystemWindow のサブクラス #Mosaic1 を作成しました。ウィンドウの初期位置を制御したいと考えています。それ、どうやったら出来るの?クラス#RealEstateAgentが関与していますが、どのように?クラスのコメントは言う

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

そこで、クラス #RealEstateAgent の設定方法と使用方法について説明を求めています。

ノート:

  • #RealEstateAgentはシングルトンです。クラス側のメソッドしかありません
  • #SystemWindowによってのみ参照されます
  • 新しい SystemWindow は、 RealEstateAgent class>> standardWindowExtentから初期エクステントを取得します
4

1 に答える 1

1

1 つの解決策は、クラス #RealEstateAgent をバイパスし、独自のコードを記述して、SystemWindow の新しいインスタンスの初期サイズと位置を処理することです。

これは、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 ]

交換

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

計算する

  • thePositionOfTheWindow
  • theExtentOfTheWindow

それからする

self morphPosition: thePositionOfTheWindow  morphExtent: theExtentOfTheWindow.
于 2013-12-15T23:55:33.610 に答える