UIPainter.st
changeset 351 7cb9f9c9a872
parent 348 26656736930c
child 358 5df60cd45881
equal deleted inserted replaced
350:28128eeb98f0 351:7cb9f9c9a872
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
    12 
    13 
       
    14 'From Smalltalk/X, Version:3.2.1 on 23-oct-1997 at 6:02:55 pm'                  !
       
    15 
    13 
    16 ApplicationModel subclass:#UIPainter
    14 ApplicationModel subclass:#UIPainter
    17 	instanceVariableNames:'treeView selectionPanel tabSelection specClass specSelector
    15 	instanceVariableNames:'treeView selectionPanel tabSelection specClass specSelector
    18 		specSuperclass aspects layoutCanvas helpCanvas specCanvas
    16 		specSuperclass aspects layoutCanvas helpCanvas specCanvas
    19 		transcript'
    17 		transcript'
   656                                                             #'extent:' #(#Point 165 24)
   654                                                             #'extent:' #(#Point 165 24)
   657                                                         )
   655                                                         )
   658                                                          #(#ActionButtonSpec
   656                                                          #(#ActionButtonSpec
   659                                                             #'name:' 'acceptButton'
   657                                                             #'name:' 'acceptButton'
   660                                                             #'activeHelpKey:' #accept
   658                                                             #'activeHelpKey:' #accept
   661                                                             #'label:' 'ok'
   659                                                             #'label:' 'accept'
   662                                                             #'tabable:' true
   660                                                             #'tabable:' true
   663                                                             #'model:' #accept
   661                                                             #'model:' #accept
   664                                                             #'enableChannel:' #modifiedChannel
   662                                                             #'enableChannel:' #modifiedChannel
   665                                                             #'extent:' #(#Point 166 24)
   663                                                             #'extent:' #(#Point 166 24)
   666                                                         )
   664                                                         )
   692                     #'handles:' #(#Any 0.880597 1.0)
   690                     #'handles:' #(#Any 0.880597 1.0)
   693                 )
   691                 )
   694               )
   692               )
   695           )
   693           )
   696       )
   694       )
       
   695 
       
   696     "Modified: / 26.10.1997 / 15:57:00 / cg"
   697 ! !
   697 ! !
   698 
   698 
   699 !UIPainter class methodsFor:'menu specs'!
   699 !UIPainter class methodsFor:'menu specs'!
   700 
   700 
   701 menuAlignment
   701 menuAlignment
  1237                        #(#MenuItem
  1237                        #(#MenuItem
  1238                           #'label:' 'browse application'
  1238                           #'label:' 'browse application'
  1239                           #'value:' #doBrowseAppClass
  1239                           #'value:' #doBrowseAppClass
  1240                           #'enabled:' #hasSpecClass
  1240                           #'enabled:' #hasSpecClass
  1241                       )
  1241                       )
       
  1242                        #(#MenuItem
       
  1243                           #'label:' 'browse aspect methods'
       
  1244                           #'value:' #doBrowseAspectMethods
       
  1245                       )
  1242                     ) nil
  1246                     ) nil
  1243                     nil
  1247                     nil
  1244                 )
  1248                 )
  1245             )
  1249             )
  1246              #(#MenuItem
  1250              #(#MenuItem
  1250                 #'submenu:' 
  1254                 #'submenu:' 
  1251                  #(#Menu
  1255                  #(#Menu
  1252                     
  1256                     
  1253                      #(
  1257                      #(
  1254                        #(#MenuItem
  1258                        #(#MenuItem
  1255                           #'label:' 'test mode'
  1259                           #'label:' 'geometry test mode'
  1256                           #'indication:' #'testMode:'
  1260                           #'indication:' #'testMode:'
  1257                       )
  1261                       )
  1258                     ) nil
  1262                     ) nil
  1259                     nil
  1263                     nil
  1260                 )
  1264                 )
  1292                 #'label:' '-'
  1296                 #'label:' '-'
  1293             )
  1297             )
  1294           ) nil
  1298           ) nil
  1295           nil
  1299           nil
  1296       )
  1300       )
       
  1301 
       
  1302     "Modified: / 26.10.1997 / 14:34:13 / cg"
  1297 ! !
  1303 ! !
  1298 
  1304 
  1299 !UIPainter methodsFor:'actions'!
  1305 !UIPainter methodsFor:'actions'!
  1300 
  1306 
  1301 accept
  1307 accept
  1491             self specTool specification hierarchicalList:editor selectorName asSymbol.
  1497             self specTool specification hierarchicalList:editor selectorName asSymbol.
  1492             self modifiedChannel value:true.
  1498             self modifiedChannel value:true.
  1493             self accept
  1499             self accept
  1494         ]
  1500         ]
  1495     ]
  1501     ]
       
  1502 !
       
  1503 
       
  1504 setMaxExtent
       
  1505     "set the windows maxExtent from its current extent"
       
  1506 
       
  1507     self painter setMaxExtent
       
  1508 
       
  1509     "Modified: / 27.10.1997 / 03:22:58 / cg"
       
  1510 !
       
  1511 
       
  1512 setMinExtent
       
  1513     "set the windows minExtent from its current extent"
       
  1514 
       
  1515     self painter setMinExtent
       
  1516 
       
  1517     "Modified: / 27.10.1997 / 03:23:10 / cg"
  1496 ! !
  1518 ! !
  1497 
  1519 
  1498 !UIPainter methodsFor:'aspects'!
  1520 !UIPainter methodsFor:'aspects'!
  1499 
  1521 
  1500 canMoveOrAlignSelection
  1522 canMoveOrAlignSelection
  1932 !
  1954 !
  1933 
  1955 
  1934 tabSelection:something
  1956 tabSelection:something
  1935     "the tab selection of the notebook changed
  1957     "the tab selection of the notebook changed
  1936     "
  1958     "
       
  1959 
       
  1960     |whatToDo|
       
  1961 
  1937     (something isNil or:[tabSelection = something]) ifTrue:[
  1962     (something isNil or:[tabSelection = something]) ifTrue:[
  1938         ^ self
  1963         ^ self
  1939     ].
  1964     ].
  1940 
  1965 
  1941     self isModified ifTrue:[
  1966     self isModified ifTrue:[
  1942         (self confirm:'accept change made in ' , tabSelection printString , ' section ?') ifFalse:[
  1967         whatToDo := DialogBox 
  1943             ^ self
  1968                         confirmWithCancel:'accept change made in ' , tabSelection printString , ' section ?'
  1944         ].
  1969                         labels:#('cancel' 'ignore' 'accept')
  1945         self accept
  1970                         default:3.
       
  1971         whatToDo isNil ifTrue:[^self].
       
  1972         whatToDo == true ifTrue:[
       
  1973             self accept
       
  1974         ] ifFalse:[
       
  1975             self cancel
       
  1976         ]
  1946     ].
  1977     ].
  1947 
  1978 
  1948     tabSelection := something.
  1979     tabSelection := something.
  1949     self raiseTabView.
  1980     self raiseTabView.
  1950     self cancel.
  1981     self cancel.
       
  1982 
       
  1983     "Modified: / 26.10.1997 / 15:54:15 / cg"
  1951 !
  1984 !
  1952 
  1985 
  1953 treeSelection
  1986 treeSelection
  1954     "called whenever the selection of the treeview changed
  1987     "called whenever the selection of the treeview changed
  1955     "
  1988     "
  2029         selectionPanel closeRequest
  2062         selectionPanel closeRequest
  2030     ].
  2063     ].
  2031     selectionPanel := nil.
  2064     selectionPanel := nil.
  2032     treeView       := nil.
  2065     treeView       := nil.
  2033 
  2066 
       
  2067     ActiveHelp stopFor:self.
       
  2068 
  2034     super closeRequest.
  2069     super closeRequest.
  2035 
  2070 
  2036     "Modified: 28.7.1997 / 18:28:37 / cg"
  2071     "Modified: / 27.10.1997 / 00:01:30 / cg"
  2037 !
  2072 !
  2038 
  2073 
  2039 closeRequestFor:aTopView
  2074 closeRequestFor:aTopView
  2040     "handle a close request for a specific view
  2075     "handle a close request for a specific view
  2041     "
  2076     "
  2122     painterView icon:(Image fromFile:'bitmaps/UIPainter.xbm' resolution:100).
  2157     painterView icon:(Image fromFile:'bitmaps/UIPainter.xbm' resolution:100).
  2123 
  2158 
  2124     selectionPanel window iconLabel:'GUI Painter'.
  2159     selectionPanel window iconLabel:'GUI Painter'.
  2125     selectionPanel window icon:(Image fromFile:'bitmaps/UIPainter.xbm' resolution:100).
  2160     selectionPanel window icon:(Image fromFile:'bitmaps/UIPainter.xbm' resolution:100).
  2126 
  2161 
  2127     "Modified: 1.8.1997 / 14:22:10 / cg"
  2162     ActiveHelp startFor:self.
       
  2163 
       
  2164     "Modified: / 27.10.1997 / 00:01:12 / cg"
  2128 !
  2165 !
  2129 
  2166 
  2130 openNewWindowCanvas
  2167 openNewWindowCanvas
  2131     "open new
  2168     "open new
  2132     "
  2169     "
  2146      via some selector
  2183      via some selector
  2147     "
  2184     "
  2148     |painter|
  2185     |painter|
  2149 
  2186 
  2150     aClass isNil ifTrue:[
  2187     aClass isNil ifTrue:[
  2151         self warn:'nil class given (class was probably renamed ?)'.
  2188         (self confirm:'nil class given to UIPainter (class was probably renamed ?)\\Open anyway (to create a new interface) ?' withCRs)
       
  2189         ifFalse:[^ nil].
  2152     ].
  2190     ].
  2153 
  2191 
  2154     self openInterface.
  2192     self openInterface.
  2155 
  2193 
  2156     aClass notNil ifTrue:[
  2194     aClass notNil ifTrue:[
  2173         (aClass respondsTo:aSelector) ifTrue:[
  2211         (aClass respondsTo:aSelector) ifTrue:[
  2174             painter setupFromSpec:(aClass perform:aSelector).
  2212             painter setupFromSpec:(aClass perform:aSelector).
  2175         ]
  2213         ]
  2176     ]
  2214     ]
  2177 
  2215 
  2178     "Modified: 1.7.1997 / 19:18:54 / cg"
  2216     "Modified: / 25.10.1997 / 19:11:51 / cg"
  2179 ! !
  2217 ! !
  2180 
  2218 
  2181 !UIPainter methodsFor:'user interaction - dialog'!
  2219 !UIPainter methodsFor:'user interaction - dialog'!
  2182 
  2220 
  2183 checkClassAndSelector
  2221 checkClassAndSelector
  2325         SystemBrowser openInClass:cls
  2363         SystemBrowser openInClass:cls
  2326     ] ifFalse:[
  2364     ] ifFalse:[
  2327         self information:'no class yet'.
  2365         self information:'no class yet'.
  2328     ].
  2366     ].
  2329 
  2367 
       
  2368 !
       
  2369 
       
  2370 doBrowseAspectMethods
       
  2371     "open a browser on the aspect methods"
       
  2372 
       
  2373     |cls methods|
       
  2374 
       
  2375     self painter isModified ifTrue:[
       
  2376         self warn:'the changes have not yet been reinstalled.\\The browser may show old code.' withCRs.
       
  2377     ].
       
  2378     cls := self resolveName:specClass.
       
  2379 
       
  2380     cls notNil ifTrue:[
       
  2381         methods := self painter aspectMethods.
       
  2382         methods isEmpty ifTrue:[
       
  2383             self warn:'no aspect methods have been installed yet.'.
       
  2384             ^ self.
       
  2385         ].
       
  2386         SystemBrowser browseMethods:methods title:'aspect methods'.
       
  2387     ] ifFalse:[
       
  2388         self information:'no class yet'.
       
  2389     ].
       
  2390 
       
  2391     "Created: / 25.10.1997 / 19:07:55 / cg"
  2330 !
  2392 !
  2331 
  2393 
  2332 doFromClass
  2394 doFromClass
  2333     "setup new specification from a class and selector accessed through
  2395     "setup new specification from a class and selector accessed through
  2334      to a dialog
  2396      to a dialog
  2436     ].
  2498     ].
  2437 
  2499 
  2438     self checkClassAndSelector ifFalse:[
  2500     self checkClassAndSelector ifFalse:[
  2439         ^ self
  2501         ^ self
  2440     ].
  2502     ].
       
  2503 
       
  2504     self isModified ifTrue:[
       
  2505         (self confirm:'accept change made in ' , tabSelection printString , ' section ?') ifTrue:[
       
  2506             self accept
       
  2507         ] ifFalse:[
       
  2508             (self confirm:'install old specification ?') ifFalse:[
       
  2509                 ^ self
       
  2510             ]
       
  2511         ]
       
  2512     ].
       
  2513 
  2441     painter := self painter.
  2514     painter := self painter.
  2442 
  2515 
  2443     painter className:specClass
  2516     painter className:specClass
  2444        superclassName:specSuperclass
  2517        superclassName:specSuperclass
  2445              selector:specSelector.
  2518              selector:specSelector.
  2446 
  2519 
  2447     code := painter generateWindowSpecMethodSource withCRs.
  2520     code := painter generateWindowSpecMethodSource withCRs.
  2448     painter resetModification.
  2521     painter resetModification.
  2449     (ReadStream on:code) fileIn.
  2522     (ReadStream on:code) fileIn.
  2450 
  2523 
       
  2524     "Modified: / 26.10.1997 / 15:47:48 / cg"
  2451 !
  2525 !
  2452 
  2526 
  2453 doNew
  2527 doNew
  2454     "remove all components and associated resources
  2528     "remove all components and associated resources
  2455     "
  2529     "
  2494 !
  2568 !
  2495 
  2569 
  2496 doStartApplication
  2570 doStartApplication
  2497     "start current edited application
  2571     "start current edited application
  2498     "
  2572     "
  2499     |cls|
  2573     |cls app infoMessage|
  2500 
  2574 
       
  2575     self isModified ifTrue:[
       
  2576         (self confirm:'accept change made in ' , tabSelection printString , ' section ?') ifTrue:[
       
  2577             self accept.
       
  2578             self painter isModified ifTrue:[
       
  2579                 (self confirm:'reinstall the new spec ?' withCRs) ifTrue:[
       
  2580                     self doInstallSpec
       
  2581                 ]
       
  2582             ].
       
  2583         ]
       
  2584     ].
  2501     self painter isModified ifTrue:[
  2585     self painter isModified ifTrue:[
  2502         (self confirm:'the changed spec has not yet been reinstalled.\\Start anyway (based upon the previous interface) ?' withCRs) ifFalse:[
  2586         (self confirm:'the changed spec has not yet been reinstalled.\\Start anyway (based upon the previous interface) ?' withCRs) ifFalse:[
  2503             ^ self
  2587             ^ self
  2504         ]
  2588         ]
  2505     ].
  2589     ].
  2506 
  2590 
  2507     (specClass isNil or:[specSelector size < 2]) ifTrue:[
  2591     (specClass isNil or:[specSelector size < 2]) ifTrue:[
  2508         ^ self information:'no class or selector defined'.
  2592         infoMessage := 'no class or selector defined'.
  2509     ].
  2593     ] ifFalse:[
  2510 
  2594         cls := self resolveName:specClass.
  2511     cls := self resolveName:specClass.
  2595 
  2512 
  2596         cls isNil ifTrue:[
  2513     cls isNil ifTrue:[
  2597             infoMessage := 'class not existant'.
  2514         ^ self information:'class not existant'.
  2598         ] ifFalse:[
  2515     ].
  2599             (cls respondsTo:specSelector) ifFalse:[
  2516 
  2600                 infoMessage := ('no method for: #' 
  2517     (cls respondsTo:specSelector) ifFalse:[
  2601                                 , specSelector , ' in ' , cls name
  2518         ^ self information:('no method for: #' 
  2602                                 , '\\(did you install the spec ?)') withCRs.
  2519                              , specSelector , ' in ' , cls name ,
  2603             ]
  2520                              '\\(did you install the spec ?)') withCRs.
  2604         ]
  2521     ].
  2605     ].
  2522     cls new openInterface:specSelector
  2606 
  2523 
  2607     infoMessage notNil ifTrue:[
  2524     "Modified: 28.7.1997 / 18:30:25 / cg"
  2608         ^ self information:infoMessage
       
  2609     ].
       
  2610     app := cls new.
       
  2611     (app respondsTo:#openInterface:) ifFalse:[
       
  2612         ^ self warn:('The application does not respond to the ''openInterface:'' message.\\(maybe its supposed to be used as subApplication/subCanvas)') withCRs.
       
  2613     ].        
       
  2614     app openInterface:specSelector
       
  2615 
       
  2616     "Modified: / 26.10.1997 / 22:57:30 / cg"
  2525 !
  2617 !
  2526 
  2618 
  2527 doWindowSpec
  2619 doWindowSpec
  2528    "create the window specification but do not write to application; instead
  2620    "create the window specification but do not write to application; instead
  2529     open a view
  2621     open a view
  2754 ! !
  2846 ! !
  2755 
  2847 
  2756 !UIPainter::TreeView methodsFor:'building'!
  2848 !UIPainter::TreeView methodsFor:'building'!
  2757 
  2849 
  2758 generateFullSpecForComponents:aSpecArray
  2850 generateFullSpecForComponents:aSpecArray
  2759     "generates an full spec for components
  2851     "generates a full spec for components
  2760     "
  2852     "
  2761     |fullSpec|
  2853     |fullSpec winSpec|
  2762 
  2854 
  2763     fullSpec := FullSpec new.
  2855     fullSpec := FullSpec new.
  2764 
  2856 
  2765     fullSpec fromBuilder:(self canvas topView)
  2857     fullSpec fromBuilder:(self canvas topView)
  2766               components:(SpecCollection new collection:aSpecArray).
  2858               components:(SpecCollection new collection:aSpecArray).
  2767 
  2859 
  2768     windowSpec notNil ifTrue:[
  2860     windowSpec notNil ifTrue:[
  2769         fullSpec window menu:(windowSpec menu).
  2861         winSpec := fullSpec window.
  2770         fullSpec window performer:(windowSpec performer).
  2862         winSpec menu:(windowSpec menu).
  2771         fullSpec window flags:(windowSpec flags).
  2863         winSpec performer:(windowSpec performer).
       
  2864         winSpec flags:(windowSpec flags).
       
  2865 winSpec forceRecursiveBackground:(windowSpec forceRecursiveBackground).
  2772     ].    
  2866     ].    
  2773     ^ fullSpec literalArrayEncoding.
  2867     ^ fullSpec literalArrayEncoding.
       
  2868 
       
  2869     "Modified: / 26.10.1997 / 22:41:51 / cg"
  2774 !
  2870 !
  2775 
  2871 
  2776 setAttributesFromWindowSpec:aWindowSpec
  2872 setAttributesFromWindowSpec:aWindowSpec
  2777     "set windowSpec from argument a WindowSpec
  2873     "set windowSpec from argument a WindowSpec
  2778     "
  2874     "