105 a number-string to a value via #value:. |
105 a number-string to a value via #value:. |
106 Useful as an editFields model, which operates on some |
106 Useful as an editFields model, which operates on some |
107 numeric value (or aspectAdaptor, which adapts to a numeric slot)" |
107 numeric value (or aspectAdaptor, which adapts to a numeric slot)" |
108 |
108 |
109 ^ (self on:aValueHolder) numberToTextFormattedBy:formatString |
109 ^ (self on:aValueHolder) numberToTextFormattedBy:formatString |
|
110 |
|
111 "Created: 4.3.1997 / 11:51:25 / cg" |
|
112 "Modified: 4.3.1997 / 11:51:41 / cg" |
|
113 ! |
|
114 |
|
115 onNumberValue:aValueHolder minValue:min maxValue:max |
|
116 "create and return a typeConverter, which retrieves |
|
117 a values string representation via #value, and converts |
|
118 a number-string to a value via #value:. |
|
119 Useful as an editFields model, which operates on some |
|
120 numeric value (or aspectAdaptor, which adapts to a numeric slot)" |
|
121 |
|
122 ^ (self on:aValueHolder) numberToTextMinValue:min maxValue:max |
110 |
123 |
111 "Created: 4.3.1997 / 11:51:25 / cg" |
124 "Created: 4.3.1997 / 11:51:25 / cg" |
112 "Modified: 4.3.1997 / 11:51:41 / cg" |
125 "Modified: 4.3.1997 / 11:51:41 / cg" |
113 ! |
126 ! |
114 |
127 |
465 updateBlock: [:m :a :p | true] |
478 updateBlock: [:m :a :p | true] |
466 |
479 |
467 "Modified: 21.2.1997 / 18:59:44 / cg" |
480 "Modified: 21.2.1997 / 18:59:44 / cg" |
468 ! |
481 ! |
469 |
482 |
|
483 numberToTextMin:minVal max:maxVal |
|
484 "setup the converter to convert from a string to a number |
|
485 and vice versa, but clamping the number into the range." |
|
486 |
|
487 self |
|
488 getBlock:[:model | |
|
489 |numericValue| |
|
490 |
|
491 (numericValue := model value) isNil ifTrue:[ |
|
492 String new |
|
493 ] ifFalse:[ |
|
494 numericValue printString |
|
495 ]] |
|
496 |
|
497 putBlock: |
|
498 [:model :string | |
|
499 |
|
500 |value| |
|
501 |
|
502 string isEmpty ifTrue:[ |
|
503 value := 0 |
|
504 ] ifFalse:[ |
|
505 value := string asNumber |
|
506 ]. |
|
507 value := (value max:minVal) min:maxVal. |
|
508 model value:value] |
|
509 |
|
510 updateBlock: [:m :a :p | true] |
|
511 |
|
512 "Modified: 21.2.1997 / 18:59:44 / cg" |
|
513 ! |
|
514 |
|
515 numberToTextMinValue:minVal maxValue:maxVal |
|
516 "setup the converter to convert from a string to a number |
|
517 and vice versa, but clamping the number into the range." |
|
518 |
|
519 self |
|
520 getBlock:[:model | |
|
521 |numericValue| |
|
522 |
|
523 (numericValue := model value) isNil ifTrue:[ |
|
524 String new |
|
525 ] ifFalse:[ |
|
526 numericValue printString |
|
527 ]] |
|
528 |
|
529 putBlock: |
|
530 [:model :string | |
|
531 |
|
532 |value| |
|
533 |
|
534 string isEmpty ifTrue:[ |
|
535 value := 0 |
|
536 ] ifFalse:[ |
|
537 value := string asNumber |
|
538 ]. |
|
539 value := (value max:minVal) min:maxVal. |
|
540 model value:value] |
|
541 |
|
542 updateBlock: [:m :a :p | true] |
|
543 |
|
544 "Modified: 21.2.1997 / 18:59:44 / cg" |
|
545 ! |
|
546 |
470 smalltalkObject |
547 smalltalkObject |
471 "setup the converter to convert from a string to any smalltalk object |
548 "setup the converter to convert from a string to any smalltalk object |
472 and vice versa. The string used is the objects storeString. |
549 and vice versa. The string used is the objects storeString. |
473 Invalid strings (i.e. empty) are converted to nil. |
550 Invalid strings (i.e. empty) are converted to nil. |
474 This is a very special converter (for the GUI builder) |
551 This is a very special converter (for the GUI builder) |