home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 1 / Amiga Tools.iso / egs-tools / egs_dev-disk / egsdemos / moreexamples / global / userwindow.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-06  |  9.6 KB  |  252 lines

  1. #ifdef EGSPUSERWINDOW
  2.   #define EXTERN
  3. #else
  4.   #define EXTERN extern
  5. #endif
  6.  
  7. #include <egs/egsintui.h>
  8. #include <egs/egsgadbox.h>
  9.  
  10.  
  11.                     /* If a user window is opened as a NON MODAL, it will run
  12.                        together with all other windows, until the winodw is
  13.                        closed. A MODAL window, will run, and hold up the
  14.                        program until completed.
  15.                     */
  16. #define WINDOW_NONMODAL      0
  17. #define WINDOW_MODAL         1
  18.  
  19. #define SIGNAL_CLOSE 0x1
  20.  
  21. /*************
  22.   Overview of UserInputWindow structure...
  23.  
  24.    Next.
  25.              PRIVATE. Don't touch this...
  26.    Window.
  27.              EI_WindowPtr to your Window.
  28.    GadCon.
  29.              Don't play around with this. This is the GadgetContext for your
  30.              window.
  31.    Create.
  32.              Function Pointer  to your gadget creation routine.
  33.              This is REQUIRED.
  34.    Redraw.
  35.              Function Pointer to your routine to Redraw all gadgets.
  36.              Not required, but needed if you want to update int gadgets and
  37.              so forth.
  38.    Close.
  39.              Function Pointer to your close routine. Use this if you have
  40.              allocated any additional memory in Create. You can free it here.
  41.              Not necessary if you don't care when the window closes.
  42.    GadgetDown.
  43.              Function Pointer to your GadgetDown processing routine. This is
  44.              where you do something based on a user's click on any of your
  45.              gadgets.
  46.              Not necessary, but your window won't do much if you don't
  47.              process you gadget events!
  48.    IDCMP.
  49.              Function Pointer to your IDCMP processing routine. Ignore this
  50.              if you only need the messages supplied for UserWindows! This
  51.              is only a last resort. If you need more control of the Event
  52.              Handler than I have written, you can steal away the entire
  53.              Event Handler fro the UserWindow module. Remember, if you do
  54.              this to copy the Event Handler from this module and copy
  55.              it in. (You will need to call the Resize and SizeVerify, and
  56.              CloseWindow stuff the same.) Once again... last resort.
  57.              Set to NULL if not needed.
  58.    Menu.
  59.              Function Pointer to your Menu processing routine. If you have
  60.              no menus, set this to NULL.
  61.    RawKey.
  62.              Function Pointer to your RawKey processing routine if you have
  63.              one. Set to NULL if not.
  64.    VanillaKey.
  65.              Function Pointer to your VanillaKey processing routine if you
  66.              have one. Set to NULL if not.
  67.    MouseMove.
  68.              Function Pointer to your MouseMove processing routine if you have
  69.              one. Set to NULL if none.
  70.    MouseButtons.
  71.              Function Pointer to your MouseButtons processing routine if you
  72.              have one. Set to NULL if none.
  73.    UserData.
  74.              PRIVATE. This is the WindowInfo structure allocated and given
  75.              to your window. I keep a copy around until the final
  76.              Close_UserWindow so we don't have to realloc it all the time.
  77.              Don't touch!!!!
  78.    Data.
  79.              PUBLIC. This is a void * pointer to do with as you will. If you
  80.              wish to alloc something and attach it to this, do so in your
  81.              Create routine, and free it in your Close routine.
  82.    ModeFlags.
  83.              PRIVATE. This is set when you call the Init_UserWindow routine.
  84.              It tells me if you want a MODAL or a NONMODAL window.
  85.              One of the following:
  86.              WINDOW_NONMODAL
  87.              WINDOW_MODAL
  88.    IDCMPFlags.
  89.              PRIVATE. This is set when you call the Init_UserWindow routine.
  90.              It contains the IDCMPFlags for this window. Any of the following,
  91.              OR'd (|) together:
  92.              EI_iMOUSEBUTTONS
  93.              EI_iMOUSEMOVE
  94.              EI_iRAWKEY
  95.              EI_iACTIVEWINDOW
  96.              EI_iREFRESHWINDOW
  97.              EI_iCLOSEWINDOW
  98.              EI_iNEWSIZE
  99.              EI_iMENUPICK
  100.              EI_iGADGETDOWN
  101.              EI_iGADGETUP
  102.              EI_iMENUVERIFY
  103.              EI_iVANILLAKEY
  104.              EI_iSIZEVERIFY
  105.              EI_iINACTIVEWINDOW
  106.              EI_iINTUITICKS
  107.              EI_iDISKINSERT
  108.              EI_iDISKREMOVE
  109.              EI_iNEWPREFS
  110.              EI_iMOVEWINDOW
  111.              EI_iDROP
  112.              EI_iMIGRATEVERIFY
  113.              EI_iMIGRATE
  114.  
  115.    Flags.
  116.              PRIVATE. This is set when you call the Init_UserWindow routine.
  117.              It contains the Flags for this window. Any of the following,
  118.              or'd (|) together:
  119.              EI_GIMMEZEROZERO
  120.              EI_BORDERLESS
  121.              EI_SUPER_BITMAP
  122.              EI_SIMPLE_REFRESH
  123.              EI_WINDOWREFRESH
  124.              EI_WINDOWACTIVE
  125.              EI_WINDOW_MENULOCAL
  126.              EI_OWN_IDCMPPORT
  127.              EI_OWN_COLORPALETTE
  128.              EI_FRONTBACKGADGET
  129.              EI_RMBTRAP
  130.              EI_REPORTMOUSE
  131.              EI_BACKDROP
  132.              EI_SMART_REFRESH
  133.              EI_WINDOW_MENUPOPUP
  134.              EI_SIZEBBOTTOM
  135.              EI_SIZEBRIGHT
  136.              EI_WINDOW_USERSTYLE
  137.              EI_ACTIVETOFRONT
  138.              EI_QUICKSCROLL
  139.              EI_WINDOW_SLEEPING
  140.              EI_FIXWINDOW_RATIO
  141.              EI_FORCE_TO_SCREEN
  142.              EI_WINDOWCENTER
  143.              EI_SEND_OUTSIDEMOVES
  144.              EI_MIGRATEABLE
  145.  
  146.    SysGadgets.
  147.              PRIVATE. This is set when you call the Init_UserWindow routine.
  148.              It contains the Bordef.SysGadgets for this window. Any of the
  149.              following or'd (|) together:
  150.              EI_WINDOWCLOSE
  151.              EI_WINDOWSIZE
  152.              EI_WINDOWFRONT
  153.              EI_WINDOWBACK
  154.              EI_WINDOWFLIP
  155.              EI_WINDOWBIG
  156.              EI_WINDOWSMALL
  157.              EI_WINDOWICON
  158.              EI_WINDOWARROWL
  159.              EI_WINDOWARROWR
  160.              EI_WINDOWARROWU
  161.              EI_WINDOWARROWD
  162.              EI_WINDOWSCROLLH
  163.              EI_WINDOWSCROLLV
  164.              EI_WINDOWDRAG
  165.  
  166.    Signals.
  167.              This is where you can tell me something. Currently this is used
  168.              to tell me you wish to close your window while running a
  169.              MODAL window. (It will close on a close window, but you can signal
  170.              me to close it earlier if you want, say on a return from an int
  171.              gadget.)
  172.              To do this, set UserWindow->Signals |= SIGNAL_CLOSE.
  173.    Title.
  174.              PRIVATE. I keep the title of your window here. It is allocated
  175.              on Init_UserWindow and freed on Close_UserWindow. Therefore,
  176.              regardless of what happens after you call Init_UserWindow,
  177.              you must call Close_UserWindow to clean up.
  178. *************************/
  179.  
  180. EXTERN struct UserInputWindow {
  181.   void *Next;
  182.   EI_WindowPtr Window;
  183.   EB_GadContext GadCon;
  184.   EB_GadBoxPtr  (*Create)     (struct UserInputWindow *UserWindow);
  185.   void (*Redraw)      (struct UserInputWindow *UserWindow);
  186.   void (*Close)       (struct UserInputWindow *UserWindow);
  187.   void (*GadgetDown)  (struct UserInputWindow *UserWindow, EI_GadgetPtr iaddress);
  188.   void (*IDCMP)       (struct UserInputWindow *UserWindow,
  189.                        struct EI_EIntuiMsg *Msg);
  190.   void (*Menu)        (struct UserInputWindow *UserWindow, UWORD code);
  191.   void (*RawKey)      (struct UserInputWindow *UserWindow, UWORD code, WORD qual);
  192.   void (*VanillaKey)  (struct UserInputWindow *UserWindow,
  193.                        UWORD code, WORD qual,  WORD x, WORD y);
  194.   void (*MouseMove)   (struct UserInputWindow *UserWinodw, WORD x, WORD y);
  195.   void (*MouseButtons)(struct UserInputWindow *UserWinodw,
  196.                        ULONG code, WORD x, WORD y);
  197.   void *UserData;
  198.   void *Data;
  199.   ULONG ModeFlags;
  200.   ULONG IDCMPFlags;
  201.   ULONG Flags;
  202.   ULONG SysGadgets;
  203.   ULONG Signals;
  204.   EI_MenuPtr MenuPtr;
  205.   struct MsgPort *Port;
  206.   char *Title;
  207. };
  208. typedef struct UserInputWindow *UserInputWindowPtr;
  209.  
  210. /************************
  211.      Overview of WindowInfo structure.
  212.  
  213.    EventHandler.
  214.                PRIVATE! Read Only. Holds our EventHandler.
  215.    UserWindow.
  216.                PRIVATE! Read Only. Reference back to our UserWindow.
  217.  
  218. ***********************/
  219.  
  220. EXTERN struct WindowInfo {
  221.   void (*EventHandler) (struct EI_EIntuiMsg *msg);  // Event Handler (pointer 2 func)
  222.   UserInputWindowPtr UserWindow;
  223. };
  224. typedef struct WindowInfo *WindowInfoPtr;
  225.  
  226.                         /*  A note about my Typedefs....
  227.                             I got used to this because EGS does it alot.
  228.                             It turns out that this makes your code much easier
  229.                             to read. Try it, you'll like it!
  230.                         */
  231.  
  232. EXTERN void Initialize_UserWindows (void);
  233. EXTERN void Init_UserWindow (UserInputWindowPtr UserWindow, char *title, WORD  ModeFlags,
  234.                       EI_MenuPtr MenuPtr, struct MsgPort *Port);
  235. EXTERN BYTE Open_UserWindow (UserInputWindowPtr UserWindow, WORD x, WORD y);
  236. EXTERN void Close_UserWindow (UserInputWindowPtr UserWindow);
  237. EXTERN void Close_All_UserWindows (void);
  238. EXTERN EI_WindowPtr Create_UserWindow (UserInputWindowPtr UserWindow,
  239.                                           EI_WindowPtr win, WORD x, WORD y);
  240. EXTERN void UserWindow_EventHandler (struct EI_EIntuiMsg *Msg);
  241. EXTERN void Sleep_All_UserWindows (void);
  242. EXTERN void Wake_All_UserWindows (void);
  243.  
  244.                        // These prototypes should be PRIVATE to UserWindow,
  245.                        // but if you use an IDCMP funstion pointer, you'll
  246.                        // need them.
  247. EXTERN void AddUserWindow (UserInputWindowPtr UserWindow);
  248. EXTERN void RemoveUserWindow (UserInputWindowPtr UserWindow);
  249. EXTERN void SizeVerify_UserWindow (UserInputWindowPtr UserWindow);
  250. EXTERN void NewSize_UserWindow (UserInputWindowPtr UserWindow);
  251. EXTERN EI_GadgetPtr myFindGadget (EB_GadContext gadcon,long id);
  252. #undef EXTERN