home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 August / macformat-027.iso / mac / Shareware City / Developers / Oberon⁄F / Form / Docu / Models (.txt) < prev    next >
Encoding:
Oberon Document  |  1994-06-07  |  9.1 KB  |  226 lines  |  [oODC/obnF]

  1. Documents.StdDocumentDesc
  2. Documents.DocumentDesc
  3. Containers.ViewDesc
  4. Views.ViewDesc
  5. Stores.StoreDesc
  6. Documents.ModelDesc
  7. Containers.ModelDesc
  8. Models.ModelDesc
  9. Stores.ElemDesc
  10. TextViews.StdViewDesc
  11. TextViews.ViewDesc
  12. TextModels.StdModelDesc
  13. TextModels.ModelDesc
  14. TextModels.AttributesDesc
  15. Geneva
  16. TextRulers.StdRulerDesc
  17. TextRulers.RulerDesc
  18. TextRulers.StdStyleDesc
  19. TextRulers.StyleDesc
  20. TextRulers.AttributesDesc
  21. Geneva
  22. Geneva
  23. Geneva
  24. Geneva
  25. 7 The Forms Subsystem
  26. 7.1 FormModels
  27. DEFINITION FormModels;
  28.     IMPORT Ports, Models, Views, Containers;
  29.     CONST minView Size = 4 * Ports.point; maxViewSize = 160 * Ports.mm;
  30.     TYPE
  31.         Model = POINTER TO ModelDesc;
  32.         ModelDesc = RECORD (Containers.ModelDesc)
  33.             PROCEDURE (m: Model) Clone (): Model;
  34.             PROCEDURE (m: Model) CopyFrom (source: Model);
  35.             PROCEDURE (m: Model) Insert (v: Views.View; l, t, r, b: LONGINT);
  36.             PROCEDURE (m: Model) Delete (v: Views.View);
  37.             PROCEDURE (m: Model) Resize (v: Views.View; l, t, r, b: LONGINT);
  38.             PROCEDURE (m: Model) PutAbove (v, p: Views.View);
  39.             PROCEDURE (m: Model) Move (v: Views.View; dx, dy: LONGINT);
  40.             PROCEDURE (m: Model) Copy (VAR v: Views.View; dx, dy: LONGINT);
  41.             PROCEDURE (m: Model) NewReader (old: Reader): Reader;
  42.             PROCEDURE (m: Model) NewWriter (old: Writer): Writer;
  43.             PROCEDURE (m: Model) ViewAt (x, y: LONGINT): Views.View;
  44.             PROCEDURE (m: Model) NofViews (): INTEGER
  45.         END;
  46.         Directory = POINTER TO DirectoryDesc;
  47.         DirectoryDesc = RECORD
  48.             PROCEDURE (d: Directory) New (): Model
  49.         END;
  50.         Context = POINTER TO ContextDesc;
  51.         ContextDesc = RECORD (Models.ContextDesc)
  52.             PROCEDURE (c: Context) ThisModel (): Model;
  53.             PROCEDURE (c: Context) GetRect (VAR l, t, r, b: LONGINT)
  54.         END;
  55.         Reader = POINTER TO ReaderDesc;
  56.         ReaderDesc = RECORD
  57.             view: Views.View;
  58.             l, t, r, b: LONGINT;
  59.             PROCEDURE (r: Reader) Set (p: Views.View);
  60.             PROCEDURE (r: Reader) ReadView (VAR v: Views.View)
  61.         END;
  62.         Writer = POINTER TO WriterDesc;
  63.         WriterDesc = RECORD
  64.             PROCEDURE (w: Writer) Set (p: Views.View);
  65.             PROCEDURE (w: Writer) WriteView (v: Views.View; l, t, r, b: LONGINT)
  66.         END;
  67.         UpdateMsg = RECORD (Models.UpdateMsg)
  68.             l, t, r, b: LONGINT
  69.         END;
  70.     VAR dir-, stdDir-: Directory;
  71.     PROCEDURE GetRect (v: Views.View; VAR l, t, r, b: LONGINT);
  72.     PROCEDURE SetDir (d: Directory);
  73. END FormModels.
  74. FormModels are container models which contain views. They have no further intrinsic contents. Form models can be used to arrange rectangular views in arbitrary layouts. Their main use is as data entry forms and as dialog layouts.
  75. CONST minViewSize
  76. This is the minimal width and height of a view which is embedded in a form model.
  77. CONST maxViewSize
  78. This is the maximal width and height of a view which is embedded in a form model.
  79. TYPE Model
  80. Interface, Extension
  81. Form models are container models (containers are not described here), which contain rectangular views and nothing else.
  82. PROCEDURE (m: Model) Clone (): Model
  83. Extension
  84. Result type is narrowed.
  85. PROCEDURE (m: Model) CopyFrom (source: Model)
  86. Copy contents of source to m.
  87. ~m.init    20
  88. source # NIL    21
  89. source.init    22
  90. m.init
  91. PROCEDURE (m: Model) Insert (v: Views.View; l, t, r, b: LONGINT)
  92. Interface, Operation
  93. Insert view v with bounding box (l, t, r, b).
  94. v # NIL    20
  95. v.init    21
  96. v.context = NIL    22
  97. l <= r    23
  98. t <= b    24
  99. v in m
  100. v.context # NIL & v.context.ThisModel() = m
  101. PROCEDURE (m: Model) Delete (v: Views.View)
  102. Interface, Operation
  103. Remove v from m.
  104. v in m    20
  105. ~(v in m)
  106. PROCEDURE (m: Model) Resize (v: Views.View; l, t, r, b: LONGINT)
  107. Interface, Operation
  108. Redefine bounding box of v.
  109. v in m    20
  110. l <= r    21
  111. t <= b    22
  112. PROCEDURE (m: Model) PutAbove (v, p: Views.View)
  113. Interface, Operation
  114. Change the vertical order of view v, such that it comes to lie directly above p if p # NIL, otherwise it is put to the bottom of the view list.
  115. v in m    20
  116. p = NIL  OR  p in f    21
  117. PROCEDURE (m: Model) Move (v: Views.View; dx, dy: LONGINT)
  118. Interface, Operation
  119. Move view v by (dx, dy), without changing its size.
  120. v in m    20
  121. PROCEDURE (m: Model) Copy (VAR v: Views.View; dx, dy: LONGINT)
  122. Interface, Operation
  123. Create a copy of v and put it at v's bounding box shifted by (dx, dy). Parameter v returns the copy.
  124. v # NIL    20
  125. v.context # NIL    21
  126. v.context.ThisModel() = m    22
  127. v # NIL  &  v # v'
  128. PROCEDURE (m: Model) ReplaceView (old, new: Views.View)
  129. Interface, Extension, Operation
  130. Retain the context of old, but replace old by new.
  131. old # NIL    20
  132. new # NIL    21
  133. old.context # NIL    22
  134. new.context = NIL  OR  new.context = old.context    23
  135. new.init    24
  136. new.context = old.context
  137. PROCEDURE (m: Model) NewReader (old: Reader): Reader
  138. Returns a reader connected to f. An old reader may be passed as input parameter, if it isn't in use anymore.
  139. result # NIL
  140. PROCEDURE (m: Model) NewWriter (old: Writer): Writer
  141. Returns a writer connected to m. An old writer may be passed as input parameter, if it isn't in use anymore.
  142. result # NIL
  143. PROCEDURE (m: Model) ViewAt (x, y: LONGINT): Views.View
  144. Returns the topmost view in m which encloses position (x, y).
  145. result # NIL
  146.     where (l, t, r, b) is the bounding box of v: (l <= x <= r) & (t <= y <= b)
  147. result = NIL
  148.     no view at (x, y)
  149. PROCEDURE (m: Model) NofViews (): INTEGER
  150. Returns the number of views currently in m.
  151. result >= 0
  152. TYPE Directory
  153. Interface
  154. Directory for the allocation of concrete form models.
  155. PROCEDURE (d: Directory) New (): Model
  156. Interface
  157. Create and return a new concrete form model.
  158. result # NIL
  159. result.init
  160. TYPE Context
  161. Extension, Interface
  162. Context of a view in a form.
  163. PROCEDURE (c: Context) ThisModel (): Model
  164. Extension, Interface
  165. Returns the form which contains the context.
  166. PROCEDURE (c: Context) GetRect (VAR l, t, r, b: LONGINT)
  167. Interface
  168. Returns the bounding box of the context's view.
  169. l < r  &  t < b
  170. TYPE Reader
  171. Interface
  172. Input rider on a form model.
  173. view: Views.View
  174. Most recently read view.
  175. l, t, r, b: LONGINT    view # NIL => l < r & t < b
  176. Bounding box of most recently read view.
  177. PROCEDURE (r: Reader) Set (p: Views.View)
  178. Interface
  179. Set position of reader r to the view above p (i.e. the next view to be read will be the one directly above p) or to the bottom if p = NIL.
  180. p in Base(r)  OR  p = NIL    20
  181. PROCEDURE (r: Reader) ReadView (VAR v: Views.View)
  182. Interface
  183. Reads the next view, in ascending order. If there is none, v is set to NIL. The reader's view and l, t, r, b fields will be set accordingly (l, t, r, b are undefined if view is NIL).
  184. v = r.view
  185. TYPE Writer
  186. Interface
  187. Output rider on a form.
  188. PROCEDURE (w: Writer) Set (p: Views.View)
  189. Interface
  190. Set position of writer w to the view above p (i.e. the next view to be written will be inserted directly above p) or to the bottom if p = NIL.
  191. p in Base(r)  OR  p = NIL    20
  192. PROCEDURE (w: Writer) WriteView (v: Views.View; l, t, r, b: LONGINT)
  193. Interface
  194. Insert view v at the current position in w's form.
  195. v # NIL    20
  196. v.init    21
  197. v.context = NIL    22
  198. l <= r    23
  199. t <= b    24
  200. v.init
  201. v.context # NIL
  202. TYPE UpdateMsg
  203. Extension
  204. This message indicates that a rectangular part of a form needs to be updated on the screen.
  205. The receiver must not switch on any marks as a reaction to having received this message.
  206. UpdateMsgs are sent by concrete form model implementations after any view modifications.
  207. UpdateMsgs are not extended.
  208. VAR dir-, stdDir-: Directory;    dir # NIL  &  stdDir # NIL
  209. Form model directories.
  210. PROCEDURE GetRect (v: Views.View; VAR l, t, r, b: LONGINT)
  211. Returns the bounding box of view v, provided it is embedded in a form model.
  212. v # NIL    20
  213. v.context # NIL    21
  214. v.context IS Context    22
  215. l < r  &  t < b
  216. PROCEDURE SetDir (d: Directory)
  217. Assign directory.
  218. d # NIL    20
  219. dir = d
  220. TextControllers.StdCtrlDesc
  221. TextControllers.ControllerDesc
  222. Containers.ControllerDesc
  223. Controllers.ControllerDesc
  224. Geneva
  225. Documents.ControllerDesc
  226.