ToolChain/bin/targets/m68k-amigaos/ndk/Examples/Reaction/ListBrowser/ListBrowserExample.c
VOID wait_for_close(struct Window *win, struct Gadget *listbrowser_gad)
{
	BOOL ok = TRUE;

	/* Just wait around until the close gadget is pressed.
	 */
	while (ok)
	{
		struct Gadget *gadget;
		struct IntuiMessage *imsg;
			
		WaitPort(win->UserPort);
		while (imsg = (struct IntuiMessage *)GetMsg(win->UserPort))
		{
			switch (imsg->Class)
			{
				case IDCMP_CLOSEWINDOW:
					ok = FALSE;
					break;

				case IDCMP_RAWKEY:
					if (!(imsg->Code & IECODE_UP_PREFIX))
					{
						switch (imsg->Code)
						{
							case RAWKEY_CURSORUP:
								if (imsg->Qualifier & QUALIFIER_CTRL)
									SetGadgetAttrs(listbrowser_gad, win, NULL,
										LISTBROWSER_Position, LBP_TOP,
										TAG_DONE);
								if (imsg->Qualifier & QUALIFIER_SHIFT)
									SetGadgetAttrs(listbrowser_gad, win, NULL,
										LISTBROWSER_Position, LBP_PAGEUP,
										TAG_DONE);
								else
									SetGadgetAttrs(listbrowser_gad, win, NULL,
										LISTBROWSER_Position, LBP_LINEUP,
										TAG_DONE);
								break;

							case RAWKEY_CURSORDOWN:
								if (imsg->Qualifier & QUALIFIER_CTRL)
									SetGadgetAttrs(listbrowser_gad, win, NULL,
										LISTBROWSER_Position, LBP_BOTTOM,
										TAG_DONE);
								if (imsg->Qualifier & QUALIFIER_SHIFT)
									SetGadgetAttrs(listbrowser_gad, win, NULL,
										LISTBROWSER_Position, LBP_PAGEDOWN,
										TAG_DONE);
								else
									SetGadgetAttrs(listbrowser_gad, win, NULL,
										LISTBROWSER_Position, LBP_LINEDOWN,
										TAG_DONE);
								break;

							default:
								break;
						}
					}
					break;

				case IDCMP_GADGETUP:
					gadget = (struct Gadget *)imsg->IAddress;
					Printf("Gadget: %ld  Code: %ld\n",
						(LONG)gadget->GadgetID, (LONG)imsg->Code);

					break;
		
				default:
					break;
			}
			ReplyMsg((struct Message *)imsg);
		}
	}
}
/* Wait for the window close gadget to be pressed.
 */
Wait for the window close gadget to be pressed.
Wait for the window close gadget to be pressed .
VOID wait_for_close(struct Window *win, struct Gadget *listbrowser_gad)
{
	BOOL ok = TRUE;
	while (ok)
	{
		struct Gadget *gadget;
		struct IntuiMessage *imsg;
		WaitPort(win->UserPort);
		while (imsg = (struct IntuiMessage *)GetMsg(win->UserPort))
		{
			switch (imsg->Class)
			{
				case IDCMP_CLOSEWINDOW:
					ok = FALSE;
					break;
				case IDCMP_RAWKEY:
					if (!(imsg->Code & IECODE_UP_PREFIX))
					{
						switch (imsg->Code)
						{
							case RAWKEY_CURSORUP:
								if (imsg->Qualifier & QUALIFIER_CTRL)
									SetGadgetAttrs(listbrowser_gad, win, NULL,
										LISTBROWSER_Position, LBP_TOP,
										TAG_DONE);
								if (imsg->Qualifier & QUALIFIER_SHIFT)
									SetGadgetAttrs(listbrowser_gad, win, NULL,
										LISTBROWSER_Position, LBP_PAGEUP,
										TAG_DONE);
								else
									SetGadgetAttrs(listbrowser_gad, win, NULL,
										LISTBROWSER_Position, LBP_LINEUP,
										TAG_DONE);
								break;
							case RAWKEY_CURSORDOWN:
								if (imsg->Qualifier & QUALIFIER_CTRL)
									SetGadgetAttrs(listbrowser_gad, win, NULL,
										LISTBROWSER_Position, LBP_BOTTOM,
										TAG_DONE);
								if (imsg->Qualifier & QUALIFIER_SHIFT)
									SetGadgetAttrs(listbrowser_gad, win, NULL,
										LISTBROWSER_Position, LBP_PAGEDOWN,
										TAG_DONE);
								else
									SetGadgetAttrs(listbrowser_gad, win, NULL,
										LISTBROWSER_Position, LBP_LINEDOWN,
										TAG_DONE);
								break;
							default:
								break;
						}
					}
					break;
				case IDCMP_GADGETUP:
					gadget = (struct Gadget *)imsg->IAddress;
					Printf("Gadget: %ld  Code: %ld\n",
						(LONG)gadget->GadgetID, (LONG)imsg->Code);
					break;
				default:
					break;
			}
			ReplyMsg((struct Message *)imsg);
		}
	}
}
VOID wait_for_close ( struct Window * win , struct Gadget * listbrowser_gad ) { BOOL ok = TRUE ; while ( ok ) { struct Gadget * gadget ; struct IntuiMessage * imsg ; WaitPort ( win -> UserPort ) ; while ( imsg = ( struct IntuiMessage * ) GetMsg ( win -> UserPort ) ) { switch ( imsg -> Class ) { case IDCMP_CLOSEWINDOW : ok = FALSE ; break ; case IDCMP_RAWKEY : if ( ! ( imsg -> Code & IECODE_UP_PREFIX ) ) { switch ( imsg -> Code ) { case RAWKEY_CURSORUP : if ( imsg -> Qualifier & QUALIFIER_CTRL ) SetGadgetAttrs ( listbrowser_gad , win , NULL , LISTBROWSER_Position , LBP_TOP , TAG_DONE ) ; if ( imsg -> Qualifier & QUALIFIER_SHIFT ) SetGadgetAttrs ( listbrowser_gad , win , NULL , LISTBROWSER_Position , LBP_PAGEUP , TAG_DONE ) ; else SetGadgetAttrs ( listbrowser_gad , win , NULL , LISTBROWSER_Position , LBP_LINEUP , TAG_DONE ) ; break ; case RAWKEY_CURSORDOWN : if ( imsg -> Qualifier & QUALIFIER_CTRL ) SetGadgetAttrs ( listbrowser_gad , win , NULL , LISTBROWSER_Position , LBP_BOTTOM , TAG_DONE ) ; if ( imsg -> Qualifier & QUALIFIER_SHIFT ) SetGadgetAttrs ( listbrowser_gad , win , NULL , LISTBROWSER_Position , LBP_PAGEDOWN , TAG_DONE ) ; else SetGadgetAttrs ( listbrowser_gad , win , NULL , LISTBROWSER_Position , LBP_LINEDOWN , TAG_DONE ) ; break ; default : break ; } } break ; case IDCMP_GADGETUP : gadget = ( struct Gadget * ) imsg -> IAddress ; Printf ( " \n " , ( LONG ) gadget -> GadgetID , ( LONG ) imsg -> Code ) ; break ; default : break ; } ReplyMsg ( ( struct Message * ) imsg ) ; } } }
Wait for the window close gadget to be pressed.
Wait for the window close gadget to be pressed .
/* Just wait around until the close gadget is pressed.
	 */