# HG changeset patch # User ca # Date 855934138 -3600 # Node ID 877a25e8f5aa8a666fc2548c0fd8ee981c3a320f # Parent 4c080ce0d4654c24b2e070bb3d299a27a7a900da intitial checkin diff -r 4c080ce0d465 -r 877a25e8f5aa UIPainter.st --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UIPainter.st Fri Feb 14 16:28:58 1997 +0100 @@ -0,0 +1,2729 @@ +" + COPYRIGHT (c) 1995 by Claus Gittinger + All Rights Reserved + + This software is furnished under a license and may be used + only in accordance with the terms of that license and with the + inclusion of the above copyright notice. This software may not + be provided or otherwise made available to, or used by, any + other person. No title to or ownership of the software is + hereby transferred. +" + +ApplicationModel subclass:#UIPainter + instanceVariableNames:'menu nameField elementMenu workView treeView outletView stringBox + actionBox listBox fileBox currentFileName topView propertyFrame + whichProperty changeSelectorHolder changeChannel + aspectSelectorHolder aspectChannel nameChannel fgChannel + bgChannel applyAction leftFractionHolder leftOffsetHolder + rightFractionHolder rightOffsetHolder topFractionHolder + topOffsetHolder bottomFractionHolder bottomOffsetHolder specClass + specSelector leftAlignmentFractionHolder + topAlignmentFractionHolder propertyShown specShown' + classVariableNames:'' + poolDictionaries:'' + category:'Interface-UIPainter' +! + +!UIPainter class methodsFor:'documentation'! + +copyright +" + COPYRIGHT (c) 1995 by Claus Gittinger + All Rights Reserved + + This software is furnished under a license and may be used + only in accordance with the terms of that license and with the + inclusion of the above copyright notice. This software may not + be provided or otherwise made available to, or used by, any + other person. No title to or ownership of the software is + hereby transferred. +" +! + +documentation +" + not yet finished, not yet published, not yet released. + + [start with:] + Builder open + + [st80 compatibility:] + UIPainter := Builder. UIPainter open +" +! ! + +!UIPainter class methodsFor:'interface specs'! + +actionButtonModelSpec + "UIPainter new openOnClass:self andSelector:#actionButtonModelSpec" + + + + ^ + + #(#FullSpec + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#FramedBoxSpec + #'layout:' #(#LayoutFrame 0 0 -1 0 251 0 289 0) + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#VerticalPanelViewSpec + #'layout:' #(#LayoutFrame 6 0 26 0 78 0 216 0) + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#LabelSpec + #'name:' 'label' + #'layout:' #(#LayoutFrame 0 0 47 0 57 0 71 0) + #'label:' 'aspect:' + ) + #(#LabelSpec + #'name:' 'label' + #'layout:' #(#LayoutFrame 0 0 119 0 62 0 143 0) + #'label:' 'change:' + ) + ) + ) + #'horizontalLayout:' #left + #'verticalLayout:' #spreadSpace + ) + #(#VerticalPanelViewSpec + #'layout:' #(#LayoutFrame 80 0 24 0 231 0 214 0) + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#InputFieldSpec + #'name:' 'aspectInput' + #'layout:' #(#LayoutFrame 0 0 49 0 163 0 69 0) + #model: #aspectChannel + #acceptOnLostFocus: true + #tabable: true + ) + #(#InputFieldSpec + #'name:' 'changeInput' + #'layout:' #(#LayoutFrame 0 0 119 0 163 0 142 0) + #model: #changeChannel + #acceptOnLostFocus: true + #tabable: true + ) + ) + ) + #'horizontalLayout:' #fit + #'verticalLayout:' #spreadSpace + ) + #(#ActionButtonSpec + #'name:' 'button' + #'layout:' #(#LayoutFrame 102 0 246 0 153 0 272 0) + #'label:' 'apply' + #'model:' #setModelAspects + ) + ) + ) + #'labelPosition:' #topLeft + #'showFrame:' false + ) + ) + ) + #'window:' + #(#WindowSpec + #'label:' 'unnamed' + #'bounds:' #(#Rectangle 0 0 255 292) + ) + ) +! + +colorSpec + "UIBuilder new openOnClass:self andSelector:#colorSpec" + "Builder new openInterface:#colorSpec" + + + + ^ + + #(#FullSpec + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#FramedBoxSpec + #'layout:' #(#LayoutFrame 0 0 -1 0 252 0 290 0) + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#VerticalPanelViewSpec + #'layout:' #(#LayoutFrame 6 0 26 0 100 0 215 0) + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#LabelSpec + #'name:' 'label' + #'layout:' #(#LayoutFrame 0 0 47 0 87 0 71 0) + #'label:' 'foreground:' + ) + #(#LabelSpec + #'name:' 'label' + #'layout:' #(#LayoutFrame 0 0 119 0 93 0 143 0) + #'label:' 'background:' + ) + ) + ) + #'horizontalLayout:' #left + #'verticalLayout:' #spreadSpace + ) + #(#VerticalPanelViewSpec + #'layout:' #(#LayoutFrame 114 0 24 0 233 0 213 0) + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#InputFieldSpec + #'layout:' #(#LayoutFrame 0 0 49 0 163 0 69 0) + #model: #foregroundChannel + ) + #(#InputFieldSpec + #'layout:' #(#LayoutFrame 0 0 119 0 163 0 142 0) + #model: #backgroundChannel + ) + ) + ) + #'horizontalLayout:' #fit + #'verticalLayout:' #spreadSpace + ) + #(#ActionButtonSpec + #'name:' 'button' + #'layout:' #(#LayoutFrame 102 0 246 0 153 0 272 0) + #'label:' 'apply' + #'model:' #setColors + ) + ) + ) + #'labelPosition:' #topLeft + #'showFrame:' false + ) + ) + ) + #'window:' + #(#WindowSpec + #'label:' 'unnamed' + #'bounds:' #(#Rectangle 0 0 255 292) + ) + ) +! + +geometrySpecForAlignmentOrigin + "UIBuilder new openOnClass:self andSelector:#geometrySpecForAlignmentOrigin" + "Builder new openInterface:#geometrySpecForAlignmentOrigin" + + + + ^ + + #(#FullSpec + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#FramedBoxSpec + #'layout:' #(#LayoutFrame 0 0 -1 0 253 0 291 0) + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#VerticalPanelViewSpec + #'layout:' #(#LayoutFrame 6 0 26 0 85 0 219 0) + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#LabelSpec + #'layout:' #(#LayoutFrame 0 0 19 0 30 0 43 0) + #'label:' 'left' + #'adjust:' #left + ) + #(#LabelSpec + #'layout:' #(#LayoutFrame 0 0 63 0 31 0 87 0) + #'label:' 'top' + #'adjust:' #left + ) + #(#LabelSpec + #'layout:' #(#LayoutFrame 0 0 107 0 41 0 131 0) + #'label:' 'align H' + #'adjust:' #left + ) + #(#LabelSpec + #'layout:' #(#LayoutFrame 0 0 151 0 61 0 175 0) + #'label:' 'align V' + #'adjust:' #left + ) + ) + ) + #'horizontalLayout:' #left + #'verticalLayout:' #spreadSpace + ) + #(#VerticalPanelViewSpec + #'layout:' #(#LayoutFrame 80 0 24 0 124 0 217 0) + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#InputFieldSpec + #'layout:' #(#LayoutFrame 0 0 21 0 71 0 42 0) + #'type:' #numberOrNil + #model: #leftFractionChannel + #acceptOnLostFocus: true + #tabable: true + ) + #(#InputFieldSpec + #'layout:' #(#LayoutFrame 0 0 64 0 71 0 85 0) + #'type:' #numberOrNil + #'model:' #'topFractionChannel' + #acceptOnLostFocus: true + #tabable: true + ) + #(#InputFieldSpec + #'layout:' #(#LayoutFrame 0 0 107 0 71 0 128 0) + #'type:' #numberOrNil + #model: #'leftAlignmentFractionChannel' + #acceptOnLostFocus: true + #tabable: true + ) + #(#InputFieldSpec + #'layout:' #(#LayoutFrame 0 0 150 0 71 0 171 0) + #'type:' #numberOrNil + #'model:' #'topAlignmentFractionChannel' + #acceptOnLostFocus: true + #tabable: true + ) + ) + ) + #'horizontalLayout:' #fit + #'verticalLayout:' #spreadSpace + ) + #(#VerticalPanelViewSpec + #'layout:' #(#LayoutFrame 150 0 24 0 220 0 216 0) + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#InputFieldSpec + #'layout:' #(#LayoutFrame 0 0 21 0 114 0 42 0) + #'type:' #numberOrNil + #model: #leftOffsetChannel + #acceptOnLostFocus: true + #tabable: true + ) + #(#InputFieldSpec + #'layout:' #(#LayoutFrame 0 0 64 0 114 0 85 0) + #'type:' #numberOrNil + #model: #topOffsetChannel + #acceptOnLostFocus: true + #tabable: true + ) + ) + ) + #'horizontalLayout:' #fit + #'verticalLayout:' #spreadSpace + ) + #(#ActionButtonSpec + #'name:' 'button' + #'layout:' #(#LayoutFrame 16 0 210 0 76 0 240 0) + #'label:' 'frame' + #'model:' #setLayoutFrame + ) + #(#ActionButtonSpec + #'name:' 'button' + #'layout:' #(#LayoutFrame 96 0 210 0 156 0 240 0) + #'label:' 'origin' + #'model:' #setLayoutOrigin + ) + #(#ActionButtonSpec + #'name:' 'button' + #'layout:' #(#LayoutFrame 176 0 210 0 236 0 240 0) + #'label:' 'align' + #'model:' #setAlignmentOrigin + #'initiallyDisabled:' true + ) + + #(#ActionButtonSpec + #'layout:' #(#LayoutFrame 96 0 260 0 156 0 290 0) + #'label:' 'apply' + #'model:' #setDimensionForAlignmentOrigin + #tabable: true + ) + #(#LabelSpec + #'layout:' #(#LayoutFrame 77 0 9 0 137 0 31 0) + #'label:' 'relative' + ) + #(#LabelSpec + #'layout:' #(#LayoutFrame 167 0 9 0 213 0 30 0) + #'label:' 'offset' + ) + ) + ) + #'labelPosition:' #topLeft + #'showFrame:' false + ) + ) + ) + #'window:' + #(#WindowSpec + #'label:' 'indy: unnamed' + #'bounds:' #(#Rectangle 0 0 255 292) + ) + ) +! + +geometrySpecForLayoutFrame + "UIBuilder new openOnClass:self andSelector:#geometrySpecForLayoutFrame" + "Builder new openInterface:#geometrySpecForLayoutFrame" + + + + ^ + + #(#FullSpec + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#FramedBoxSpec + #'layout:' #(#LayoutFrame 0 0 -1 0 253 0 291 0) + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#VerticalPanelViewSpec + #'layout:' #(#LayoutFrame 6 0 26 0 85 0 219 0) + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#LabelSpec + #'layout:' #(#LayoutFrame 0 0 19 0 30 0 43 0) + #'label:' 'left' + #'adjust:' #left + ) + #(#LabelSpec + #'layout:' #(#LayoutFrame 0 0 63 0 30 0 87 0) + #'label:' 'top' + #'adjust:' #left + ) + #(#LabelSpec + #'layout:' #(#LayoutFrame 0 0 107 0 40 0 131 0) + #'label:' 'right' + #'adjust:' #left + ) + #(#LabelSpec + #'layout:' #(#LayoutFrame 0 0 151 0 40 0 175 0) + #'label:' 'bottom' + #'adjust:' #left + ) + ) + ) + #'horizontalLayout:' #left + #'verticalLayout:' #spreadSpace + ) + #(#VerticalPanelViewSpec + #'layout:' #(#LayoutFrame 80 0 24 0 124 0 217 0) + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#InputFieldSpec + #'layout:' #(#LayoutFrame 0 0 21 0 71 0 42 0) + #'type:' #numberOrNil + #model: #leftFractionChannel + #acceptOnLostFocus: true + #tabable: true + ) + #(#InputFieldSpec + #'layout:' #(#LayoutFrame 0 0 64 0 71 0 85 0) + #'type:' #numberOrNil + #'model:' #'topFractionChannel' + #acceptOnLostFocus: true + #tabable: true + ) + #(#InputFieldSpec + #'layout:' #(#LayoutFrame 0 0 107 0 71 0 128 0) + #'type:' #numberOrNil + #model: #'rightFractionChannel' + #acceptOnLostFocus: true + #tabable: true + ) + #(#InputFieldSpec + #'layout:' #(#LayoutFrame 0 0 150 0 71 0 171 0) + #'type:' #numberOrNil + #'model:' #'bottomFractionChannel' + #acceptOnLostFocus: true + #tabable: true + ) + ) + ) + #'horizontalLayout:' #fit + #'verticalLayout:' #spreadSpace + ) + #(#VerticalPanelViewSpec + #'layout:' #(#LayoutFrame 150 0 24 0 220 0 216 0) + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#InputFieldSpec + #'layout:' #(#LayoutFrame 0 0 21 0 114 0 42 0) + #'type:' #numberOrNil + #model: #leftOffsetChannel + #acceptOnLostFocus: true + #tabable: true + ) + #(#InputFieldSpec + #'layout:' #(#LayoutFrame 0 0 64 0 114 0 85 0) + #'type:' #numberOrNil + #model: #topOffsetChannel + #acceptOnLostFocus: true + #tabable: true + ) + #(#InputFieldSpec + #'layout:' #(#LayoutFrame 0 0 107 0 114 0 128 0) + #'type:' #numberOrNil + #'model:' #rightOffsetChannel + #acceptOnLostFocus: true + #tabable: true + ) + #(#InputFieldSpec + #'layout:' #(#LayoutFrame 0 0 150 0 114 0 171 0) + #'type:' #numberOrNil + #'model:' #bottomOffsetChannel + #acceptOnLostFocus: true + #tabable: true + ) + ) + ) + #'horizontalLayout:' #fit + #'verticalLayout:' #spreadSpace + ) + + #(#ActionButtonSpec + #'name:' 'button' + #'layout:' #(#LayoutFrame 16 0 210 0 76 0 240 0) + #'label:' 'frame' + #'model:' #setLayoutFrame + #'initiallyDisabled:' true + ) + #(#ActionButtonSpec + #'name:' 'button' + #'layout:' #(#LayoutFrame 96 0 210 0 156 0 240 0) + #'label:' 'origin' + #'model:' #setLayoutOrigin + ) + #(#ActionButtonSpec + #'name:' 'button' + #'layout:' #(#LayoutFrame 176 0 210 0 236 0 240 0) + #'label:' 'align' + #'model:' #setAlignmentOrigin + ) + + #(#ActionButtonSpec + #'layout:' #(#LayoutFrame 96 0 260 0 156 0 290 0) + #'label:' 'apply' + #'model:' #setDimensionForLayoutFrame + #tabable: true + ) + #(#LabelSpec + #'layout:' #(#LayoutFrame 77 0 9 0 137 0 31 0) + #'label:' 'relative' + ) + #(#LabelSpec + #'layout:' #(#LayoutFrame 167 0 9 0 213 0 30 0) + #'label:' 'offset' + ) + ) + ) + #'labelPosition:' #topLeft + #'showFrame:' false + ) + ) + ) + #'window:' + #(#WindowSpec + #'label:' 'indy: unnamed' + #'bounds:' #(#Rectangle 0 0 255 292) + ) + ) +! + +geometrySpecForLayoutOrigin + "UIPainter new openOnClass:self andSelector:#geometrySpecForLayoutOrigin" + "Builder new openInterface:#geometrySpecForLayoutOrigin" + + + + ^ + + #(#FullSpec + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#FramedBoxSpec + #'name:' 'framedBox' + #'layout:' #(#LayoutFrame 0 0 -1 0 253 0 291 0) + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#VerticalPanelViewSpec + #'name:' 'verticalPanelView' + #'layout:' #(#LayoutFrame 6 0 26 0 85 0 219 0) + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#LabelSpec + #'name:' 'label' + #'layout:' #(#LayoutFrame 0 0 19 0 30 0 43 0) + #'label:' 'left' + #'adjust:' #left + ) + #(#LabelSpec + #'name:' 'label' + #'layout:' #(#LayoutFrame 0 0 63 0 31 0 87 0) + #'label:' 'top' + #'adjust:' #left + ) + ) + ) + #'horizontalLayout:' #left + #'verticalLayout:' #spreadSpace + ) + #(#VerticalPanelViewSpec + #'name:' 'verticalPanelView' + #'layout:' #(#LayoutFrame 80 0 24 0 124 0 217 0) + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#InputFieldSpec + #'layout:' #(#LayoutFrame 0 0 21 0 71 0 42 0) + #'type:' #numberOrNil + #model: #leftFractionChannel + #'acceptOnLostFocus:' true + #tabable: true + ) + #(#InputFieldSpec + #'layout:' #(#LayoutFrame 0 0 64 0 71 0 85 0) + #'type:' #numberOrNil + #'model:' #'topFractionChannel' + #acceptOnLostFocus: true + #tabable: true + ) + ) + ) + #'horizontalLayout:' #fit + #'verticalLayout:' #spreadSpace + ) + #(#VerticalPanelViewSpec + #'name:' 'verticalPanelView' + #'layout:' #(#LayoutFrame 150 0 24 0 220 0 216 0) + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#InputFieldSpec + #'layout:' #(#LayoutFrame 0 0 21 0 114 0 42 0) + #'type:' #numberOrNil + #model: #leftOffsetChannel + #acceptOnLostFocus: true + #tabable: true + ) + #(#InputFieldSpec + #'layout:' #(#LayoutFrame 0 0 64 0 114 0 85 0) + #'type:' #numberOrNil + #model: #topOffsetChannel + #acceptOnLostFocus: true + #tabable: true + ) + ) + ) + #'horizontalLayout:' #fit + #'verticalLayout:' #spreadSpace + ) + #(#ActionButtonSpec + #'name:' 'button' + #'layout:' #(#LayoutFrame 16 0 210 0 76 0 240 0) + #'label:' 'frame' + #'model:' #setLayoutFrame + ) + #(#ActionButtonSpec + #'name:' 'button' + #'layout:' #(#LayoutFrame 96 0 210 0 156 0 240 0) + #'label:' 'origin' + #'model:' #setLayoutOrigin + #'initiallyDisabled:' true + ) + #(#ActionButtonSpec + #'name:' 'button' + #'layout:' #(#LayoutFrame 176 0 210 0 236 0 240 0) + #'label:' 'align' + #'model:' #setAlignmentOrigin + ) + #(#ActionButtonSpec + #'name:' 'button' + #'layout:' #(#LayoutFrame 96 0 260 0 156 0 290 0) + #'label:' 'apply' + #'model:' #setDimensionForLayoutOrigin + ) + #(#LabelSpec + #'name:' 'label' + #'layout:' #(#LayoutFrame 77 0 9 0 137 0 31 0) + #'label:' 'relative' + ) + #(#LabelSpec + #'name:' 'label' + #'layout:' #(#LayoutFrame 159 0 9 0 205 0 30 0) + #'label:' 'offset' + ) + ) + ) + #'labelPosition:' #topLeft + #'showFrame:' false + ) + ) + ) + #'window:' + #(#WindowSpec + #'label:' 'indy: unnamed' + #'bounds:' #(#Rectangle 0 0 255 292) + ) + ) + +! + +miscSpec + "UIBuilder new openOnClass:self andSelector:#miscSpec" + "Builder new openInterface:#miscSpec" + + + + ^ + + #(#FullSpec + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#FramedBoxSpec + #'layout:' #(#LayoutFrame 0 0 -1 0 251 0 289 0) + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#VerticalPanelViewSpec + #'layout:' #(#LayoutFrame 6 0 26 0 61 0 215 0) + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#LabelSpec + #'layout:' #(#LayoutFrame 0 0 47 0 57 0 71 0) + #'label:' 'name:' + ) + ) + ) + #'horizontalLayout:' #left + #'verticalLayout:' #spreadSpace + ) + #(#VerticalPanelViewSpec + #'layout:' #(#LayoutFrame 60 0 24 0 230 0 213 0) + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#InputFieldSpec + #model: #nameChannel + #'layout:' #(#LayoutFrame 0 0 49 0 163 0 69 0) + #acceptOnLostFocus: true + #tabable: true + ) + ) + ) + #'horizontalLayout:' #fit + #'verticalLayout:' #spreadSpace + ) + #(#ActionButtonSpec + #'layout:' #(#LayoutFrame 102 0 246 0 153 0 272 0) + #'label:' 'apply' + #'model:' #setMiscAspects + #tabable: true + ) + ) + ) + #'labelPosition:' #topLeft + #'showFrame:' false + ) + ) + ) + #'window:' + #(#WindowSpec + #'label:' 'unnamed' + #'bounds:' #(#Rectangle 0 0 255 292) + ) + ) +! + +modelSpec + "UIBuilder new openOnClass:self andSelector:#modelSpec" + "Builder new openInterface:#modelSpec" + + + + ^ + + #(#FullSpec + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#FramedBoxSpec + #'layout:' #(#LayoutFrame 0 0 -1 0 251 0 289 0) + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#VerticalPanelViewSpec + #'layout:' #(#LayoutFrame 6 0 26 0 78 0 216 0) + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#LabelSpec + #'name:' 'label' + #'layout:' #(#LayoutFrame 0 0 47 0 57 0 71 0) + #'label:' 'aspect:' + ) + #(#LabelSpec + #'name:' 'label' + #'layout:' #(#LayoutFrame 0 0 119 0 62 0 143 0) + #'label:' 'change:' + ) + ) + ) + #'horizontalLayout:' #left + #'verticalLayout:' #spreadSpace + ) + #(#VerticalPanelViewSpec + #'layout:' #(#LayoutFrame 80 0 24 0 231 0 214 0) + #'component:' + #(#SpecCollection + #'collection:' + #( + #(#InputFieldSpec + #'name:' 'aspectInput' + #'layout:' #(#LayoutFrame 0 0 49 0 163 0 69 0) + #model: #aspectChannel + #acceptOnLostFocus: true + #tabable: true + ) + #(#InputFieldSpec + #'name:' 'changeInput' + #'layout:' #(#LayoutFrame 0 0 119 0 163 0 142 0) + #model: #changeChannel + #acceptOnLostFocus: true + #tabable: true + ) + ) + ) + #'horizontalLayout:' #fit + #'verticalLayout:' #spreadSpace + ) + #(#ActionButtonSpec + #'name:' 'button' + #'layout:' #(#LayoutFrame 102 0 246 0 153 0 272 0) + #'label:' 'apply' + #'model:' #setModelAspects + ) + ) + ) + #'labelPosition:' #topLeft + #'showFrame:' false + ) + ) + ) + #'window:' + #(#WindowSpec + #'label:' 'unnamed' + #'bounds:' #(#Rectangle 0 0 255 292) + ) + ) +! ! + +!UIPainter methodsFor:'BuilderView interface'! + +setUndoLabel:aString + aString isNil ifTrue:[ + (menu menuAt:#edit) labelAt:#undoAction put:'undo'. + (menu menuAt:#edit) disable:#undoAction + ] ifFalse:[ + (menu menuAt:#edit) labelAt:#undoAction put:'undo: ' , aString. + (menu menuAt:#edit) enable:#undoAction + ] +! + +update:something with:parameter + |singleSelection| + + elementMenu deselect. + + something == #undoHistory ifTrue:[ + ^ self setUndoLabel:parameter + ]. + + singleSelection := workView singleSelection. + + (something == #layout or:[something == #any]) ifTrue:[ + singleSelection notNil ifTrue:[ + self fetchLayoutFrom:singleSelection + ]. + ^ self + ]. + + (something == #aspects or:[something == #any]) ifTrue:[ + singleSelection notNil ifTrue:[ + self fetchModelAspectsFrom:singleSelection + ]. + ^ self + ]. + + (something == #selection or:[something == #any]) ifTrue:[ + self showPropertyView. + self showOutletsFor:(workView selection). + + singleSelection isNil ifFalse:[ + nameChannel isNil ifTrue:[self nameChannel]. + nameChannel value:singleSelection name. + + self fetchLayoutFrom:singleSelection. + self fetchModelAspectsFrom:singleSelection. + ]. + ^ self + ]. +! ! + +!UIPainter methodsFor:'aspects'! + +aspectChannel + ^ aspectChannel + + "Modified: 6.9.1995 / 01:00:30 / claus" +! + +backgroundChannel + ^ bgChannel +! + +bottomFractionChannel + ^ bottomFractionHolder +! + +bottomOffsetChannel + ^ bottomOffsetHolder + +! + +changeChannel + ^ changeChannel + + "Modified: 6.9.1995 / 01:00:33 / claus" +! + +foregroundChannel + ^ fgChannel +! + +leftAlignmentFractionChannel + ^ leftAlignmentFractionHolder + +! + +leftFractionChannel + ^ leftFractionHolder + +! + +leftOffsetChannel + ^ leftOffsetHolder + +! + +nameChannel + nameChannel isNil ifTrue:[ + nameChannel := '' asValue. + ]. + ^ nameChannel + + "Modified: 6.9.1995 / 00:38:00 / claus" +! + +rightFractionChannel + ^ rightFractionHolder + +! + +rightOffsetChannel + ^ rightOffsetHolder + +! + +topAlignmentFractionChannel + ^ topAlignmentFractionHolder + +! + +topFractionChannel + ^ topFractionHolder + +! + +topOffsetChannel + ^ topOffsetHolder + +! ! + +!UIPainter methodsFor:'filein & fileout'! + +openFile:aFileName + |aStream | + + aStream := FileStream readonlyFileNamed:aFileName. + aStream notNil ifTrue:[ + workView fileInContentsFrom:aStream. + aStream close. + currentFileName := aFileName + ] + +! + +saveAs:aFileName + |aStream| + + aStream := FileStream newFileNamed:aFileName. + aStream notNil ifTrue:[ + workView storeContentsOn:aStream. + aStream close + ]. + currentFileName := aFileName + +! ! + +!UIPainter methodsFor:'help'! + +helpTextFor:aComponent + |sel| + + (aComponent isKindOf:Button) ifTrue:[ + (sel := aComponent changeMessage) notNil ifTrue:[ + "/ take the buttons change symbol as resource-key + ^ resources string:(sel asString) + ] + ]. + ^ nil + + "Modified: 31.8.1995 / 20:49:58 / claus" +! ! + +!UIPainter methodsFor:'initialization'! + +buttonPanelSpec + "return a spec for the buttons in the panel; + entries consists of selector and bitmap-filename. + nil selectors are taken as separators (see setupButtonPanel)" + + ^ #( + #(alignSelectionLeft true 'b_alignL.xbm' nil false) + #(alignSelectionRight true 'b_alignR.xbm' nil false) + #(alignSelectionLeftAndRight true 'b_alignLR.xbm' nil false) + #(nil nil nil nil) + #(alignSelectionTop true 'b_alignT.xbm' nil false) + #(alignSelectionBottom true 'b_alignB.xbm' nil false) + #(alignSelectionTopAndBottom true 'b_alignTB.xbm' nil false) + #(nil nil nil nil) + #(alignSelectionCenterHor true 'b_alignCH.xbm' nil false) + #(alignSelectionCenterVer true 'b_alignCV.xbm' nil false) + #(nil nil nil nil) + #(moveSelectionLeft true 'b_moveLeft.xbm' nil true) + #(moveSelectionRight true 'b_moveRight.xbm' nil true) + #(moveSelectionUp true 'b_moveUp.xbm' nil true) + #(moveSelectionDown true 'b_moveDown.xbm' nil true) + #(moveSelectionLeft10 true 'b_moveLeft2.xbm' nil true) + #(moveSelectionRight10 true 'b_moveRight2.xbm' nil true) + #(moveSelectionUp10 true 'b_moveUp2.xbm' nil true) + #(moveSelectionDown10 true 'b_moveDown2.xbm' nil true) + ) + + "Modified: 5.9.1995 / 22:20:36 / claus" +! + +createCanvas + |topView| + + super initialize. + + topView := StandardSystemView new. + topView label:'unnamed'. + topView extent:300@300. + + workView := UIPainterView in:topView. + workView layout:(0.0 @ 0.0 corner:1.0 @ 1.0) asLayout. + + ^ workView. + + "Builder new createCanvas open" +! + +createPaletteIn:aViewOrNil + |topView v| + + aViewOrNil isNil ifTrue:[ + topView := StandardSystemView new. + topView label:'element palette'. + topView extent:200@400. + ] ifFalse:[ + topView := aViewOrNil + ]. + v := HVScrollableView for:SelectionInListView miniScrollerH:true in:topView. + v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). + elementMenu := v scrolledView. + + ^ elementMenu. + + "(Builder new createPaletteIn:nil) topView open" + + "Modified: 5.9.1995 / 23:52:57 / claus" +! + +initChannels + + bottomFractionHolder := nil asValue. + bottomOffsetHolder := nil asValue. + leftFractionHolder := nil asValue. + leftOffsetHolder := nil asValue. + rightFractionHolder := nil asValue. + rightOffsetHolder := nil asValue. + topFractionHolder := nil asValue. + topOffsetHolder := nil asValue. + leftAlignmentFractionHolder := nil asValue. + topAlignmentFractionHolder := nil asValue. + + fgChannel := nil asValue. + bgChannel := nil asValue. + + aspectChannel := nil asValue. + changeChannel := nil asValue. + +! + +initPullDownMenu + menu labels:(resources array:#( + 'file' + 'edit' + 'font' + 'type' + 'align' + 'dimension' + 'form' + 'special' + 'code' + 'debug' + 'test' + )). + + menu selectors:#(#file + #edit + #font + #type + #align + #dimension + #form + #special + #code + #debugging + #test + ). + + menu at:#file + putLabels:(resources array: + #('new' + 'from class' + 'pick a view ' + '-' + 'save' + 'save as ...' + '-' + 'compile' + '-' + 'source' + 'windowSpec' + 'inspect me' + '-' + 'print' + '-' + 'quit' + )) + selectors:#(doNew + doFromClass + doPickAView + nil + doSave + doSaveAs + nil + doCompile + nil + doSource + doWindowSpec + inspect + nil + doPrint + nil + doFinish + ) + receiver:self. + + menu at:#edit + putLabels:(resources array:#( + 'undo' +"/ 'copy' + 'cut' +"/ 'paste' + )) + selectors:#( + undoAction +"/ copySelection + deleteSelection +"/ pasteBuffer + ) + receiver:workView. + + menu at:#font + putLabels:(resources array:#( + 'larger' + 'smaller' + '-' + 'normal' + 'bold' + 'italic' + 'bold italic' + '-' + 'font panel' + ) ) + selectors:#(largerFont + smallerFont + nil + normalFont + boldFont + italicFont + boldItalicFont + nil + showFontPanel + ) + receiver:workView. + + menu at:#type + putLabels:(resources array:#( + 'basic widgets' + 'layout' + 'text' + 'interactors' + 'modal' + 'other' + '-' + 'all' + ) ) + selectors:#(showBasicWidgets + showLayoutWidgets + showTextWidgets + showInteractorWidgets + showModalWidgets + showOtherWidgets + nil + showAllWidgets + ) + receiver:self. + + menu at:#align + putLabels:(resources array:#( +"/ 'raise' +"/ 'lower' +"/ '-' + 'align left' + 'align right' + 'align left & right' + 'align top' + 'align bottom' + 'align centered vertical' + 'align centered horizontal' + '-' + 'spread horizontal' + 'spread vertical' + 'center horizontal in frame' + 'center vertical in frame' + ) ) + selectors:#( +"/ raiseSelection +"/ lowerSelection +"/ nil + alignSelectionLeft + alignSelectionRight + alignSelectionLeftAndRight + alignSelectionTop + alignSelectionBottom + alignSelectionCenterHor + alignSelectionCenterVer + nil + spreadSelectionHor + spreadSelectionVer + centerSelectionHor + centerSelectionVer + ) + receiver:workView. + + menu at:#dimension + putLabels:(resources array:#( + 'default extent' + 'default width' + 'default height' + '-' + 'copy extent' + 'paste extent' + 'paste width' + 'paste height' + '-' + 'insert' + ) ) + selectors:#( + setToDefaultExtent + setToDefaultWidth + setToDefaultHeight + nil + copyExtent + pasteExtent + pasteWidth + pasteHeight + nil + insertSelection + ) + receiver:workView. + + menu at:#form + putLabels:(resources array:#( + 'align to grid' + 'show grid' + ) ) + selectors:#( + alignOn + toggleGrid + ) + receiver:self. + + menu at:#special + putLabels:(resources array:#( + 'group radioButtons' + 'group enterFields' + ) ) + selectors:#( + groupRadioButtons + groupEnterFields + ) + receiver:workView. + + menu at:#code + putLabels:(resources array:#( + 'class' + 'method' +"/ 'variables' + ) ) + selectors:#( + changeClass + changeMethod +"/ changeVariables + ) + receiver:self. + + menu at:#debugging + putLabels:(resources array:#( + 'inspect' + 'inspect attributes' + ) ) + selectors:#( + inspectSelection + inspectAttributes + ) + receiver:workView. + + menu at:#test + putLabels:(resources array:#( + 'test on' + ) ) + selectors:#(toggleTest + ) + receiver:self. + + self setUndoLabel:nil. +! + +openInterface + |list panel topPane botPanel v + leftPanel middlePanel rightPanel buttonPanel propSelector| + + super initialize. + + self initChannels. + + whichProperty := SelectionInList new. + whichProperty list:#('dimension' 'colors' 'model' 'misc' 'attribute list'). + whichProperty onChangeSend:#propertySelectionChanged to:self. + + workView :=self createCanvas. + + topView := StandardSystemView new. + topView label:'Interface Builder'. + topView icon:(Image fromFile:'bitmaps/Builder.xbm' resolution:100). + topView extent:(600 @ 400). + + menu := PullDownMenu in:topView. + + buttonPanel := self setupButtonPanelIn:topView below:menu. + + leftPanel := View in:topView. + leftPanel origin:(0.0 @ 0.0) corner:0.3@1.0. + leftPanel topInset:menu height + buttonPanel height + View viewSpacing. + + middlePanel := View in:topView. + middlePanel origin:(0.3 @ 0.0) corner:0.6@1.0. + middlePanel topInset:menu height + buttonPanel height + View viewSpacing. + + rightPanel := View in:topView. + rightPanel origin:(0.6 @ 0.0) corner:1.0@1.0. + rightPanel topInset:menu height + buttonPanel height + View viewSpacing. + + v := HVScrollableView for:UIPainterView miniScrollerH:true in:middlePanel. + v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). + treeView := v scrolledView. + + propSelector := PopUpList label:'properties' in:rightPanel. + propSelector origin:(0.0 @ 0.0) corner:1.0@(propSelector preferredExtent y). + propSelector horizontalInset:View viewSpacing. + propSelector model:whichProperty. + + propertyFrame := View in:rightPanel. + propertyFrame origin:(0.0 @ 0.0) corner:1.0@1.0. + propertyFrame topInset:propSelector height + View viewSpacing. + +"/ panel := VariableVerticalPanel in:topView. +"/ panel origin:(0.0 @ 0.0) corner:0.5@1.0. +"/ panel topInset:menu height + buttonPanel height + View viewSpacing. + +"/ topPane := View in:panel. +"/ topPane origin:(0.0 @ 0.0) corner:(1.0 @ 0.5). +"/ topPane borderWidth:0. + +"/ botPanel := VariableHorizontalPanel in:panel. +"/ botPanel origin:(0.0 @ 0.5) corner:(1.0 @ 1.0). +"/ botPanel borderWidth:0. + + elementMenu := self createPaletteIn:leftPanel. + +"/ v := ScrollableView for:UIPainterView in:botPanel. +"/ v origin:(0.0 @ 0.0) corner:(0.5 @ 1.0). +"/ treeView := v scrolledView. + +"/ v := ScrollableView for:SelectionInListView in:botPanel. +"/ v origin:(0.5 @ 0.0) corner:(1.0 @ 1.0). +"/ outletView := v scrolledView. +"/ outletView action:[:lineNr | self selectOutlet:lineNr]. + +"/ v := ScrollableView for:TextCollector in:topPane. +"/ v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). +"/ infoView := v scrolledView. + + treeView builderView:workView. "link workview with treeview" + + workView addDependent:treeView. + workView addDependent:self. + + self initPullDownMenu. + + elementMenu action:[:selection | + workView testMode ifTrue:[ + elementMenu deselect + ] ifFalse:[ + selection notNil ifTrue:[ + workView createWidgetWithClass: + (Smalltalk at:(elementMenu selectionValue asSymbol)) + ] + ] + ]. + topView application:self. + builder window:topView. + + topView beMaster. + workView topView beSlave. + + "/ can be created as embedded or side-menu + elementMenu topView ~~ topView ifTrue:[ + elementMenu topView beSlave. + ]. + + topView open. + workView topView openInGroup:(topView windowGroup). + elementMenu topView ~~ topView ifTrue:[ + elementMenu topView openInGroup:(topView windowGroup). + ] + + " + Builder open + " + + "Modified: 6.9.1995 / 00:26:59 / claus" +! + +openNewWindowCanvas + self open. + + +! + +openOnClass:aClass andSelector:aSelector + "open up an interface builder, fetching a spec from someClass + via some selector" + + |specArray| + + specClass := aClass. + specSelector := aSelector. + self openInterface. + workView className:aClass name. + workView methodName:aSelector. + workView setupFromSpec:(aClass perform:aSelector). +! + +openOnSpec:aSpecOrSpecArray + "open up an interface builder, given some specArray" + + |newBuilder| + + newBuilder := self new. +! + +setupButtonPanelIn:aTopView below:aMenu + "create the buttonPanel" + + |spc mh buttonPanel| + + spc := View viewSpacing // 2. + buttonPanel := HorizontalPanelView in:aTopView. + buttonPanel level:-1; borderWidth:0. + buttonPanel horizontalLayout:#leftSpace. + + self buttonPanelSpec do:[:entry | + |sel toCanvas imgFile label b sep autoRepeat| + + sel := entry at:1. + sel isNil ifTrue:[ + sep := View in:buttonPanel. + sep extent:20@1; borderWidth:0. + ] ifFalse:[ + toCanvas := entry at:2. + imgFile := entry at:3. + label := entry at:4. + autoRepeat := entry at:5. + b := Button in:buttonPanel. + autoRepeat ifTrue:[ + b autoRepeat:autoRepeat. + b controller beTriggerOnDown. + ]. + imgFile notNil ifTrue:[ + b logo:(Image fromFile:imgFile). + ] ifFalse:[ + b logo:label + ]. + toCanvas ifTrue:[ + b model:workView + ] ifFalse:[ + b model:self + ]. + b changeMessage:sel + ] + ]. + + mh := aMenu height. + buttonPanel origin:0.0 @ (mh + spc) + corner:(1.0 @ (mh + spc + buttonPanel preferredExtent y)). + + buttonPanel leftInset:spc; rightInset:spc. + ^ buttonPanel + + "Modified: 5.9.1995 / 22:23:13 / claus" +! ! + +!UIPainter methodsFor:'misc'! + +listOfOutletsFor:aViewClass + "return a list of outlets for a view-class" + + |l1 l2 all rej| + + (aViewClass == Object) ifTrue:[^ nil]. + + l1 := self listOfOutletsFor:(aViewClass superclass). + l2 := self listOfOutletsForClass:aViewClass. + + l2 isNil ifTrue:[ + all := l1 + ] ifFalse:[ + l1 isNil ifTrue:[ + all := l2 + ] ifFalse:[ + all := l1 , l2 + ] + ]. + rej := self rejectOutletsForClass:aViewClass. + rej notNil ifTrue:[ + rej do:[:x | + all := all copyWithout:x + ] + ]. + ^ all +! + +listOfOutletsForClass:aViewClass + "return a list of outlets for a view-class" + + "could this be done automatically ?" + + (aViewClass == Label) ifTrue:[ + ^ #('label' + 'iconic-label' + 'label layout' + 'fixed size' + 'foreground-color' + 'background-color' + ) + ]. + (aViewClass == Button) ifTrue:[ + ^ #( + 'active foreground-color' + 'active background-color' + 'active level' + 'passive level' + 'press action' + ) + ]. + (aViewClass == Toggle) ifTrue:[ + ^ #( + 'release action' + ) + ]. + (aViewClass == CheckBox) ifTrue:[ + ^ #( + 'label' + ) + ]. + (aViewClass == FramedBox) ifTrue:[ + ^ #( + 'label' + 'label position' + 'frame shown' + ) + ]. + (aViewClass == VerticalPanelView) ifTrue:[ + ^ #( + 'horizontal layout' + 'vertical layout' + ) + ]. + (aViewClass == HorizontalPanelView) ifTrue:[ + ^ #( + 'horizontal layout' + 'vertical layout' + ) + ]. + (aViewClass == VariableVerticalPanel) ifTrue:[ + ^ #( + 'handle position' + 'style' + ) + ]. + (aViewClass == ListView) ifTrue:[ + ^ #( + 'contents' + ) + ]. + (aViewClass == SelectionInListView) ifTrue:[ + ^ #( + 'press action' + ) + ]. + (aViewClass == EditField) ifTrue:[ + ^#( + 'initialText' + 'field type' + 'field length' + ) + ]. + (aViewClass == View) ifTrue:[ + ^ #( + 'level' + 'view background-color' + ) + ]. + (aViewClass == Scroller) ifTrue:[ + ^ #( + 'scroll action' + 'asynchronous' + 'synchronous' + ) + ]. + (aViewClass == ScrollBar) ifTrue:[ + ^ #( + 'scroll action' + 'scrollDown action' + 'scrollUp action' + 'asynchronous' + 'synchronous' + ) + ]. + (aViewClass == HorizontalScrollBar) ifTrue:[ + ^ #( + 'scrollLeft action' + 'scrollRight action' + ) + ]. + (aViewClass == PullDownMenu) ifTrue:[ + ^ #( + 'labels' + 'actions' + ) + ]. + (aViewClass == Separator) ifTrue:[ + ^ #( + 'orientation' + ) + ]. + ^ nil + + "Modified: 6.9.1995 / 13:42:09 / claus" +! + +rejectOutletsForClass:aViewClass + "return a list of suppressed outlets for a view-class" + + "could this be done automatically ?" + + (aViewClass == CheckToggle) ifTrue:[ + ^ #( + 'iconic-label' + ) + ]. + (aViewClass == CheckBox) ifTrue:[ + ^ #( + 'horizontal layout' + 'vertical layout' + ) + ]. + (aViewClass == HorizontalScrollBar) ifTrue:[ + ^ #( + 'scrollUp action' + 'scrollDown action' + ) + ]. + ^ nil + + "Modified: 4.9.1995 / 18:55:03 / claus" +! + +setupPropertyFromSpec:aSpec + "setup menu from spec + " + outletView := nil. + + specShown ~= aSpec ifTrue:[ + propertyFrame destroySubViews. + builder buildFromSpec:aSpec in:propertyFrame. + propertyFrame realizeAllSubViews. + ]. + specShown := aSpec +! + +showOutletsFor:aView + |c outlets| + + outletView isNil ifTrue:[^ self]. + + (aView isKindOf:SimpleView) ifFalse:[ + outletView list:nil. + ^ self + ]. + c := aView class. + + outlets := self listOfOutletsFor:c. + outletView list:outlets + + "Modified: 5.9.1995 / 21:51:57 / claus" +! ! + +!UIPainter methodsFor:'private - fetch'! + +fetchLayoutFrom:aView + |layout extent| + + layout := aView geometryLayout. + layout isNil ifTrue:[^ self]. + + layout isLayout ifFalse:[ + layout isRectangle ifTrue:[ + leftOffsetHolder value:(layout left). + rightOffsetHolder value:(layout right). + topOffsetHolder value:(layout top). + bottomOffsetHolder value:(layout bottom). + ^ self + ]. + layout isPoint ifTrue:[ + leftOffsetHolder value:(layout left). + rightOffsetHolder value:(layout right). + ^ self + ]. + ]. + + leftOffsetHolder value:(layout leftOffset). + leftFractionHolder value:(layout leftFraction). + topFractionHolder value:(layout topFraction). + topOffsetHolder value:(layout topOffset). + + layout isLayoutFrame ifTrue:[ + rightOffsetHolder value:(layout rightOffset). + bottomOffsetHolder value:(layout bottomOffset). + rightFractionHolder value:(layout rightFraction). + bottomFractionHolder value:(layout bottomFraction). + + leftAlignmentFractionHolder value:0. + topAlignmentFractionHolder value:0. + + ] ifFalse:[ + extent := aView extent. + + rightOffsetHolder value:(layout leftOffset + extent x). + bottomOffsetHolder value:(layout topOffset + extent y). + + rightFractionHolder value:0. + bottomFractionHolder value:0. + + layout isAlignmentOrigin ifTrue:[ + leftAlignmentFractionHolder value:(layout leftAlignmentFraction). + topAlignmentFractionHolder value:(layout topAlignmentFraction) + ] ifFalse:[ + leftAlignmentFractionHolder value:0. + topAlignmentFractionHolder value:0 + ] + ]. + + +! + +fetchModelAspectsFrom:aView + aspectChannel value:(workView aspectSelectorForView:aView). + changeChannel value:(workView changeSelectorForView:aView). + +! ! + +!UIPainter methodsFor:'setup choices'! + +showAllWidgets + "create list of basic widgets" + + self showWidgetsWhere:[:class | true] +! + +showBasicWidgets + "create list of basic widgets" + + self showWidgetsInCategory:'Views-Basic' + butNot:[:class | class isKindOf:ModalBox class] +! + +showInteractorWidgets + "create list of interactor widgets" + + self showWidgetsInCategory:'Views-Interactors' + butNot:[:class | class isKindOf:ModalBox class] +! + +showLayoutWidgets + "create list of basic widgets" + + self showWidgetsInCategory:'Views-Layout' + butNot:[:class | class isKindOf:ModalBox class] +! + +showModalWidgets + "create list of modal widgets" + + self showWidgetsWhere:[:class | class isKindOf:ModalBox class] +! + +showOtherWidgets + "create list of other widgets" + + |check cat| + + check := [:class | + (#('Views-Basic' + 'Views-Interactors' + 'Views-Layout' + 'Views-Text') includes:class category) not]. + self showWidgetsWhere:check + butNot:[:class | class isKindOf:ModalBox class] +! + +showTextWidgets + "create list of basic widgets" + + self showWidgetsInCategory:'Views-Text' + butNot:[:class | class isKindOf:ModalBox class] +! + +showWidgetsInCategory:aCategory + "create list of basic widgets" + + self showWidgetsWhere:[:class | class category = aCategory] +! + +showWidgetsInCategory:aCategory butNot:excludeBlock + "create list of basic widgets" + + self showWidgetsWhere:[:class | class category = aCategory] + butNot:excludeBlock +! + +showWidgetsWhere:aBlock + "create list of widgets where aBlock avaluates to true" + + self showWidgetsWhere:aBlock butNot:[:class | false] +! + +showWidgetsWhere:aBlock butNot:excludeBlock + "create list of widgets where aBlock evaluates to true and excludeBlock + evaluates to false" + + |list| + + list := OrderedCollection new:0. + SimpleView allSubclassesDo:[:aSubclass | + (aBlock value:aSubclass) ifTrue:[ + (excludeBlock value:aSubclass) ifFalse:[ + list add:(aSubclass name) + ] + ] + ]. + (aBlock value:View) ifTrue:[ + (excludeBlock value:View) ifFalse:[ + list add:'View' + ] + ]. + (list size == 0) ifFalse:[ + list sort + ]. + elementMenu list:list +! ! + +!UIPainter methodsFor:'user actions - dimension'! + +setAlignmentOrigin + "apply is pressed in the geometry-sub view, with a alignmentOrigin selected + " + self setupPropertyFromSpec:(self class geometrySpecForAlignmentOrigin) +! + +setDimensionForAlignmentOrigin + |view layout| + + view := workView singleSelection. + + view notNil ifTrue:[ + layout := AlignmentOrigin new. + + layout leftOffset:(leftOffsetHolder value) ? 0. + layout topOffset:(topOffsetHolder value) ? 0. + layout leftFraction:(leftFractionHolder value) ? 0. + layout topFraction:(topFractionHolder value) ? 0. + + layout leftAlignmentFraction:(leftAlignmentFractionHolder value) ? 0. + layout topAlignmentFraction:(topAlignmentFractionHolder value) ? 0. + + workView setDimension:layout. + ] +! + +setDimensionForLayoutFrame + |view layout| + + view := workView singleSelection. + + view notNil ifTrue:[ + layout := LayoutFrame new. + + layout leftOffset:(leftOffsetHolder value) ? 0. + layout rightOffset:(rightOffsetHolder value) ? 0. + layout topOffset:(topOffsetHolder value) ? 0. + layout bottomOffset:(bottomOffsetHolder value) ? 0. + layout leftFraction:(leftFractionHolder value) ? 0. + layout rightFraction:(rightFractionHolder value) ? 0. + layout topFraction:(topFractionHolder value) ? 0. + layout bottomFraction:(bottomFractionHolder value) ? 0. + + workView setDimension:layout. + ] +! + +setDimensionForLayoutOrigin + |view layout| + + view := workView singleSelection. + + view notNil ifTrue:[ + layout := LayoutOrigin new. + + layout leftOffset:(leftOffsetHolder value) ? 0. + layout topOffset:(topOffsetHolder value) ? 0. + + layout leftFraction:(leftFractionHolder value) ? 0. + layout topFraction:(topFractionHolder value) ? 0. + + workView setDimension:layout. + ] +! + +setLayoutFrame + "apply is pressed in the geometry-sub view, with a layoutFrame selected + " + self setupPropertyFromSpec:(self class geometrySpecForLayoutFrame) +! + +setLayoutOrigin + "apply is pressed in the geometry-sub view, with a layoutOrigin selected + " + self setupPropertyFromSpec:(self class geometrySpecForLayoutOrigin) +! ! + +!UIPainter methodsFor:'user actions - form'! + +alignOff + |m| + + m := menu menuAt:#form. + m labelAt:#alignOff put:(resources string:'align to grid'). + m selectorAt:#alignOff put:#alignOn. + workView alignOff +! + +alignOn + |m| + + m := menu menuAt:#form. + m labelAt:#alignOn put:(resources string:'do not align to grid'). + m selectorAt:#alignOn put:#alignOff. + workView alignOn +! + +toggleGrid + |m| + + m := menu menuAt:#form. + + workView gridShown ifFalse:[ + m labelAt:#toggleGrid put:(resources string:'hide grid'). + workView showGrid + ] ifTrue:[ + m labelAt:#toggleGrid put:(resources string:'show grid'). + workView hideGrid + ] +! ! + +!UIPainter methodsFor:'user interaction'! + +closeRequest + workView notNil ifTrue:[workView release]. + fileBox notNil ifTrue:[fileBox destroy]. + stringBox notNil ifTrue:[stringBox destroy]. + actionBox notNil ifTrue:[actionBox destroy]. + listBox notNil ifTrue:[listBox destroy]. + super closeRequest +! + +doCompile + |code| + + code := workView generateCode. + (ReadStream on:code) fileIn. + + "Modified: 4.9.1995 / 17:06:10 / claus" +! + +doFinish + self closeRequest +! + +doFromClass + |className methodName cls sel accepted failed spec s| + + className := '' asValue. + methodName := '' asValue. + (s := workView className) notNil ifTrue:[ + className value:s + ]. + (s := workView methodName) notNil ifTrue:[ + methodName value:s + ]. + + failed := false. + [ + accepted := + (DialogBox new + addTextLabel:'Classes name:'; + addInputFieldOn:className; + addVerticalSpace; + addTextLabel:'methods name:'; + addInputFieldOn:methodName; + addAbortButton; + addOkButton; + open + ) accepted. + + accepted ifTrue:[ + cls := Smalltalk classNamed:className value. + cls isNil ifTrue:[ + failed := true. + self warn:'no such class'. + ] ifFalse:[ + sel := methodName value asSymbol. + (cls respondsTo:sel ) ifFalse:[ + failed := true. + self warn:'no such method' + ] ifTrue:[ + spec := cls perform:sel. + spec isArray ifFalse:[ + failed := true. + self warn:'not a windowSpec method' + ]. + "/ ok, got it + workView className:className value. + workView methodName:methodName value. + workView setupFromSpec:spec. + ^ self + ] + ] + ] + ] doWhile:[accepted and:[failed]]. + + "Modified: 5.9.1995 / 18:47:57 / claus" +! + +doNew + workView removeAll. + ^ self + + "Modified: 5.9.1995 / 20:52:21 / claus" +! + +doOpen + fileBox isNil ifTrue:[ + fileBox := FileSelectionBox + title:'' + "pattern:'*.sib'" + okText:'' + abortText:(Resource name:'BUILDER_ABORT_LABEL' + fromFile:'Builder.rs') + action:[nil] + ]. + fileBox title:(Resource name:'BUILDER_OPEN_TITLE' fromFile:'Builder.rs'). + fileBox action:[:fileName | self openFile:fileName]. + fileBox okText:(Resource name:'BUILDER_OPEN_OK_LABEL' fromFile:'Builder.rs'). + fileBox showAtPointer +! + +doPickAView + |view className methodName cls sel accepted spec s| + + view := Display viewFromUser. + view isNil ifTrue:[^ self]. + + spec := UISpecification fromView:view topView. + + "/ ok, got it + workView setupFromSpec:spec. + workView className:view class name. + workView methodName:#newSpec. + ^ self + + "Modified: 5.9.1995 / 23:25:53 / claus" +! + +doPrint + ^ self +! + +doSave + currentFileName notNil ifTrue:[ + self saveAs:currentFileName + ] ifFalse:[ + self doSaveAs + ] +! + +doSaveAs + fileBox isNil ifTrue:[ + fileBox := FileSelectionBox + title:'' + "pattern:'*.draw'" + okText:'' + abortText:(Resource name:'BUILDER_ABORT_LABEL' + fromFile:'Builder.rs') + action:[nil] + ]. + fileBox title:(Resource name:'BUILDER_SAVE_TITLE' fromFile:'Builder.rs'). + fileBox action:[:fileName | self saveAs:fileName]. + fileBox okText:(Resource name:'BUILDER_SAVE_OK_LABEL' fromFile:'Builder.rs'). + fileBox showAtPointer +! + +doSource + |code v| + + code := workView generateCode. + v := CodeView open. + v contents:code. + v label:(workView applicationName). + ^ self + + "Modified: 5.9.1995 / 21:02:05 / claus" +! + +doWindowSpec + |code v| + + code := workView generateWindowSpec. + v := CodeView open. + v contents:code. + v label:'windowSpec'. + ^ self + + "Modified: 5.9.1995 / 21:04:14 / claus" +! + +propertySelectionChanged + workView singleSelectionDo:[:selectedView | + propertyShown := whichProperty selection. + self showPropertyView + ] +! + +selectOutlet:nr + |outlet type sel text box action initialText initialList + view prop t val| + + outlet := outletView selectionValue. + outletView deselect. + view := workView selection. + view isNil ifTrue:[ + self notify:'select something first'. + ^ self + ]. + action := [:s | self setOutlet:sel type:type to:s in:view]. + (outlet = 'label') ifTrue:[ + type := #string. + sel := #label:. + text := 'label-text:'. + initialText := view label + ]. + (outlet = 'fixed size') ifTrue:[ + type := #boolean. + sel := #sizeFixed:. + text := 'size is fix:'. + ]. + (outlet = 'frame shown') ifTrue:[ + type := #boolean. + sel := #showFrame:. + text := 'frame is to be drawn:'. + ]. + (outlet = 'labels') ifTrue:[ + type := #strings. + sel := #labels:. + initialText := view labels + ]. + (outlet = 'contents') ifTrue:[ + type := #text. + sel := #contents:. + initialText := view contents + ]. + (outlet = 'initialText') ifTrue:[ + type := #string. + sel := #initialText:. + initialText := view contents + ]. + (outlet = 'field type') ifTrue:[ + type := #fieldTypeSymbol. + sel := #type:. + initialList := #(number + string + password + ). + initialText := view converter isNil ifTrue:[#string] ifFalse:[view converter type]. + ]. + (outlet = 'field length') ifTrue:[ + type := #numberOrNil. + sel := #maxChars:. + text := 'field length (empty -> unlimited)'. + initialText := view maxChars isNil ifTrue:[''] ifFalse:[view maxChars printString]. + ]. + (outlet = 'level') ifTrue:[ + type := #number. + sel := #level:. + initialText := view level printString + ]. + (outlet = 'active level') ifTrue:[ + type := #number. + sel := #onLevel:. + initialText := view onLevel printString + ]. + (outlet = 'passive level') ifTrue:[ + type := #number. + sel := #offLevel:. + initialText := view offLevel printString + ]. + (outlet = 'iconic-label') ifTrue:[ + type := #form. + sel := #label:. + text := 'label-icon:' + ]. + (outlet = 'view background-color') ifTrue:[ + type := #color. + sel := #viewBackground:. + text := 'view background color'. + initialText := 'Black' + ]. + (outlet = 'foreground-color') ifTrue:[ + type := #color. + sel := #foregroundColor:. + text := 'foreground color'. + initialText := 'Black' + ]. + (outlet = 'background-color') ifTrue:[ + type := #color. + sel := #backgroundColor:. + text := 'background color'. + initialText := 'Grey' + ]. + (outlet = 'active foreground-color') ifTrue:[ + type := #color. + sel := #activeForegroundColor:. + text := 'active foreground color'. + initialText := 'Yellow' + ]. + (outlet = 'active background-color') ifTrue:[ + type := #color. + sel := #activeBackgroundColor:. + text := 'active background color'. + initialText := 'Grey' + ]. + (outlet = 'scroll action') ifTrue:[ + type := #block. + sel := #scrollAction:. + text := 'action block when scrolled' + ]. + (outlet = 'scrollUp action') ifTrue:[ + type := #block. + sel := #scrollUpAction:. + text := 'action block when scrolled up' + ]. + (outlet = 'scrollDown action') ifTrue:[ + type := #block. + sel := #scrollDownAction:. + text := 'action block when scrolled down' + ]. + (outlet = 'scrollLeft action') ifTrue:[ + type := #block. + sel := #scrollLeftAction:. + text := 'action block when scrolled left' + ]. + (outlet = 'scrollRight action') ifTrue:[ + type := #block. + sel := #scrollRightAction:. + text := 'action block when scrolled right' + ]. + (outlet = 'press action') ifTrue:[ + type := #block. + sel := #pressAction:. + text := 'action block when pressed' + ]. + (outlet = 'release action') ifTrue:[ + type := #block. + sel := #releaseAction:. + text := 'action block when released' + ]. + (outlet = 'style') ifTrue:[ + type := #symbol. + sel := #style:. + initialList := #(motif next) + ]. + (outlet = 'handle position') ifTrue:[ + type := #symbol. + sel := #handlePosition:. + initialList := #(left center right) + ]. + (outlet = 'horizontal layout') ifTrue:[ + type := #symbol. + sel := #horizontalLayout:. + text := 'horizontal components layout'. + initialList := #(left + leftSpace + leftMax + leftSpaceMax + center + centerMax + right + rightSpace + rightMax + rightSpaceMax + spread + spreadSpace + spreadMax + spreadSpaceMax + fit + fitSpace). + initialText := view horizontalLayout printString + ]. + (outlet = 'vertical layout') ifTrue:[ + type := #symbol. + sel := #verticalLayout:. + text := 'vertical components layout'. + initialList := #(top + topSpace + center + bottom + bottomSpace + spread + spreadSpace + fit + fitSpace). + initialText := view verticalLayout printString + ]. + (outlet = 'label position') ifTrue:[ + type := #symbol. + sel := #labelPosition:. + initialList := #(topLeft topCenter topRight bottomLeft bottomCenter bottomRight). + initialText := view labelPosition printString + ]. + (outlet = 'label layout') ifTrue:[ + type := #symbol. + sel := #adjust:. + initialList := #( left right center centerLeft centerRight fit ). + initialText := view adjust printString + ]. + (outlet = 'orientation') ifTrue:[ + type := #symbol. + sel := #orientation:. + initialList := #( horizontal vertical ). + initialText := view orientation printString + ]. + + (type == #color) ifTrue:[ + initialList := #('Black' + 'White' + 'LightGrey' + 'Grey' + 'DarkGrey' + 'Yellow' + 'Red' + 'Green' + 'Blue' + ) + ]. + + text isNil ifTrue:[ + text := outlet + ]. + + "what type of box do we need" + + t := type. + ((type == #color) or:[type == #symbol or:[type == #fieldTypeSymbol]]) ifTrue:[ + t := #list + ]. + ((type == #number) or:[type == #numberOrNil]) ifTrue:[ + t := #string + ]. + (type == #strings) ifTrue:[ + t := #text + ]. + (type == #block) ifTrue:[ + t := #text. + initialText := workView outletValueOf:sel for:view. + initialText isNil ifTrue:[initialText := '[statements]'] + ]. + (type == #block1) ifTrue:[ + t := #text. + type := #block. + initialText := workView outletValueOf:sel for:view. + initialText isNil ifTrue:[initialText := '[:argument | statements ]'] + ]. + (type == #block2) ifTrue:[ + t := #text. + type := #block. + initialText := workView outletValueOf:sel for:view. + initialText isNil ifTrue:[initialText := '[:arg1 :arg2 | statements ]'] + ]. + + "show a box to enter thing" + + (t == #boolean) ifTrue:[ + val := Dialog confirmWithCancel:text. + (val == true or:[val == false]) ifTrue:[ + action value:val + ]. + ^ self + ]. + (t == #string) ifTrue:[ +"/ stringBox isNil ifTrue:[ + stringBox := EnterBox new. +"/ ]. + box := stringBox + ]. + (t == #list) ifTrue:[ +"/ listBox isNil ifTrue:[ + listBox := ListSelectionBox new. +"/ ]. + listBox list:initialList. + box := listBox + ]. + (t == #text) ifTrue:[ +"/ actionBox isNil ifTrue:[ + actionBox := TextBox new. +"/ ]. + actionBox initialText:initialText. + box := actionBox + ]. +" +Transcript show:'outlet: '. Transcript showCR:outlet. +Transcript show:'type: '. Transcript showCR:type. +Transcript show:'sel: '. Transcript showCR:sel. +Transcript show:'text: '. Transcript showCR:text. +" + + box isNil ifTrue:[ + self notify:'not yet implemented' + ] ifFalse:[ + box initialText:initialText. + box title:text. + box action:action. + box showAtPointer + ] + + "Modified: 6.9.1995 / 13:46:29 / claus" +! + +setColors + |fg bg| + + fg := fgChannel value. + (fg notNil and:[fg notEmpty]) ifTrue:[ + fg := Color readFrom:fg. + workView singleSelectionDo:[:selectedView | + selectedView ~~ workView ifTrue:[ + selectedView foregroundColor:fg + ]. + ]. + ]. + bg := bgChannel value. + (bg notNil and:[bg notEmpty]) ifTrue:[ + bg := Color readFrom:bg. + workView singleSelectionDo:[:selectedView | + selectedView ~~ workView ifTrue:[ + selectedView backgroundColor:bg + ]. + ]. + ]. +! + +setMiscAspects + "sent when apply is pressen in the misc-sub view" + + workView singleSelectionDo:[:selectedView | + selectedView ~~ workView ifTrue:[ + workView changeVariableNameOf:selectedView to:nameChannel value + ] + ]. +! + +setModelAspects + "sent when apply is pressen in the model-sub view" + + |aspectSymbol| + + aspectSymbol := aspectChannel value. + (aspectSymbol notNil and:[aspectSymbol notEmpty]) ifTrue:[ + aspectSymbol := aspectSymbol asSymbol. + workView singleSelectionDo:[:selectedView | + selectedView ~~ workView ifTrue:[ + workView setAspectSelector:aspectSymbol forView:selectedView + ]. + ]. + ]. +! + +setOutlet:outletSymbol type:type to:outletValue in:aView + |block val messageSymbol| + + messageSymbol := outletSymbol. + val := outletValue. + (type == #block) ifTrue:[ + block := Compiler evaluate:val. + (block == #Error) ifTrue:[ + self warn:'action will not work in test-mode'. + workView addOutletDefinitionFor:outletSymbol + type:type + value:outletValue + for:aView. + ^ self + ]. + val := block + ]. + (type == #number) ifTrue:[ + val := Number readFromString:outletValue onError:0 + ]. + (type == #numberOrNil) ifTrue:[ + val := Number readFromString:outletValue onError:nil + ]. + (type == #text) ifTrue:[ + val := outletValue asString + ]. + (type == #strings) ifTrue:[ + val := outletValue asText + ]. + (type == #symbol) ifTrue:[ + val := outletValue asSymbol. + ]. + (type == #fieldTypeSymbol) ifTrue:[ + val := outletValue asSymbol. + val == #password ifTrue:[ + aView passwordCharacter:$* + ] ifFalse:[ + aView passwordCharacter:nil + ]. + val := (PrintConverter new initFor:val). + messageSymbol := #converter: + ]. + (type == #color) ifTrue:[ + val := Color name:outletValue. + val isNil ifTrue:[ + self warn:('no such color:' , outletValue). + ^ self + ] + ]. +Transcript show:(val printString). +Transcript showCR:('(' , val class printString , ')'). + + workView selectionHiddenDo:[ + aView perform:messageSymbol with:val. + workView elementChanged:aView. + aView redraw. + ]. + workView addOutletDefinitionFor:outletSymbol + type:type + value:outletValue + for:aView + + "Modified: 6.9.1995 / 13:44:46 / claus" +! + +showPropertyView + |v l spec| + + workView singleSelectionDo:[:selectedView | + propertyShown = 'dimension' ifTrue:[ + (l := selectedView geometryLayout) notNil ifTrue:[ + l isLayout ifTrue:[ + l isAlignmentOrigin ifTrue:[ + spec := self class geometrySpecForAlignmentOrigin + ] ifFalse:[ + l isLayoutFrame ifFalse:[ + spec := self class geometrySpecForLayoutOrigin + ] + ] + ] + ]. + spec isNil ifTrue:[ + spec := self class geometrySpecForLayoutFrame + ]. + ^ self setupPropertyFromSpec:spec + ]. + + propertyShown = 'colors' ifTrue:[ + ^ self setupPropertyFromSpec:(self class colorSpec) + ]. + + propertyShown = 'model' ifTrue:[ + ^ self setupPropertyFromSpec:(self class modelSpec) + ]. + + propertyShown = 'misc' ifTrue:[ + ^ self setupPropertyFromSpec:(self class miscSpec) + ]. + + propertyShown = 'attribute list' ifTrue:[ + specShown ~~ #attributeList ifTrue:[ + propertyFrame destroySubViews. + v := ScrollableView for:SelectionInListView in:propertyFrame. + v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). + outletView := v scrolledView. + outletView action:[:lineNr | lineNr notNil ifTrue:[self selectOutlet:lineNr]]. + propertyFrame realizeAllSubViews. + specShown := #attributeList. + ]. + self showOutletsFor:(workView selection). + ^ self + ]. + ]. + + propertyFrame destroySubViews. + outletView := nil. + specShown := nil. + +! + +toggleTest + |m t| + + m := menu menuAt:#test. + t := workView testMode not. + + t ifTrue:[ + m labelAt:#toggleTest put:(resources string:'test off') + ] ifFalse:[ + m labelAt:#toggleTest put:(resources string:'test on') + ]. + workView testMode:t +! ! + +!UIPainter class methodsFor:'documentation'! + +version + ^ '$Header$' +! !