--- a/UIPainter.st Fri Aug 05 18:37:40 2005 +0200
+++ b/UIPainter.st Tue Sep 20 12:57:11 2005 +0200
@@ -1714,16 +1714,6 @@
translateLabel: true
)
(MenuItem
- activeHelpKey: editDelete
- enabled: valueOfCanCut
- label: 'Delete'
- itemValue: deleteTotalSelection
- translateLabel: true
- )
- (MenuItem
- label: '-'
- )
- (MenuItem
activeHelpKey: pasteWithLayout
enabled: valueOfCanPasteWithKeepingLayout
label: 'Paste with Layout'
@@ -1738,6 +1728,20 @@
translateLabel: true
)
(MenuItem
+ activeHelpKey: editDelete
+ enabled: valueOfCanCut
+ label: 'Delete'
+ itemValue: deleteTotalSelection
+ translateLabel: true
+ )
+ (MenuItem
+ label: 'Replace'
+ translateLabel: true
+ submenuChannel: menuReplaceWidget
+ keepLinkedMenu: true
+ enabled: canReplaceSelection
+ )
+ (MenuItem
label: '-'
)
(MenuItem
@@ -1977,6 +1981,36 @@
)
!
+menuReplaceWidget
+ "This resource specification was automatically generated
+ by the MenuEditor of ST/X."
+
+ "Do not manually edit this!! If it is corrupted,
+ the MenuEditor may not be able to read the specification."
+
+ "
+ MenuEditor new openOnClass:UIPainter andSelector:#menuReplaceWidget
+ (Menu new fromLiteralArrayEncoding:(UIPainter menuReplaceWidget)) startUp
+ "
+
+ <resource: #menu>
+
+ ^
+ #(Menu
+ (
+ (MenuItem
+ activeHelpKey: moveWidgetUp
+ enabled: canChangeOrderInContainer
+ label: 'Replace By...'
+ itemValue: doAskAndReplaceWidgetBy
+ translateLabel: true
+ )
+ )
+ nil
+ nil
+ )
+!
+
menuToolbar
"This resource specification was automatically generated
by the MenuEditor of ST/X."
@@ -2324,6 +2358,11 @@
^ builder booleanValueAspectFor:#canMoveSelectionOutOfContainer
!
+canReplaceSelection
+ treeView isCanvasSelected ifTrue:[^ false].
+ ^ true
+!
+
enableChannel
"true if modifications are allowed otherwise running test"
@@ -2799,14 +2838,14 @@
!UIPainter methodsFor:'event handling'!
doesNotUnderstand:aMessage
- "if does not understand incoming messages, detour them to painter"
+ "forward misunderstood messages to the painter"
|painter|
painter := self painter.
(painter respondsTo:(aMessage selector)) ifTrue:[
- ^ aMessage sendTo:painter
+ ^ aMessage sendTo:painter
].
super doesNotUnderstand:aMessage
@@ -2861,6 +2900,34 @@
m findGuiResourcesIn:self.
m
].
+!
+
+menuReplaceWidget
+ ^ [
+ |m i specAndView spec usefulReplacementSpecClasses|
+
+ m := self class menuReplaceWidget.
+ m := m decodeAsLiteralArray.
+
+ specAndView := self selectedSpecAndView.
+ spec := specAndView first.
+
+ usefulReplacementSpecClasses := spec usefulReplacementSpecClasses.
+ usefulReplacementSpecClasses notEmptyOrNil ifTrue:[
+ m addSeparator.
+ usefulReplacementSpecClasses do:[:eachClass |
+ |item|
+
+ item := MenuItem new label:(resources string:'Replace by %1' with:eachClass userFriendlyName).
+ item value:#replaceWidgetByClass:.
+ item argument:eachClass.
+ m addItem:item.
+ ].
+ ].
+
+ m findGuiResourcesIn:self.
+ m
+ ].
! !
!UIPainter methodsFor:'private'!
@@ -3198,6 +3265,30 @@
self updateChannels.
!
+selectedSpec
+ |specAndView|
+
+ specAndView := self selectedSpecAndView.
+ ^ specAndView first
+!
+
+selectedSpecAndView
+ |spec view property|
+
+ treeView isCanvasSelected ifTrue:[
+ spec := treeView canvasSpec.
+ view := self painter topView.
+ ] ifFalse:[
+ (property := treeView propertySelected) notNil ifTrue:[
+ treeView canResizeSelectedWidget ifTrue:[
+ view := property view.
+ ].
+ spec := property spec copy.
+ ]
+ ].
+ ^ Array with:spec with:view
+!
+
selectionChangeAllowed:newSelection
self isModified ifFalse:[^ true].
@@ -3236,7 +3327,7 @@
treeSelectionChanged
"called whenever the selection of the treeview has changed"
- |view spec property|
+ |specAndView view spec|
self askForUnsavedModifications ifFalse:[^ self].
"/ self isModified ifTrue:[
@@ -3245,17 +3336,9 @@
"/ ]
"/ ].
- treeView isCanvasSelected ifTrue:[
- spec := treeView canvasSpec.
- view := self painter topView.
- ] ifFalse:[
- (property := treeView propertySelected) notNil ifTrue:[
- treeView canResizeSelectedWidget ifTrue:[
- view := property view.
- ].
- spec := property spec copy.
- ]
- ].
+ specAndView := self selectedSpecAndView.
+ spec := specAndView first.
+ view := specAndView last.
self setViewInLayoutTool:view spec:spec.
self specTool specification:spec.
@@ -3720,6 +3803,16 @@
]
!
+doAskAndReplaceWidgetBy
+ |widgetClass|
+
+ widgetClass := Dialog requestClass:'Spec- or View-Class:' okLabel:'OK' initialAnswer:nil.
+ widgetClass isNil ifTrue:[
+ ^ self
+ ].
+ self replaceWidgetByClass:widgetClass
+!
+
doBrowseAspectMethods
"opens a browser on the aspect methods"
@@ -4066,9 +4159,9 @@
|spec document|
(spec := self specForSelection) isNil ifTrue:[
- treeView isCanvasSelected ifTrue:[
- spec := nil
- ]
+"/ treeView isCanvasSelected ifTrue:[
+"/ spec := nil
+"/ ]
].
spec notNil ifTrue:[
document := 'tools/uipainter/', spec documentFileName,'.html'
@@ -4076,8 +4169,6 @@
document := 'tools/uipainter/WindowSpec.html'
].
HTMLDocumentView openFullOnDocumentationFile: document
-
-
!
doPickAView
@@ -4238,6 +4329,34 @@
openWith: self painter generateWindowSpecMethodSource
title: 'Window Spec'
+!
+
+replaceWidgetByClass:aSpecOrWidgetClass
+ |specClass oldSpec newSpec sel painter|
+
+ (aSpecOrWidgetClass isSubclassOf:UISpecification) ifTrue:[
+ specClass := aSpecOrWidgetClass.
+ ] ifFalse:[
+ (aSpecOrWidgetClass isSubclassOf:View) ifTrue:[
+ specClass := aSpecOrWidgetClass basicNew specClass.
+ ] ifFalse:[
+ ].
+ ].
+ specClass isNil ifTrue:[
+ Dialog warn:'Invalid Spec- or View-Class: ' , aSpecOrWidgetClass name.
+ ^ self.
+ ].
+
+ treeView isCanvasSelected ifTrue:[
+ ^ self
+ ].
+ oldSpec := self selectedSpec.
+ newSpec := specClass cloneFrom:oldSpec.
+
+ painter := self painter.
+ painter deleteSelectionBuffered:false.
+ sel := painter pasteSpecifications:(Array with:newSpec) keepLayout:false.
+ painter select:sel.
! !
!UIPainter::TreeView class methodsFor:'documentation'!