diff -r 04e802a6a920 -r cfbbec0a33c6 UIPainter.st --- a/UIPainter.st Mon Mar 30 14:45:46 1998 +0200 +++ b/UIPainter.st Mon Mar 30 14:47:36 1998 +0200 @@ -46,9 +46,8 @@ documentation " - GUI-Builder: - this class allows the user to build its own applications providing a graphical - user interface to buildin components and to define the behavior of the components + The GUI Painter allows the user to build its own applications providing a graphical + user interface to building components and to define the behavior of the components during runtime. The resulting specifications can be installed as methods on classes, typically subclasses of an ApplicationModel. These specifications are used by the UIBuilder to generate the application window and its component @@ -195,6 +194,9 @@ #editInspectSpec 'Opens an inspector on the spec of the selected widget.' +#editInspectView +'Opens an inspector on the view of the selected widget.' + #editOpenSpecDocumentation 'Opens the documentation of the selected widget.' @@ -228,6 +230,18 @@ #generateHookMethods 'Generates startup/release methods. (#closeRequest, #postBuildWith:, #postOpenWith:)' +#helpExamples +'Opens a HTML-Browser on the documentation file with some examples of the GUI Painter.' + +#helpFunctions +'Opens a HTML-Browser on the documentation file with the functions of the GUI Painter.' + +#helpLayoutTool +'Opens a HTML-Browser on the documentation file of the Layout Tool.' + +#helpSelectedWidget +'Opens a HTML-Browser on the documentation file of the selected widget.' + #moveWidgetDown 'Moves the selected widget one step down.' @@ -590,7 +604,7 @@ #name: 'AlignCheckBox' #layout: #(#Point 23 52) #model: #alignToGrid - #label: 'Align to Grid' + #label: 'Align To Grid' ) #(#LabelSpec #name: 'HorizontalPixelsLabel' @@ -655,11 +669,11 @@ #window: #(#WindowSpec #name: 'GUI Painter' - #layout: #(#LayoutFrame 50 0 310 0 579 0 796 0) + #layout: #(#LayoutFrame 123 0 269 0 662 0 743 0) #label: 'GUI Painter' - #min: #(#Point 10 10) + #min: #(#Point 540 490) #max: #(#Point 1160 870) - #bounds: #(#Rectangle 50 310 580 797) + #bounds: #(#Rectangle 123 269 663 744) #menu: #menu #usePreferredExtent: false ) @@ -766,17 +780,17 @@ #verticalSpace: 0 ) #(#ActionButtonSpec - #name: 'openSpecDocumentationButton' + #name: 'openWidgetDocumentationButton' #layout: #(#LayoutFrame -32 1 -1 0 0 1 31 0) #activeHelpKey: #editOpenSpecDocumentation #hasCharacterOrientedLabel: false #label: 'helpIcon' - #model: #openSpecDocumentation + #model: #openWidgetDocumentation ) #(#ActionButtonSpec #name: 'cancelButton' #layout: #(#LayoutFrame 2 0 -26 1 -1 0.5 -2 1) - #activeHelpKey: #cancel + #activeHelpKey: #commitCancel #label: 'Cancel' #tabable: true #model: #cancel @@ -785,7 +799,7 @@ #(#ActionButtonSpec #name: 'acceptButton' #layout: #(#LayoutFrame 1 0.5 -26 1 -2 1 -2 1) - #activeHelpKey: #accept + #activeHelpKey: #commitOK #label: 'OK' #tabable: true #model: #accept @@ -815,7 +829,7 @@ "This resource specification was automatically generated by the UIPainter of ST/X." - "Do not manually edit this. If it is corrupted, + "Do not manually edit this!! If it is corrupted, the UIPainter may not be able to read the specification." " @@ -831,11 +845,11 @@ #window: #(#WindowSpec #name: 'GUI Painter' - #layout: #(#LayoutFrame 575 0 296 0 1127 0 833 0) + #layout: #(#LayoutFrame 177 0 249 0 716 0 723 0) #label: 'GUI Painter' #min: #(#Point 10 10) #max: #(#Point 1160 870) - #bounds: #(#Rectangle 575 296 1128 834) + #bounds: #(#Rectangle 177 249 717 724) #menu: #menu #usePreferredExtent: false ) @@ -961,7 +975,7 @@ #tabable: true #model: #cancel #enableChannel: #modifiedChannel - #extent: #(#Point 183 24) + #extent: #(#Point 178 24) ) #(#ActionButtonSpec #name: 'acceptButton' @@ -970,7 +984,7 @@ #tabable: true #model: #accept #enableChannel: #modifiedChannel - #extent: #(#Point 183 24) + #extent: #(#Point 179 24) ) ) ) @@ -1077,7 +1091,7 @@ ) #(#MenuItem #label: 'Define Class And Selector...' - #value: #defineClassAndSelector + #value: #doDefineClassAndSelector #activeHelpKey: #fileSaveAs ) #(#MenuItem @@ -1220,10 +1234,11 @@ #label: 'Undo Manager...' #value: #openUndoMenu #activeHelpKey: #settingsUndoManager + #enabled: #hasUndoHistory ) #(#MenuItem #label: 'Grid Manager...' - #value: #gridMenu + #value: #doDefineGrid #activeHelpKey: #settingsGridManager ) ) nil @@ -1243,7 +1258,6 @@ #( #(#MenuItem #label: 'Tutorial' - #translateLabel: true #value: #openHTMLDocument: #activeHelpKey: #helpTutorial #argument: 'tools/uipainter/TOP.html' @@ -1253,24 +1267,45 @@ ) #(#MenuItem #label: 'Functions' - #translateLabel: true #value: #openHTMLDocument: - #activeHelpKey: #helpTutorial + #activeHelpKey: #helpFunctions #argument: 'tools/uipainter/Functions.html' ) #(#MenuItem #label: 'Examples' - #translateLabel: true #value: #openHTMLDocument: - #activeHelpKey: #helpTutorial + #activeHelpKey: #helpExamples #argument: 'tools/uipainter/Examples.html' ) #(#MenuItem #label: '-' ) #(#MenuItem + #label: 'Help Tool' + #value: #openHTMLDocument: + #activeHelpKey: #helpHelpTool + #argument: 'tools/uipainter/HelpTool.html' + ) + #(#MenuItem + #label: 'Layout Tool' + #value: #openHTMLDocument: + #activeHelpKey: #helpLayoutTool + #argument: 'tools/uipainter/Layout.html' + ) + #(#MenuItem + #label: '-' + ) + #(#MenuItem + #label: 'Selected Widget' + #value: #openWidgetDocumentation + #activeHelpKey: #helpSelectedWidget + #enabled: #hasOneSelectionOtherThanCanvas + ) + #(#MenuItem + #label: '-' + ) + #(#MenuItem #label: 'Show Help Texts' - #translateLabel: true #activeHelpKey: #helpShowHelp #indication: #showHelp: ) @@ -1398,7 +1433,7 @@ "This resource specification was automatically generated by the MenuEditor of ST/X." - "Do not manually edit this. If it is corrupted, + "Do not manually edit this!! If it is corrupted, the MenuEditor may not be able to read the specification." " @@ -1466,6 +1501,7 @@ ) #(#MenuItem #label: 'Move' + #enabled: #canMoveSelection #submenuChannel: #menuMove ) #(#MenuItem @@ -1543,11 +1579,20 @@ #label: '-' ) #(#MenuItem - #label: 'Open Spec Documentation' - #value: #openSpecDocumentation + #label: 'Open Widget Documentation' + #value: #openWidgetDocumentation #activeHelpKey: #editOpenSpecDocumentation ) #(#MenuItem + #label: '-' + ) + #(#MenuItem + #label: 'Inspect View' + #value: #inspectView + #activeHelpKey: #editInspectView + #enabled: #hasOneSelectionOtherThanCanvas + ) + #(#MenuItem #label: 'Inspect Spec' #value: #inspectSpec #activeHelpKey: #editInspectSpec @@ -1561,7 +1606,7 @@ "This resource specification was automatically generated by the MenuEditor of ST/X." - "Do not manually edit this. If it is corrupted, + "Do not manually edit this!! If it is corrupted, the MenuEditor may not be able to read the specification." " @@ -1580,14 +1625,14 @@ #label: 'Up' #value: #doStepUp #activeHelpKey: #moveWidgetUp - #enabled: #canMoveOrAlignSelection + #enabled: #canChangeOrderInContainer #labelImage: #(#ResourceRetriever #ToolApplicationModel #upIcon 'Up') ) #(#MenuItem #label: 'Down' #value: #doStepDown #activeHelpKey: #moveWidgetDown - #enabled: #canMoveOrAlignSelection + #enabled: #canChangeOrderInContainer #labelImage: #(#ResourceRetriever #ToolApplicationModel #downIcon 'Down') ) #(#MenuItem @@ -1837,16 +1882,16 @@ ! transcriptHelp - "get whether the help transcript is turned on/off + "answer whether the help transcript is turned on/off " - ^self class settings at: #transcriptHelp - ifAbsent: [self class settings at: #transcriptHelp put: false] + ^self class settings at: #TranscriptHelp + ifAbsent: [self class settings at: #TranscriptHelp put: false] ! transcriptHelp:aBoolean "turn on/off the help transcript " - self class settings at: #transcriptHelp put: aBoolean + self class settings at: #TranscriptHelp put: aBoolean ! ! @@ -1934,6 +1979,10 @@ key := spec activeHelpKey. ]. self helpTool helpKey:key. + + treeView isCanvasSelected ifTrue: [ + spec := treeView canvasSpec. + ]. self specTool specification:spec. view := self layoutTool layoutView. @@ -1951,7 +2000,7 @@ |spec| - (spec := self painter specForSelection) isNil ifTrue:[ + (spec := self specForSelection) isNil ifTrue:[ treeView isCanvasSelected ifTrue:[ spec := treeView canvasSpec. ] @@ -1960,8 +2009,20 @@ spec inspect ] - "Created: / 10.3.1998 / 18:11:42 / stefan" - "Modified: / 10.3.1998 / 18:19:55 / stefan" + +! + +inspectView + "inspect the view of the selected specification" + + |selection view| + + ((selection := self painter selection) isCollection and: [selection size >= 1]) ifTrue:[ + selection first inspect + ] ifFalse: [ + selection inspect + ] + ! moveSelectionDown @@ -1991,19 +2052,24 @@ ! -openSpecDocumentation - "open documentation for the selected specification" - - |spec| - - (spec := self painter specForSelection) isNil ifTrue:[ +openWidgetDocumentation + "open documentation for the selected widget" + + |spec document| + + (spec := self specForSelection) isNil ifTrue:[ treeView isCanvasSelected ifTrue:[ - spec := treeView canvasSpec. + spec := nil ] ]. spec notNil ifTrue:[ - HTMLDocumentView openFullOnDocumentationFile: 'tools/uipainter/', spec userFriendlyName,'.html' - ] + document := 'tools/uipainter/Widgets/', spec userFriendlyName,'.html' + ] ifFalse: [ + document := 'tools/uipainter/TOP.html#THEWIDGETSANDHOWDOTHEYWORK' + ]. + HTMLDocumentView openFullOnDocumentationFile: document + + ! ! !UIPainter methodsFor:'aspects'! @@ -2028,6 +2094,13 @@ ^ builder booleanValueAspectFor:#canMoveOrAlignSelection ! +canMoveSelection + + ^self canChangeOrderInContainer value | + self canMoveSelectionOutOfContainer value | + self canMoveSelectionOutOfContainer value +! + canMoveSelectionIntoContainer "returns a boolean value holder which is true in case that one component is selected and can change its container widget to the next element in the list which will have @@ -2085,7 +2158,7 @@ noteBook := View new. layoutTool := UILayoutTool new. helpTool := UIHelpTool new. - helpTool helpSpecFrom:specClass. + helpTool buildFromClass:specClass. specTool := UISpecificationTool new. channel := self modifiedChannel. @@ -2133,8 +2206,7 @@ |holder| (holder := builder bindingAt:#tabList) isNil ifTrue:[ - builder aspectAt:#tabList put:(holder := ValueHolder new). - holder value:#( 'Properties' ). + builder aspectAt:#tabList put:(holder := #(Basics Details Layout) asValue). ]. ^ holder ! @@ -2547,83 +2619,6 @@ ^true ! -defineClassAndSelector - "launch a dialog to define class, superclass and method" - - |again tmp| - - [ - again := false. - - (tmp := specClass) isNil ifTrue:[tmp := 'NewApplication']. - aspects at:#classNameChannel put:tmp asValue. - - (tmp := specSelector) isNil ifTrue:[tmp := 'windowSpec']. - aspects at:#methodNameChannel put:tmp asValue. - - (tmp := specSuperclass) isNil ifTrue:[tmp := 'ApplicationModel']. - aspects at:#superclassNameChannel put:tmp asValue. - - (self openDialogInterface:#dialogSpecForDefiningClassAndSelector) ifTrue:[ - - specClass := (self aspectFor:#classNameChannel) value. - specSelector := (self aspectFor:#methodNameChannel) value. - specSelector notNil ifTrue:[specSelector := specSelector asSymbol]. - specSuperclass := (self aspectFor:#superclassNameChannel) value. - - (again := self checkClassAndSelector not) ifFalse:[ - self painter className:specClass - superclassName:specSuperclass - selector:specSelector. - ] - ] - ifFalse: - [ - ^nil - ] - - ] doWhile:[again]. - - self specClass:specClass. - self helpTool modified: true -! - -gridMenu - "open a dialog for grip parameters configuration - " - |hspace vspace bindings painter gridPara| - - painter := self painter. - bindings := IdentityDictionary new. - gridPara := painter gridParameters copy. - - bindings at:#showGrid put:(painter gridShown asValue). - bindings at:#alignToGrid put:(painter gridAlign asValue). - bindings at:#hspace put:((gridPara at:1) asValue). - bindings at:#vspace put:((gridPara at:2) asValue). - - (self openDialogInterface:#dialogSpecForDefiningGridParameters withBindings:bindings) ifFalse:[ - ^ self - ]. - - hspace := (bindings at:#hspace) value ? 5. - vspace := (bindings at:#vspace) value ? 5. - - gridPara at:1 put:hspace. - gridPara at:2 put:vspace. - gridPara at:5 put:hspace. - gridPara at:6 put:vspace. - - painter gridShown:false. - painter gridAlign:false. - painter gridParameters:gridPara. - painter gridAlign:(bindings at:#alignToGrid) value. - painter gridShown:(bindings at:#showGrid) value. - painter clear. - painter clear. - -! - hideUIView:aView "hide the view which is an application or top view " @@ -2663,7 +2658,7 @@ [(cls := self resolveName:(msg at:1)) notNil]) ifTrue: [ - specClass := cls name. + self specClass:cls. specSuperclass := cls superclass name. specSelector := (msg at: 2) asSymbol. ^true @@ -2718,9 +2713,11 @@ specClass := aClass isBehavior ifTrue:[aClass name] ifFalse:[aClass]. - self helpTool helpSpecFrom:specClass. - - "Modified: / 5.2.1998 / 09:42:57 / stefan" + + self helpTool buildFromClass:specClass. + self helpTool updateList. + self modifiedChannel value: false. + ! ! !UIPainter methodsFor:'private tools'! @@ -2878,13 +2875,23 @@ size := slices size. view notNil ifTrue:[ - list := Array new:(size + 2). - list at:(size + 2) put:(UILayoutTool label). + self treeView isCanvasSelected + ifFalse: + [ + list := Array new:(size + 2). + list at:(size + 2) put:(UILayoutTool label). + ] + ifTrue: + [ + list := Array new:(size + 1). + list at:(size + 1) put:(UILayoutTool label). + ]. ] ifFalse:[ list := Array new:(size + 1). ]. + 1 to:size do:[:i| list at:i put:((slices at:i) first asString)]. - list at:(size + 1) put:(UIHelpTool label). + self treeView isCanvasSelected ifFalse: [list at:(size + 1) put:(UIHelpTool label)]. self tabList value:list. self show:(spec class name). @@ -2910,7 +2917,7 @@ clipboard isCollection ifTrue:[clipboard notEmpty ifTrue:[sel := clipboard first]] ifFalse:[sel := clipboard]. - canPaste := (sel isKindOf:UISpecification) and: + canPaste := (sel isKindOf:UISpecification) and: [treeView selection size = 1 and:[treeView selection first == 1 or: [self canPasteInto: treeView selectedNode contents view]]] @@ -2918,7 +2925,7 @@ self valueOfCanCut value: canCutOrCopy. self valueOfCanCopy value: canCutOrCopy. - self valueOfCanPaste value: canPaste. + self valueOfCanPaste value: canPaste. self valueOfCanPasteWithKeepingLayout value: (canPaste & self canKeepLayoutInSelection). @@ -2984,7 +2991,7 @@ ifTrue: [ aSelector := readStream upToEnd asSymbol. - self setClass: aClass selector: aSelector. + self setClass: aClass selector: aSelector. (aClass respondsTo:aSelector) ifTrue: [ @@ -3054,9 +3061,8 @@ topView label:'GUI Painter'. painterView openInGroup:(topView windowGroup). - - painterView application:self. painterView open. + painterView application:self. painterView application:self. selectionPanel := UISelectionPanel new. @@ -3079,7 +3085,6 @@ selectionPanel window iconLabel:'GUI Painter'. selectionPanel window icon:(Image fromFile:'bitmaps/UIPainter.xbm' resolution:100). - ActiveHelp startFor:self. ! openOnClass:aClass @@ -3120,11 +3125,23 @@ postOpenWith: aBuilder + |painter settings gridPara hspace vspace| + super postOpenWith: aBuilder. treeView selection: (Array with: 1). - self treeSelection. - self tabSelection: 'Basics' + self treeSelection. + + painter := self painter. + settings := self class settings. + gridPara := painter gridParameters copy. + hspace := settings at: #HGridSpace ifAbsent: [10]. + vspace := settings at: #VGridSpace ifAbsent: [10]. + gridPara at:1 put:hspace; at:2 put:vspace; at:5 put:hspace; at:6 put:vspace. + painter gridParameters:gridPara. + painter gridShown: (settings at: #GridShown ifAbsent: [false]). + painter gridAlign: (settings at: #GridAlign ifAbsent: [false]). + painter clear. ! ! @@ -3186,6 +3203,96 @@ ] ! +doDefineClassAndSelector + "launch a dialog to define class, superclass, and selector" + + |again tmp helpDict helpKey| + + [ + again := false. + + (tmp := specClass) isNil ifTrue:[tmp := 'NewApplication']. + aspects at:#classNameChannel put:tmp asValue. + + (tmp := specSelector) isNil ifTrue:[tmp := 'windowSpec']. + aspects at:#methodNameChannel put:tmp asValue. + + (tmp := specSuperclass) isNil ifTrue:[tmp := 'ApplicationModel']. + aspects at:#superclassNameChannel put:tmp asValue. + + (self openDialogInterface:#dialogSpecForDefiningClassAndSelector) ifTrue:[ + + specClass := (self aspectFor:#classNameChannel) value. + specSelector := (self aspectFor:#methodNameChannel) value. + specSelector notNil ifTrue:[specSelector := specSelector asSymbol]. + specSuperclass := (self aspectFor:#superclassNameChannel) value. + + (again := self checkClassAndSelector not) ifFalse:[ + self painter className:specClass + superclassName:specSuperclass + selector:specSelector. + ] + ] + ifFalse: + [ + ^nil + ] + + ] doWhile:[again]. + + specClass := specClass isBehavior ifTrue:[specClass name] + ifFalse:[specClass]. + + helpDict := self helpTool dictionary. + helpKey := self helpTool helpKey. + self helpTool buildFromClass:specClass. + self helpTool dictionary declareAllFrom: helpDict. + self helpTool updateList. + self helpTool helpKey: helpKey. + self modifiedChannel value: false. + self helpTool modified: true. +! + +doDefineGrid + "open a dialog for grip parameters configuration + " + |hspace vspace bindings painter gridPara settings| + + painter := self painter. + bindings := IdentityDictionary new. + gridPara := painter gridParameters copy. + + bindings at:#showGrid put:((self class settings at: #GridShown ifAbsent: [painter gridShown]) asValue). + bindings at:#alignToGrid put:((self class settings at: #GridAlign ifAbsent: [painter gridAlign]) asValue). + bindings at:#hspace put:((gridPara at:1) asValue). + bindings at:#vspace put:((gridPara at:2) asValue). + + (self openDialogInterface:#dialogSpecForDefiningGridParameters withBindings:bindings) ifFalse:[ + ^ self + ]. + + hspace := (bindings at:#hspace) value ? 5. + vspace := (bindings at:#vspace) value ? 5. + + gridPara at:1 put:hspace. + gridPara at:2 put:vspace. + gridPara at:5 put:hspace. + gridPara at:6 put:vspace. + + painter gridShown:false. + painter gridAlign:false. + painter gridParameters:gridPara. + painter gridAlign:(bindings at:#alignToGrid) value. + painter gridShown:(bindings at:#showGrid) value. + settings := self class settings. + settings at: #GridShown put: (bindings at:#showGrid) value. + settings at: #GridAlign put: (bindings at:#alignToGrid) value. + settings at: #HGridSpace put: hspace. + settings at: #VGridSpace put: vspace. + painter clear. + +! + doGenerateAspectMethods "generate aspect and action methods " @@ -3194,7 +3301,7 @@ self treeSelection. "accept modifications" self hasSpecClassAndSelector ifFalse:[ - self defineClassAndSelector + self doDefineClassAndSelector ]. self checkClassAndSelector ifFalse:[ @@ -3218,7 +3325,7 @@ self treeSelection. "accept modifications" self hasSpecClassAndSelector ifFalse:[ - self defineClassAndSelector + self doDefineClassAndSelector ]. self checkClassAndSelector ifFalse:[ @@ -3287,7 +3394,7 @@ self painter removeAll. treeView canvas topView name: UIPainter defaultNameOfCanvas. treeView canvas topView label: UIPainter defaultNameOfCanvas. - self helpTool reset. + self helpTool doNew. treeView selection:#(1). self treeSelection. self updateInfoLabel. @@ -3330,7 +3437,7 @@ self treeSelection. "ask for modification" self hasSpecClassAndSelector ifFalse:[ - (self defineClassAndSelector) isNil ifTrue: [^nil] + (self doDefineClassAndSelector) isNil ifTrue: [^nil] ]. (specClass notNil and: [(Smalltalk at: specClass asSymbol) isClass]) @@ -3356,7 +3463,7 @@ selector:specSelector. code := painter generateWindowSpecMethodSource withCRs. - painter resetModification. + (ReadStream on:code) fileIn. self helpTool installHelpSpecsOnClass:specClass. @@ -3582,6 +3689,14 @@ ^ nil +! + +lastDrawnMaster + "returns the lastDrawnMaster + " + ^ lastDrawnMaster + + ! ! !UIPainter::TreeView methodsFor:'accessing property'! @@ -3937,7 +4052,7 @@ self model iconAction: [:aNode| - |specClass| + |specClass| (specClass := aNode contents spec) isNil ifTrue: [ @@ -3954,7 +4069,7 @@ [ specClass class icon ] - ] + ]. ]. self model labelAction: