home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / self / contrib.lha / contrib / 491 / aa / selection.self < prev    next >
Encoding:
Text File  |  1993-07-18  |  4.1 KB  |  180 lines

  1. " Editing functions for equations.
  2. "
  3. "
  4. *
  5. * /home/2user2/richards/cvs/491/aa/selection.self,v 1.6 1993/07/18 20:22:33 richards Exp
  6. *
  7. * selection.self,v
  8. # Revision 1.6  1993/07/18  20:22:33  richards
  9. # Added substitution of polynomials (not quite working properly yet).
  10. # Some tests for this added to test4.
  11. # Buttons work, selections work, and eventHandling is coming along.
  12. #
  13. # Revision 1.5  1993/07/14  16:51:13  richards
  14. # Renamed editor.self to selection.self.
  15. #
  16. # Revision 1.4  1993/07/13  21:47:01  richards
  17. # July 13 checkin.
  18. #
  19. # Revision 1.3  1993/06/23  21:18:10  richards
  20. # Daily checkin.
  21. #
  22. # Revision 1.2  1993/06/23  02:04:24  richards
  23. # Progress towards being able to select equations.
  24. #
  25. # Revision 1.1  1993/06/23  00:36:52  richards
  26. # Editor.self contains the code to do selection, and eventually, all user interaction.
  27. #
  28. *
  29. *
  30. "
  31.  
  32. aa _AddSlotsIfAbsent: (| editor = () |).
  33.  
  34. aa editor _AddSlotsIfAbsent: (|
  35.     ^ prototypes* = ().
  36.     ^ oddballs*   = ().
  37.     ^ traits      = ().
  38.     ^ mixins      = ().
  39. |)
  40.  
  41. " **** SELECTION RECORD ***** "
  42.  
  43. aa editor traits _AddSlotsIfAbsent: (|
  44.     portion = ().
  45.     selectedPortion = ().
  46.     unselectedPortion = ().
  47. |)
  48.  
  49. aa editor prototypes _AddSlotsIfAbsent: (|
  50.     selectedPortion = ().
  51.     unselectedPortion = ().
  52. |)
  53.  
  54. " **************
  55.   TRAITS SECTION
  56.   **************
  57. "
  58.  
  59. aa editor traits portion _Define: (|
  60.     parent* = traits clonable.
  61.     
  62.     ^ becomeSelected = (
  63.     selectionParent: aa editor traits selectedPortion.
  64.     selectedViews: set copy.
  65.     ).
  66.  
  67.     ^ becomeSelectedWith: vue = (
  68.     becomeSelected.
  69.     selectedArea: vue area.
  70.     selectedBoite: vue model canonicalPolyObject.
  71.     selectedPolynum: selectedBoite polyObject.
  72.     selectedWindow: vue heavySuperView.
  73.     selectedViews add: vue.
  74.     highlightViews.
  75.     ).
  76.  
  77.     ^ becomeUnselected = (
  78.     selectionParent: aa editor traits unselectedPortion.
  79.     selectedViews do: [ |:aSv|
  80.         aSv unHighlight.
  81.     ].
  82.     selectedViews: set copy.
  83.     iPolynum: nil.
  84.     iBoite: nil.
  85.     iArea: (0@0)#(0@0).
  86.     ).
  87. |)
  88.  
  89. aa editor traits selectedPortion _Define: (|
  90.     parent* = aa editor traits portion.
  91.     
  92.     ^ copy = (| c. |
  93.     c: clone.
  94.     c selectedArea: selectedArea copy.
  95.     c selectedViews: set copy.
  96.     c
  97.     ).
  98.  
  99.     isValidSelection = ( true ).
  100.  
  101.     becomeEnclosingEqn = (| up. |
  102.     up: selectedBoite upPolyObject.
  103.     up isNil ifFalse: [
  104.         selectedBoite: up.
  105.         selectedBoite leafsDo: [ | :aSubBoite. subBoiteView. |
  106.         (selectedWindow boiteSubViews includesKey: aSubBoite) ifTrue: [
  107.             subBoiteView: selectedWindow boiteSubViews at: aSubBoite.
  108.             selectedArea: selectedArea union: subBoiteView area.
  109.             subBoiteView highlight.
  110.             selectedViews add: subBoiteView.
  111.         ].
  112.         ].
  113.         selectedPolynum: selectedBoite polyObject.
  114.     ] True: [
  115.         becomeUnselected.
  116.     ].
  117.     ).
  118.  
  119.     highlightViews = (
  120.     selectedBoite leafsDo: [ | :aSubBoite. subBoiteView. |
  121.         (selectedWindow boiteSubViews includesKey: aSubBoite) ifTrue: [
  122.         subBoiteView: selectedWindow boiteSubViews at: aSubBoite.
  123.         selectedArea: selectedArea union: subBoiteView area.
  124.         subBoiteView highlight.
  125.         selectedViews add: subBoiteView.
  126.         ].
  127.     ].
  128.     ).
  129.  
  130.     ^ selectedArea = ( iArea ).
  131.     ^ selectedArea: a = ( iArea: a ).
  132.     ^ selectedPolynum = ( iPolynum ).
  133.     ^ selectedPolynum: p = ( iPolynum: p ).
  134.     ^ selectedBoite = ( iBoite ).
  135.     ^ selectedBoite: v = (iBoite: v).
  136. |)
  137.  
  138. " dummy to indicate failure to match anything "
  139.  
  140. aa editor traits unselectedPortion _Define: (|
  141.     _ parent* = aa editor traits portion.
  142.     ^ copy = (| c. |
  143.     c: clone.
  144.     c
  145.     ).
  146.  
  147.     ^ isValidSelection = ( false ). 
  148.     ^ selectedArea = ((0@0)#(0@0)).
  149.     ^ selectedPolynum = (nil).
  150.     ^ selectedBoite = (nil).
  151. |)
  152.  
  153.  
  154. " ******************
  155.   PROTOTYPES SECTION
  156.   ******************
  157. "
  158.  
  159. aa editor prototypes selectedPortion _Define: (|
  160.     _ selectionParent* <- aa editor traits selectedPortion.
  161.     ^ iArea <- (0@0)#(0@0).
  162.     ^ selectedWindow.
  163.     ^ iBoite.
  164.     ^ iPolynum.
  165.     ^ selectedViews.
  166. |)
  167.  
  168. aa editor prototypes unselectedPortion _Define: (|
  169.     _ selectionParent* <- aa editor traits unselectedPortion.
  170.     ^ iArea <- (0@0)#(0@0).
  171.     ^ selectedWindow.
  172.     ^ iBoite.
  173.     ^ iPolynum.
  174.     ^ selectedViews <- set copy.
  175. |)
  176.  
  177.     
  178.     
  179.       
  180.