amigagui.c
BOOL handleIDCMP(struct Window *win, BOOL done)
{
  struct IntuiMessage *message;
  USHORT code;
  SHORT mousex, mousey;
  ULONG class;

  /* Remove all of the messages from the port by calling GetMsg()
  ** until it returns NULL.
  **
  ** The code should be able to handle three cases:
  **
  ** 1.  No messages waiting at the port, and the first call to GetMsg()
  ** returns NULL.  In this case the code should do nothing.
  **
  ** 2.  A single message waiting.  The code should remove the message,
  ** processes it, and finish.
  **
  ** 3.  Multiple messages waiting.  The code should process each waiting
  ** message, and finish.
  */
  while (NULL != (message = (struct IntuiMessage *)GetMsg(win->UserPort)))  {
    /* It is often convenient to copy the data out of the message.
    ** In many cases, this lets the application reply to the message
    ** quickly.  Copying the data is not required, if the code does
    ** not reply to the message until the end of the loop, then
    ** it may directly reference the message information anywhere
    ** before the reply.
    */
    class  = message->Class;
    code   = message->Code;
    mousex = message->MouseX;
    mousey = message->MouseY;

    /* The loop should reply as soon as possible.  Note that the code
    ** may not reference data in the message after replying to the
    ** message.  Thus, the application should not reply to the message
    ** until it is done referencing information in it.
    **
    ** Be sure to reply to every message received with GetMsg().
    */
    ReplyMsg((struct Message *)message);

    /* The class contains the IDCMP type of the message. */
    switch (class) {
    case IDCMP_CLOSEWINDOW:
      done = TRUE;
      break;
    case IDCMP_VANILLAKEY:
      printf("IDCMP_VANILLAKEY (%lc)\n",code);
      break;
    case IDCMP_RAWKEY:
      printf("IDCMP_RAWKEY\n");
      break;
    case IDCMP_DISKINSERTED:
      printf("IDCMP_DISKINSERTED\n");
      break;
    case IDCMP_DISKREMOVED:
      printf("IDCMP_DISKREMOVED\n");
      break;
    case IDCMP_REFRESHWINDOW:
      /* With GadTools, the application must use GT_BeginRefresh()
      ** where it would normally have used BeginRefresh()
      */
      GT_BeginRefresh(global.window);
      GT_EndRefresh(global.window, TRUE);
      break;
    case IDCMP_MOUSEBUTTONS:
      /* the code often contains useful data, such as the ASCII
      ** value (for IDCMP_VANILLAKEY), or the type of button
      ** event here.
      */
      switch (code)
	{
	case SELECTUP:
	  printf("SELECTUP at %d,%d\n",mousex,mousey);
	  break;
	case SELECTDOWN:
	  printf("SELECTDOWN at %d,%d\n",mousex,mousey);
	  break;
	case MENUUP:
	  printf("MENUUP\n");
	  break;
	case MENUDOWN:
	  printf("MENUDOWN\n");
	  break;
	default:
	  printf("UNKNOWN CODE\n");
	  break;
	}
      break;
    default:
      printf("Unknown IDCMP message\n");
      break;
    }
  }
  return(done);
}
/*
** handleIDCMP() - handle all of the messages from an IDCMP.
*/
handle all of the messages from an IDCMP.
handle all of the messages from an IDCMP .
BOOL handleIDCMP(struct Window *win, BOOL done)
{
  struct IntuiMessage *message;
  USHORT code;
  SHORT mousex, mousey;
  ULONG class;
  while (NULL != (message = (struct IntuiMessage *)GetMsg(win->UserPort)))  {
    class  = message->Class;
    code   = message->Code;
    mousex = message->MouseX;
    mousey = message->MouseY;
    ReplyMsg((struct Message *)message);
    switch (class) {
    case IDCMP_CLOSEWINDOW:
      done = TRUE;
      break;
    case IDCMP_VANILLAKEY:
      printf("IDCMP_VANILLAKEY (%lc)\n",code);
      break;
    case IDCMP_RAWKEY:
      printf("IDCMP_RAWKEY\n");
      break;
    case IDCMP_DISKINSERTED:
      printf("IDCMP_DISKINSERTED\n");
      break;
    case IDCMP_DISKREMOVED:
      printf("IDCMP_DISKREMOVED\n");
      break;
    case IDCMP_REFRESHWINDOW:
      GT_BeginRefresh(global.window);
      GT_EndRefresh(global.window, TRUE);
      break;
    case IDCMP_MOUSEBUTTONS:
      switch (code)
	{
	case SELECTUP:
	  printf("SELECTUP at %d,%d\n",mousex,mousey);
	  break;
	case SELECTDOWN:
	  printf("SELECTDOWN at %d,%d\n",mousex,mousey);
	  break;
	case MENUUP:
	  printf("MENUUP\n");
	  break;
	case MENUDOWN:
	  printf("MENUDOWN\n");
	  break;
	default:
	  printf("UNKNOWN CODE\n");
	  break;
	}
      break;
    default:
      printf("Unknown IDCMP message\n");
      break;
    }
  }
  return(done);
}
BOOL handleIDCMP ( struct Window * win , BOOL done ) { struct IntuiMessage * message ; USHORT code ; SHORT mousex , mousey ; ULONG class ; while ( NULL != ( message = ( struct IntuiMessage * ) GetMsg ( win -> UserPort ) ) ) { class = message -> Class ; code = message -> Code ; mousex = message -> MouseX ; mousey = message -> MouseY ; ReplyMsg ( ( struct Message * ) message ) ; switch ( class ) { case IDCMP_CLOSEWINDOW : done = TRUE ; break ; case IDCMP_VANILLAKEY : printf ( " \n " , code ) ; break ; case IDCMP_RAWKEY : printf ( " \n " ) ; break ; case IDCMP_DISKINSERTED : printf ( " \n " ) ; break ; case IDCMP_DISKREMOVED : printf ( " \n " ) ; break ; case IDCMP_REFRESHWINDOW : GT_BeginRefresh ( global . window ) ; GT_EndRefresh ( global . window , TRUE ) ; break ; case IDCMP_MOUSEBUTTONS : switch ( code ) { case SELECTUP : printf ( " \n " , mousex , mousey ) ; break ; case SELECTDOWN : printf ( " \n " , mousex , mousey ) ; break ; case MENUUP : printf ( " \n " ) ; break ; case MENUDOWN : printf ( " \n " ) ; break ; default : printf ( " \n " ) ; break ; } break ; default : printf ( " \n " ) ; break ; } } return ( done ) ; }
handleIDCMP() - handle all of the messages from an IDCMP.
handleIDCMP () - handle all of the messages from an IDCMP .
/* Remove all of the messages from the port by calling GetMsg()
  ** until it returns NULL.
  **
  ** The code should be able to handle three cases:
  **
  ** 1.  No messages waiting at the port, and the first call to GetMsg()
  ** returns NULL.  In this case the code should do nothing.
  **
  ** 2.  A single message waiting.  The code should remove the message,
  ** processes it, and finish.
  **
  ** 3.  Multiple messages waiting.  The code should process each waiting
  ** message, and finish.
  */ /* It is often convenient to copy the data out of the message.
    ** In many cases, this lets the application reply to the message
    ** quickly.  Copying the data is not required, if the code does
    ** not reply to the message until the end of the loop, then
    ** it may directly reference the message information anywhere
    ** before the reply.
    */ /* The loop should reply as soon as possible.  Note that the code
    ** may not reference data in the message after replying to the
    ** message.  Thus, the application should not reply to the message
    ** until it is done referencing information in it.
    **
    ** Be sure to reply to every message received with GetMsg().
    */ /* The class contains the IDCMP type of the message. */ /* With GadTools, the application must use GT_BeginRefresh()
      ** where it would normally have used BeginRefresh()
      */ /* the code often contains useful data, such as the ASCII
      ** value (for IDCMP_VANILLAKEY), or the type of button
      ** event here.
      */