UIPainter.st
changeset 533 dde823aeca4c
parent 527 6dc446339dc2
child 538 3d75219adb32
equal deleted inserted replaced
532:de091386bbae 533:dde823aeca4c
   159 #copyLayout
   159 #copyLayout
   160 'Copies layout of the selected widget.'
   160 'Copies layout of the selected widget.'
   161 
   161 
   162 #fileLoad
   162 #fileLoad
   163 'Opens dialog to load an interface from a class.'
   163 'Opens dialog to load an interface from a class.'
       
   164 
       
   165 #fileLoadSubspec
       
   166 'Opens dialog to load an subspec interface from a class.'
   164 
   167 
   165 #fileNew
   168 #fileNew
   166 'Creates new interface.'
   169 'Creates new interface.'
   167 
   170 
   168 #filePickAnInterface
   171 #filePickAnInterface
   660                 )
   663                 )
   661                  #(#UISubSpecification
   664                  #(#UISubSpecification
   662                     #'name:' 'infoBarSubSpec'
   665                     #'name:' 'infoBarSubSpec'
   663                     #'layout:' #(#LayoutFrame 0 0.0 -22 1 0 1.0 0 1.0)
   666                     #'layout:' #(#LayoutFrame 0 0.0 -22 1 0 1.0 0 1.0)
   664                     #'majorKey:' #ToolApplicationModel
   667                     #'majorKey:' #ToolApplicationModel
   665                     #'minorKey:' #windowSpecForInfoBar
   668                     #'minorKey:' #windowSpecForInfoBarWithClock
   666                 )
   669                 )
   667               )
   670               )
   668           )
   671           )
   669       )
   672       )
   670 ! !
   673 ! !
   712                       )
   715                       )
   713                        #(#MenuItem
   716                        #(#MenuItem
   714                           #'label:' 'Load...'
   717                           #'label:' 'Load...'
   715                           #'value:' #doFromClass
   718                           #'value:' #doFromClass
   716                           #'activeHelpKey:' #fileLoad
   719                           #'activeHelpKey:' #fileLoad
       
   720                       )
       
   721                        #(#MenuItem
       
   722                           #'label:' 'Load Subspec...'
       
   723                           #'value:' #loadSubspec
       
   724                           #'activeHelpKey:' #fileLoadSubspec
   717                       )
   725                       )
   718                        #(#MenuItem
   726                        #(#MenuItem
   719                           #'label:' '-'
   727                           #'label:' '-'
   720                       )
   728                       )
   721                        #(#MenuItem
   729                        #(#MenuItem
  1464         ] ifFalse:[
  1472         ] ifFalse:[
  1465             self painter updateFromSpec:spec.
  1473             self painter updateFromSpec:spec.
  1466         ]
  1474         ]
  1467     ].
  1475     ].
  1468     self modifiedChannel value:false.
  1476     self modifiedChannel value:false.
       
  1477 !
       
  1478 
       
  1479 addWidgetOfSpec: aSpec
       
  1480 
       
  1481     |newSel|
       
  1482     (newSel := self pasteSpecifications:aSpec keepLayout:false at:0@0) notNil
       
  1483     ifTrue:
       
  1484     [
       
  1485         self select: newSel
       
  1486     ]
       
  1487     ifFalse:
       
  1488     [   
       
  1489         treeView selection size = 0
       
  1490         ifTrue:
       
  1491         [                          
       
  1492             treeView selection: #(1).
       
  1493         ]
       
  1494         ifFalse:
       
  1495         [
       
  1496             treeView selectNode: (treeView detectNode: [:n| n = treeView selectedNode parent])
       
  1497         ].
       
  1498         self addWidgetOfSpec: aSpec
       
  1499     ]
       
  1500 
  1469 !
  1501 !
  1470 
  1502 
  1471 cancel
  1503 cancel
  1472     "cancel all changes done to the specification; reread attributes from the
  1504     "cancel all changes done to the specification; reread attributes from the
  1473      assigned component
  1505      assigned component
  2398     "Created: / 25.10.1997 / 19:07:55 / cg"
  2430     "Created: / 25.10.1997 / 19:07:55 / cg"
  2399 !
  2431 !
  2400 
  2432 
  2401 doFromClass
  2433 doFromClass
  2402 
  2434 
  2403     self loadFromInClassesOf: #Object
  2435     self loadFromMessage: 
       
  2436         (ResourceSelectionBrowser
       
  2437             request: 'Load Interface From Class'
       
  2438             onSuperclass: nil
       
  2439             andClass: specClass
       
  2440             andSelector: specSelector
       
  2441             withResourceTypes: #(canvas))
  2404 !
  2442 !
  2405 
  2443 
  2406 doInstallAspects
  2444 doInstallAspects
  2407     "install aspects and actions
  2445     "install aspects and actions
  2408     "
  2446     "
  2590 
  2628 
  2591    v := CodeView open.
  2629    v := CodeView open.
  2592    v contents:code.
  2630    v contents:code.
  2593    v label:'windowSpec'.
  2631    v label:'windowSpec'.
  2594 
  2632 
  2595 !
       
  2596 
       
  2597 loadFromInClassesOf: aSuperclassOrSymbol
       
  2598 
       
  2599     self loadFromMessage: 
       
  2600         (ResourceSelectionBrowser
       
  2601             request: 'Load Interface From Class'
       
  2602             onSuperclass: aSuperclassOrSymbol
       
  2603             andClass: specClass
       
  2604             andSelector: specSelector
       
  2605             withResourceTypes: #(canvas))
       
  2606 !
  2633 !
  2607 
  2634 
  2608 loadFromMessage: aMessage
  2635 loadFromMessage: aMessage
  2609 
  2636 
  2610     ((aMessage size > 0) and: [self checkModified])
  2637     ((aMessage size > 0) and: [self checkModified])
  2623                 self painter setupFromSpec:(aClass perform:aSelector).
  2650                 self painter setupFromSpec:(aClass perform:aSelector).
  2624             ]
  2651             ]
  2625         ]
  2652         ]
  2626     ]
  2653     ]
  2627 
  2654 
       
  2655 !
       
  2656 
       
  2657 loadSubspec
       
  2658 
       
  2659     |subSpecMessage|
       
  2660     (subSpecMessage := ResourceSelectionBrowser
       
  2661             request: 'Load Subspec From Class'
       
  2662             onSuperclass: nil
       
  2663             andClass: specClass
       
  2664             andSelector: specSelector
       
  2665             withResourceTypes: #(canvas)) notNil
       
  2666     ifTrue:
       
  2667     [
       
  2668         |readStream aClass aSelector|
       
  2669         readStream := subSpecMessage readStream.
       
  2670         (aClass := Smalltalk at: (readStream upTo: $ ) asSymbol) notNil
       
  2671         ifTrue:
       
  2672         [
       
  2673             aSelector :=  readStream upToEnd asSymbol.
       
  2674             (aClass name == specClass and: [aSelector == specSelector]) ifTrue: [^self warn: 'Current interface as subspec not allowed!!'].
       
  2675             (aClass respondsTo:aSelector) 
       
  2676             ifTrue:
       
  2677             [
       
  2678                 self addWidgetOfSpec: (Array with: (UISubSpecification new majorKey: aClass name; minorKey: aSelector))
       
  2679             ]
       
  2680         ]
       
  2681     ]
  2628 ! !
  2682 ! !
  2629 
  2683 
  2630 !UIPainter methodsFor:'user interactions - dialog'!
  2684 !UIPainter methodsFor:'user interactions - dialog'!
  2631 
  2685 
  2632 checkClassAndSelector
  2686 checkClassAndSelector
  2932 !UIPainter::TreeView methodsFor:'adding & removing'!
  2986 !UIPainter::TreeView methodsFor:'adding & removing'!
  2933 
  2987 
  2934 addProperty:aProperty
  2988 addProperty:aProperty
  2935     "add a new item
  2989     "add a new item
  2936     "
  2990     "
  2937     |parent|
  2991     |parent| 
  2938 
  2992 
  2939     parent := self detectItemRespondsToView:(aProperty view superView).
  2993     parent := self detectItemRespondsToView:(aProperty view superView).
  2940 
  2994 
  2941     parent notNil ifTrue:[
  2995     parent notNil ifTrue:[
  2942         model add:(TreeItem name:(aProperty name) contents:aProperty) below:parent
  2996         model add:(TreeItem name:(aProperty name) contents:aProperty) below:parent