home *** CD-ROM | disk | FTP | other *** search
- /* UserWIndow.c
- This module is designed to handle all of the
- subtle things about gadget windows for you.
- I use this in EGS-Paint for every window that's
- not a DrawWindow (even the toolpanel and palette).
- This code is freely distributable (in its orignial
- state).
- Feel free to use this in your development, or just
- use it to gain some insight to how all this stuff
- works.
- I use the UserData item in the Window structure
- to reference back to the associated UserWindow.
- This helps in the message processing. (see any
- of the main modules.)
- Great Valley Products Inc.
- Patrick Hager October 26, 1993.
- */
-
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <proto/exec.h>
- #include "egslibraries.h"
-
- #include <egs/egsintui.h>
- #include <egs/clib/egsintui_protos.h>
- #include <egs/pragmas/egsintui_pragmas.h>
- #include <egs/egsgadbox.h>
- #include <egs/clib/egsgadbox_protos.h>
- #include <egs/pragmas/egsgadbox_pragmas.h>
- #define EGSPUSERWINDOW
- #include "userwindow.h"
- #undef EGSPUSERWINDOW
-
-
-
-
- void *UserList=NULL; // Our list of UserWindows.
-
- void RunUserWindow (UserInputWindowPtr UserWindow);
-
-
-
-
- /************************************
- PUBLIC: myFindGadget.
- Anyone can use this. When dealing with Master Gadgets,
- there are many type casts necessary to do a FindGadget,
- so this does it for you.
- ************************************/
- EI_GadgetPtr myFindGadget (EB_GadContext gadcon,long id) {
- EI_GadgetPtr tgad;
-
- if (gadcon) {
- if (tgad = EB_FindGadget ( ((EI_MasterGadPtr)gadcon->First)->FirstSon,
- ((EI_MasterGadPtr)gadcon->First)->NumSons,
- id)) {
- return tgad;
- }
- else
- return NULL;
- }
- else
- return NULL;
- }
-
-
- /**********************************
- PUBLIC: Init_UserWindow.
- This routine must be run for each window you wish to create.
- It clears all of the structures and NULLs all function
- pointers. It must be run before an Open_UserWindow.
- Once opened, don't run it again.
- **********************************/
- void Init_UserWindow (UserInputWindowPtr UserWindow, char *title, WORD ModeFlags,
- EI_MenuPtr MenuPtr, struct MsgPort *Port) {
-
- if (UserWindow) {
- UserWindow->Window=NULL;
- UserWindow->GadCon=NULL;
- UserWindow->Create=NULL;
- UserWindow->Redraw=NULL;
- UserWindow->Close=NULL;
- UserWindow->GadgetDown=NULL;
- UserWindow->IDCMP=NULL;
- UserWindow->Menu=NULL;
- UserWindow->RawKey=NULL;
- UserWindow->VanillaKey=NULL;
- UserWindow->MouseMove=NULL;
- UserWindow->MouseButtons=NULL;
-
- UserWindow->UserData=NULL;
- UserWindow->Title=NULL;
- UserWindow->Next=NULL;
- UserWindow->MenuPtr = MenuPtr;
- UserWindow->Port=Port;
- UserWindow->Signals=NULL;
- UserWindow->ModeFlags=ModeFlags;
- if (UserWindow->Title=(char *)malloc ((strlen (title)+2)*sizeof (char))) {
- strcpy (UserWindow->Title,title);
- }
- }
- }
-
-
-
-
- /****************************************************
- PUBLIC: Open_UserWindow.
- Call this routine to open a new UserWindow, or to open a UserWindow
- which was previously closed.
- ***************************************************/
- BYTE Open_UserWindow (UserInputWindowPtr UserWindow, WORD x, WORD y) {
-
- BYTE ret=0;
-
- if (!UserWindow->Window) {
- // The window is not currently open on the Screen.
- if (UserWindow->GadCon) {
- /* If the UserWindow's GadContext exists, then the
- window has been previously opened and closed.
- Now we can just reopen the window using the
- NewWindow structure contained in the
- GadContext.
- */
- if (UserWindow->Window= EI_OpenWindow (UserWindow->GadCon->NewWin)) {
- UserWindow->Window->UserData = (void *) UserWindow->UserData;
- AddUserWindow (UserWindow);
- EI_ActivateWindow (UserWindow->Window);
- ret=1;
- }
- else {
- // Maybe no memory to open... We'll close to
- // clean things up.
- Close_UserWindow (UserWindow);
- ret=0;
- }
- }
- else {
- /* This is the first time this window has been
- opened. We'll first create the window's
- gadget list, then attempt to open from
- the NewWindow structure contained in the
- newly created gadContext.
- */
- //printf ("calling create.\n");
- if (UserWindow->Window=Create_UserWindow (UserWindow,NULL,x,y)) {
- //printf ("Created.\n");
- //printf ("add to list...\n");
- AddUserWindow (UserWindow);
- //printf ("added!\n");
- EI_ActivateWindow (UserWindow->Window);
- ret = 1;
- }
- else {
- // Maybe no memory to open this window....
- // We'll close to clean things up.
- Close_UserWindow (UserWindow);
- ret=0;
- }
- }
-
- if (ret=1) {
- // Successfull Open.
- // Call the Redraw function if the UserWindow has
- // one...
- if (UserWindow->Redraw)
- UserWindow->Redraw (UserWindow);
- ((WindowInfoPtr)UserWindow->Window->UserData)->UserWindow=UserWindow;
- }
- }
- else {
- // Window is allready open. Let's just bring it
- // to the front.
- EI_WindowToFront (UserWindow->Window);
- ret = 1;
- }
- if ((ret)&&(UserWindow->ModeFlags&WINDOW_MODAL)) {
- /* If we had called Init_UserWindow and supplied
- the flag WINDOW_MODAL, it means we wish to run
- this window and only this window, until it is
- finished or closed. We will be stuck in
- RunUserWindow until that happens.
- We'll put all the other windows to sleep so the user
- can't click on them until this window is closed.
- */
- RunUserWindow (UserWindow);
- }
-
- return ret;
- }
-
-
-
- /********************************
- PUBLIC: Close_UserWindow.
- This routine is called ONLY when the Window
- is closed the very last time.
- Otherwise, UserWindow.c will close the window and keep the old
- GadContext.
- ********************************/
- void Close_UserWindow (UserInputWindowPtr UserWindow) {
-
- if (UserWindow) {
- // If the UserWindow has a close function,
- // call it.
- if (UserWindow->Close)
- UserWindow->Close (UserWindow);
- RemoveUserWindow (UserWindow);
- if (UserWindow->Window) {
- if (UserWindow->Window->UserData) {
- free (UserWindow->Window->UserData);
- UserWindow->UserData=NULL;
- }
- EI_CloseWindow (UserWindow->Window);
- UserWindow->Window=NULL;
- }
- if (UserWindow->GadCon) {
- EB_DeleteGadContext (UserWindow->GadCon);
- UserWindow->GadCon = NULL;
- }
- if (UserWindow->Title) {
- free (UserWindow->Title);
- UserWindow->Title=NULL;
- }
- }
- }
-
-
- /********************************
- PUBLIC: Close_All_UserWindows.
- Here's a quick way to end your program. This routine will close
- any UserWindow currently on Screen (as well as any associated
- Close function pointers so you can free any memory you may have
- allocated along with that particular Window.
- ********************************/
- void Close_All_UserWindows (void) {
- UserInputWindowPtr user;
-
- while (user=(UserInputWindowPtr)UserList) {
- Close_UserWindow (user);
- }
- }
-
- /***************************************************
- PRIVATE: UserWindow_EventHandler.
- This is the Event Handler used by the UserWindow module.
- ***************************************************/
- void UserWindow_EventHandler (struct EI_EIntuiMsg *Msg) {
- ULONG class;
- UWORD code;
- WORD qual;
- WORD x,y;
- EI_GadgetPtr iaddress=NULL;
- EI_WindowPtr win;
- UserInputWindowPtr UserWindow;
-
- UserWindow= (UserInputWindowPtr) ((WindowInfoPtr)Msg->IDCMPWindow->UserData)->
- UserWindow;
- if (UserWindow->IDCMP) {
- UserWindow->IDCMP (UserWindow,Msg);
- }
- else {
- class = Msg->Class;
- code = Msg->Code;
- iaddress = Msg->IAddress;
- qual = Msg->Qualifier;
- win = Msg->IDCMPWindow;
- x=Msg->MouseX;
- y=Msg->MouseY;
- ReplyMsg ( (struct Message *)Msg);
-
- switch (class) {
- /* Here, a close window is temporary.
- We copy the current window size,pos
- to the UserWindow's GadContext's
- NewWindow structure.
- */
- case EI_iCLOSEWINDOW:
- if (UserWindow->Close)
- UserWindow->Close (UserWindow);
- RemoveUserWindow (UserWindow);
- UserWindow->GadCon->NewWin->LeftEdge= UserWindow->Window->LeftEdge;
- UserWindow->GadCon->NewWin->TopEdge = UserWindow->Window->TopEdge;
- UserWindow->GadCon->NewWin->Width=UserWindow->Window->Width;
- UserWindow->GadCon->NewWin->Height=UserWindow->Window->Height;
- UserWindow->GadCon->NewWin->MinWidth=UserWindow->Window->MinWidth;
- UserWindow->GadCon->NewWin->MinHeight=UserWindow->Window->MinHeight;
- UserWindow->GadCon->NewWin->MaxWidth=UserWindow->Window->MaxWidth;
- UserWindow->GadCon->NewWin->MaxHeight=UserWindow->Window->MaxHeight;
- EI_CloseWindow (UserWindow->Window);
- UserWindow->Window=NULL;
- UserWindow->GadCon->NewWin->FirstGadgets->NextGadget=NULL;
- break;
-
- case EI_iSIZEVERIFY:
- SizeVerify_UserWindow (UserWindow);
- break;
-
- case EI_iNEWSIZE:
- NewSize_UserWindow (UserWindow);
- if (UserWindow->Redraw)
- UserWindow->Redraw (UserWindow);
- break;
-
- case EI_iGADGETDOWN:
- if (UserWindow->GadgetDown)
- UserWindow->GadgetDown (UserWindow,iaddress);
- break;
-
- case EI_iMENUPICK:
- if (UserWindow->Menu)
- UserWindow->Menu (UserWindow, code);
- break;
- case EI_iRAWKEY:
- if (UserWindow->RawKey)
- UserWindow->RawKey (UserWindow,code, qual);
- break;
-
- case EI_iVANILLAKEY:
- if (UserWindow->VanillaKey)
- UserWindow->VanillaKey (UserWindow, code, qual, x, y);
- break;
-
- case EI_iREFRESHWINDOW:
- if (EI_BeginRefresh (UserWindow->Window,(LONG)iaddress)) {
- if (UserWindow->Redraw) {
- UserWindow->Redraw (UserWindow);
- }
- EI_EndRefresh (UserWindow->Window,TRUE);
- }
- break;
-
- case EI_iMOUSEMOVE:
- if (UserWindow->MouseMove)
- UserWindow->MouseMove (UserWindow, x, y);
- break;
-
- case EI_iMOUSEBUTTONS:
- if (UserWindow->MouseButtons)
- UserWindow->MouseButtons (UserWindow, code, x, y);
- break;
-
- }
- }
- }
-
-
- /*********************************
- PRIVATE: SizeVerify_UserWindow.
- This routine is called on a size verify event.
- *********************************/
- void SizeVerify_UserWindow (UserInputWindowPtr UserWindow) {
-
- EI_LockIntuition ();
- EI_RemoveGadget (UserWindow->Window,UserWindow->GadCon->First);
- if (UserWindow->GadCon) {
- EB_DeleteGadContext (UserWindow->GadCon);
- UserWindow->GadCon=NULL;
- }
- EI_UnlockIntuition ();
- }
-
-
- /**********************************
- PRIVATE: NewSize_UserWindow.
- This routine is called on a newsize event.
- **********************************/
- void NewSize_UserWindow (UserInputWindowPtr UserWindow) {
-
- EI_LockIntuition ();
- UserWindow->Window = Create_UserWindow (UserWindow,UserWindow->Window,
- UserWindow->Window->LeftEdge,
- UserWindow->Window->TopEdge);
- EI_AddGadget (UserWindow->Window,UserWindow->GadCon->First);
- EI_UnlockIntuition ();
- }
-
-
- /******************************
- PRIVATE: Create_UserWindow.
- Creates the gadboxes and gadgets for the
- Example Wand control panel (Stencil Options).
- *******************************/
- EI_WindowPtr Create_UserWindow (UserInputWindowPtr UserWindow,
- EI_WindowPtr win, WORD x, WORD y) {
- EB_GadBoxPtr root;
- EI_WindowPtr retwin=NULL;
-
- //printf ("Create_UserWindow:\n");
- UserWindow->GadCon = EB_CreateGadContext (NULL,NULL,-1,-1);
-
- //printf ("Calling Example_Create.\n");
- if (root=UserWindow->Create (UserWindow)) {
- //printf ("OK. Back...\n");
- root = EB_CreateMasterWindow (UserWindow->GadCon,win,root);
- if (EB_ProcessGadBoxes (UserWindow->GadCon,root)) {
- UserWindow->GadCon->NewWin->IDCMPFlags = UserWindow->IDCMPFlags;
- UserWindow->GadCon->NewWin->Bordef.SysGadgets = UserWindow->SysGadgets;
- UserWindow->GadCon->NewWin->Flags = UserWindow->Flags;
- UserWindow->GadCon->NewWin->Menu = UserWindow->MenuPtr;
- UserWindow->GadCon->NewWin->Title = UserWindow->Title;
- if (!(UserWindow->ModeFlags&WINDOW_MODAL)) {
- UserWindow->GadCon->NewWin->Port=UserWindow->Port;
- }
- if ((x>=0)&&(y>=0)) {
- UserWindow->GadCon->NewWin->LeftEdge =x;
- UserWindow->GadCon->NewWin->TopEdge = y;
- }
- else {
- // First time only, open in center.
- UserWindow->GadCon->NewWin->Flags|=EI_WINDOWCENTER;
- }
- if (win==NULL) {
- retwin = EI_OpenWindow (UserWindow->GadCon->NewWin);
- //printf ("Opened in create.\n");
- //UserWindow->Window=retwin;
- UserWindow->GadCon->NewWin->Flags&= (~EI_WINDOWCENTER);
- if (retwin) {
- if (UserWindow->Port==NULL)
- UserWindow->Port=UserWindow->Window->UserPort;
- if (retwin->UserData = (struct WindowInfo *) malloc (1*
- sizeof (struct WindowInfo))) {
- ((struct WindowInfo *)retwin->UserData)->EventHandler =
- UserWindow_EventHandler;
- UserWindow->UserData=retwin->UserData;
- }
- else {
- Close_UserWindow (UserWindow);
- retwin=NULL;
- }
- }
- else {
- Close_UserWindow (UserWindow);
- retwin=NULL;
- }
- return retwin;
- }
- else {
- return (win);
- }
- }
- else
- return NULL;
- }
- else
- return NULL;
- }
-
- /*************************************
- PRIVATE: RunUserWindow.
- This is here for MODAL windows. It will run the GUI of the
- UserWindow, until it is closed (or finished).
- *************************************/
- void RunUserWindow (UserInputWindowPtr UserWindow) {
- struct EI_EIntuiMsg *Msg;
- ULONG class;
- UWORD code;
- WORD qual;
- WORD x,y;
- EI_GadgetPtr iaddress;
- EI_WindowPtr win;
-
- if (UserWindow->ModeFlags&WINDOW_MODAL) {
- while (!UserWindow->Signals&SIGNAL_CLOSE) {
- Wait (1<<UserWindow->Window->UserPort->mp_SigBit);
-
- while (Msg = (struct EI_EIntuiMsg *)GetMsg (UserWindow->Window->UserPort)) {
- class = Msg->Class;
- code = Msg->Code;
- qual = Msg->Qualifier;
- x=Msg->MouseX;
- y=Msg->MouseY;
- iaddress=(EI_GadgetPtr)Msg->IAddress;
- win=(EI_WindowPtr)Msg->IDCMPWindow;
- ReplyMsg ( (struct Message *)Msg);
-
- switch (class) {
- case EI_iCLOSEWINDOW:
- UserWindow->Signals |= SIGNAL_CLOSE;
- break;
-
- case EI_iSIZEVERIFY:
- SizeVerify_UserWindow (UserWindow);
- break;
-
- case EI_iNEWSIZE:
- NewSize_UserWindow (UserWindow);
- if (UserWindow->Redraw)
- UserWindow->Redraw (UserWindow);
- break;
-
- case EI_iGADGETDOWN:
- if (UserWindow->GadgetDown)
- UserWindow->GadgetDown (UserWindow,iaddress);
- break;
-
- case EI_iMENUPICK:
- if (UserWindow->Menu)
- UserWindow->Menu (UserWindow, code);
- break;
- case EI_iRAWKEY:
- if (UserWindow->RawKey)
- UserWindow->RawKey (UserWindow,code, qual);
- break;
-
- case EI_iVANILLAKEY:
- if (UserWindow->VanillaKey)
- UserWindow->VanillaKey (UserWindow, code, qual, x, y);
- break;
-
- case EI_iREFRESHWINDOW:
- if (EI_BeginRefresh (UserWindow->Window,(LONG)iaddress)) {
- if (UserWindow->Redraw) {
- UserWindow->Redraw (UserWindow);
- }
- EI_EndRefresh (UserWindow->Window,TRUE);
- }
- break;
-
- case EI_iMOUSEMOVE:
- if (UserWindow->MouseMove)
- UserWindow->MouseMove (UserWindow, x, y);
- break;
-
- case EI_iMOUSEBUTTONS:
- if (UserWindow->MouseButtons)
- UserWindow->MouseButtons (UserWindow, code, x, y);
- break;
-
- }
- }
- }
- }
- }
-
-
- void Sleep_All_UserWindows (void) {
- UserInputWindowPtr user;
-
- user=(UserInputWindowPtr)UserList;
- while (user) {
- EI_SleepWindow (user->Window);
- user=(UserInputWindowPtr)user->Next;
- }
- }
-
- void Wake_All_UserWindows (void) {
- UserInputWindowPtr user;
-
- user=(UserInputWindowPtr)UserList;
- while (user) {
- EI_WakeWindow (user->Window);
- user=(UserInputWindowPtr)user->Next;
- }
- }
-
-
- /****************************
- PRIVATE: AddUserWindow.
- This routine is called internally from UserWindow.c. It adds
- a UserWindow to the linked list for management. If you need
- to call this function yourself, add it's prototype to the
- UserWindow.h file, but be carefll not to corrupt the
- linked list.
- ****************************/
- void AddUserWindow (UserInputWindowPtr UserWindow) {
-
- //printf ("AddUserWindow.%x\n",UserWindow);
- if (UserWindow) {
- if (UserList==NULL) {
- //printf ("added to beginning.\n");
- UserList=(void *)UserWindow;
- UserWindow->Next=NULL;
- }
- else {
- //printf ("added to beginning, set poiunter to next.(%x)\n",UserList);
- UserWindow->Next=UserList;
- UserList=(void *)UserWindow;
- }
- }
- }
-
- /****************************
- PRIVATE: RemoveUserWindow.
- This routine is called internally from UserWindow.c. It removes
- a UserWindow from the linked list for management. If you need
- to call this function yourself, add it's prototype to the
- UserWindow.h file, but be carefll not to corrupt the
- linked list.
- ****************************/
- void RemoveUserWindow (UserInputWindowPtr UserWindow) {
- UserInputWindowPtr user, lastuser;
- BYTE Found=0;
-
- user=(UserInputWindowPtr)UserList;
- lastuser=NULL;
- while ((user)&&(!Found)) {
- if (user==UserWindow) {
- Found=1;
- if (lastuser) {
- //printf ("Found userwindow to remove.%08x\n",user);
- //printf ("assigning lastuser->Next=user->next.%07x,%07x\n",lastuser->Next,user->Next);
- lastuser->Next=user->Next;
- user->Next=NULL;
- }
- else {
- //printf ("Found userwindow to remove.%08x\n",user);
- //printf ("Assigning userlist to user->Next.%08x\n",user->Next);
- UserList=user->Next;
- user->Next=NULL;
- }
- }
- lastuser=user;
- user=(UserInputWindowPtr)user->Next;
- }
- }
-
- /******************************************************
- Examples for code you need to write!
- *******************************************************
-
- struct UserInputWindow Example_Request;
-
- BYTE Open_ExampleWindow (WORD x, WORD y);
- EB_GadBoxPtr Create_Example (UserInputWindowPtr UserWindow);
- void Close_Example (UserInputWindowPtr UserWindow);
- void Redraw_Example (UserInputWindowPtr UserWindow);
- void Refresh_Example (UserInputWindowPtr UserWindow);
- void GadgetDown_Example (UserInputWindowPtr UserWindow, EI_GadgetPtr iaddress);
- void IDCMP_Example (struct UserInputWindow *UserWindow, struct EI_EIntuiMsg *Msg);
-
- void CloseDown_Example (void);
-
- /***********************************
- PUBLIC: Open_ExampleWindow.
- This is called by anyone who wants to open the
- Example Control Window.
- ***********************************/
- BYTE Open_ExampleWindow (WORD x, WORD y) {
- static First=1;
-
- if (First) {
- Init_UserWindow (&Example_Request,"FreeHand Example Control",0);
- Example_Request.Redraw = Redraw_Example;
- Example_Request.GadgetDown = GadgetDown_Example;
- Example_Request.Create = Create_Example;
- Example_Request.Close = Close_Example;
- Example_Request.IDCMP = IDCMP_Example;
- //Example_Request.Data = (LONG *)&RefreshFlag; // ... or whatever....
- }
- if (!Open_UserWindow (&Example_Request,-1,-1)) {
- SayOne ("No Memory to open FreeHand Example Control Panel.",-1,-1);
- return 0;
- }
-
- return 1;
- }
-
- /*************************************
- PRIVATE: Create_Example.
- This routine is called by the UserWindow routines.
- It passes back a GadBoxPtr to the gadgets wanted.
- *************************************/
- EB_GadBoxPtr Create_Example (UserInputWindowPtr UserWindow) {
- EB_GadBoxPtr root,help;
- EB_GadContext gadcon;
-
- gadcon = UserWindow->GadCon;
- root = EB_CreateVertiBox (gadcon);
- EB_AddLastSon (root,EB_CreateVertiFill (gadcon,0,0));
- return root;
- }
-
- /*************************************
- PRIVATE: Close_Example.
- This routine CANNOT be used to close the Example
- Control Window!!! It is called by the UserWindow
- routines to allow this window to clean up any
- allocated memory.
- To Close the Example Control Window, call
- CloseDown_Example ();
- *************************************/
- void Close_Example (UserInputWindowPtr UserWindow) {
-
- //if (UserWindow->Data)
- // free (UserWindow->Data); // or something...
- }
-
- /**************************************
- PUBLIC: Redraw_Example.
- This routine handles redraw events to the Example
- Control Window. Called by UserWindow routines, and
- could be called by other routines as well.
- Also called on an EI_iREFRESHWINDOW message.
- **************************************/
- void Redraw_Example (UserInputWindowPtr UserWindow) {
-
- }
-
-
- /**************************************
- PUBLIC: Refresh_Example.
- This routine is called on a EI_iREFRESHWINDOW message.
- If you have nothing to refresh, set the Example_Request.Refresh
- to NULL.
- **************************************/
- void Refresh_Example (UserInputWindowPtr UserWindow) {
- }
-
-
- /**************************************
- PRIVATE: GadgetDown_Example.
- This routine handles the gadget down events passed to the
- Example Control Window.
- **************************************/
- void GadgetDown_Example (UserInputWindowPtr UserWindow, EI_GadgetPtr iaddress) {
-
-
- switch (iaddress->GadgetID) {
- }
- }
-
- /**************************************
- PRIVATE: Menu_Example.
- This routine handles the Menu events passed to the
- Example Control Window.
- **************************************/
- char Menu_Example (UserInputWindowPtr UserWindow, UWORD code) {
-
-
- }
-
-
- /***************************************
- PRIVATE: IDCMP_Example.
- This routine is used in place of GadgetDown_Example if
- you need access to any IDCMP message, not just GadgetDown,
- ie. MouseMove, MouseButton etc.
- You must leave in the code found here, as the normal event
- handler will NOT be called if this function is not NULL.
- This includes rawkey, newsize etc.
- Also note the GadgetDown_Example code will not be called,
- even if it exists, if this function is called. So remember to
- add in your gadget instructions as well.
- Using just the GadgetDown_Example code makes your job MUCH
- easier, but this is here if you have special applications
- (ie. in my case the palette window (yes- its a UserWindow!))
- **************************************/
- void IDCMP_Example (struct UserInputWindow *UserWindow, struct EI_EIntuiMsg *Msg){
- ULONG class;
- UWORD code;
- WORD qual;
- WORD x,y;
- EI_GadgetPtr iaddress=NULL;
- EI_WindowPtr win;
-
- class = Msg->Class;
- code = Msg->Code;
- iaddress = Msg->IAddress;
- qual = Msg->Qualifier;
- win = Msg->IDCMPWindow;
- x=Msg->MouseX;
- y=Msg->MouseY;
- ReplyMsg ( (struct Message *)Msg);
-
- switch (class) {
- case EI_iCLOSEWINDOW:
- if (UserWindow->Close)
- UserWindow->Close (UserWindow);
- RemoveUserWindow (UserWindow);
- UserWindow->GadCon->NewWin->LeftEdge= UserWindow->Window->LeftEdge;
- UserWindow->GadCon->NewWin->TopEdge = UserWindow->Window->TopEdge;
- UserWindow->GadCon->NewWin->Width=UserWindow->Window->Width;
- UserWindow->GadCon->NewWin->Height=UserWindow->Window->Height;
- UserWindow->GadCon->NewWin->MinWidth=UserWindow->Window->MinWidth;
- UserWindow->GadCon->NewWin->MinHeight=UserWindow->Window->MinHeight;
- UserWindow->GadCon->NewWin->MaxWidth=UserWindow->Window->MaxWidth;
- UserWindow->GadCon->NewWin->MaxHeight=UserWindow->Window->MaxHeight;
- EI_CloseWindow (UserWindow->Window);
- UserWindow->Window=NULL;
- UserWindow->GadCon->NewWin->FirstGadgets->NextGadget=NULL;
- if (Last_Used_DrawWindow)
- EI_ActivateWindow (Last_Used_DrawWindow->Window);
- else
- ActivateToolWindow ();
- break;
-
- case EI_iSIZEVERIFY:
- SizeVerify_UserWindow (UserWindow);
- break;
-
- case EI_iNEWSIZE:
- NewSize_UserWindow (UserWindow);
- if (UserWindow->Redraw)
- UserWindow->Redraw (UserWindow);
- break;
-
- case EI_iGADGETDOWN:
- switch (iaddress->GadgetID) {
- }
- break;
- case EI_iMOUSEBUTTONS:
- if (code==SELECTDOWN) {
- }
- else if (code == SELECTUP) {
- }
- break;
-
- case EI_iMOUSEMOVE:
- break;
-
- case EI_iMENUPICK:
- EGSPMenuPick (win,code);
- break;
- case EI_iRAWKEY:
- ProcessRawKey (code,qual);
- break;
-
- case EI_iVANILLAKEY:
- ProcessVanillaKey (Last_Used_DrawWindow,code,qual,x,y);
- break;
-
- case EI_iREFRESHWINDOW:
- if (EI_BeginRefresh (UserWindow->Window,(LONG)iaddress)) {
- if (UserWindow->Refresh) {
- UserWindow->Refresh (UserWindow);
- }
- EI_EndRefresh (UserWindow->Window,TRUE);
- }
- break;
- }
- }
-
- /**************************************
- PUBLIC: CloseDown_Example.
- This can be used to close down the Example Control Window,
- however, it should really be closed by itself.
- (or else through Close_All_UserWindows ());
- **************************************/
- void CloseDown_Example (void) {
-
- Close_UserWindow (&Example_Request);
- }
-
- ******************************************************/
-