home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / libraries / mui20dev.lha / MUI / Developer / Modula / txt / MuiMacros.def < prev    next >
Encoding:
Modula Definition  |  1994-02-11  |  13.1 KB  |  448 lines

  1. DEFINITION MODULE MuiMacros;
  2.  
  3. (*$ DEFINE Locale:=FALSE *)
  4.  
  5. (****************************************************************************
  6. **
  7. **      MUI Macros 2.0
  8. **
  9. **      Converted to Modula by Christian "Kochtopf" Scholz
  10. **
  11. **      refer also to MuiMacros.mod if you want to know, how they are made.
  12. **
  13. **      $Id: MuiMacros.def,v 1.4 1994/02/09 14:50:03 Kochtopf Exp $
  14. **
  15. **      $Log: MuiMacros.def,v $
  16. # Revision 1.4  1994/02/09  14:50:03  Kochtopf
  17. # Versionsnummer in 2.0 geaendert.
  18. #
  19. **
  20. ****************************************************************************
  21. ** Class Tree
  22. ****************************************************************************
  23. **
  24. ** rootclass               (BOOPSI's base class)
  25. ** +--Notify               (implements notification mechanism)
  26. **    +--Application       (main class for all applications)
  27. **    +--Window            (handles intuition window related topics)
  28. **    +--Area              (base class for all GUI elements)
  29. **       +--Rectangle      (creates empty rectangles)
  30. **       +--Image          (creates images)
  31. **       +--Text           (creates some text)
  32. **       +--String         (creates a string gadget)
  33. **       +--Prop           (creates a proportional gadget)
  34. **       +--Gauge          (creates a fule gauge)
  35. **       +--Scale          (creates a percentage scale)
  36. **       +--Boopsi         (interface to BOOPSI gadgets)
  37. **       +--Colorfield     (creates a field with changeable color)
  38. **       +--List           (creates a line-oriented list)
  39. **       !  +--Floattext   (special list with floating text)
  40. **       !  +--Volumelist  (special list with volumes)
  41. **       !  +--Scrmodelist (special list with screen modes)
  42. **       !  \--Dirlist     (special list with files)
  43. **       +--Group          (groups other GUI elements)
  44. **          +--Virtgroup   (handles virtual groups)
  45. **          +--Scrollgroup (handles virtual groups with scrollers)
  46. **          +--Scrollbar   (creates a scrollbar)
  47. **          +--Listview    (creates a listview)
  48. **          +--Radio       (creates radio buttons)
  49. **          +--Cycle       (creates cycle gadgets)
  50. **          +--Slider      (creates slider gadgets)
  51. **          +--Coloradjust (creates some RGB sliders)
  52. **          \--Palette     (creates a complete palette gadget)
  53. **
  54. ****************************************************************************)
  55.  
  56. IMPORT  MD:MuiD;
  57. IMPORT  ML:MuiL;
  58. IMPORT  UD:UtilityD;
  59. FROM    UtilityD IMPORT HookPtr;
  60. FROM    SYSTEM IMPORT ADDRESS, ADR, TAG;
  61.  
  62. TYPE    APTR    = ADDRESS;      (* just for readability *)
  63.         StrPtr  = ADDRESS;
  64.  
  65.         ShortString = ARRAY[0..3] OF CHAR;  (* for MakeID *)
  66.  
  67.         (* Here some Types you have to use, IF you want to fill the
  68.            array, the ListDisplayHook gets as parameter and which the hook
  69.            has to fill *)
  70.  
  71.         STRING      = ARRAY[0..128] OF CHAR;
  72.         STRPTR      = POINTER TO STRING;
  73.         STRARR      = ARRAY[0..10] OF STRPTR; (* set 10 to the number of columns you have in your list *)
  74.         STRARRPTR   = POINTER TO STRARR;
  75.  
  76.         (* Use it the following way :
  77.  
  78.         Your Hookfunction :
  79.  
  80.         PROCEDURE dspfunc(hook : HookPtr; array : APTR; entry : APTR) : APTR;
  81.  
  82.             BEGIN
  83.                 CAST(STRARRPTR,array)^[0]:=ADR(first string);
  84.                 CAST(STRARRPTR,array)^[1]:=ADR(second string);
  85.                 ...
  86.                 RETURN 0;
  87.             END dspfunc;
  88.  
  89.         As you see, it is the same as string-arrays in C  *)
  90.  
  91.  
  92.         (* Here your PROCEDURE-Prototype for your hookfunction : *)
  93.  
  94.         HookDef     = PROCEDURE(HookPtr, APTR, APTR):APTR;
  95.  
  96. (*
  97. **  MUI - Object Generation
  98. **
  99. **  These Macros are equal to the C-Macros which can be found in mui.h
  100. **  But notice, that you have a different usage of these :
  101. **
  102. **  Instead of
  103. **
  104. **      app = ApplicationObject,
  105. **
  106. **              ...
  107. **
  108. **            End;
  109. **
  110. **  you now write :
  111. **
  112. **      app := ApplicationObject(TAG(buffer,    (* TAG from SYSTEM *)
  113. **
  114. **              ...
  115. **
  116. **             tagEnd));    (* tagEnd imported from UtilityD *)
  117. **
  118. **  Also you can't use :
  119. **
  120. **      app := ApplicationObject(TAG(buffer,
  121. **
  122. **              ...
  123. **  ====>            window:=WindowObject(TAG(buffer, ... , tagEnd)),
  124. **              ...
  125. **
  126. **             tagEnd));
  127. **
  128. **  instead of this, you have to define your Window-Object before the
  129. **  Application-Object and then use the pointer in the App-Definition :
  130. **
  131. **      window := WindowObject(TAG(buffer, ... , tagEnd)),
  132. **
  133. **      app := ApplicationObject(TAG(buffer,
  134. **
  135. **              ...
  136. **                   window,
  137. **              ...
  138. **
  139. **             tagEnd));
  140. **
  141. **  So you can't define a whole application with one command if you need
  142. **  the pointer of some objects later on (for a Notify, etc.)
  143. **
  144. *)
  145.  
  146. CONST   Child           = MD.maGroupChild;
  147.         SubWindow       = MD.maApplicationWindow;
  148.         WindowContents  = MD.maWindowRootObject;
  149.  
  150. PROCEDURE WindowObject(tags : UD.TagItemPtr) : APTR;
  151. PROCEDURE ImageObject(tags : UD.TagItemPtr) : APTR;
  152. PROCEDURE NotifyObject(tags : UD.TagItemPtr) : APTR;
  153. PROCEDURE ApplicationObject(tags : UD.TagItemPtr) : APTR;
  154. PROCEDURE TextObject(tags : UD.TagItemPtr) : APTR;
  155. PROCEDURE RectangleObject(tags : UD.TagItemPtr) : APTR;
  156. PROCEDURE ListObject(tags : UD.TagItemPtr) : APTR;
  157. PROCEDURE PropObject(tags : UD.TagItemPtr) : APTR;
  158. PROCEDURE StringObject(tags : UD.TagItemPtr) : APTR;
  159. PROCEDURE ScrollbarObject(tags : UD.TagItemPtr) : APTR;
  160. PROCEDURE ListviewObject(tags : UD.TagItemPtr) : APTR;
  161. PROCEDURE RadioObject(tags : UD.TagItemPtr) : APTR;
  162. PROCEDURE VolumelistObject(tags : UD.TagItemPtr) : APTR;
  163. PROCEDURE FloattextObject(tags : UD.TagItemPtr) : APTR;
  164. PROCEDURE DirlistObject(tags : UD.TagItemPtr) : APTR;
  165. PROCEDURE SliderObject(tags : UD.TagItemPtr) : APTR;
  166. PROCEDURE CycleObject(tags : UD.TagItemPtr) : APTR;
  167. PROCEDURE GaugeObject(tags : UD.TagItemPtr) : APTR;
  168. PROCEDURE ScaleObject(tags : UD.TagItemPtr) : APTR;
  169. PROCEDURE BoopsiObject(tags : UD.TagItemPtr) : APTR;
  170. PROCEDURE ColorfieldObject(tags : UD.TagItemPtr) : APTR;
  171. PROCEDURE ColoradjustObject(tags : UD.TagItemPtr) : APTR;
  172. PROCEDURE PaletteObject(tags : UD.TagItemPtr) : APTR;
  173. PROCEDURE GroupObject(tags : UD.TagItemPtr) : APTR;
  174. PROCEDURE VirtgroupObject(tags : UD.TagItemPtr) : APTR;
  175. PROCEDURE ScrollgroupObject(tags : UD.TagItemPtr) : APTR;
  176. (* missing Defs!
  177. PROCEDURE Popstring(tags : UD.TagItemPtr) : APTR;
  178. PROCEDURE Popobject(tags : UD.TagItemPtr) : APTR;
  179. PROCEDURE Popasl(tags : UD.TagItemPtr) : APTR;
  180. *)
  181. PROCEDURE ScrmodelistObject(tags : UD.TagItemPtr) : APTR;
  182. PROCEDURE VGroup(tags : UD.TagItemPtr) : APTR;
  183. PROCEDURE HGroup(tags : UD.TagItemPtr) : APTR;
  184. PROCEDURE ColGroup(cols : LONGCARD; tags : UD.TagItemPtr) : APTR;
  185. PROCEDURE RowGroup(rows : LONGCARD; tags : UD.TagItemPtr) : APTR;
  186. PROCEDURE PageGroup(tags : UD.TagItemPtr) : APTR;
  187. PROCEDURE VGroupV(tags : UD.TagItemPtr) : APTR;
  188. PROCEDURE HGroupV(tags : UD.TagItemPtr) : APTR;
  189. PROCEDURE ColGroupV(cols : LONGCARD; tags : UD.TagItemPtr) : APTR;
  190. PROCEDURE RowGroupV(rows : LONGCARD; tags : UD.TagItemPtr) : APTR;
  191. PROCEDURE PageGroupV(tags : UD.TagItemPtr) : APTR;
  192.  
  193.  
  194. (*
  195. **  MakeID
  196. **  Generate an ID out of a 4-char-string.
  197. **  Use it the as WindowID ! (look in MuiTest for an example!)
  198. *)
  199.  
  200. PROCEDURE MakeID (name : ShortString): LONGINT;
  201.  
  202. (*
  203. **
  204. **  Hook Macros
  205. **
  206. **  Use it the following way :
  207. **      1. Write your Hook-Function :
  208. **          PROCEDURE hookfunc(hook:HookPtr; obj : APTR; args : APTR) : APTR
  209. **              BEGIN
  210. **              ...
  211. **              END hookfunc;
  212. **          Note, that your function needs not to specify registers, but
  213. **          your PROCEDURE must be looking like name(HookPtr, APTR, APTR)!!
  214. **
  215. **      2. Define in your VAR-section a pointer to a Hookrecord :
  216. **          VAR hook    : UtilitiesD.HookPtr;
  217. **
  218. **      3. fill it with MakeHook :
  219. **          MakeHook(hookfunc,hook);
  220. **
  221. **      4. Use it with MUI, as you like, e.g. :
  222. **          DoMethod(button,TAG(buffer,MD.mmCallHook,hook,arg1,arg2));
  223. **
  224. *)
  225.  
  226. PROCEDURE MakeHook(entry:HookDef; VAR hook : HookPtr);
  227.  
  228. (*
  229. **
  230. **  Spacing Macros
  231. **
  232. **  (not all from mui.h)
  233. **
  234. *)
  235.  
  236. PROCEDURE HVSpace() : APTR;
  237. PROCEDURE HSpace(x : LONGCARD) : APTR;
  238. PROCEDURE VSpace(x : LONGCARD) : APTR;
  239.  
  240. (*
  241. **
  242. **  Popup-Object
  243. **
  244. **
  245. *)
  246.  
  247. PROCEDURE Popup (object : APTR;
  248.                  hook : HookPtr;
  249.              VAR imageObj : APTR;
  250.                  imgSpec : ADDRESS) : APTR;
  251.  
  252.  
  253. (*
  254. **
  255. ** String-Object
  256. **
  257. ** Creates a simple String-Gadget
  258. **
  259. *)
  260.  
  261. (*$ IF Locale *)
  262. PROCEDURE String(contents : StrPtr; maxlen : LONGINT) : APTR;
  263. PROCEDURE KeyString(contents : StrPtr; maxlen : LONGINT; key : CHAR) : APTR;
  264. (*$ ELSE *)
  265. PROCEDURE String(contents : ARRAY OF CHAR; maxlen : LONGINT) : APTR;
  266. PROCEDURE KeyString(contents : ARRAY OF CHAR; maxlen : LONGINT; key : CHAR) : APTR;
  267. (*$ ENDIF *)
  268.  
  269. (*
  270. **
  271. ** Checkmark
  272. **
  273. ** creates a Checkmark Gadget
  274. **
  275. *)
  276.  
  277. PROCEDURE Checkmark(selected : BOOLEAN) : APTR;
  278. PROCEDURE KeyCheckmark(selected : BOOLEAN; key : CHAR) : APTR;
  279.  
  280. (*
  281. **
  282. ** Buttons
  283. **
  284. ** Here the same note : Use small letters for Keybuttons!
  285. **
  286. *)
  287.  
  288. (*$ IF Locale *)
  289. PROCEDURE Simplebutton(name : StrPtr) : APTR;
  290. PROCEDURE Keybutton(name : StrPtr; key : CHAR) : APTR;
  291. (*$ ELSE *)
  292. PROCEDURE Simplebutton(name : ARRAY OF CHAR) : APTR;
  293. PROCEDURE Keybutton(name : ARRAY OF CHAR; key : CHAR) : APTR;
  294. (*$ ENDIF *)
  295. (*
  296. **
  297. **  Radio Object
  298. **
  299. *)
  300. (*$ IF Locale *)
  301. PROCEDURE Radio(name : StrPtr; array : APTR) : APTR;
  302. (*$ ELSE *)
  303. PROCEDURE Radio(name : ARRAY OF CHAR; array : APTR) : APTR;
  304. (*$ ENDIF *)
  305.  
  306. (*$ IF Locale *)
  307. PROCEDURE KeyRadio(name : StrPtr; array : APTR; key : CHAR) : APTR;
  308. (*$ ELSE *)
  309. PROCEDURE KeyRadio(name : ARRAY OF CHAR; array : APTR; key : CHAR) : APTR;
  310. (*$ ENDIF *)
  311.  
  312. (*
  313. **
  314. ** Label Objects
  315. **
  316. ** The same as in mui.h
  317. **
  318. ** Label()  : create a Label for Objects without a frame
  319. ** Label1() : create a label for Objects with a standard frame (Checkmarks...)
  320. ** Label2() : create a label for Objects with double high frame (String Gadgets...)
  321. **
  322. *)
  323. (*$ IF Locale *)
  324. PROCEDURE Label(label : StrPtr) : APTR;
  325. PROCEDURE Label1(label : StrPtr) : APTR;
  326. PROCEDURE Label2(label : StrPtr) : APTR;
  327. PROCEDURE KeyLabel(label : StrPtr; HiChar : CHAR) : APTR;
  328. PROCEDURE KeyLabel1(label : StrPtr; HiChar : CHAR) : APTR;
  329. PROCEDURE KeyLabel2(label : StrPtr; HiChar : CHAR) : APTR;
  330. (*$ ELSE *)
  331. PROCEDURE Label(label : ARRAY OF CHAR) : APTR;
  332. PROCEDURE Label1(label : ARRAY OF CHAR) : APTR;
  333. PROCEDURE Label2(label : ARRAY OF CHAR) : APTR;
  334. PROCEDURE KeyLabel(label : ARRAY OF CHAR; HiChar : CHAR) : APTR;
  335. PROCEDURE KeyLabel1(label : ARRAY OF CHAR; HiChar : CHAR) : APTR;
  336. PROCEDURE KeyLabel2(label : ARRAY OF CHAR; HiChar : CHAR) : APTR;
  337. (*$ ENDIF *)
  338.  
  339. (*
  340. **
  341. **  Cycle-Objects
  342. **
  343. *)
  344.  
  345. PROCEDURE Cycle(array : APTR) : APTR;
  346. PROCEDURE KeyCycle(array : APTR; key : CHAR) : APTR;
  347.  
  348. (*
  349. **
  350. **  Slider-Objects
  351. **
  352. *)
  353.  
  354. PROCEDURE Slider(min, max, level : LONGINT; horiz : BOOLEAN) : APTR;
  355. PROCEDURE KeySlider(min, max, level : LONGINT; horiz : BOOLEAN; key : CHAR) : APTR;
  356.  
  357.  
  358. (*
  359. **
  360. ** Controlling Objects
  361. **
  362. ** Again the same as in mui.h :
  363. **
  364. ** set : set an attribute of an object
  365. ** get : get an attribute of an object
  366. **       didn't work in previous releases :-( (but now!! :-)
  367. **
  368. *)
  369.  
  370. PROCEDURE get(obj : APTR; attr : LONGCARD; store : ADDRESS);
  371. PROCEDURE set(obj : APTR; attr : LONGCARD; value : LONGINT);
  372. PROCEDURE setmutex(obj : APTR; n : LONGINT);
  373. PROCEDURE setcycle(obj : APTR; n : LONGINT);
  374. (*$ IF Locale *)
  375. PROCEDURE setstring(obj : APTR; s : StrPtr);
  376. (*$ ELSE *)
  377. PROCEDURE setstring(obj : APTR; s : ARRAY OF CHAR);
  378. (*$ ENDIF *)
  379. PROCEDURE setcheckmark(obj : APTR; b : BOOLEAN);
  380. PROCEDURE setslider(obj : APTR; l : LONGINT);
  381.  
  382. (*
  383. ** Now some macros which are not part of mui.h (in other words : my own ;-)
  384. **
  385. ** First : NoteClose (app,obj,ID)
  386. **         ----------------------
  387. **         This macro sets up a notification on the close-gadget of a window
  388. **         if it gets pressed, the app-obj gets back an ID
  389. **         app : the application-object, which will receive the ID
  390. **         obj : the window-object
  391. **         ID  : the ID, which will be send to the app-obj, when the user
  392. **               presses the close-gadget of the window-object specified in
  393. **               obj.
  394. *)
  395.  
  396. PROCEDURE NoteClose(app : APTR;
  397.                     obj : APTR;
  398.                     ID  : LONGINT);
  399.  
  400. (*
  401. **  Notebutton (app,obj,ID)
  402. **  -----------------------
  403. **  Sets up a notification on a button. If it gets pressed, the app-obj
  404. **  receives an ID.
  405. **  app : the app-obj, which will receive the ID.
  406. **  obj : the pointer to the Button-Object (created by Keybutton, etc.)
  407. **  ID  : The ID, which will be send to the app-obj.
  408. **
  409. *)
  410.  
  411. PROCEDURE NoteButton(app : APTR;
  412.                      obj : APTR;
  413.                      ID  : LONGINT);
  414.  
  415. (*
  416. ** RemMember (obj,member)
  417. ** ----------------------
  418. ** The following macro deletes a member from an object
  419. **
  420. ** obj      : The object which holds the child to remove
  421. ** member   : The child which shall be removed
  422. ** ATTENTION: You have to dispose the removed child-objects yourself!
  423. **
  424. *)
  425.  
  426. PROCEDURE RemMember(obj : APTR; member : APTR);
  427.  
  428. (*
  429. ** AddMember (obj,member)
  430. ** ----------------------
  431. ** This macro will add a new child to an group-  or application-object
  432. **
  433. ** obj      : The group or application to which the new object will be added
  434. ** member   : The new child-object which shall be added to obj.
  435. **
  436. *)
  437.  
  438. PROCEDURE AddMember(obj : APTR; member : APTR);
  439.  
  440. END MuiMacros.
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.