made a copy
[strongtalk-kjk.git] / StrongtalkSource / PreferenceModifier.dlt
blobbef575f48298a5e09d0f7f5d07112d4780261b45
1 Delta define: #PreferenceModifier as: (\r
2 (Class subclassOf: 'PreferenceCaching |> VisualWrapper' instanceVariables: 'prefsBlock <[PreferenceModifier]>\r
3                 "Is called whenever the preferences need to be computed.  The block takes the receiver\r
4                         as its argumetn, and should compute\r
5               the min,max, and natural, and use the #natural:min:max: message to store\r
6                   them in the receiver."\r
7 gridBlock <[PreferenceModifier,Point, ^Rectangle]>\r
8         ')) !\r
9 \r
10 (Delta mirrorFor: #PreferenceModifier) revision: '$Revision: 1.1 $'!\r
12 (Delta mirrorFor: #PreferenceModifier) group: 'ui'!\r
14 (Delta mirrorFor: #PreferenceModifier)\r
15 comment: \r
16 'Modifies the preferences of its child based on a block that computes the new \r
17 preferences.\r
19 Tags: %User %UI\r
21 (c) 1995-1997 Sun Microsystems, Inc. ALL RIGHTS RESERVED. \r
22 Use and distribution of this software is subject to the terms of the attached source license.   $Revision: 1.1 \r
23 '!\r
25 ! (Delta mirrorFor: #PreferenceModifier) methodsFor: 'accessing' !\r
28 continuousGridFor: p <Point> ^<Rect>\r
30         "This method is here to make the inherited method public"\r
31         ^super continuousGridFor: p!\r
33 gridBlock ^<[PreferenceModifier,Point, ^Rectangle]>\r
35         ^gridBlock!\r
37 gridBlock: b <[PreferenceModifier,Point, ^Rectangle]>\r
39         gridBlock := b!\r
41 natural: nat <Region> min: mn <Region> max: mx <Region>\r
43         self natural: nat; min: mn; max: mx!\r
45 newNatural: nat <Rect>\r
46         "This sets the prefsBlock to one that changes the natural size of the child only.  The min and max are left the\r
47                 same, other than making sure that min <= natural <= max."\r
49         self prefsBlock:\r
50                 [ :pm <PreferenceModifier> |\r
51                         self\r
52                                 natural: nat\r
53                                 min: (pm part min enclosingRect intersect: nat)\r
54                                 max: (pm part max enclosingRect merge: nat).\r
55                 ]!\r
57 prefsBlock ^<[PreferenceModifier]>\r
59         ^prefsBlock!\r
61 prefsBlock: blk <[PreferenceModifier]>\r
63         prefsBlock := blk! !\r
65 ! (Delta mirrorFor: #PreferenceModifier) methodsFor: 'private' !\r
68 computePreferences\r
70         self prefsBlock value: self!\r
72 skipCheckLayout ^<Boolean>\r
74         ^false! !\r
76 ! (Delta mirrorFor: #PreferenceModifier) methodsFor: 'initialization' !\r
79 initialize\r
81         super initialize.\r
82         self prefsBlock:\r
83                 [ :pm <PreferenceModifier> |\r
84                         pm      natural: pm part natural\r
85                                         min: pm part min\r
86                                         max: pm part max ].\r
87         self gridBlock:\r
88                 [ :pm <PreferenceModifier> :loc <Point> |\r
89                         pm part gridFor: loc ]! !\r