1524 |
1529 |
1525 newBuilder := self new. |
1530 newBuilder := self new. |
1526 ! |
1531 ! |
1527 |
1532 |
1528 setupButtonPanelIn:aTopView below:aMenu |
1533 setupButtonPanelIn:aTopView below:aMenu |
1529 "create the buttonPanel" |
1534 "create the buttonPanel |
1530 |
1535 " |
1531 |spc mh buttonPanel| |
1536 |spc mh buttonPanel pressAction| |
1532 |
1537 |
1533 spc := View viewSpacing // 2. |
1538 spc := View viewSpacing // 2. |
1534 buttonPanel := HorizontalPanelView in:aTopView. |
1539 buttonPanel := HorizontalPanelView in:aTopView. |
1535 buttonPanel level:-1; borderWidth:0. |
1540 buttonPanel level:-1; borderWidth:0. |
1536 buttonPanel horizontalLayout:#leftSpace. |
1541 buttonPanel horizontalLayout:#leftSpace. |
1537 |
1542 |
1538 self buttonPanelSpec do:[:entry | |
1543 pressAction := [:aButton :aSelector| |
1539 |sel toCanvas imgFile label b sep autoRepeat| |
1544 |menu org top| |
1540 |
1545 |
1541 sel := entry at:1. |
1546 workView selection notNil ifTrue:[ |
1542 sel isNil ifTrue:[ |
1547 top := aButton topView. |
1543 sep := View in:buttonPanel. |
1548 |
1544 sep extent:20@1; borderWidth:0. |
1549 org := top origin + (aButton originRelativeTo:top) |
1545 ] ifFalse:[ |
1550 + (0@((spc + aButton extent y))). |
1546 toCanvas := entry at:2. |
1551 |
1547 imgFile := entry at:3. |
1552 menu := PopUpMenu labels:#( '1' '2' '4' '10' '..' ) |
1548 label := entry at:4. |
1553 args:#( 1 2 4 10 nil ). |
1549 autoRepeat := entry at:5. |
1554 |
1550 b := Button in:buttonPanel. |
1555 menu action:[:anArg||no| |
1551 autoRepeat ifTrue:[ |
1556 (no := anArg) isNil ifTrue:[ |
1552 b autoRepeat:autoRepeat. |
1557 no := EnterBox request:'number'. |
1553 b controller beTriggerOnDown. |
1558 no := SmallInteger readFrom:no onError:0. |
1554 ]. |
1559 ]. |
1555 imgFile notNil ifTrue:[ |
1560 no ~~ 0 ifTrue:[ |
1556 b logo:(Image fromFile:imgFile). |
1561 workView perform:aSelector with:no |
1557 ] ifFalse:[ |
1562 ] |
1558 b logo:label |
1563 ]. |
1559 ]. |
1564 menu showAt:org. |
1560 toCanvas ifTrue:[ |
1565 ]. |
1561 b model:workView |
1566 aButton turnOff |
1562 ] ifFalse:[ |
1567 ]. |
1563 b model:self |
1568 |
1564 ]. |
1569 self buttonPanelSpec do:[:anArray| |selector image button| |
1565 b changeMessage:sel |
1570 selector := anArray at:1. |
1566 ] |
1571 |
|
1572 selector notNil ifTrue:[ |
|
1573 image := Image fromFile:( anArray at:2 ). |
|
1574 button := Button label:image in:buttonPanel. |
|
1575 |
|
1576 selector last == $: ifFalse:[ |
|
1577 button action:[ workView perform:selector ] |
|
1578 ] ifTrue:[ |
|
1579 button pressAction:[ pressAction value:button value:selector ] |
|
1580 ] |
|
1581 ] ifFalse:[|sep| |
|
1582 sep := View in:buttonPanel. |
|
1583 sep extent:20@1; borderWidth:0. |
|
1584 ] |
1567 ]. |
1585 ]. |
1568 |
1586 |
1569 mh := aMenu height. |
1587 mh := aMenu height. |
1570 buttonPanel origin:0.0 @ (mh + spc) |
1588 buttonPanel origin:0.0 @ (mh + spc) |
1571 corner:(1.0 @ (mh + spc + buttonPanel preferredExtent y)). |
1589 corner:(1.0 @ (mh + spc + buttonPanel preferredExtent y)). |
1572 |
1590 |
1573 buttonPanel leftInset:spc; rightInset:spc. |
1591 buttonPanel leftInset:spc; rightInset:spc. |
1574 ^ buttonPanel |
1592 ^ buttonPanel |
1575 |
|
1576 "Modified: 5.9.1995 / 22:23:13 / claus" |
|
1577 ! ! |
1593 ! ! |
1578 |
1594 |
1579 !UIPainter methodsFor:'misc'! |
1595 !UIPainter methodsFor:'misc'! |
1580 |
1596 |
1581 listOfOutletsFor:aViewClass |
1597 listOfOutletsFor:aViewClass |
2030 closeRequest |
2064 closeRequest |
2031 workView notNil ifTrue:[workView release. workView := nil]. |
2065 workView notNil ifTrue:[workView release. workView := nil]. |
2032 super closeRequest |
2066 super closeRequest |
2033 ! |
2067 ! |
2034 |
2068 |
2035 doCompile |
2069 closeRequestFor:aTopView |
2036 |code| |
2070 aTopView ~~ topView ifTrue:[ |
2037 |
2071 topView device beep. |
2038 code := workView generateCode. |
2072 ^ self |
2039 (ReadStream on:code) fileIn. |
2073 ]. |
2040 |
2074 super closeRequestFor:aTopView |
2041 "Modified: 4.9.1995 / 17:06:10 / claus" |
2075 ! |
2042 ! |
2076 |
|
2077 propertySelectionChanged |
|
2078 workView singleSelectionDo:[:selectedView | |
|
2079 propertyShown := whichProperty selection. |
|
2080 self showPropertyView |
|
2081 ] |
|
2082 ! |
|
2083 |
|
2084 selectOutlet:nr |
|
2085 |outlet type sel text box action initialText initialList |
|
2086 view prop t val| |
|
2087 |
|
2088 outlet := outletView selectionValue. |
|
2089 outletView deselect. |
|
2090 view := workView selection. |
|
2091 view isNil ifTrue:[ |
|
2092 self notify:'select something first'. |
|
2093 ^ self |
|
2094 ]. |
|
2095 action := [:s | self setOutlet:sel type:type to:s in:view]. |
|
2096 (outlet = 'label') ifTrue:[ |
|
2097 type := #string. |
|
2098 sel := #label:. |
|
2099 text := 'label-text:'. |
|
2100 initialText := view label |
|
2101 ]. |
|
2102 (outlet = 'fixed size') ifTrue:[ |
|
2103 type := #boolean. |
|
2104 sel := #sizeFixed:. |
|
2105 text := 'size is fix:'. |
|
2106 ]. |
|
2107 (outlet = 'frame shown') ifTrue:[ |
|
2108 type := #boolean. |
|
2109 sel := #showFrame:. |
|
2110 text := 'frame is to be drawn:'. |
|
2111 ]. |
|
2112 (outlet = 'labels') ifTrue:[ |
|
2113 type := #strings. |
|
2114 sel := #labels:. |
|
2115 initialText := view labels |
|
2116 ]. |
|
2117 (outlet = 'contents') ifTrue:[ |
|
2118 type := #text. |
|
2119 sel := #contents:. |
|
2120 initialText := view contents |
|
2121 ]. |
|
2122 (outlet = 'initialText') ifTrue:[ |
|
2123 type := #string. |
|
2124 sel := #initialText:. |
|
2125 initialText := view contents |
|
2126 ]. |
|
2127 (outlet = 'field type') ifTrue:[ |
|
2128 type := #fieldTypeSymbol. |
|
2129 sel := #type:. |
|
2130 initialList := #(number |
|
2131 string |
|
2132 password |
|
2133 ). |
|
2134 initialText := view converter isNil ifTrue:[#string] ifFalse:[view converter type]. |
|
2135 ]. |
|
2136 (outlet = 'field length') ifTrue:[ |
|
2137 type := #numberOrNil. |
|
2138 sel := #maxChars:. |
|
2139 text := 'field length (empty -> unlimited)'. |
|
2140 initialText := view maxChars isNil ifTrue:[''] ifFalse:[view maxChars printString]. |
|
2141 ]. |
|
2142 (outlet = 'level') ifTrue:[ |
|
2143 type := #number. |
|
2144 sel := #level:. |
|
2145 initialText := view level printString |
|
2146 ]. |
|
2147 (outlet = 'active level') ifTrue:[ |
|
2148 type := #number. |
|
2149 sel := #onLevel:. |
|
2150 initialText := view onLevel printString |
|
2151 ]. |
|
2152 (outlet = 'passive level') ifTrue:[ |
|
2153 type := #number. |
|
2154 sel := #offLevel:. |
|
2155 initialText := view offLevel printString |
|
2156 ]. |
|
2157 (outlet = 'iconic-label') ifTrue:[ |
|
2158 type := #form. |
|
2159 sel := #label:. |
|
2160 text := 'label-icon:' |
|
2161 ]. |
|
2162 (outlet = 'view background-color') ifTrue:[ |
|
2163 type := #color. |
|
2164 sel := #viewBackground:. |
|
2165 text := 'view background color'. |
|
2166 initialText := 'Black' |
|
2167 ]. |
|
2168 (outlet = 'foreground-color') ifTrue:[ |
|
2169 type := #color. |
|
2170 sel := #foregroundColor:. |
|
2171 text := 'foreground color'. |
|
2172 initialText := 'Black' |
|
2173 ]. |
|
2174 (outlet = 'background-color') ifTrue:[ |
|
2175 type := #color. |
|
2176 sel := #backgroundColor:. |
|
2177 text := 'background color'. |
|
2178 initialText := 'Grey' |
|
2179 ]. |
|
2180 (outlet = 'active foreground-color') ifTrue:[ |
|
2181 type := #color. |
|
2182 sel := #activeForegroundColor:. |
|
2183 text := 'active foreground color'. |
|
2184 initialText := 'Yellow' |
|
2185 ]. |
|
2186 (outlet = 'active background-color') ifTrue:[ |
|
2187 type := #color. |
|
2188 sel := #activeBackgroundColor:. |
|
2189 text := 'active background color'. |
|
2190 initialText := 'Grey' |
|
2191 ]. |
|
2192 (outlet = 'scroll action') ifTrue:[ |
|
2193 type := #block. |
|
2194 sel := #scrollAction:. |
|
2195 text := 'action block when scrolled' |
|
2196 ]. |
|
2197 (outlet = 'scrollUp action') ifTrue:[ |
|
2198 type := #block. |
|
2199 sel := #scrollUpAction:. |
|
2200 text := 'action block when scrolled up' |
|
2201 ]. |
|
2202 (outlet = 'scrollDown action') ifTrue:[ |
|
2203 type := #block. |
|
2204 sel := #scrollDownAction:. |
|
2205 text := 'action block when scrolled down' |
|
2206 ]. |
|
2207 (outlet = 'scrollLeft action') ifTrue:[ |
|
2208 type := #block. |
|
2209 sel := #scrollLeftAction:. |
|
2210 text := 'action block when scrolled left' |
|
2211 ]. |
|
2212 (outlet = 'scrollRight action') ifTrue:[ |
|
2213 type := #block. |
|
2214 sel := #scrollRightAction:. |
|
2215 text := 'action block when scrolled right' |
|
2216 ]. |
|
2217 (outlet = 'press action') ifTrue:[ |
|
2218 type := #block. |
|
2219 sel := #pressAction:. |
|
2220 text := 'action block when pressed' |
|
2221 ]. |
|
2222 (outlet = 'release action') ifTrue:[ |
|
2223 type := #block. |
|
2224 sel := #releaseAction:. |
|
2225 text := 'action block when released' |
|
2226 ]. |
|
2227 (outlet = 'style') ifTrue:[ |
|
2228 type := #symbol. |
|
2229 sel := #style:. |
|
2230 initialList := #(motif next) |
|
2231 ]. |
|
2232 (outlet = 'handle position') ifTrue:[ |
|
2233 type := #symbol. |
|
2234 sel := #handlePosition:. |
|
2235 initialList := #(left center right) |
|
2236 ]. |
|
2237 (outlet = 'horizontal layout') ifTrue:[ |
|
2238 type := #symbol. |
|
2239 sel := #horizontalLayout:. |
|
2240 text := 'horizontal components layout'. |
|
2241 initialList := #(left |
|
2242 leftSpace |
|
2243 leftMax |
|
2244 leftSpaceMax |
|
2245 center |
|
2246 centerMax |
|
2247 right |
|
2248 rightSpace |
|
2249 rightMax |
|
2250 rightSpaceMax |
|
2251 spread |
|
2252 spreadSpace |
|
2253 spreadMax |
|
2254 spreadSpaceMax |
|
2255 fit |
|
2256 fitSpace). |
|
2257 initialText := view horizontalLayout printString |
|
2258 ]. |
|
2259 (outlet = 'vertical layout') ifTrue:[ |
|
2260 type := #symbol. |
|
2261 sel := #verticalLayout:. |
|
2262 text := 'vertical components layout'. |
|
2263 initialList := #(top |
|
2264 topSpace |
|
2265 center |
|
2266 bottom |
|
2267 bottomSpace |
|
2268 spread |
|
2269 spreadSpace |
|
2270 fit |
|
2271 fitSpace). |
|
2272 initialText := view verticalLayout printString |
|
2273 ]. |
|
2274 (outlet = 'label position') ifTrue:[ |
|
2275 type := #symbol. |
|
2276 sel := #labelPosition:. |
|
2277 initialList := #(topLeft topCenter topRight bottomLeft bottomCenter bottomRight). |
|
2278 initialText := view labelPosition printString |
|
2279 ]. |
|
2280 (outlet = 'label layout') ifTrue:[ |
|
2281 type := #symbol. |
|
2282 sel := #adjust:. |
|
2283 initialList := #( left right center centerLeft centerRight fit ). |
|
2284 initialText := view adjust printString |
|
2285 ]. |
|
2286 (outlet = 'orientation') ifTrue:[ |
|
2287 type := #symbol. |
|
2288 sel := #orientation:. |
|
2289 initialList := #( horizontal vertical ). |
|
2290 initialText := view orientation printString |
|
2291 ]. |
|
2292 |
|
2293 (type == #color) ifTrue:[ |
|
2294 initialList := #('Black' |
|
2295 'White' |
|
2296 'LightGrey' |
|
2297 'Grey' |
|
2298 'DarkGrey' |
|
2299 'Yellow' |
|
2300 'Red' |
|
2301 'Green' |
|
2302 'Blue' |
|
2303 ) |
|
2304 ]. |
|
2305 |
|
2306 text isNil ifTrue:[ |
|
2307 text := outlet |
|
2308 ]. |
|
2309 |
|
2310 "what type of box do we need" |
|
2311 |
|
2312 t := type. |
|
2313 ((type == #color) or:[type == #symbol or:[type == #fieldTypeSymbol]]) ifTrue:[ |
|
2314 t := #list |
|
2315 ]. |
|
2316 ((type == #number) or:[type == #numberOrNil]) ifTrue:[ |
|
2317 t := #string |
|
2318 ]. |
|
2319 (type == #strings) ifTrue:[ |
|
2320 t := #text |
|
2321 ]. |
|
2322 (type == #block) ifTrue:[ |
|
2323 t := #text. |
|
2324 initialText := workView outletValueOf:sel for:view. |
|
2325 initialText isNil ifTrue:[initialText := '[statements]'] |
|
2326 ]. |
|
2327 (type == #block1) ifTrue:[ |
|
2328 t := #text. |
|
2329 type := #block. |
|
2330 initialText := workView outletValueOf:sel for:view. |
|
2331 initialText isNil ifTrue:[initialText := '[:argument | statements ]'] |
|
2332 ]. |
|
2333 (type == #block2) ifTrue:[ |
|
2334 t := #text. |
|
2335 type := #block. |
|
2336 initialText := workView outletValueOf:sel for:view. |
|
2337 initialText isNil ifTrue:[initialText := '[:arg1 :arg2 | statements ]'] |
|
2338 ]. |
|
2339 |
|
2340 "show a box to enter thing" |
|
2341 |
|
2342 (t == #boolean) ifTrue:[ |
|
2343 val := Dialog confirmWithCancel:text. |
|
2344 (val == true or:[val == false]) ifTrue:[ |
|
2345 action value:val |
|
2346 ]. |
|
2347 ^ self |
|
2348 ]. |
|
2349 (t == #string) ifTrue:[ |
|
2350 "/ stringBox isNil ifTrue:[ |
|
2351 stringBox := EnterBox new. |
|
2352 "/ ]. |
|
2353 box := stringBox |
|
2354 ]. |
|
2355 (t == #list) ifTrue:[ |
|
2356 "/ listBox isNil ifTrue:[ |
|
2357 listBox := ListSelectionBox new. |
|
2358 "/ ]. |
|
2359 listBox list:initialList. |
|
2360 box := listBox |
|
2361 ]. |
|
2362 (t == #text) ifTrue:[ |
|
2363 "/ actionBox isNil ifTrue:[ |
|
2364 actionBox := TextBox new. |
|
2365 "/ ]. |
|
2366 actionBox initialText:initialText. |
|
2367 box := actionBox |
|
2368 ]. |
|
2369 " |
|
2370 Transcript show:'outlet: '. Transcript showCR:outlet. |
|
2371 Transcript show:'type: '. Transcript showCR:type. |
|
2372 Transcript show:'sel: '. Transcript showCR:sel. |
|
2373 Transcript show:'text: '. Transcript showCR:text. |
|
2374 " |
|
2375 |
|
2376 box isNil ifTrue:[ |
|
2377 self notify:'not yet implemented' |
|
2378 ] ifFalse:[ |
|
2379 box initialText:initialText. |
|
2380 box title:text. |
|
2381 box action:action. |
|
2382 box showAtPointer |
|
2383 ] |
|
2384 |
|
2385 "Modified: 6.9.1995 / 13:46:29 / claus" |
|
2386 ! |
|
2387 |
|
2388 setColors |
|
2389 |fg bg| |
|
2390 |
|
2391 fg := self foregroundChannel value. |
|
2392 (fg notNil and:[fg notEmpty]) ifTrue:[ |
|
2393 fg := Color readFrom:fg. |
|
2394 workView singleSelectionDo:[:selectedView | |
|
2395 selectedView foregroundColor:fg |
|
2396 ]. |
|
2397 ]. |
|
2398 bg := self backgroundChannel value. |
|
2399 (bg notNil and:[bg notEmpty]) ifTrue:[ |
|
2400 bg := Color readFrom:bg. |
|
2401 workView singleSelectionDo:[:selectedView | |
|
2402 selectedView backgroundColor:bg |
|
2403 ]. |
|
2404 ]. |
|
2405 ! |
|
2406 |
|
2407 setMiscAspects |
|
2408 "sent when apply is pressen in the misc-sub view" |
|
2409 |
|
2410 workView singleSelectionDo:[:selectedView | |
|
2411 selectedView ~~ workView ifTrue:[ |
|
2412 workView changeVariableNameOf:selectedView to:nameChannel value |
|
2413 ] |
|
2414 ]. |
|
2415 ! |
|
2416 |
|
2417 setModelAspects |
|
2418 "sent when apply is pressen in the model-sub view" |
|
2419 |
|
2420 |aspectSymbol| |
|
2421 |
|
2422 aspectSymbol := (self aspectFor:#aspectChannel) value. |
|
2423 (aspectSymbol notNil and:[aspectSymbol notEmpty]) ifTrue:[ |
|
2424 aspectSymbol := aspectSymbol asSymbol. |
|
2425 workView singleSelectionDo:[:selectedView | |
|
2426 selectedView ~~ workView ifTrue:[ |
|
2427 workView setAspectSelector:aspectSymbol forView:selectedView |
|
2428 ]. |
|
2429 ]. |
|
2430 ]. |
|
2431 ! |
|
2432 |
|
2433 setOutlet:outletSymbol type:type to:outletValue in:aView |
|
2434 |block val messageSymbol| |
|
2435 |
|
2436 messageSymbol := outletSymbol. |
|
2437 val := outletValue. |
|
2438 (type == #block) ifTrue:[ |
|
2439 block := Compiler evaluate:val. |
|
2440 (block == #Error) ifTrue:[ |
|
2441 self warn:'action will not work in test-mode'. |
|
2442 workView addOutletDefinitionFor:outletSymbol |
|
2443 type:type |
|
2444 value:outletValue |
|
2445 for:aView. |
|
2446 ^ self |
|
2447 ]. |
|
2448 val := block |
|
2449 ]. |
|
2450 (type == #number) ifTrue:[ |
|
2451 val := Number readFromString:outletValue onError:0 |
|
2452 ]. |
|
2453 (type == #numberOrNil) ifTrue:[ |
|
2454 val := Number readFromString:outletValue onError:nil |
|
2455 ]. |
|
2456 (type == #text) ifTrue:[ |
|
2457 val := outletValue asString |
|
2458 ]. |
|
2459 (type == #strings) ifTrue:[ |
|
2460 val := outletValue asText |
|
2461 ]. |
|
2462 (type == #symbol) ifTrue:[ |
|
2463 val := outletValue asSymbol. |
|
2464 ]. |
|
2465 (type == #fieldTypeSymbol) ifTrue:[ |
|
2466 val := outletValue asSymbol. |
|
2467 val == #password ifTrue:[ |
|
2468 aView passwordCharacter:$* |
|
2469 ] ifFalse:[ |
|
2470 aView passwordCharacter:nil |
|
2471 ]. |
|
2472 val := (PrintConverter new initFor:val). |
|
2473 messageSymbol := #converter: |
|
2474 ]. |
|
2475 (type == #color) ifTrue:[ |
|
2476 val := Color name:outletValue. |
|
2477 val isNil ifTrue:[ |
|
2478 self warn:('no such color:' , outletValue). |
|
2479 ^ self |
|
2480 ] |
|
2481 ]. |
|
2482 Transcript show:(val printString). |
|
2483 Transcript showCR:('(' , val class printString , ')'). |
|
2484 |
|
2485 workView selectionHiddenDo:[ |
|
2486 aView perform:messageSymbol with:val. |
|
2487 workView elementChanged:aView. |
|
2488 aView redraw. |
|
2489 ]. |
|
2490 workView addOutletDefinitionFor:outletSymbol |
|
2491 type:type |
|
2492 value:outletValue |
|
2493 for:aView |
|
2494 |
|
2495 "Modified: 6.9.1995 / 13:44:46 / claus" |
|
2496 ! |
|
2497 |
|
2498 showPropertyView |
|
2499 |v l spec| |
|
2500 |
|
2501 workView singleSelectionDo:[:selectedView | |
|
2502 propertyShown = 'dimension' ifTrue:[ |
|
2503 (l := selectedView geometryLayout) notNil ifTrue:[ |
|
2504 l isLayout ifTrue:[ |
|
2505 l isAlignmentOrigin ifTrue:[ |
|
2506 spec := self class geometrySpecForAlignmentOrigin |
|
2507 ] ifFalse:[ |
|
2508 l isLayoutFrame ifFalse:[ |
|
2509 spec := self class geometrySpecForLayoutOrigin |
|
2510 ] |
|
2511 ] |
|
2512 ] |
|
2513 ]. |
|
2514 spec isNil ifTrue:[ |
|
2515 spec := self class geometrySpecForLayoutFrame |
|
2516 ]. |
|
2517 ^ self setupPropertyFromSpec:spec |
|
2518 ]. |
|
2519 |
|
2520 propertyShown = 'colors' ifTrue:[ |
|
2521 ^ self setupPropertyFromSpec:(self class colorSpec) |
|
2522 ]. |
|
2523 |
|
2524 propertyShown = 'model' ifTrue:[ |
|
2525 ^ self setupPropertyFromSpec:(self class modelSpec) |
|
2526 ]. |
|
2527 |
|
2528 propertyShown = 'misc' ifTrue:[ |
|
2529 ^ self setupPropertyFromSpec:(self class miscSpec) |
|
2530 ]. |
|
2531 |
|
2532 propertyShown = 'attribute list' ifTrue:[ |
|
2533 specShown ~~ #attributeList ifTrue:[ |
|
2534 propertyFrame destroySubViews. |
|
2535 v := ScrollableView for:SelectionInListView in:propertyFrame. |
|
2536 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
2537 outletView := v scrolledView. |
|
2538 outletView action:[:lineNr | lineNr notNil ifTrue:[self selectOutlet:lineNr]]. |
|
2539 propertyFrame realizeAllSubViews. |
|
2540 specShown := #attributeList. |
|
2541 ]. |
|
2542 self showOutletsFor:(workView selection). |
|
2543 ^ self |
|
2544 ]. |
|
2545 ]. |
|
2546 |
|
2547 propertyFrame destroySubViews. |
|
2548 outletView := nil. |
|
2549 specShown := nil. |
|
2550 |
|
2551 ! ! |
|
2552 |
|
2553 !UIPainter methodsFor:'user interaction - dialogs'! |
|
2554 |
|
2555 checkClassAndSelector |
|
2556 "check for class & superclass" |
|
2557 |
|
2558 |superclass cls| |
|
2559 |
|
2560 (cls := Smalltalk at:specClass asSymbol) isNil ifTrue:[ |
|
2561 (superclass := Smalltalk at:specSuperclass asSymbol) isNil ifTrue:[ |
|
2562 self warn:'no class named ' , specSuperclass , ' exists.'. |
|
2563 ^ false. |
|
2564 ]. |
|
2565 (self confirm:'create ' , specClass , ' ?') ifTrue:[ |
|
2566 superclass subclass:(specClass asSymbol) |
|
2567 instanceVariableNames:'' |
|
2568 classVariableNames:'' |
|
2569 poolDictionaries:'' |
|
2570 category:'New-Applications'. |
|
2571 ^ true. |
|
2572 ]. |
|
2573 ^ false. |
|
2574 ]. |
|
2575 cls isBehavior ifFalse:[ |
|
2576 self warn:'a global named ' , specClass , ' exists, but is no class.'. |
|
2577 ^ false. |
|
2578 ]. |
|
2579 |
|
2580 specSuperclass notNil ifTrue:[ |
|
2581 (superclass := Smalltalk at:specSuperclass asSymbol) isNil ifTrue:[ |
|
2582 self warn:'no class named ' , specSuperclass , ' exists.'. |
|
2583 ^ false. |
|
2584 ]. |
|
2585 |
|
2586 (cls isSubclassOf:superclass) ifFalse:[ |
|
2587 self warn:'a global named ' , specClass , ' exists, but is not a subclass of ' , superclass name , '.'. |
|
2588 ^ false. |
|
2589 ] |
|
2590 ]. |
|
2591 ^ true |
|
2592 ! |
|
2593 |
|
2594 defineClassAndSelector |
|
2595 "launch a dialog to define class, superclass and method" |
|
2596 |
|
2597 |again| |
|
2598 |
|
2599 [ |
|
2600 again := false. |
|
2601 (self openDialogInterface:#nameAndSelectorSpec) ifTrue:[ |
|
2602 |
|
2603 specClass := (self aspectFor:#classNameChannel) value. |
|
2604 specSelector := (self aspectFor:#methodNameChannel) value. |
|
2605 specSuperclass := (self aspectFor:#superclassNameChannel) value. |
|
2606 |
|
2607 again := self checkClassAndSelector not. |
|
2608 again ifFalse:[ |
|
2609 workView className:specClass superclassName:specSuperclass selector:specSelector. |
|
2610 ]. |
|
2611 ] |
|
2612 ] doWhile:[again] |
|
2613 |
|
2614 ! ! |
|
2615 |
|
2616 !UIPainter methodsFor:'user interaction - menu'! |
2043 |
2617 |
2044 doFinish |
2618 doFinish |
2045 self closeRequest |
2619 self closeRequest |
2046 ! |
2620 ! |
2047 |
2621 |
2176 v contents:code. |
2771 v contents:code. |
2177 v label:(workView applicationName). |
2772 v label:(workView applicationName). |
2178 ^ self |
2773 ^ self |
2179 |
2774 |
2180 "Modified: 5.9.1995 / 21:02:05 / claus" |
2775 "Modified: 5.9.1995 / 21:02:05 / claus" |
2181 ! |
2776 ! ! |
|
2777 |
|
2778 !UIPainter methodsFor:'user interaction - menu'! |
2182 |
2779 |
2183 doWindowSpec |
2780 doWindowSpec |
2184 |code v| |
2781 |code v| |
2185 |
2782 |
2186 code := workView generateWindowSpec. |
2783 code := workView generateWindowSpecMethodSource. |
2187 v := CodeView open. |
2784 v := CodeView open. |
2188 v contents:code. |
2785 v contents:code. |
2189 v label:'windowSpec'. |
2786 v label:'windowSpec'. |
2190 ^ self |
2787 ^ self |
2191 |
2788 |
2192 "Modified: 5.9.1995 / 21:04:14 / claus" |
2789 "Modified: 5.9.1995 / 21:04:14 / claus" |
2193 ! |
2790 ! |
2194 |
2791 |
2195 propertySelectionChanged |
|
2196 workView singleSelectionDo:[:selectedView | |
|
2197 propertyShown := whichProperty selection. |
|
2198 self showPropertyView |
|
2199 ] |
|
2200 ! |
|
2201 |
|
2202 selectOutlet:nr |
|
2203 |outlet type sel text box action initialText initialList |
|
2204 view prop t val| |
|
2205 |
|
2206 outlet := outletView selectionValue. |
|
2207 outletView deselect. |
|
2208 view := workView selection. |
|
2209 view isNil ifTrue:[ |
|
2210 self notify:'select something first'. |
|
2211 ^ self |
|
2212 ]. |
|
2213 action := [:s | self setOutlet:sel type:type to:s in:view]. |
|
2214 (outlet = 'label') ifTrue:[ |
|
2215 type := #string. |
|
2216 sel := #label:. |
|
2217 text := 'label-text:'. |
|
2218 initialText := view label |
|
2219 ]. |
|
2220 (outlet = 'fixed size') ifTrue:[ |
|
2221 type := #boolean. |
|
2222 sel := #sizeFixed:. |
|
2223 text := 'size is fix:'. |
|
2224 ]. |
|
2225 (outlet = 'frame shown') ifTrue:[ |
|
2226 type := #boolean. |
|
2227 sel := #showFrame:. |
|
2228 text := 'frame is to be drawn:'. |
|
2229 ]. |
|
2230 (outlet = 'labels') ifTrue:[ |
|
2231 type := #strings. |
|
2232 sel := #labels:. |
|
2233 initialText := view labels |
|
2234 ]. |
|
2235 (outlet = 'contents') ifTrue:[ |
|
2236 type := #text. |
|
2237 sel := #contents:. |
|
2238 initialText := view contents |
|
2239 ]. |
|
2240 (outlet = 'initialText') ifTrue:[ |
|
2241 type := #string. |
|
2242 sel := #initialText:. |
|
2243 initialText := view contents |
|
2244 ]. |
|
2245 (outlet = 'field type') ifTrue:[ |
|
2246 type := #fieldTypeSymbol. |
|
2247 sel := #type:. |
|
2248 initialList := #(number |
|
2249 string |
|
2250 password |
|
2251 ). |
|
2252 initialText := view converter isNil ifTrue:[#string] ifFalse:[view converter type]. |
|
2253 ]. |
|
2254 (outlet = 'field length') ifTrue:[ |
|
2255 type := #numberOrNil. |
|
2256 sel := #maxChars:. |
|
2257 text := 'field length (empty -> unlimited)'. |
|
2258 initialText := view maxChars isNil ifTrue:[''] ifFalse:[view maxChars printString]. |
|
2259 ]. |
|
2260 (outlet = 'level') ifTrue:[ |
|
2261 type := #number. |
|
2262 sel := #level:. |
|
2263 initialText := view level printString |
|
2264 ]. |
|
2265 (outlet = 'active level') ifTrue:[ |
|
2266 type := #number. |
|
2267 sel := #onLevel:. |
|
2268 initialText := view onLevel printString |
|
2269 ]. |
|
2270 (outlet = 'passive level') ifTrue:[ |
|
2271 type := #number. |
|
2272 sel := #offLevel:. |
|
2273 initialText := view offLevel printString |
|
2274 ]. |
|
2275 (outlet = 'iconic-label') ifTrue:[ |
|
2276 type := #form. |
|
2277 sel := #label:. |
|
2278 text := 'label-icon:' |
|
2279 ]. |
|
2280 (outlet = 'view background-color') ifTrue:[ |
|
2281 type := #color. |
|
2282 sel := #viewBackground:. |
|
2283 text := 'view background color'. |
|
2284 initialText := 'Black' |
|
2285 ]. |
|
2286 (outlet = 'foreground-color') ifTrue:[ |
|
2287 type := #color. |
|
2288 sel := #foregroundColor:. |
|
2289 text := 'foreground color'. |
|
2290 initialText := 'Black' |
|
2291 ]. |
|
2292 (outlet = 'background-color') ifTrue:[ |
|
2293 type := #color. |
|
2294 sel := #backgroundColor:. |
|
2295 text := 'background color'. |
|
2296 initialText := 'Grey' |
|
2297 ]. |
|
2298 (outlet = 'active foreground-color') ifTrue:[ |
|
2299 type := #color. |
|
2300 sel := #activeForegroundColor:. |
|
2301 text := 'active foreground color'. |
|
2302 initialText := 'Yellow' |
|
2303 ]. |
|
2304 (outlet = 'active background-color') ifTrue:[ |
|
2305 type := #color. |
|
2306 sel := #activeBackgroundColor:. |
|
2307 text := 'active background color'. |
|
2308 initialText := 'Grey' |
|
2309 ]. |
|
2310 (outlet = 'scroll action') ifTrue:[ |
|
2311 type := #block. |
|
2312 sel := #scrollAction:. |
|
2313 text := 'action block when scrolled' |
|
2314 ]. |
|
2315 (outlet = 'scrollUp action') ifTrue:[ |
|
2316 type := #block. |
|
2317 sel := #scrollUpAction:. |
|
2318 text := 'action block when scrolled up' |
|
2319 ]. |
|
2320 (outlet = 'scrollDown action') ifTrue:[ |
|
2321 type := #block. |
|
2322 sel := #scrollDownAction:. |
|
2323 text := 'action block when scrolled down' |
|
2324 ]. |
|
2325 (outlet = 'scrollLeft action') ifTrue:[ |
|
2326 type := #block. |
|
2327 sel := #scrollLeftAction:. |
|
2328 text := 'action block when scrolled left' |
|
2329 ]. |
|
2330 (outlet = 'scrollRight action') ifTrue:[ |
|
2331 type := #block. |
|
2332 sel := #scrollRightAction:. |
|
2333 text := 'action block when scrolled right' |
|
2334 ]. |
|
2335 (outlet = 'press action') ifTrue:[ |
|
2336 type := #block. |
|
2337 sel := #pressAction:. |
|
2338 text := 'action block when pressed' |
|
2339 ]. |
|
2340 (outlet = 'release action') ifTrue:[ |
|
2341 type := #block. |
|
2342 sel := #releaseAction:. |
|
2343 text := 'action block when released' |
|
2344 ]. |
|
2345 (outlet = 'style') ifTrue:[ |
|
2346 type := #symbol. |
|
2347 sel := #style:. |
|
2348 initialList := #(motif next) |
|
2349 ]. |
|
2350 (outlet = 'handle position') ifTrue:[ |
|
2351 type := #symbol. |
|
2352 sel := #handlePosition:. |
|
2353 initialList := #(left center right) |
|
2354 ]. |
|
2355 (outlet = 'horizontal layout') ifTrue:[ |
|
2356 type := #symbol. |
|
2357 sel := #horizontalLayout:. |
|
2358 text := 'horizontal components layout'. |
|
2359 initialList := #(left |
|
2360 leftSpace |
|
2361 leftMax |
|
2362 leftSpaceMax |
|
2363 center |
|
2364 centerMax |
|
2365 right |
|
2366 rightSpace |
|
2367 rightMax |
|
2368 rightSpaceMax |
|
2369 spread |
|
2370 spreadSpace |
|
2371 spreadMax |
|
2372 spreadSpaceMax |
|
2373 fit |
|
2374 fitSpace). |
|
2375 initialText := view horizontalLayout printString |
|
2376 ]. |
|
2377 (outlet = 'vertical layout') ifTrue:[ |
|
2378 type := #symbol. |
|
2379 sel := #verticalLayout:. |
|
2380 text := 'vertical components layout'. |
|
2381 initialList := #(top |
|
2382 topSpace |
|
2383 center |
|
2384 bottom |
|
2385 bottomSpace |
|
2386 spread |
|
2387 spreadSpace |
|
2388 fit |
|
2389 fitSpace). |
|
2390 initialText := view verticalLayout printString |
|
2391 ]. |
|
2392 (outlet = 'label position') ifTrue:[ |
|
2393 type := #symbol. |
|
2394 sel := #labelPosition:. |
|
2395 initialList := #(topLeft topCenter topRight bottomLeft bottomCenter bottomRight). |
|
2396 initialText := view labelPosition printString |
|
2397 ]. |
|
2398 (outlet = 'label layout') ifTrue:[ |
|
2399 type := #symbol. |
|
2400 sel := #adjust:. |
|
2401 initialList := #( left right center centerLeft centerRight fit ). |
|
2402 initialText := view adjust printString |
|
2403 ]. |
|
2404 (outlet = 'orientation') ifTrue:[ |
|
2405 type := #symbol. |
|
2406 sel := #orientation:. |
|
2407 initialList := #( horizontal vertical ). |
|
2408 initialText := view orientation printString |
|
2409 ]. |
|
2410 |
|
2411 (type == #color) ifTrue:[ |
|
2412 initialList := #('Black' |
|
2413 'White' |
|
2414 'LightGrey' |
|
2415 'Grey' |
|
2416 'DarkGrey' |
|
2417 'Yellow' |
|
2418 'Red' |
|
2419 'Green' |
|
2420 'Blue' |
|
2421 ) |
|
2422 ]. |
|
2423 |
|
2424 text isNil ifTrue:[ |
|
2425 text := outlet |
|
2426 ]. |
|
2427 |
|
2428 "what type of box do we need" |
|
2429 |
|
2430 t := type. |
|
2431 ((type == #color) or:[type == #symbol or:[type == #fieldTypeSymbol]]) ifTrue:[ |
|
2432 t := #list |
|
2433 ]. |
|
2434 ((type == #number) or:[type == #numberOrNil]) ifTrue:[ |
|
2435 t := #string |
|
2436 ]. |
|
2437 (type == #strings) ifTrue:[ |
|
2438 t := #text |
|
2439 ]. |
|
2440 (type == #block) ifTrue:[ |
|
2441 t := #text. |
|
2442 initialText := workView outletValueOf:sel for:view. |
|
2443 initialText isNil ifTrue:[initialText := '[statements]'] |
|
2444 ]. |
|
2445 (type == #block1) ifTrue:[ |
|
2446 t := #text. |
|
2447 type := #block. |
|
2448 initialText := workView outletValueOf:sel for:view. |
|
2449 initialText isNil ifTrue:[initialText := '[:argument | statements ]'] |
|
2450 ]. |
|
2451 (type == #block2) ifTrue:[ |
|
2452 t := #text. |
|
2453 type := #block. |
|
2454 initialText := workView outletValueOf:sel for:view. |
|
2455 initialText isNil ifTrue:[initialText := '[:arg1 :arg2 | statements ]'] |
|
2456 ]. |
|
2457 |
|
2458 "show a box to enter thing" |
|
2459 |
|
2460 (t == #boolean) ifTrue:[ |
|
2461 val := Dialog confirmWithCancel:text. |
|
2462 (val == true or:[val == false]) ifTrue:[ |
|
2463 action value:val |
|
2464 ]. |
|
2465 ^ self |
|
2466 ]. |
|
2467 (t == #string) ifTrue:[ |
|
2468 "/ stringBox isNil ifTrue:[ |
|
2469 stringBox := EnterBox new. |
|
2470 "/ ]. |
|
2471 box := stringBox |
|
2472 ]. |
|
2473 (t == #list) ifTrue:[ |
|
2474 "/ listBox isNil ifTrue:[ |
|
2475 listBox := ListSelectionBox new. |
|
2476 "/ ]. |
|
2477 listBox list:initialList. |
|
2478 box := listBox |
|
2479 ]. |
|
2480 (t == #text) ifTrue:[ |
|
2481 "/ actionBox isNil ifTrue:[ |
|
2482 actionBox := TextBox new. |
|
2483 "/ ]. |
|
2484 actionBox initialText:initialText. |
|
2485 box := actionBox |
|
2486 ]. |
|
2487 " |
|
2488 Transcript show:'outlet: '. Transcript showCR:outlet. |
|
2489 Transcript show:'type: '. Transcript showCR:type. |
|
2490 Transcript show:'sel: '. Transcript showCR:sel. |
|
2491 Transcript show:'text: '. Transcript showCR:text. |
|
2492 " |
|
2493 |
|
2494 box isNil ifTrue:[ |
|
2495 self notify:'not yet implemented' |
|
2496 ] ifFalse:[ |
|
2497 box initialText:initialText. |
|
2498 box title:text. |
|
2499 box action:action. |
|
2500 box showAtPointer |
|
2501 ] |
|
2502 |
|
2503 "Modified: 6.9.1995 / 13:46:29 / claus" |
|
2504 ! |
|
2505 |
|
2506 setColors |
|
2507 |fg bg| |
|
2508 |
|
2509 fg := fgChannel value. |
|
2510 (fg notNil and:[fg notEmpty]) ifTrue:[ |
|
2511 fg := Color readFrom:fg. |
|
2512 workView singleSelectionDo:[:selectedView | |
|
2513 selectedView ~~ workView ifTrue:[ |
|
2514 selectedView foregroundColor:fg |
|
2515 ]. |
|
2516 ]. |
|
2517 ]. |
|
2518 bg := bgChannel value. |
|
2519 (bg notNil and:[bg notEmpty]) ifTrue:[ |
|
2520 bg := Color readFrom:bg. |
|
2521 workView singleSelectionDo:[:selectedView | |
|
2522 selectedView ~~ workView ifTrue:[ |
|
2523 selectedView backgroundColor:bg |
|
2524 ]. |
|
2525 ]. |
|
2526 ]. |
|
2527 ! |
|
2528 |
|
2529 setMiscAspects |
|
2530 "sent when apply is pressen in the misc-sub view" |
|
2531 |
|
2532 workView singleSelectionDo:[:selectedView | |
|
2533 selectedView ~~ workView ifTrue:[ |
|
2534 workView changeVariableNameOf:selectedView to:nameChannel value |
|
2535 ] |
|
2536 ]. |
|
2537 ! |
|
2538 |
|
2539 setModelAspects |
|
2540 "sent when apply is pressen in the model-sub view" |
|
2541 |
|
2542 |aspectSymbol| |
|
2543 |
|
2544 aspectSymbol := (self aspectFor:#aspectChannel) value. |
|
2545 (aspectSymbol notNil and:[aspectSymbol notEmpty]) ifTrue:[ |
|
2546 aspectSymbol := aspectSymbol asSymbol. |
|
2547 workView singleSelectionDo:[:selectedView | |
|
2548 selectedView ~~ workView ifTrue:[ |
|
2549 workView setAspectSelector:aspectSymbol forView:selectedView |
|
2550 ]. |
|
2551 ]. |
|
2552 ]. |
|
2553 ! |
|
2554 |
|
2555 setOutlet:outletSymbol type:type to:outletValue in:aView |
|
2556 |block val messageSymbol| |
|
2557 |
|
2558 messageSymbol := outletSymbol. |
|
2559 val := outletValue. |
|
2560 (type == #block) ifTrue:[ |
|
2561 block := Compiler evaluate:val. |
|
2562 (block == #Error) ifTrue:[ |
|
2563 self warn:'action will not work in test-mode'. |
|
2564 workView addOutletDefinitionFor:outletSymbol |
|
2565 type:type |
|
2566 value:outletValue |
|
2567 for:aView. |
|
2568 ^ self |
|
2569 ]. |
|
2570 val := block |
|
2571 ]. |
|
2572 (type == #number) ifTrue:[ |
|
2573 val := Number readFromString:outletValue onError:0 |
|
2574 ]. |
|
2575 (type == #numberOrNil) ifTrue:[ |
|
2576 val := Number readFromString:outletValue onError:nil |
|
2577 ]. |
|
2578 (type == #text) ifTrue:[ |
|
2579 val := outletValue asString |
|
2580 ]. |
|
2581 (type == #strings) ifTrue:[ |
|
2582 val := outletValue asText |
|
2583 ]. |
|
2584 (type == #symbol) ifTrue:[ |
|
2585 val := outletValue asSymbol. |
|
2586 ]. |
|
2587 (type == #fieldTypeSymbol) ifTrue:[ |
|
2588 val := outletValue asSymbol. |
|
2589 val == #password ifTrue:[ |
|
2590 aView passwordCharacter:$* |
|
2591 ] ifFalse:[ |
|
2592 aView passwordCharacter:nil |
|
2593 ]. |
|
2594 val := (PrintConverter new initFor:val). |
|
2595 messageSymbol := #converter: |
|
2596 ]. |
|
2597 (type == #color) ifTrue:[ |
|
2598 val := Color name:outletValue. |
|
2599 val isNil ifTrue:[ |
|
2600 self warn:('no such color:' , outletValue). |
|
2601 ^ self |
|
2602 ] |
|
2603 ]. |
|
2604 Transcript show:(val printString). |
|
2605 Transcript showCR:('(' , val class printString , ')'). |
|
2606 |
|
2607 workView selectionHiddenDo:[ |
|
2608 aView perform:messageSymbol with:val. |
|
2609 workView elementChanged:aView. |
|
2610 aView redraw. |
|
2611 ]. |
|
2612 workView addOutletDefinitionFor:outletSymbol |
|
2613 type:type |
|
2614 value:outletValue |
|
2615 for:aView |
|
2616 |
|
2617 "Modified: 6.9.1995 / 13:44:46 / claus" |
|
2618 ! |
|
2619 |
|
2620 showPropertyView |
|
2621 |v l spec| |
|
2622 |
|
2623 workView singleSelectionDo:[:selectedView | |
|
2624 propertyShown = 'dimension' ifTrue:[ |
|
2625 (l := selectedView geometryLayout) notNil ifTrue:[ |
|
2626 l isLayout ifTrue:[ |
|
2627 l isAlignmentOrigin ifTrue:[ |
|
2628 spec := self class geometrySpecForAlignmentOrigin |
|
2629 ] ifFalse:[ |
|
2630 l isLayoutFrame ifFalse:[ |
|
2631 spec := self class geometrySpecForLayoutOrigin |
|
2632 ] |
|
2633 ] |
|
2634 ] |
|
2635 ]. |
|
2636 spec isNil ifTrue:[ |
|
2637 spec := self class geometrySpecForLayoutFrame |
|
2638 ]. |
|
2639 ^ self setupPropertyFromSpec:spec |
|
2640 ]. |
|
2641 |
|
2642 propertyShown = 'colors' ifTrue:[ |
|
2643 ^ self setupPropertyFromSpec:(self class colorSpec) |
|
2644 ]. |
|
2645 |
|
2646 propertyShown = 'model' ifTrue:[ |
|
2647 ^ self setupPropertyFromSpec:(self class modelSpec) |
|
2648 ]. |
|
2649 |
|
2650 propertyShown = 'misc' ifTrue:[ |
|
2651 ^ self setupPropertyFromSpec:(self class miscSpec) |
|
2652 ]. |
|
2653 |
|
2654 propertyShown = 'attribute list' ifTrue:[ |
|
2655 specShown ~~ #attributeList ifTrue:[ |
|
2656 propertyFrame destroySubViews. |
|
2657 v := ScrollableView for:SelectionInListView in:propertyFrame. |
|
2658 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
2659 outletView := v scrolledView. |
|
2660 outletView action:[:lineNr | lineNr notNil ifTrue:[self selectOutlet:lineNr]]. |
|
2661 propertyFrame realizeAllSubViews. |
|
2662 specShown := #attributeList. |
|
2663 ]. |
|
2664 self showOutletsFor:(workView selection). |
|
2665 ^ self |
|
2666 ]. |
|
2667 ]. |
|
2668 |
|
2669 propertyFrame destroySubViews. |
|
2670 outletView := nil. |
|
2671 specShown := nil. |
|
2672 |
|
2673 ! |
|
2674 |
|
2675 toggleTest |
2792 toggleTest |
2676 |m t| |
2793 |m t| |
2677 |
2794 |
2678 m := menu menuAt:#test. |
2795 m := menu menuAt:#test. |
2679 t := workView testMode not. |
2796 t := workView testMode not. |