The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Cooperating Windows

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Cooperating Windows Posted: Dec 3, 2004 12:37 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Cooperating Windows
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Cincom Smalltalk Blog - Smalltalk with Rants

Advertisement

A common need in any application is Windows that cooperate - child windows that close when their parent closes, etc. It turns out that it's pretty easy to set that up in VisualWorks - I've needed it in BottomFeeder, and I'm sure that most Cincom Smalltalk developers need this capability at some point. So how do you do it? Let's start with the 'main application window' - add this to the #postBuildWithMethod:


postBuildWith: bldr
	super postBuildWith: bldr.
	bldr window 
		application: self;
		beMaster.

That sets the 'main application' window up as a master - child windows will receive most of the same window events and follow them. Now you need to set up the child window. Let's say that it opens up from some method in the main application:


openSomeTool
	| tool |
	tool := SomeTool new.
	toolBuilder := tool allButOpenInterface: #windowSpec.
	toolBuilder
		window application: self;
		beSlave.
	tool finallyOpen.

What's going on here is that you are registering a specific window as the 'master', and another as the 'slave' - which means that a set of events received by the master window will be passed along. If you want events passed equally, then use #bePartner to all involved windows.

It turns out that you can customize the set of events you care about - a quick look at #beMaster and #beSlave in class ApplicationModel shows this:


beMaster
	"Send windowState events to other ApplicationWindows that have the same 
	application as us. Effectively the dual of beSlave."

	self sendWindowEvents: #(#close #collapse #expand ); receiveWindowEvents: #(#expand )


beSlave
	"Receive windowState events from some other ApplicationWindow that has the 
	same application as us. Effectively the dual of beMaster."

	self receiveWindowEvents: #(#close #collapse #expand ); sendWindowEvents: #(#expand )

You could easily add your own custom versions of #beMaster and #beSlave - and either expand or contract the list of window events. You can also use #sendWindowEvents: and #receiveWindowEvents: to tailor the event stream. It's all pretty easy to manage.

Read: Cooperating Windows

Topic: Comment Spam Previous Topic   Next Topic Topic: Print Media declining

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use