--- a/UIPainter.st Thu Sep 05 00:10:44 2013 +0200
+++ b/UIPainter.st Thu Sep 05 15:39:42 2013 +0200
@@ -339,9 +339,6 @@
#generateHookMethods
'Generates startup/release methods. (#closeRequest, #postBuildWith:, #postOpenWith:)'
-"/ #group
-"/ ''
-
#helpExamples
'Show some examples uses of the GUI Painter'
@@ -456,6 +453,9 @@
#useDefaultColorToggle
'Toggle between default and explicit color'
+#wrapInto
+''
+
)
! !
@@ -2217,6 +2217,13 @@
itemValue: doAskAndReplaceWidgetBy
)
(MenuItem
+ activeHelpKey: wrapInto
+ enabled: canWrapeSelection
+ label: 'Wrap Into...'
+ itemValue: doAskAndWrapWidgetInto
+ isVisible: false
+ )
+ (MenuItem
label: '-'
)
(MenuItem
@@ -3011,6 +3018,11 @@
^ builder booleanValueAspectFor:#canResizeSelection
!
+canWrapSelection
+ treeView isCanvasSelected ifTrue:[^ false].
+ ^ true
+!
+
editToolBarVisibleHolder
|holder|
@@ -4925,6 +4937,10 @@
!
doAskAndReplaceWidgetBy
+ "ask for a widget class,
+ and replace the selected widget by a new instance of that one,
+ which gets the old widget's layout"
+
|widgetClass list common selectedSpec|
selectedSpec := self selectedSpec.
@@ -4943,7 +4959,7 @@
list addAllFirst:(common , (Array with:'-')).
].
widgetClass := Dialog
- requestClass:'Spec- or View-Class:'
+ requestClass:'Replace by (Spec or View Class):'
list:list
okLabel:'OK'
initialAnswer:nil.
@@ -4955,6 +4971,38 @@
"Modified: / 05-09-2012 / 19:31:22 / cg"
!
+doAskAndWrapWidgetInto
+ "ask for a container class,
+ and put the selected widget into a new instance of that one,
+ which gets the wrapped widget's layout"
+
+ |widgetClass list selectedSpec|
+
+Dialog information:'sorry - unfinished.'.
+^ self.
+ selectedSpec := self selectedSpec.
+ selectedSpec isNil ifTrue:[^ self].
+
+ list := UISpecification allSubclasses
+ select:[:cls |
+ [ cls viewClass notNil
+ and:[ cls supportsSubComponents ]]
+ on: NotFoundError
+ do:[ false ]
+ ].
+ list sort:[:a :b | a name < b name].
+
+ widgetClass := Dialog
+ requestClass:'Wrap into (Spec or View Class):'
+ list:list
+ okLabel:'OK'
+ initialAnswer:nil.
+ widgetClass isNil ifTrue:[
+ ^ self
+ ].
+ self wrapWidgetIntoClass:widgetClass
+!
+
doBrowseActionMethod:aspectSelector
"browse or create the action method as entered in the field (button beside input filed pressed)"
@@ -5848,8 +5896,29 @@
!
replaceWidgetByClass:aSpecOrWidgetClass
+ "replace the selected widget by a new instance of aSpecOrWidgetClass,
+ which gets the old widget's layout"
+
|newSpecClass oldSpec newSpec|
+ treeView isCanvasSelected ifTrue:[
+ ^ self
+ ].
+ (newSpecClass := self specClassFromUsersSpecOrWidgetClass:aSpecOrWidgetClass) isNil ifTrue:[
+ ^ newSpecClass
+ ].
+
+ oldSpec := self selectedSpec.
+ newSpec := newSpecClass cloneFrom:oldSpec.
+
+ self painter replaceSelectionBy:newSpec.
+
+ "Modified: / 05-09-2012 / 19:24:40 / cg"
+!
+
+specClassFromUsersSpecOrWidgetClass:aSpecOrWidgetClass
+ |newSpecClass|
+
(aSpecOrWidgetClass isSubclassOf:UISpecification) ifTrue:[
newSpecClass := aSpecOrWidgetClass.
] ifFalse:[
@@ -5861,18 +5930,9 @@
].
newSpecClass isNil ifTrue:[
Dialog warn:'Invalid Spec- or View-Class: ' , aSpecOrWidgetClass name.
- ^ self.
- ].
-
- treeView isCanvasSelected ifTrue:[
- ^ self
- ].
- oldSpec := self selectedSpec.
- newSpec := newSpecClass cloneFrom:oldSpec.
-
- self painter replaceSelectionBy:newSpec.
-
- "Modified: / 05-09-2012 / 19:24:40 / cg"
+ ^ nil.
+ ].
+ ^ newSpecClass
!
useBackgroundImage
@@ -5902,6 +5962,27 @@
painter useSketchFile:fn
"Created: / 16-01-2008 / 17:49:20 / cg"
+!
+
+wrapWidgetIntoClass:aSpecOrWidgetClass
+ "put the selected widget into a new instance of aSpecOrWidgetClass,
+ which gets the wrapped widget's layout"
+
+ |newSpecClass oldSpec newSpec|
+
+ treeView isCanvasSelected ifTrue:[
+ ^ self
+ ].
+ (newSpecClass := self specClassFromUsersSpecOrWidgetClass:aSpecOrWidgetClass) isNil ifTrue:[
+ ^ newSpecClass
+ ].
+
+ oldSpec := self selectedSpec.
+ newSpec := newSpecClass cloneFrom:oldSpec.
+
+ self painter wrapSelectionInto:newSpec.
+
+ "Modified: / 05-09-2012 / 19:24:40 / cg"
! !
!UIPainter::TreeView class methodsFor:'documentation'!