Logos.txt 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. MODULE StdLogos;
  2. (* THIS IS TEXT COPY OF BlackBox 1.6-rc6 Std/Mod/Logos.odc *)
  3. (* DO NOT EDIT *)
  4. IMPORT Ports, Stores, Views, Controllers, Properties;
  5. CONST
  6. W = 4;
  7. baseSize = 24 * Ports.point;
  8. colBase = 00202020H;
  9. changeColorKey = "#System:ChangeColor";
  10. minVersion = 0; maxVersion = 0;
  11. TYPE
  12. View = POINTER TO RECORD (Views.View)
  13. c: Ports.Color
  14. END;
  15. ChangeSizeOp = POINTER TO RECORD (Stores.Operation)
  16. view: View;
  17. size: INTEGER;
  18. END;
  19. ChangeColorOp = POINTER TO RECORD (Stores.Operation)
  20. view: View;
  21. color: Ports.Color
  22. END;
  23. (* curve painting *)
  24. PROCEDURE Paint (f: Views.Frame; size: INTEGER; col, bgnd: Ports.Color);
  25. VAR i, d, s, g, m, a, b, l, l0, rl, rt, rr, rb: INTEGER; c: Ports.Color;
  26. BEGIN
  27. s := size DIV 10; d := size DIV 2; g := d DIV 8; m := size * W DIV 2;
  28. f.DrawOval(0, s * 2, size * W, size, Ports.fill, col);
  29. f.DrawOval(s * W, s * 11 DIV 4, (size - s) * W, size - s * 3 DIV 4, Ports.fill, bgnd);
  30. a := m; b := m + d; c := 7 * colBase; i := 0;
  31. WHILE i < 4 DO
  32. f.DrawOval(a, 0, b, d, Ports.fill, c);
  33. INC(a, g); DEC(b, g); DEC(c, colBase); INC(i)
  34. END;
  35. f.rider.GetRect(rl, rt, rr, rb);
  36. l0 := rl; l := (f.gx + m + d DIV 2) DIV f.unit;
  37. IF l < rr THEN
  38. f.rider.SetRect(l, rt, rr, rb);
  39. a := m; b := m + d; c := 0; i := 0;
  40. WHILE i < 4 DO
  41. f.DrawOval(a, 0, b, d, Ports.fill, c);
  42. INC(a, g); DEC(b, g); INC(c, colBase); INC(i)
  43. END;
  44. f.rider.SetRect(l0, rt, rr, rb)
  45. END
  46. END Paint;
  47. (* ChangeOp *)
  48. PROCEDURE (op: ChangeSizeOp) Do;
  49. VAR v: View; size, w: INTEGER;
  50. BEGIN
  51. v := op.view;
  52. size := op.size; v.context.GetSize(w, op.size); v.context.SetSize(size * W, size);
  53. Views.Update(v, Views.keepFrames)
  54. END Do;
  55. PROCEDURE (op: ChangeColorOp) Do;
  56. VAR v: View; color: Ports.Color;
  57. BEGIN
  58. v := op.view;
  59. color := op.color; op.color := v.c; v.c := color;
  60. Views.Update(v, Views.keepFrames)
  61. END Do;
  62. (* View *)
  63. PROCEDURE (v: View) Internalize (VAR rd: Stores.Reader);
  64. VAR thisVersion: INTEGER;
  65. BEGIN
  66. v.Internalize^(rd); IF rd.cancelled THEN RETURN END;
  67. rd.ReadVersion(minVersion, maxVersion, thisVersion); IF rd.cancelled THEN RETURN END;
  68. rd.ReadInt(v.c)
  69. END Internalize;
  70. PROCEDURE (v: View) Externalize (VAR wr: Stores.Writer);
  71. BEGIN
  72. v.Externalize^(wr);
  73. wr.WriteVersion(maxVersion);
  74. wr.WriteInt(v.c)
  75. END Externalize;
  76. PROCEDURE (v: View) CopyFromSimpleView (source: Views.View);
  77. BEGIN
  78. WITH source: View DO v.c := source.c END
  79. END CopyFromSimpleView;
  80. PROCEDURE (v: View) Restore (f: Views.Frame; l, t, r, b: INTEGER);
  81. VAR w, h: INTEGER; bgnd: Ports.Color; g: Views.Frame;
  82. BEGIN
  83. g := f;
  84. REPEAT
  85. g := Views.HostOf(g);
  86. bgnd := Views.transparent;
  87. g.view.GetBackground(bgnd)
  88. UNTIL bgnd # Views.transparent;
  89. v.context.GetSize(w, h);
  90. Paint(f, h, v.c, bgnd)
  91. END Restore;
  92. PROCEDURE (v: View) HandleCtrlMsg (f: Views.Frame; VAR msg: Controllers.Message;
  93. VAR focus: Views.View);
  94. BEGIN
  95. WITH msg: Properties.CollectMsg DO
  96. Views.HandlePropMsg(v, msg.poll)
  97. | msg: Properties.EmitMsg DO
  98. Views.HandlePropMsg(v, msg.set)
  99. ELSE (* ignore other messages *)
  100. END
  101. END HandleCtrlMsg;
  102. PROCEDURE (v: View) HandlePropMsg (VAR msg: Properties.Message);
  103. VAR q: Properties.Property; p: Properties.StdProp;
  104. cop: ChangeColorOp;
  105. BEGIN
  106. WITH msg: Properties.SizePref DO
  107. IF (msg.w > Views.undefined) & (msg.h > Views.undefined) THEN
  108. (* constrain proposed size *)
  109. Properties.ProportionalConstraint(W, 1, msg.fixedW, msg.fixedH, msg.w, msg.h)
  110. ELSE
  111. (* return default size *)
  112. msg.w := W * baseSize; msg.h := baseSize
  113. END
  114. | msg: Properties.PollMsg DO
  115. NEW(p); p.known := {Properties.color}; p.valid := p.known;
  116. p.color.val := v.c;
  117. msg.prop := p
  118. | msg: Properties.SetMsg DO
  119. q := msg.prop;
  120. WHILE q # NIL DO
  121. WITH q: Properties.StdProp DO
  122. IF Properties.color IN q.valid THEN
  123. NEW(cop); cop.view := v; cop.color := q.color.val;
  124. Views.Do(v, changeColorKey, cop)
  125. END;
  126. ELSE
  127. END;
  128. q :=q.next
  129. END
  130. ELSE
  131. END
  132. END HandlePropMsg;
  133. PROCEDURE Deposit*;
  134. VAR v: View;
  135. BEGIN
  136. NEW(v); v.c := Ports.grey50; Views.Deposit(v)
  137. END Deposit;
  138. END StdLogos.