53 " |
53 " |
54 not yet finished, not yet published, not yet released. |
54 not yet finished, not yet published, not yet released. |
55 " |
55 " |
56 ! ! |
56 ! ! |
57 |
57 |
|
58 !UIPainterView class methodsFor:'defaults'! |
|
59 |
|
60 defaultMenuMessage |
|
61 "This message is the default yo be sent to the menuHolder to get a menu |
|
62 " |
|
63 ^ #menu |
|
64 |
|
65 |
|
66 ! ! |
|
67 |
58 !UIPainterView methodsFor:'accessing'! |
68 !UIPainterView methodsFor:'accessing'! |
59 |
|
60 className |
|
61 ^ className |
|
62 |
|
63 "Modified: 5.9.1995 / 18:41:30 / claus" |
|
64 ! |
|
65 |
|
66 className:aString |
|
67 className := aString |
|
68 |
|
69 "Modified: 5.9.1995 / 18:47:17 / claus" |
|
70 ! |
|
71 |
|
72 methodName |
|
73 ^ methodName |
|
74 |
|
75 "Modified: 5.9.1995 / 18:41:34 / claus" |
|
76 ! |
|
77 |
|
78 methodName:aString |
|
79 methodName := aString |
|
80 |
|
81 "Modified: 5.9.1995 / 18:47:27 / claus" |
|
82 ! ! |
|
83 |
|
84 !UIPainterView methodsFor:'builder interface'! |
|
85 |
69 |
86 application |
70 application |
87 self halt. |
71 self halt. |
88 ^ nil |
72 ^ nil |
89 |
73 |
90 "Modified: 6.9.1995 / 00:46:44 / claus" |
74 "Modified: 6.9.1995 / 00:46:44 / claus" |
91 ! |
75 ! |
92 |
76 |
93 aspectAt:aSymbol |
77 className |
94 self halt. |
78 ^ className |
95 ^ nil |
79 |
96 |
80 "Modified: 5.9.1995 / 18:41:30 / claus" |
97 "Modified: 6.9.1995 / 00:45:35 / claus" |
81 ! |
98 ! |
82 |
99 |
83 className:aString |
100 createdComponent:newView forSpec:aSpec |
84 className := aString |
101 "callBack from UISpec view building" |
85 |
102 |
86 "Modified: 5.9.1995 / 18:47:17 / claus" |
103 |props| |
87 ! |
104 |
88 |
105 props := self propertiesForNewView:newView. |
89 methodName |
106 |
90 ^ methodName |
107 aSpec name notNil ifTrue:[ |
91 |
108 (self propertyOfName:(aSpec name)) isNil ifTrue:[ |
92 "Modified: 5.9.1995 / 18:41:34 / claus" |
109 props name:aSpec name |
93 ! |
110 ] |
94 |
111 ]. |
95 methodName:aString |
112 |
96 methodName := aString |
113 props labelSelector:(aSpec labelSelector). |
97 |
114 props aspectSelector:(aSpec modelSelector). |
98 "Modified: 5.9.1995 / 18:47:27 / claus" |
115 |
99 ! |
116 viewProperties add:props. |
100 |
|
101 selectNames:aStringOrCollection |
|
102 |prop coll s| |
|
103 |
|
104 (aStringOrCollection isNil or:[aStringOrCollection isEmpty]) ifTrue:[ |
|
105 ^ self unselect |
|
106 ]. |
|
107 |
|
108 (s := aStringOrCollection) isString ifFalse:[ |
|
109 s size == 1 ifTrue:[ |
|
110 s := s first |
|
111 ] ifFalse:[ |
|
112 coll := OrderedCollection new. |
|
113 |
|
114 s do:[:aName| |
|
115 (prop := self propertyOfName:aName) notNil ifTrue:[ |
|
116 coll add:(prop view) |
|
117 ] |
|
118 ]. |
|
119 coll size == 1 ifTrue:[ ^ self select:(coll at:1) ]. |
|
120 coll size == 0 ifTrue:[ ^ self unselect ]. |
|
121 |
|
122 self hideSelection. |
|
123 selection := coll. |
|
124 self showSelection. |
|
125 ^ self changed:#selection |
|
126 ] |
|
127 ]. |
|
128 |
|
129 prop := self propertyOfName:s. |
|
130 prop isNil ifTrue:[^ self unselect] |
|
131 ifFalse:[^ self select:(prop view)] |
|
132 |
117 ! ! |
133 ! ! |
118 |
134 |
119 !UIPainterView methodsFor:'code manipulation'! |
135 !UIPainterView methodsFor:'code manipulation'! |
120 |
136 |
121 changeClass |
137 changeClass |
216 "set default properties for a created object |
232 "set default properties for a created object |
217 " |
233 " |
218 |props| |
234 |props| |
219 |
235 |
220 props := self addProperties:nil for:anObject. |
236 props := self addProperties:nil for:anObject. |
221 self undoCreate:(props identifier). |
237 |
222 ! ! |
238 undoHistory transaction:#create text:(props name) do:[ |
223 |
239 self undoCreate:(props identifier). |
224 !UIPainterView methodsFor:'cut & paste'! |
240 ]. |
225 |
|
226 convertForPaste:something |
|
227 ^ nil |
|
228 |
|
229 |
|
230 ! |
|
231 |
|
232 copySelection |
|
233 "copy the selection into the cut&paste-buffer |
|
234 " |
|
235 |tmp| |
|
236 |
|
237 tmp := OrderedCollection new. |
|
238 |
|
239 self selectionDo:[:aView||topSpec| |
|
240 topSpec := aView specClass |
|
241 fromView:aView |
|
242 callBack:[:spec :aSubView | |
|
243 aSubView geometryLayout:(aSubView geometryLayout copy) |
|
244 ]. |
|
245 tmp add:topSpec. |
|
246 ]. |
|
247 |
|
248 self setSelection:tmp |
|
249 |
|
250 ! |
|
251 |
|
252 deleteSelection |
|
253 "delete the selection |
|
254 " |
|
255 undoHistory transactionNamed:'delete' do:[ |
|
256 super deleteSelection |
|
257 ]. |
|
258 |
|
259 |
|
260 ! |
|
261 |
|
262 pasteBuffer |
|
263 "add the objects in the paste-buffer |
|
264 " |
|
265 |sel firstEntry builder| |
|
266 |
|
267 sel := self getSelection. |
|
268 self unselect. |
|
269 |
|
270 sel size == 0 ifTrue:[firstEntry := sel] |
|
271 ifFalse:[firstEntry := sel at:1]. |
|
272 |
|
273 (firstEntry isKindOf:UISpecification) ifFalse:[ |
|
274 ^ self |
|
275 ]. |
|
276 builder := UIBuilder new. |
|
277 selection := OrderedCollection new. |
|
278 |
|
279 sel do:[:aSpec| |
|
280 builder componentCreationHook:[:view :spec :aBuilder | |
|
281 self createdComponent:view forSpec:spec |
|
282 ]. |
|
283 builder applicationClass:(Smalltalk classNamed:className). |
|
284 selection add:(aSpec buildViewWithLayoutFor:builder in:self). |
|
285 ]. |
|
286 |
|
287 undoHistory transactionNamed:'paste' do:[ |
|
288 selection do:[:aView| |props| |
|
289 props := self propertyOfView:aView. |
|
290 self undoCreate:(props identifier) |
|
291 ] |
|
292 ]. |
|
293 |
|
294 selection size == 1 ifTrue:[ |
|
295 selection := selection at:1 |
|
296 ]. |
|
297 self showSelection. |
|
298 self realizeAllSubViews. |
|
299 inputView raise. |
|
300 self changed:#tree |
|
301 |
|
302 ! ! |
241 ! ! |
303 |
242 |
304 !UIPainterView methodsFor:'generating output'! |
243 !UIPainterView methodsFor:'generating output'! |
305 |
244 |
306 generateClassDefinition |
245 generateClassDefinition |
869 props isNil ifTrue:[^ nil]. |
805 props isNil ifTrue:[^ nil]. |
870 "/ ^ props changeSelector |
806 "/ ^ props changeSelector |
871 ^ nil |
807 ^ nil |
872 ! |
808 ! |
873 |
809 |
|
810 createdComponent:newView forSpec:aSpec |
|
811 "callBack from UISpec view building" |
|
812 |
|
813 |props| |
|
814 |
|
815 props := self propertiesForNewView:newView. |
|
816 |
|
817 aSpec name notNil ifTrue:[ |
|
818 (self propertyOfName:(aSpec name)) isNil ifTrue:[ |
|
819 props name:aSpec name |
|
820 ] |
|
821 ]. |
|
822 |
|
823 props labelSelector:(aSpec labelSelector). |
|
824 props aspectSelector:(aSpec modelSelector). |
|
825 |
|
826 viewProperties add:props. |
|
827 ! |
|
828 |
874 generatePropertiesFor:aCollectionOfViews |
829 generatePropertiesFor:aCollectionOfViews |
875 |
830 |
876 "/ done as two loops, to get bread-first naming |
831 "/ done as two loops, to get bread-first naming |
877 |
832 |
878 aCollectionOfViews do:[:aView| |
833 aCollectionOfViews do:[:aView| |
910 setAspectSelector:aspectSymbol forView:aView |
865 setAspectSelector:aspectSymbol forView:aView |
911 |props| |
866 |props| |
912 |
867 |
913 props := self propertyOfView:aView. |
868 props := self propertyOfView:aView. |
914 |
869 |
915 undoHistory transactionNamed:'aspect' do:[ |
870 props notNil ifTrue:[ |
916 self selectionDo:[:aView| |
871 self transaction:#aspect selectionDo:[:aView| |
917 undoHistory isTransactionOpen ifTrue:[ |
872 |oldAspect| |
918 |oldAspect| |
873 |
919 |
874 oldAspect := props aspectSelector. |
920 oldAspect := props aspectSelector. |
875 |
921 undoHistory addUndoBlock:[ |
876 undoHistory addUndoBlock:[ |
922 props aspectSelector:oldAspect. |
877 props aspectSelector:oldAspect. |
923 self elementChanged:aView. |
878 aView superView sizeChanged:nil |
924 ] |
879 ] |
925 ]. |
|
926 ]. |
880 ]. |
927 ]. |
881 props aspectSelector:aspectSymbol |
928 |
882 ] |
929 props aspectSelector:aspectSymbol |
|
930 |
|
931 ! |
883 ! |
932 |
884 |
933 setChangeSelector:changeSymbol forView:aView |
885 setChangeSelector:changeSymbol forView:aView |
934 |props| |
886 |props| |
935 |
887 |
936 props := self propertyOfView:aView. |
888 props := self propertyOfView:aView. |
937 props changeSelector:changeSymbol |
889 props notNil ifTrue:[ |
938 |
890 props changeSelector:changeSymbol |
|
891 ] |
939 ! |
892 ! |
940 |
893 |
941 setupFromSpec:specOrSpecArray |
894 setupFromSpec:specOrSpecArray |
942 self removeAll. |
895 self removeAll. |
943 self addSpec:specOrSpecArray |
896 self addSpec:specOrSpecArray |
958 fontPanel action:action. |
911 fontPanel action:action. |
959 fontPanel showAtPointer |
912 fontPanel showAtPointer |
960 ] |
913 ] |
961 ! ! |
914 ! ! |
962 |
915 |
|
916 !UIPainterView methodsFor:'menu & submenus'! |
|
917 |
|
918 menu |
|
919 testMode ifFalse:[ |
|
920 selection notNil ifTrue:[^ self menuSelection ] |
|
921 ifFalse:[^ self menuPainter ] |
|
922 ]. |
|
923 ^ nil |
|
924 ! |
|
925 |
|
926 menuPainter |
|
927 "menu in case of non empty selection; for views |
|
928 " |
|
929 |menu gridMenu| |
|
930 |
|
931 menu := PopUpMenu labels:( |
|
932 resources array:#( |
|
933 'paste' |
|
934 '-' |
|
935 'undo' |
|
936 'grid' |
|
937 ) |
|
938 ) |
|
939 selectors:#( |
|
940 #pasteBuffer |
|
941 nil |
|
942 #undo |
|
943 #grid |
|
944 ) |
|
945 receiver:self. |
|
946 |
|
947 |
|
948 undoHistory isEmpty ifTrue:[ |
|
949 menu disable:#undo |
|
950 ] ifFalse:[ |
|
951 menu subMenuAt:#undo put:(undoHistory popupMenu) |
|
952 ]. |
|
953 |
|
954 gridMenu := PopUpMenu labels:( |
|
955 resources array:#( |
|
956 '\c show' |
|
957 '\c align' |
|
958 ) |
|
959 ) |
|
960 selectors:#( |
|
961 #gridShown: |
|
962 #gridAlign: |
|
963 ). |
|
964 |
|
965 gridMenu checkToggleAt:#gridShown: put:(self gridShown). |
|
966 gridMenu checkToggleAt:#gridAlign: put:aligning. |
|
967 menu subMenuAt:#grid put:gridMenu. |
|
968 |
|
969 ^ menu |
|
970 |
|
971 |
|
972 ! |
|
973 |
|
974 menuSelection |
|
975 "menu in case of non empty selection; for views |
|
976 " |
|
977 |menu arrangeMenu subMenuAlign| |
|
978 |
|
979 menu := PopUpMenu labels:( resources array:#( |
|
980 'copy' |
|
981 'cut' |
|
982 'paste' |
|
983 '-' |
|
984 'arrange' |
|
985 'dimension' |
|
986 ) |
|
987 ) |
|
988 selectors:#( #copySelection |
|
989 #deleteSelection |
|
990 #pasteBuffer |
|
991 nil |
|
992 #arrange |
|
993 #dimension |
|
994 ) |
|
995 receiver:self. |
|
996 |
|
997 (self supportsSubComponents:selection) ifFalse:[ |
|
998 menu disable:#pasteBuffer |
|
999 ]. |
|
1000 |
|
1001 arrangeMenu := PopUpMenu labels:#( 'to front' 'to back' ) |
|
1002 selectors:#( #raiseSelection #lowerSelection ) |
|
1003 receiver:self. |
|
1004 |
|
1005 |
|
1006 menu subMenuAt:#arrange put:arrangeMenu. |
|
1007 menu subMenuAt:#dimension put:(self subMenuDimension). |
|
1008 |
|
1009 selection size > 1 ifTrue:[ |
|
1010 menu addLabels:( resources array:#('align') ) |
|
1011 selectors:#( align ). |
|
1012 |
|
1013 menu subMenuAt:#align put:self subMenuAlign |
|
1014 ]. |
|
1015 ^ menu |
|
1016 ! |
|
1017 |
|
1018 subMenuAlign |
|
1019 "returns submenu alignment |
|
1020 " |
|
1021 |menu| |
|
1022 |
|
1023 menu := PopUpMenu labels:( |
|
1024 resources array:#( |
|
1025 'align left' |
|
1026 'align right' |
|
1027 'align left & right' |
|
1028 'align top' |
|
1029 'align bottom' |
|
1030 'align centered vertical' |
|
1031 'align centered horizontal' |
|
1032 '-' |
|
1033 'spread horizontal' |
|
1034 'spread vertical' |
|
1035 'center horizontal in frame' |
|
1036 'center vertical in frame' |
|
1037 ) |
|
1038 ) |
|
1039 |
|
1040 selectors:#( |
|
1041 alignSelectionLeft |
|
1042 alignSelectionRight |
|
1043 alignSelectionLeftAndRight |
|
1044 alignSelectionTop |
|
1045 alignSelectionBottom |
|
1046 alignSelectionCenterHor |
|
1047 alignSelectionCenterVer |
|
1048 nil |
|
1049 spreadSelectionHor |
|
1050 spreadSelectionVer |
|
1051 centerSelectionHor |
|
1052 centerSelectionVer |
|
1053 ) |
|
1054 receiver:self. |
|
1055 ^ menu |
|
1056 |
|
1057 ! |
|
1058 |
|
1059 subMenuDimension |
|
1060 "returns submenu dimension |
|
1061 " |
|
1062 |menu| |
|
1063 |
|
1064 menu := PopUpMenu labels:( |
|
1065 resources array:#( |
|
1066 'default extent' |
|
1067 'default width' |
|
1068 'default height' |
|
1069 '-' |
|
1070 'copy extent' |
|
1071 '-' |
|
1072 'paste extent' |
|
1073 'paste width' |
|
1074 'paste height' |
|
1075 ) |
|
1076 ) |
|
1077 selectors:#( |
|
1078 setToDefaultExtent |
|
1079 setToDefaultWidth |
|
1080 setToDefaultHeight |
|
1081 nil |
|
1082 copyExtent |
|
1083 nil |
|
1084 pasteExtent |
|
1085 pasteWidth |
|
1086 pasteHeight |
|
1087 ) |
|
1088 receiver:self. |
|
1089 ^ menu |
|
1090 ! ! |
|
1091 |
|
1092 !UIPainterView methodsFor:'menu actions'! |
|
1093 |
|
1094 copySelection |
|
1095 "copy the selection into the cut&paste-buffer |
|
1096 " |
|
1097 |specs| |
|
1098 |
|
1099 specs := self generateSpecFor:selection. |
|
1100 |
|
1101 specs notNil ifTrue:[ |
|
1102 self setSelection:specs |
|
1103 ]. |
|
1104 self unselect. |
|
1105 ! |
|
1106 |
|
1107 deleteSelection |
|
1108 "delete the selection |
|
1109 " |
|
1110 |specs text| |
|
1111 |
|
1112 selection notNil ifTrue:[ |
|
1113 specs := self generateSpecFor:selection. |
|
1114 text := self transactionTextFor:selection. |
|
1115 |
|
1116 undoHistory transaction:#cut text:text do:[ |
|
1117 super deleteSelection |
|
1118 ]. |
|
1119 self setSelection:specs |
|
1120 ] |
|
1121 ! |
|
1122 |
|
1123 gridAlign:aBool |
|
1124 aBool ifTrue:[self alignOn] |
|
1125 ifFalse:[self alignOff] |
|
1126 ! |
|
1127 |
|
1128 gridShown:aBool |
|
1129 aBool ifTrue:[self showGrid] |
|
1130 ifFalse:[self hideGrid] |
|
1131 |
|
1132 ! |
|
1133 |
|
1134 lowerSelection |
|
1135 |
|
1136 self selectionDo:[:aView| aView lower ]. |
|
1137 ! |
|
1138 |
|
1139 pasteBuffer |
|
1140 "add the objects in the paste-buffer |
|
1141 " |
|
1142 |sel firstEntry builder frame| |
|
1143 |
|
1144 sel := self getSelection. |
|
1145 frame := self. |
|
1146 |
|
1147 selection notNil ifTrue:[ |
|
1148 (self supportsSubComponents:selection) ifTrue:[ |
|
1149 frame := selection |
|
1150 ]. |
|
1151 self unselect |
|
1152 ]. |
|
1153 |
|
1154 sel size == 0 ifTrue:[firstEntry := sel] |
|
1155 ifFalse:[firstEntry := sel at:1]. |
|
1156 |
|
1157 (firstEntry isKindOf:UISpecification) ifFalse:[ |
|
1158 ^ self |
|
1159 ]. |
|
1160 builder := UIBuilder new. |
|
1161 selection := OrderedCollection new. |
|
1162 |
|
1163 sel do:[:aSpec||v| |
|
1164 builder componentCreationHook:[:view :spec :aBuilder | |
|
1165 self createdComponent:view forSpec:spec |
|
1166 ]. |
|
1167 builder applicationClass:(Smalltalk classNamed:className). |
|
1168 v := aSpec buildViewWithLayoutFor:builder in:frame. |
|
1169 v realize. |
|
1170 selection add:v. |
|
1171 ]. |
|
1172 |
|
1173 self transaction:#paste selectionDo:[:v| |
|
1174 self undoCreate:((self propertyOfView:v) identifier) |
|
1175 ]. |
|
1176 selection size == 1 ifTrue:[ |
|
1177 selection := selection at:1 |
|
1178 ]. |
|
1179 self showSelection. |
|
1180 self realizeAllSubViews. |
|
1181 inputView raise. |
|
1182 self changed:#tree |
|
1183 |
|
1184 ! |
|
1185 |
|
1186 raiseSelection |
|
1187 |
|
1188 self selectionDo:[:aView| |
|
1189 aView raise. |
|
1190 inputView raise. |
|
1191 ]. |
|
1192 |
|
1193 ! ! |
|
1194 |
963 !UIPainterView methodsFor:'misc'! |
1195 !UIPainterView methodsFor:'misc'! |
964 |
1196 |
965 changeFontFamily:family face:face style:style size:size |
1197 changeFontFamily:family face:face style:style size:size |
966 |f| |
1198 |f| |
967 |
1199 |
1038 prop := self propertyOf:aView |
1270 prop := self propertyOf:aView |
1039 ]. |
1271 ]. |
1040 |
1272 |
1041 prop notNil ifTrue:[^ prop name] |
1273 prop notNil ifTrue:[^ prop name] |
1042 ifFalse:[^ 'self'] |
1274 ifFalse:[^ 'self'] |
1043 |
|
1044 ! ! |
|
1045 |
|
1046 !UIPainterView methodsFor:'private undo-actions'! |
|
1047 |
|
1048 undoCreate:aViewIdentifier |
|
1049 |
|
1050 undoHistory isTransactionOpen ifTrue:[ |
|
1051 undoHistory addUndoBlock:[ |
|
1052 |props| |
|
1053 |
|
1054 props := self propertyOfIdentifier:aViewIdentifier. |
|
1055 |
|
1056 props notNil ifTrue:[ |
|
1057 self removeObject:(props view) |
|
1058 ] |
|
1059 ] |
|
1060 ] |
|
1061 ! |
|
1062 |
|
1063 undoRemove:propertyOfView |
|
1064 |clsName layout parent aView| |
|
1065 |
|
1066 undoHistory isTransactionOpen ifFalse:[ |
|
1067 ^ self |
|
1068 ]. |
|
1069 |
|
1070 aView := propertyOfView view. |
|
1071 clsName := aView class. |
|
1072 layout := aView geometryLayout. |
|
1073 parent := aView superView. |
|
1074 |
|
1075 parent ~~ self ifTrue:[ |
|
1076 parent := (self propertyOf:parent) identifier. |
|
1077 ] ifFalse:[ |
|
1078 parent := nil |
|
1079 ]. |
|
1080 propertyOfView view:nil. |
|
1081 |
|
1082 undoHistory addUndoBlock:[ |
|
1083 |recreatedView props| |
|
1084 |
|
1085 parent notNil ifTrue:[ |
|
1086 props := self propertyOfIdentifier:parent. |
|
1087 |
|
1088 props notNil ifTrue:[parent := props view] |
|
1089 ifFalse:[parent := self] |
|
1090 ] ifFalse:[ |
|
1091 parent := self |
|
1092 ]. |
|
1093 |
|
1094 recreatedView := clsName in:parent. |
|
1095 recreatedView geometryLayout:layout. |
|
1096 propertyOfView view:recreatedView. |
|
1097 self addProperties:propertyOfView for:recreatedView. |
|
1098 recreatedView realize. |
|
1099 inputView raise. |
|
1100 self changed:#tree. |
|
1101 ]. |
|
1102 aView := nil. |
|
1103 |
1275 |
1104 ! ! |
1276 ! ! |
1105 |
1277 |
1106 !UIPainterView methodsFor:'removing components'! |
1278 !UIPainterView methodsFor:'removing components'! |
1107 |
1279 |
1153 anObject subViews copy do:[:sub | |
1325 anObject subViews copy do:[:sub | |
1154 self removeTreeFrom:sub |
1326 self removeTreeFrom:sub |
1155 ] |
1327 ] |
1156 ]. |
1328 ]. |
1157 props := self propertyOf:anObject. |
1329 props := self propertyOf:anObject. |
1158 self undoRemove:props. |
1330 |
1159 viewProperties remove:props. |
1331 props notNil ifTrue:[ |
|
1332 self undoRemove:props. |
|
1333 viewProperties remove:props |
|
1334 ]. |
1160 anObject destroy |
1335 anObject destroy |
1161 ] |
1336 ] |
1162 ! ! |
1337 ! ! |
1163 |
1338 |
1164 !UIPainterView methodsFor:'selections'! |
1339 !UIPainterView methodsFor:'searching'! |
1165 |
1340 |
1166 addNameToSelection:aString |
1341 findObjectAt:aPoint |
1167 |prop| |
1342 "find the origin/corner of the currentWidget |
1168 |
1343 " |
1169 prop := self propertyOfName:aString. |
1344 |view| |
1170 |
1345 |
1171 prop notNil ifTrue:[ |
1346 view := super findObjectAt:aPoint. |
1172 self addToSelection:(prop view) |
1347 |
1173 ] |
1348 view notNil ifTrue:[ |
1174 |
1349 "can be a view within a view not visible |
1175 ! |
1350 " |
1176 |
1351 [ (self propertyOfView:view) isNil ] whileTrue:[ |
1177 removeNameFromSelection:aString |
1352 (view := view superView) == self ifTrue:[^ nil] |
1178 |prop| |
1353 ] |
1179 |
1354 ]. |
1180 prop := self propertyOfName:aString. |
1355 ^ view |
1181 |
|
1182 prop notNil ifTrue:[ |
|
1183 self removeFromSelection:(prop view) |
|
1184 ] |
|
1185 |
|
1186 ! |
|
1187 |
|
1188 selectName:aStringOrCollection |
|
1189 |prop coll s| |
|
1190 |
|
1191 (aStringOrCollection isNil or:[aStringOrCollection isEmpty]) ifTrue:[ |
|
1192 ^ self unselect |
|
1193 ]. |
|
1194 |
|
1195 (s := aStringOrCollection) isString ifFalse:[ |
|
1196 s size == 1 ifTrue:[ |
|
1197 s := s first |
|
1198 ] ifFalse:[ |
|
1199 coll := OrderedCollection new. |
|
1200 |
|
1201 s do:[:aName| |
|
1202 (prop := self propertyOfName:aName) notNil ifTrue:[ |
|
1203 coll add:(prop view) |
|
1204 ] |
|
1205 ]. |
|
1206 coll size == 1 ifTrue:[ ^ self select:(coll at:1) ]. |
|
1207 coll size == 0 ifTrue:[ ^ self unselect ]. |
|
1208 |
|
1209 self hideSelection. |
|
1210 selection := coll. |
|
1211 self showSelection. |
|
1212 ^ self changed:#selection |
|
1213 ] |
|
1214 ]. |
|
1215 |
|
1216 prop := self propertyOfName:s. |
|
1217 prop isNil ifTrue:[^ self unselect] |
|
1218 ifFalse:[^ self select:(prop view)] |
|
1219 |
|
1220 ! ! |
1356 ! ! |
1221 |
1357 |
1222 !UIPainterView methodsFor:'seraching property'! |
1358 !UIPainterView methodsFor:'seraching property'! |
1223 |
1359 |
1224 propertyOf:something |
1360 propertyOf:something |
1290 (aComponent isKindOf:Slider) ifTrue:[ |
1432 (aComponent isKindOf:Slider) ifTrue:[ |
1291 ^ aComponent orientation == #vertical |
1433 ^ aComponent orientation == #vertical |
1292 ]. |
1434 ]. |
1293 ^ true |
1435 ^ true |
1294 |
1436 |
|
1437 |
|
1438 ! ! |
|
1439 |
|
1440 !UIPainterView methodsFor:'transaction & undo'! |
|
1441 |
|
1442 transaction:aType objects:something do:aOneArgBlock |
|
1443 "opens a transaction and evaluates a block within the transaction; the |
|
1444 argument to the block is a view from derived from something |
|
1445 " |
|
1446 |text| |
|
1447 |
|
1448 something notNil ifTrue:[ |
|
1449 text := self transactionTextFor:something. |
|
1450 |
|
1451 undoHistory transaction:aType text:text do:[ |
|
1452 something isCollection ifTrue:[ |
|
1453 something do:[:aView| aOneArgBlock value:aView ] |
|
1454 ] ifFalse:[ |
|
1455 aOneArgBlock value:something |
|
1456 ] |
|
1457 ] |
|
1458 ] |
|
1459 ! |
|
1460 |
|
1461 transactionTextFor:anElementOrCollection |
|
1462 "returns text used by transaction or nil |
|
1463 " |
|
1464 |props| |
|
1465 |
|
1466 anElementOrCollection notNil ifTrue:[ |
|
1467 anElementOrCollection size > 1 ifTrue:[ |
|
1468 ^ 'a collection' |
|
1469 ]. |
|
1470 |
|
1471 anElementOrCollection isCollection ifFalse:[ |
|
1472 props := self propertyOfView:anElementOrCollection |
|
1473 ] ifTrue:[ |
|
1474 anElementOrCollection notEmpty ifTrue:[ |
|
1475 props := self propertyOfView:(anElementOrCollection at:1) |
|
1476 ] |
|
1477 ]. |
|
1478 |
|
1479 props notNil ifTrue:[ |
|
1480 ^ props name |
|
1481 ] |
|
1482 ]. |
|
1483 ^ nil |
|
1484 ! |
|
1485 |
|
1486 undoCreate:aViewIdentifier |
|
1487 |
|
1488 undoHistory isTransactionOpen ifTrue:[ |
|
1489 undoHistory addUndoBlock:[ |
|
1490 |props| |
|
1491 |
|
1492 props := self propertyOfIdentifier:aViewIdentifier. |
|
1493 |
|
1494 props notNil ifTrue:[ |
|
1495 self removeObject:(props view) |
|
1496 ] |
|
1497 ] |
|
1498 ] |
|
1499 ! |
|
1500 |
|
1501 undoRemove:propertyOfView |
|
1502 |clsName layout parent aView| |
|
1503 |
|
1504 (propertyOfView notNil and:[undoHistory isTransactionOpen]) ifFalse:[ |
|
1505 ^ self |
|
1506 ]. |
|
1507 |
|
1508 aView := propertyOfView view. |
|
1509 clsName := aView class. |
|
1510 layout := aView geometryLayout. |
|
1511 parent := aView superView. |
|
1512 |
|
1513 parent ~~ self ifTrue:[ |
|
1514 parent := (self propertyOf:parent) identifier. |
|
1515 ] ifFalse:[ |
|
1516 parent := nil |
|
1517 ]. |
|
1518 propertyOfView view:nil. |
|
1519 |
|
1520 undoHistory addUndoBlock:[ |
|
1521 |recreatedView props| |
|
1522 |
|
1523 parent notNil ifTrue:[ |
|
1524 props := self propertyOfIdentifier:parent. |
|
1525 |
|
1526 props notNil ifTrue:[parent := props view] |
|
1527 ifFalse:[parent := self] |
|
1528 ] ifFalse:[ |
|
1529 parent := self |
|
1530 ]. |
|
1531 |
|
1532 recreatedView := clsName in:parent. |
|
1533 recreatedView geometryLayout:layout. |
|
1534 propertyOfView view:recreatedView. |
|
1535 self addProperties:propertyOfView for:recreatedView. |
|
1536 recreatedView realize. |
|
1537 inputView raise. |
|
1538 ]. |
|
1539 aView := nil. |
1295 |
1540 |
1296 ! ! |
1541 ! ! |
1297 |
1542 |
1298 !UIPainterView::ViewProperty class methodsFor:'instance creation'! |
1543 !UIPainterView::ViewProperty class methodsFor:'instance creation'! |
1299 |
1544 |