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

  1. " Implementation of graphics boxes (a la TeX) for Self"
  2.  
  3. "
  4. *
  5. * aaviews.self,v 1.2 1993/07/13 21:46:56 richards Exp
  6. *
  7. * /home/2user2/richards/cvs/491/aa/aaviews.self,v 1.2 1993/07/13 21:46:56 richards Exp
  8. *
  9. * aaviews.self,v
  10. # Revision 1.2  1993/07/13  21:46:56  richards
  11. # July 13 checkin.
  12. #
  13. # Revision 1.1  1993/06/24  21:24:27  richards
  14. # Split drawing out of boites and into light weight views.
  15. #
  16. *
  17. *
  18. "
  19.  
  20.  
  21. aa _AddSlotsIfAbsent: (| views* = (). |)
  22. aa views _AddSlotsIfAbsent: (| traits = () |)
  23. aa views _AddSlotsIfAbsent: (| prototypes* = () |)
  24.     
  25. aa views traits _AddSlotsIfAbsent: (|
  26.     boiteView = ().
  27. |)
  28.  
  29. aa views prototypes _AddSlotsIfAbsent: (|
  30.     boiteView = ().
  31. |)
  32.  
  33. aa views traits boiteView _Define: (|
  34.     parent** = traits views lwView.
  35.  
  36.     copying* = (|
  37.     copyForBoite: b At: pt = (| nv. |
  38.         nv: copyUnrealised.
  39.         nv model: b.
  40.         nv area: ((pt x)@(pt y - b upY))#((pt x + b xSize)@(pt y + b downY)).
  41.         nv boiteOriginPt: pt.
  42.         nv isHighlighted: isHighlighted.
  43.         nv
  44.     ).
  45.     |).
  46.  
  47.     drawing* = (|
  48.     simpleRedraw = (
  49.         model drawOn: self At: boiteOriginPt.
  50.     ).
  51.     highlight = (
  52.         'highliting: ' print. model printLine.
  53.         isHighlighted: true.
  54.     ).
  55.     unHighlight = (
  56.         isHighlighted: false.
  57.     ).
  58.     drawAt: p String: s = (
  59.         heavySuperView drawAt: p String: s
  60.     ).
  61.     drawFrom: o To: c Width: w = (
  62.         heavySuperView drawFrom: o To: c Width: w
  63.     ).
  64.     drawFrom: o To: c = (
  65.         heavySuperVIew drawFrom: o To: c
  66.     ).
  67.     drawLine: r = (
  68.         heavySuperView drawLine: r
  69.     ).
  70.     drawFrom: o For: c = (
  71.         heavySuperView drawFrom: o For: c
  72.     ).
  73.     drawAt: p String: s InFontNamed: fname = (
  74.         drawAt: p String: s InFont: (manager openFontNamed: fname).
  75.     ).
  76.     drawAt: p String: s InFont: fontStruct = ( | fg. bg. |
  77.         isHighlighted ifTrue: [
  78.         fg: manager gcWithCharacteristics: [ | :aGc |
  79.             (aGc fontId = fontStruct fid) &&
  80.               (aGc whitePixel = manager display screen blackPixel) &&
  81.               (aGc blackPixel = manager display screen whitePixel)
  82.         ] MakeIt: [ | :aGc |
  83.             aGc fontId: fontStruct fid.
  84.             aGc whitePixel: manager display screen blackPixel.
  85.             aGc blackPixel: manager display screen whitePixel.
  86.         ].
  87.         bg: manager gc.
  88.         ] False: [
  89.         fg: manager gcWithCharacteristics: [ | :aGc |
  90.             (aGc fontId = fontStruct fid) &&
  91.               (aGc blackPixel = manager display screen blackPixel) &&
  92.               (aGc whitePixel = manager display screen whitePixel)
  93.         ] MakeIt: [ | :aGc |
  94.             aGc fontId: fontStruct fid.
  95.             aGc blackPixel: manager display screen blackPixel.
  96.             aGc whitePixel: manager display screen whitePixel.
  97.             aGc
  98.         ].
  99.         bg: manager gcb.
  100.         ].
  101.         window fillRectangle: area GC: bg.
  102.         window drawString: s At: p GC: fg.
  103.     ).
  104.     
  105.     |).
  106.  
  107.     viewEvents* = (|
  108.     ^ selectDown: pt WithSelection: es = (
  109.         (area includes: pt) ifTrue: [
  110.         es isValidSelection ifFalse: [
  111.             " new selection "
  112.             es becomeSelectedWith: self.
  113.         ] True: [
  114.             " there was an old selection "
  115.             (es selectedBoite contains: model) ifTrue: [
  116.             " we selected the same object again "
  117.             " -> expand if possible"
  118.             es becomeEnclosingEqn.
  119.             ] False: [
  120.             es becomeSelectedWith: self.
  121.             ].
  122.         ].
  123.         ].
  124.     ).
  125.     |).
  126. |)  
  127.  
  128. aa views prototypes boiteView _Define: prototypes views lwView
  129. aa views prototypes boiteView _AddSlots: (|
  130.     parent* = aa views traits boiteView.
  131.     boiteOriginPt.
  132.     isHighlighted <- false.
  133. |)
  134.  
  135.