class: ApplicationModel
authorClaus Gittinger <cg@exept.de>
Sat, 06 Jul 2013 19:06:24 +0200
changeset 3192 cfb6ff5f6b39
parent 3191 8675735eddd3
child 3193 84e87100e57b
class: ApplicationModel added: #shouldRememberLastExtent changed: #closeDownViews #defaultExtentFor:
ApplicationModel.st
--- a/ApplicationModel.st	Fri Jul 05 01:09:20 2013 +0200
+++ b/ApplicationModel.st	Sat Jul 06 19:06:24 2013 +0200
@@ -13,7 +13,8 @@
 
 Model subclass:#ApplicationModel
 	instanceVariableNames:'builder resources device masterApplication'
-	classVariableNames:'DefaultLabels DefaultVisuals RecentlyOpenedApplications'
+	classVariableNames:'DefaultLabels DefaultVisuals RecentlyOpenedApplications
+		DefaultExtents'
 	poolDictionaries:''
 	category:'Interface-Framework'
 !
@@ -640,6 +641,13 @@
 
 !ApplicationModel class methodsFor:'queries'!
 
+defaultExtentFor:anApplicationClass
+    DefaultExtents notNil ifTrue:[
+        ^ DefaultExtents at:anApplicationClass name ifAbsent:nil
+    ].
+    ^ nil.
+!
+
 interfaceSpecFor:aSelector
     "return an interface spec"
     
@@ -693,6 +701,14 @@
 
     "Created: / 27-10-1997 / 16:38:02 / cg"
     "Modified: / 02-03-2012 / 15:57:02 / cg"
+!
+
+shouldRememberLastExtent
+    "to be redefined by concrete applications:
+     if true is answered, the application's extent is remembered on close
+     and used as a default when opened the next time"
+
+    ^ false
 ! !
 
 !ApplicationModel class methodsFor:'resources'!
@@ -3337,6 +3353,14 @@
     ^ (aKey isNil or:[masterApplication isNil or:[self respondsTo:aKey]])
 !
 
+shouldRememberLastExtent
+    "to be redefined by concrete applications:
+     if true is answered, the application's extent is remembered on close
+     and used as a default when opened the next time"
+
+    ^ self class shouldRememberLastExtent
+!
+
 topApplication
     "return the top-master application"
 
@@ -3374,6 +3398,8 @@
     self release.
     ActiveHelp stopFor:self.
 
+    window := self window.
+
     (wg := self windowGroup) notNil ifTrue:[
         wgProcess := wg process.
         (Processor activeProcess ~~ wgProcess
@@ -3381,12 +3407,20 @@
             wgProcess terminate
         ] ifFalse:[
             wg closeDownViews.
-        ]
+        ].
     ] ifFalse:[
-        (window := self window) notNil ifTrue:[
+        window notNil ifTrue:[
             window destroy.
         ]
     ].
+    self shouldRememberLastExtent ifTrue:[
+        (window notNil and:[window isTopView]) ifTrue:[
+            DefaultExtents isNil ifTrue:[
+                DefaultExtents := Dictionary new.
+            ].
+            DefaultExtents at:self class name put:(window extent).
+        ].
+    ].
 
     "Modified: / 28-02-2011 / 17:57:12 / cg"
 !
@@ -3968,11 +4002,11 @@
 !ApplicationModel class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/ApplicationModel.st,v 1.338 2013-06-06 23:15:23 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/ApplicationModel.st,v 1.339 2013-07-06 17:06:24 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libview2/ApplicationModel.st,v 1.338 2013-06-06 23:15:23 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/ApplicationModel.st,v 1.339 2013-07-06 17:06:24 cg Exp $'
 ! !