/* Compile me to get full executable. */

#include <stdio.h>
#include <exec/types.h>
#include <exec/memory.h>
#include <dos/dosextens.h>
#include <intuition/screens.h>
#include <intuition/intuition.h>
#include <intuition/gadgetclass.h>
#include <libraries/gadtools.h>
#include <diskfont/diskfont.h>
#include <utility/utility.h>
#include <graphics/gfxbase.h>
#include <workbench/workbench.h>
#include <graphics/scale.h>
#include <clib/exec_protos.h>
#include <clib/wb_protos.h>
#include <clib/intuition_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/graphics_protos.h>
#include <clib/utility_protos.h>
#include <string.h>
#include <clib/diskfont_protos.h>

#include "UserDataEditor.h"

void ProcessWindowUE_Win( LONG Class, UWORD Code, APTR IAddress )
{
struct Gadget *gad;
switch ( Class )
  {
  case IDCMP_GADGETUP :
    /* Gadget message, gadget = gad. */
    gad = (struct Gadget *)IAddress;
    switch ( gad->GadgetID )
      {
      case UE_UserSlider :
        /* Scroller changed, Text of gadget : User */
        break;
      case UE_UserNum :
        /* Integer entered , Text of gadget :  */
        break;
      case UE_Handle :
        /* String entered  , Text of gadget : _Handle */
        break;
      case UE_RealName :
        /* String entered  , Text of gadget : Real _Name */
        break;
      case UE_Group :
        /* String entered  , Text of gadget : _Group */
        break;
      case UE_GeoLocation :
        /* String entered  , Text of gadget : Geo _Location */
        break;
      case UE_Country :
        /* String entered  , Text of gadget : _Country */
        break;
      case UE_PhoneNumber :
        /* String entered  , Text of gadget : _Phone Number */
        break;
      case UE_ComputerType :
        /* String entered  , Text of gadget : C_omputer Type */
        break;
      case UE_Sentby :
        /* String entered  , Text of gadget : _Sentby */
        break;
      case UE_Calls :
        /* Integer entered , Text of gadget : Calls */
        break;
      case UE_Access :
        /* Integer entered , Text of gadget : _Access */
        break;
      case UE_LastCalled :
        /* String entered  , Text of gadget : Last Called */
        break;
      case UE_LastUpload :
        /* String entered  , Text of gadget : Last Upload */
        break;
      case UE_TransferOptions :
        /* Button pressed  , Text of gadget : Transfer Options */
        break;
      }
    break;
  case IDCMP_CLOSEWINDOW :
    /* CloseWindow Now */
    break;
  case IDCMP_REFRESHWINDOW :
    GT_BeginRefresh( UE_Win);
    /* Refresh window. */
  RendWindowUE_Win( UE_Win, UE_WinVisualInfo );
    GT_EndRefresh( UE_Win, TRUE);
  GT_RefreshWindow( UE_Win, NULL);
  RefreshGList( UE_WinGList, UE_Win, NULL, ~0);
    break;
  }
}


int main(void)
{
int done=0;
ULONG class;
UWORD code;
struct Gadget *pgsel;
struct IntuiMessage *imsg;
OpenDiskFonts();
if (OpenWindowUE_Win()==0)
  {
  while(done==0)
    {
    Wait(1L << UE_Win->UserPort->mp_SigBit);
    imsg=GT_GetIMsg(UE_Win->UserPort);
    while (imsg != NULL )
      {
      class=imsg->Class;
      code=imsg->Code;
      pgsel=(struct Gadget *)imsg->IAddress; /* Only reference if it is a gadget message */
      GT_ReplyIMsg(imsg);
      ProcessWindowUE_Win(class, code, pgsel);
      /* The next line is just so you can quit, remove when proper method implemented. */
      if (class==IDCMP_CLOSEWINDOW)
        done=1;
      imsg=GT_GetIMsg(UE_Win->UserPort);
      }
    }

  CloseWindowUE_Win();
  }
else
  printf("Cannot open window.\n");
}
