home *** CD-ROM | disk | FTP | other *** search
/ Megahits 4 / MegaHits_Vol.4.iso / mui / dev / gui / txt / muiclasses.def next >
Text File  |  1994-10-23  |  11KB  |  331 lines

  1. DEFINITION MODULE MUIClasses;
  2.  
  3. (*************************************************************************
  4. ** Structures and Macros for creating MUI custom classes.
  5. **
  6. ** converted for M2 by Christian 'Kochtopf' Scholz
  7. **
  8. **************************************************************************
  9. **
  10. ** $Id: MUIClasses.def 1.2 1994/02/19 12:42:19 Kochtopf Exp $
  11. **
  12. ** $Log: MUIClasses.def $
  13. # Revision 1.2  1994/02/19  12:42:19  Kochtopf
  14. # Neue Prozeduren hinzugefuegt, die in mui.h definiert waren.
  15. # Ausserdem etwas die Reihenfolge geaendert, so dass man jetzt alles
  16. # benutzen koennen sollte.
  17. #
  18. # Revision 1.1  1994/02/02  09:37:18  Kochtopf
  19. # Initial revision
  20. #
  21. **
  22. **************************************************************************)
  23.  
  24. FROM    SYSTEM      IMPORT ADDRESS, WORD, BYTE, LONGSET;
  25. FROM    IntuitionD  IMPORT ObjectPtr, WindowPtr, ScreenPtr, DrawInfoPtr, IBox,
  26.                            IntuiMessagePtr, IClassPtr;
  27. FROM    GraphicsD   IMPORT TextFontPtr, RastPortPtr;
  28. FROM    MuiSupport  IMPORT APTR;
  29.  
  30. (*
  31. ** at the beginning some general things used for BOOPSI-Objects
  32. *)
  33.  
  34. (* get a pointer to our instance data *)
  35.  
  36. PROCEDURE InstData(cl : IClassPtr; obj : ObjectPtr) : ADDRESS;
  37.  
  38. (* get the size ... *)
  39.  
  40. PROCEDURE InstSize(cl : IClassPtr) : CARDINAL;
  41.  
  42.  
  43. (*
  44. ** now the things concerning MUI's view of the things
  45. **
  46. ** GENERAL NOTES:
  47. **
  48. ** - Everything described in this defintion file is only valid within
  49. **   MUI classes. You may never use any of these things out of
  50. **   a class, e.g. in a traditional MUI application.
  51. **
  52. ** - Except when otherwise stated, all structures are strictly read only.
  53. *)
  54.  
  55. (* Pointer-Types *)
  56.  
  57. TYPE mGlobalInfoPtr     = POINTER TO mGlobalInfo;
  58.      mMinMaxPtr         = POINTER TO mMinMax;
  59.      mNotifyDataPtr     = POINTER TO mNotifyData;
  60.      mAreaDataPtr       = POINTER TO mAreaData;
  61.      mRenderInfoPtr     = POINTER TO mRenderInfo;
  62.      mConfigurationPtr  = ADDRESS;
  63.      WORDPtr            = POINTER TO WORD;
  64.  
  65.  
  66. (* 
  67. ** Definitions for madFlags 
  68. ** (you will get these flags e.g. with a Draw-Method.)
  69. *)
  70.  
  71. TYPE  MADFlags = (drawObject, (* completely redraw yourself *)
  72.                   drawUpdate, (* only update! *)
  73.                   p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
  74.                   p12, p13, p14, p15, p16, p17, p18, p19, p20, p21,
  75.                   p22, p23, p24, p25, p26, p27, p28, p29, p30, p31
  76.                   (* rest is private, but must be specified to get a LONGSET *)
  77.                  );
  78.  
  79.       MADFlagSet = SET OF MADFlags;
  80.  
  81.  
  82. (* 
  83. ** Type definitions of some important Methods
  84. ** You will need them in your own classes.
  85. *)
  86.  
  87. (* Area *)
  88.  
  89. TYPE    mpAskMinMaxPtr  = POINTER TO mpAskMinMax;
  90.         mpDrawPtr       = POINTER TO mpDraw;
  91.         mpHandleInputPtr= POINTER TO mpHandleInput;
  92.         mpSetUpPtr      = POINTER TO mpSetUp;
  93.  
  94. TYPE    mpAskMinMax     = RECORD
  95.                             id          : LONGINT;
  96.                             MinMaxInfo  : mMinMaxPtr;
  97.                           END;
  98.  
  99.         mpDraw          = RECORD
  100.                             id          : LONGINT;
  101.                             flags       : MADFlagSet;
  102.                           END;
  103.  
  104.         mpHandleInput   = RECORD
  105.                             id          : LONGINT;
  106.                             imsg        : IntuiMessagePtr;
  107.                             muikey      : LONGINT;
  108.                           END;
  109.  
  110.         mpSetUp         = RECORD
  111.                             id          : LONGINT;
  112.                             RenderInfo  : mRenderInfoPtr;
  113.                           END;
  114.  
  115. (* (partial) instance data of notify class *)
  116.  
  117. TYPE mNotifyData = RECORD
  118.         mndGlobalInfo       : mGlobalInfoPtr;
  119.         mndUserData         : LONGINT;
  120.         priv0               : LONGINT;
  121.         priv1               : LONGINT;
  122.         priv2               : LONGINT;
  123.         priv3               : LONGINT;
  124.         priv4               : LONGINT;
  125.     END;
  126.  
  127.  
  128. (* mMinMax structure holds information about minimum, maximum
  129.    and default dimensions of an object. *)
  130.  
  131.      mMinMax = RECORD
  132.                 MinWidth   : CARDINAL;
  133.                 MinHeight  : CARDINAL;
  134.                 MaxWidth   : CARDINAL;
  135.                 MaxHeight  : CARDINAL;
  136.                 DefWidth   : CARDINAL;
  137.                 DefHeight  : CARDINAL;
  138.         END;
  139.  
  140. CONST mMAXMAX = 10000; (* use this if a dimension is not limited. *)
  141.  
  142.  
  143. (* (partial) instance data of area class *)
  144.  
  145. TYPE mAreaData = RECORD
  146.                 madRenderInfo       : mRenderInfoPtr;     (* RenderInfo for this object *)
  147.                 madBackground       : ADDRESS(*mImagePtr*); (* Background Image *)
  148.                 madFont             : TextFontPtr;          (* Font *)
  149.                 madMinMax           : mMinMax;              (* min/max/default sizes *)
  150.                 madBox              : IBox;                 (* position and dimension *)
  151.  
  152.                 madAddLeft          : BYTE;                 (* frame & innerspacing left offset *)
  153.                 madAddTop           : BYTE;                 (* frame & innerspacing top offset *)
  154.                 madSubWidth         : BYTE;                 (* frame & innerspacing add. width *)
  155.                 madSubHeight        : BYTE;                 (* frame & innerspacing add. height *)
  156.  
  157.                 madFlags            : MADFlagSet;           (* see definitions above *)
  158.  
  159.                 (* ... private data follows ... *)
  160.         END;
  161.  
  162.  
  163.  
  164. (* Global information about configuration and parent application. *)
  165.  
  166. TYPE mGlobalInfo = RECORD
  167.                         mgiConfiguration            : mConfigurationPtr;
  168.                         mgiApplicationObject        : ObjectPtr;
  169.                         (* ... private data follows ... *)
  170.                      END;
  171.  
  172. (* MUI's draw pens *)
  173.  
  174. CONST MPENSHINE      =0;
  175. CONST MPENHALFSHINE  =1;
  176. CONST MPENBACKGROUND =2;
  177. CONST MPENHALFSHADOW =3;
  178. CONST MPENSHADOW     =4;
  179. CONST MPENTEXT       =5;
  180. CONST MPENFILL       =6;
  181. CONST MPENCOUNT      =7;
  182.  
  183.  
  184. (* Information on display environment *)
  185.  
  186. TYPE mRenderInfo = RECORD
  187.                             mriWindowObject        : ObjectPtr;     (* valid between MUIMSetup/MUIMCleanup *)
  188.  
  189.                             mriScreen              : ScreenPtr;     (* valid between MUIMSetup/MUIMCleanup *)
  190.                             mriDrawInfo            : DrawInfoPtr;   (* valid between MUIMSetup/MUIMCleanup *)
  191.                             mriPens                : WORDPtr;       (* valid between MUIMSetup/MUIMCleanup *)
  192.                             mriWindow              : WindowPtr;     (* valid between MUIMShow/MUIMHide *)
  193.                             mriRastPort            : RastPortPtr;   (* valid between MUIMShow/MUIMHide *)
  194.  
  195.                         (* ... private data follows ... *)
  196.                      END;
  197.     
  198.  
  199. (*
  200. ** some procedures to get some information about our object 
  201. *)
  202.  
  203. PROCEDURE muiNotifyData(obj : APTR) : mNotifyDataPtr;
  204. PROCEDURE muiAreaData(obj : APTR) : mAreaDataPtr;
  205. PROCEDURE muiGlobalInfo(obj : APTR) : mGlobalInfoPtr;
  206. PROCEDURE muiRenderInfo(obj : APTR) : mRenderInfoPtr;
  207.  
  208. (*
  209. ** some more specialized functions to retain information about special
  210. ** object-data like rastport, window, etc.
  211. *)
  212.  
  213. PROCEDURE OBJ_app(obj : APTR) : ObjectPtr;
  214. PROCEDURE OBJ_win(obj : APTR) : ObjectPtr;
  215. PROCEDURE OBJ_dri(obj : APTR) : DrawInfoPtr;
  216. PROCEDURE OBJ_window(obj : APTR) : WindowPtr;
  217. PROCEDURE OBJ_screen(obj : APTR) : ScreenPtr;
  218. PROCEDURE OBJ_rp(obj : APTR) : RastPortPtr;
  219. PROCEDURE OBJ_left(obj : APTR) : INTEGER;
  220. PROCEDURE OBJ_top(obj : APTR) : INTEGER;
  221. PROCEDURE OBJ_width(obj : APTR) : INTEGER;
  222. PROCEDURE OBJ_height(obj : APTR) : INTEGER;
  223. PROCEDURE OBJ_right(obj : APTR) : INTEGER;
  224. PROCEDURE OBJ_bottom(obj : APTR) : INTEGER;
  225. PROCEDURE OBJ_addleft(obj : APTR) : INTEGER;
  226. PROCEDURE OBJ_addtop(obj : APTR) : INTEGER;
  227. PROCEDURE OBJ_subwidth(obj : APTR) : INTEGER;
  228. PROCEDURE OBJ_subheight(obj : APTR) : INTEGER;
  229. PROCEDURE OBJ_mleft(obj : APTR) : INTEGER;
  230. PROCEDURE OBJ_mtop(obj : APTR) : INTEGER;
  231. PROCEDURE OBJ_mwidth(obj : APTR) : INTEGER;
  232. PROCEDURE OBJ_mheight(obj : APTR) : INTEGER;
  233. PROCEDURE OBJ_mright(obj : APTR) : INTEGER;
  234. PROCEDURE OBJ_mbottom(obj : APTR) : INTEGER;
  235. PROCEDURE OBJ_font(obj : APTR) : TextFontPtr;
  236. PROCEDURE OBJ_flags(obj : APTR) : MADFlagSet;
  237.  
  238.    
  239. (* User configurable keyboard events coming with MUIMHandleInput *)
  240.  
  241. CONST MUIKEYRELEASE     = -2; (* not a real key, faked when MUIKEYPRESS is released *)
  242. CONST MUIKEYNONE        = -1;
  243. CONST MUIKEYPRESS       =  0;
  244. CONST MUIKEYTOGGLE      =  1;
  245. CONST MUIKEYUP          =  2;
  246. CONST MUIKEYDOWN        =  3;
  247. CONST MUIKEYPAGEUP      =  4;
  248. CONST MUIKEYPAGEDOWN    =  5;
  249. CONST MUIKEYTOP         =  6;
  250. CONST MUIKEYBOTTOM      =  7;
  251. CONST MUIKEYLEFT        =  8;
  252. CONST MUIKEYRIGHT       =  9;
  253. CONST MUIKEYWORDLEFT    = 10;
  254. CONST MUIKEYWORDRIGHT   = 11;
  255. CONST MUIKEYLINESTART   = 12;
  256. CONST MUIKEYLINEEND     = 13;
  257. CONST MUIKEYGADGETNEXT  = 14;
  258. CONST MUIKEYGADGETPREV  = 15;
  259. CONST MUIKEYGADGETOFF   = 16;
  260. CONST MUIKEYWINDOWCLOSE = 17;
  261. CONST MUIKEYWINDOWNEXT  = 18;
  262. CONST MUIKEYWINDOWPREV  = 19;
  263. CONST MUIKEYHELP        = 20;
  264. CONST MUIKEYCOUNT       = 21; (* private *)
  265.  
  266. (*
  267. ** now something about dispatchers.
  268. ** if you have written your dispatcher make sure it has the format of
  269. ** PROCEDURE Dispatcher(cl : IClassPtr; obj : ADDRESS; msg : ADDRESS) : ADDRESS
  270. ** (like DispatcherDef)
  271. ** Then call in your main routine the procedure MakeDispatcher like this :
  272. ** MakeDispatcher(Dispatcher, MyClass),
  273. ** where MyClass is the initialized IClassPtr of your new class.
  274. ** This function will then set up your dispatcher with a little stub which
  275. ** will restore A4 for your (will mean, your programm will be pure, if you
  276. ** do all right)
  277. *)
  278.  
  279. (* here the definition of a dispatcher! *)
  280.  
  281. TYPE    DispatcherDef = PROCEDURE ( (*class*)   IClassPtr,
  282.                                     (*object*)  ADDRESS,
  283.                                     (*message*) ADDRESS) : ADDRESS;
  284.  
  285.  
  286.  
  287. (* now the procedure MakeDispatcher : *)
  288.  
  289. PROCEDURE MakeDispatcher(entry:DispatcherDef; VAR myclass : IClassPtr);
  290.  
  291.  
  292.  
  293. (* 
  294. ** at last a little procedure to fill in the values in the MinMax-Record.
  295. ** You can call it inside an AskMinMax-Method, because it is ever the same...
  296. *)
  297.  
  298. PROCEDURE FillMinMaxInfo (msg : mpAskMinMaxPtr; MinWidth   : CARDINAL;
  299.                                                 DefWidth   : CARDINAL;
  300.                                                 MaxWidth   : CARDINAL;
  301.                                                 MinHeight  : CARDINAL;
  302.                                                 DefHeight  : CARDINAL;
  303.                                                 MaxHeight  : CARDINAL);
  304.  
  305.  
  306. (*
  307. ** 2 useful procedures for testing if some coordinates are inside your object
  308. ** (converted from the ones in class3.c. So look there how to use... )
  309. *)
  310.  
  311. (* this will test if x is between a and b *)
  312.  
  313. PROCEDURE OBJ_between(a,x,b : INTEGER) : BOOLEAN;
  314.  
  315. (* this will test, if the position (x, y) is inside the Object obj *)
  316.  
  317. PROCEDURE OBJ_isInObject(x, y : INTEGER; obj : ObjectPtr) : BOOLEAN;
  318.  
  319.  
  320.  
  321.  
  322.  
  323. (* 
  324. ** here is space for future extensions.... :) 
  325. *)
  326.  
  327.  
  328.  
  329.  
  330. END MUIClasses.
  331.