--- a/UIPainter.st Tue Feb 26 18:38:41 2008 +0100
+++ b/UIPainter.st Tue Feb 26 18:39:19 2008 +0100
@@ -269,6 +269,9 @@
#generateHookMethods
'Generates startup/release methods. (#closeRequest, #postBuildWith:, #postOpenWith:)'
+#group
+''
+
#helpExamples
'Show some examples uses of the GUI Painter.'
@@ -332,6 +335,9 @@
#settingsUndoManager
'Opens a dialog to undo modifications.'
+#sortItems
+'Sort the selected items by position (left to right, top to bottom)'
+
#spreadSelectionHor
'Sets the horizontal spaces between the selected widgets to the same value.'
@@ -1681,8 +1687,8 @@
(MenuItem
activeHelpKey: pasteWithLayout
enabled: canPasteKeepingLayoutHolder
- label: 'Paste with Layout'
- itemValue: pasteWithLayout
+ label: 'Paste without Layout'
+ itemValue: pasteWithoutLayout
translateLabel: true
)
(MenuItem
@@ -1834,10 +1840,13 @@
label: '-'
)
(MenuItem
- activeHelpKey: group
- enabled: enGroup
- label: 'Group'
- itemValue: group
+ activeHelpKey: sortItems
+ label: 'Sort Selected Items'
+ itemValue: doSortItems
+ translateLabel: true
+ )
+ (MenuItem
+ label: 'Action'
translateLabel: true
)
(MenuItem
@@ -1879,6 +1888,12 @@
translateLabel: true
)
(MenuItem
+ activeHelpKey: editBrowseViewClass
+ label: 'Browse Specification Class'
+ itemValue: doBrowseSpecificationClass
+ translateLabel: true
+ )
+ (MenuItem
activeHelpKey: editInspectSpec
label: 'Inspect Spec'
itemValue: doInspectSpec
@@ -2604,6 +2619,7 @@
!
valueOfCanPasteWithKeepingLayout
+ <resource: #obsolete>
self obsoleteMethodWarning:'stupid name - use #canPasteKeepingLayoutHolder'.
^ self canPasteKeepingLayoutHolder
! !
@@ -2900,16 +2916,14 @@
self canMoveSelectionOutOfContainer value:(treeView canMoveSelectionOutOfContainer).
self hasOneSelectionOtherThanCanvas value:(treeView hasOneSelectionOtherThanCanvas).
- treeView notNil
- ifTrue:
- [
+ painterView notNil ifTrue:[
treeSelection := treeView selection.
"/ the top-node cannot be cut, copied or pasted.
canCutOrCopy := treeSelection size >= 1 and:[treeSelection first ~~ 1].
- clipboard := self getClipboardObject.
-
- clipboard isCollection
- ifTrue:[clipboard notEmpty ifTrue:[sel := clipboard first]]
+ clipboard := painterView getClipboardObject.
+
+ clipboard notEmptyOrNil
+ ifTrue:[sel := clipboard first]
ifFalse:[sel := clipboard].
canPaste := (sel isKindOf:UISpecification)
@@ -4310,6 +4324,21 @@
UserPreferences systemBrowserClass openInClass:(self resolveName:specClassName)
!
+doBrowseSpecificationClass
+ "opens an browser on the spec class of the selected widget"
+
+ |spec|
+
+ (spec := self painter specForSelection) isNil ifTrue:[
+ treeView isCanvasSelected ifTrue:[
+ spec := treeView canvasSpec.
+ ]
+ ].
+ spec notNil ifTrue:[
+ spec class browse
+ ]
+!
+
doBrowseViewClass
"opens a browser on the selected widgets class"
@@ -4884,6 +4913,12 @@
"/ UserPreferences current systemBrowserClass openInClass:cls selector:aspect
!
+doSortItems
+ "sort the selected items by position"
+
+ treeView doSortItems
+!
+
doStartApplication
"starts the application on the editing window spec"
@@ -5730,6 +5765,47 @@
canvas pasteWithLayout.
!
+doSortItems
+ "moves child 'anOffset' forward or backward in list of children"
+
+ |selectedItems parent sortedItems newChildren itemList parentView|
+
+ self askForSelectionChangeAllowed ifFalse:[^ self].
+
+ selectedItems := self selectedNodes.
+ selectedItems size <= 1 ifTrue:[^ self].
+ parent := selectedItems first parent.
+ (parent isNil or:[(selectedItems conform:[:e| e parent == parent]) not]) ifTrue:[^ self].
+
+ sortedItems := selectedItems sort:[:a :b| a contents view origin isLeftOrAbove:(b contents view origin)].
+ itemList := selectedItems asIdentitySet.
+
+ newChildren := parent children collect:[:eachChild|
+ (itemList includes:eachChild) ifTrue:[
+ sortedItems removeFirst.
+ ] ifFalse:[
+ eachChild.
+ ].
+ ].
+
+ self setSelection:nil.
+ model remove:parent children.
+ model add:newChildren beforeIndex:1 below:parent.
+
+ parentView := parent contents view.
+
+ self canvas hideSelection.
+ newChildren keysAndValuesDo:[:idx :eachItem|
+ parentView changeSequenceOrderFor:eachItem contents view to:idx.
+ ].
+ parentView specClass isLayoutContainer ifFalse:[
+ parentView subViews do:[:v| v raise ].
+ ].
+ self canvas showSelection.
+
+ self selectNodes:itemList.
+!
+
doStepIn
"move the currently selected widget into the next available container below"