'From Pharo1.3a of ''18 January 2011'' [Latest update: #13257] on 9 June 2011 at 1:57:41 pm'! StandardWindow subclass: #WindowOrganiser instanceVariableNames: 'tabGroup' classVariableNames: '' poolDictionaries: '' category: 'Guru'! !SystemWindow methodsFor: '*Polymorph-Widgets' stamp: 'GaryChambers 6/9/2011 13:27'! activate "Activate the owner too." |mo mc| mo := self modalOwner. mc := self modalChild. mc isNil ifFalse: [mc owner notNil ifTrue: [ mc activate. ^mc modalChild isNil ifTrue: [mc indicateModalChild]]]. (isCollapsed not and: [ self paneMorphs size > 1 and: [self splitters isEmpty]]) ifTrue: [self addPaneSplitters]. TopWindow isNil ifFalse: [ TopWindow rememberKeyboardFocus: ActiveHand keyboardFocus]. super activate. self isEmbedded ifFalse: [ self basicActivate]. self rememberedKeyboardFocus ifNil: [(self respondsTo: #navigateFocusForward) ifTrue: [self navigateFocusForward]] ifNotNil: [|m| m := self rememberedKeyboardFocus. m world ifNil: [self rememberKeyboardFocus: nil] "deleted" ifNotNil: [ m wantsKeyboardFocus ifTrue: [m takeKeyboardFocus] ifFalse: [(self respondsTo: #navigateFocusForward) ifTrue: [self navigateFocusForward]]]]. (mo notNil and: [mo isKindOf: SystemWindow]) ifTrue: [mo bringBehind: self]! ! !SystemWindow methodsFor: '*Polymorph-Widgets' stamp: 'GaryChambers 6/9/2011 13:38'! configureForEmbedding "Set up the window so it can be embedded into another morph." labelArea owner notNil ifTrue: [ self hasDropShadow: false; beWithoutGrips; removeLabelArea; makeBorderless. self submorphsDo: [:m | m unlock]]! ! !SystemWindow methodsFor: '*Polymorph-Widgets' stamp: 'GaryChambers 6/9/2011 13:26'! configureForUnembedding "Set up the window so it can be unembedded and placed in the world." labelArea owner isNil ifTrue: [ self removeProperty: #processingMouseDown; makeBordered; initializeLabelArea; themeChanged; addGrips; hasDropShadow: true]! ! !SystemWindow methodsFor: '*Polymorph-Widgets' stamp: 'GaryChambers 6/9/2011 13:21'! isEmbedded "Answer whether the receiver is embedd, i.e. has an owner that is not the world." ^self owner notNil and: [self owner ~= self world]! ! !SystemWindow methodsFor: '*Polymorph-Widgets' stamp: 'GaryChambers 6/9/2011 12:18'! makeBordered "Add the border and border width offsets." |b| self borderWidth = 0 ifFalse: [^self]. b := self class borderWidth. self submorphsDo: [:m | | l | l := m layoutFrame. l ifNotNil: [ l rightFraction = 1 ifTrue: [l rightOffset: l rightOffset - b]. l leftFraction = 0 ifTrue: [l leftOffset: l leftOffset + b]. l bottomFraction = 1 ifTrue: [l bottomOffset: l bottomOffset - b]]]. self theme configureWindowBorderFor: self! ! !SystemWindow methodsFor: '*Polymorph-Widgets' stamp: 'GaryChambers 6/9/2011 12:13'! makeBorderless "Remove the border and border width offsets.." |b| b := self class borderWidth. self submorphsDo: [:m | | l | l := m layoutFrame. l ifNotNil: [ l rightFraction = 1 ifTrue: [l rightOffset: l rightOffset + b]. l leftFraction = 0 ifTrue: [l leftOffset: l leftOffset - b]. l bottomFraction = 1 ifTrue: [l bottomOffset: l bottomOffset + b]]]. self borderWidth: 0! ! !SystemWindow methodsFor: '*Polymorph-Widgets' stamp: 'GaryChambers 6/9/2011 13:54'! passivate "Make me unable to respond to mouse and keyboard" super passivate. self setStripeColorsFrom: self paneColorToUse. self isEmbedded ifTrue: [^self]. model modelSleep. "Control boxes remain active, except in novice mode" self lockInactivePortions. labelArea ifNil: "i.e. label area is nil, so we're titleless" [self adjustBorderUponDeactivationWhenLabeless]! ! !SystemWindow methodsFor: 'events' stamp: 'GaryChambers 6/9/2011 13:35'! handlesMouseDown: evt "If I am not the topWindow, then I will only respond to dragging by the title bar. Any other click will only bring me to the top" self isEmbedded ifTrue: [^false]. (self labelRect containsPoint: evt cursorPoint) ifTrue: [^ true]. ^ self activeOnlyOnTop and: [self ~~ TopWindow]! ! !SystemWindow methodsFor: 'events' stamp: 'GaryChambers 6/9/2011 13:33'! mouseDown: evt "Changed to properly process the mouse down event if passing to submorphs." (self valueOfProperty: #processingMouseDown) == true ifTrue: [^self]. "recursive handling" self isEmbedded ifTrue: [^self]. evt hand waitForClicksOrDrag: self event: evt. "allow double-click response" self setProperty: #clickPoint toValue: evt cursorPoint. TopWindow == self ifTrue: [self comeToFront] "rise above non-window morphs" ifFalse:[ TopWindow ifNotNil: [:w | w rememberKeyboardFocus: evt hand keyboardFocus]. evt hand releaseKeyboardFocus. self activate. self announce: (WindowActivated new event: evt; window: self; yourself). ]. model windowActiveOnFirstClick ifTrue: ["Normally window keeps control of first click. Need explicit transmission for first-click activity." self setProperty: #processingMouseDown toValue: true. [evt wasHandled: false. self processEvent: evt] ensure: [self setProperty: #processingMouseDown toValue: false]]! ! !WindowOrganiser methodsFor: 'as yet unclassified' stamp: 'GaryChambers 6/9/2011 13:12'! acceptDroppingMorph: aSystemWindow event: evt "Add the window." self addWindow: aSystemWindow! ! !WindowOrganiser methodsFor: 'as yet unclassified' stamp: 'GaryChambers 6/9/2011 13:47'! addWindow: aSystemWindow "Add an existing window to the pages." TopWindow = aSystemWindow ifTrue: [self class passivateTopWindow]. self tabGroup addPage: aSystemWindow configureForEmbedding label: (self tabLabelFor: aSystemWindow); selectedPageIndex: self tabGroup pages size! ! !WindowOrganiser methodsFor: 'as yet unclassified' stamp: 'GaryChambers 6/9/2011 12:45'! grabWindow "Request an existing window from the user and add it." |windows choice| windows := self world visibleSystemWindows. choice := UIManager default chooseFrom: (windows collect: [:e | e labelString]) values: windows lines: #() message: 'Choose a window to add to the organiser' translated title: 'Grab window' translated. choice ifNotNil: [self addWindow: choice]! ! !WindowOrganiser methodsFor: 'as yet unclassified' stamp: 'GaryChambers 6/9/2011 13:19'! handleDropMorph: anEvent "Handle a dropping morph." | aMorph | aMorph := anEvent contents. "Ignore whether the dropping morph wants to be dropped, just whether the receiver wants it" (self wantsDroppedMorph: aMorph event: anEvent) ifFalse: [^ self]. anEvent wasHandled: true. self acceptDroppingMorph: aMorph event: anEvent. aMorph justDroppedInto: self event: anEvent ! ! !WindowOrganiser methodsFor: 'as yet unclassified' stamp: 'GaryChambers 6/9/2011 13:15'! initialize "Add the tab group with an inital workspace." super initialize. self tabGroup: self newTabGroup. self tabGroup tabSelectorMorph addDependent: self. self title: 'Window Organiser' translated; dropEnabled: true; addMorph: self tabGroup frame: (0@0 corner: 1@1). self tabGroup color: Color transparent! ! !WindowOrganiser methodsFor: 'as yet unclassified' stamp: 'GaryChambers 6/9/2011 12:35'! newTabGroup "Answer a new tab group." ^(self newTabGroup: #()) cornerStyle: #square! ! !WindowOrganiser methodsFor: 'as yet unclassified' stamp: 'GaryChambers 6/9/2011 12:40'! offerWindowMenu "Popup the window menu. Fill from current workspace." | aMenu | aMenu := self buildWindowMenu. aMenu addLine; add: 'Grab window...' target: self action: #grabWindow. aMenu lastItem icon: self theme smallWindowIcon. self tabGroup page ifNotNil: [: page | page model addModelItemsToWindowMenu: aMenu]. aMenu popUpEvent: self currentEvent in: self world! ! !WindowOrganiser methodsFor: 'as yet unclassified' stamp: 'GaryChambers 6/9/2011 12:50'! removeWindow: aSystemWindow "Remove a window from the pages." self tabGroup removePage: aSystemWindow. aSystemWindow configureForUnembedding. self world addMorph: aSystemWindow! ! !WindowOrganiser methodsFor: 'as yet unclassified' stamp: 'GaryChambers 6/9/2011 12:55'! tabLabelFor: aSystemWindow "Answer the tab label to use for the given page." ^self newRow: { self newButtonLabel: aSystemWindow labelString. self newCloseControlFor: nil action: [self removeWindow: aSystemWindow] help: 'Close this tab'}! ! !WindowOrganiser methodsFor: 'as yet unclassified' stamp: 'GaryChambers 6/9/2011 13:14'! wantsDroppedMorph: aMorph event: evt "Accept if a SystemWindow." self visible ifFalse: [^ false]. self dropEnabled ifFalse: [^ false]. ^aMorph isSystemWindow! ! !WindowOrganiser methodsFor: 'accessing' stamp: 'GaryChambers 6/9/2011 12:36'! tabGroup ^ tabGroup! ! !WindowOrganiser methodsFor: 'accessing' stamp: 'GaryChambers 6/9/2011 12:36'! tabGroup: anObject tabGroup := anObject! !