		/* Project: unnamed */

	/* Includes */

#include <exec/types.h>
#include <exec/lists.h>
#include <intuition/intuition.h>
#include <libraries/intuisup.h>
#ifdef AZTEC_C
#include <functions.h>
#endif

	/* Defines and data for window */

#define RENDER_INFO_FLAGS  3
#define OPEN_WINDOW_FLAGS  0

#define WINDOW_LEFT_EDGE   98
#define WINDOW_TOP_EDGE    123
#define WINDOW_WIDTH       524
#define WINDOW_HEIGHT      132

STATIC struct NewWindow  test_new_window = {
   WINDOW_LEFT_EDGE, WINDOW_TOP_EDGE, WINDOW_WIDTH, WINDOW_HEIGHT, 0, 1,
   CLOSEWINDOW | GADGET_IDCMP_FLAGS_ALL, WINDOWCLOSE | WINDOWDRAG |
   WINDOWDEPTH | SMART_REFRESH | NOCAREREFRESH | ACTIVATE, NULL, NULL,
   (UBYTE *)"unnamed", NULL, NULL, 0, 0, 0, 0, WBENCHSCREEN
};
	/* Defines and data for borders */

#define TEST_BORDER_BORDER1   0
#define TEST_BORDER_BORDER2   1
#define TEST_BORDER_BORDER3   2
#define TEST_BORDER_BORDER4   3

STATIC struct BorderData  test_border_data[] = {
   {
      4, 273, 33, 87, 25
   }, {
      2, 275, 106, 95, 21
   }, {
      1, 397, 112, 97, 15
   }, {
      3, 374, 6, 63, 14
   }, {
      INTUISUP_DATA_END
   }
};
	/* Data for fonts */

STATIC struct TextAttr  test_text_attr[] = {
   {
      (STRPTR)"topaz.font", 8, FS_NORMAL, FPF_ROMFONT
   }, {
      (STRPTR)"topaz.font", 9, FS_NORMAL, FPF_ROMFONT
   }
};
	/* Defines and data for texts */

#define TEST_TEXT_TEXT1   0
#define TEST_TEXT_TEXT2   1
#define TEST_TEXT_TEXT3   2

STATIC struct TextData  test_text_data[] = {
   {
      1, 6, 291, 40,
      "Laber", &test_text_attr[1]
   }, {
      1, 65, 302, 92,
      "Humbug", &test_text_attr[1]
   }, {
      1, 128, 40, 112,
      "Blubber", &test_text_attr[0]
   }, {
      INTUISUP_DATA_END
   }
};
	/* Defines and data for gadgets */

#define TEST_GADGET_GADGET1   0
#define TEST_GADGET_GADGET2   1
#define TEST_GADGET_GADGET3   2
#define TEST_GADGET_GADGET4   3
#define TEST_GADGET_GADGET5   4
#define TEST_GADGET_GADGET6   5
#define TEST_GADGET_GADGET7   6
#define TEST_GADGET_GADGET8   7
#define TEST_GADGET_GADGET9   8
#define TEST_GADGET_GADGET10   9
#define TEST_GADGET_GADGET11   10

IMPORT struct List  test_gadget1_list;
STATIC struct Node  test_gadget1_node[] = {
   {
      &test_gadget1_node[1], (struct Node *)&test_gadget1_list.lh_Head, 0, 0,
      "Entry 1"
   }, {
      &test_gadget1_node[2], &test_gadget1_node[0], 0, 0,
      "Entry 2"
   }, {
      &test_gadget1_node[3], &test_gadget1_node[1], 0, 0,
      "Entry 3"
   }, {
      &test_gadget1_node[4], &test_gadget1_node[2], 0, 0,
      "Entry 4"
   }, {
      &test_gadget1_node[5], &test_gadget1_node[3], 0, 0,
      "Entry 5"
   }, {
      &test_gadget1_node[6], &test_gadget1_node[4], 0, 0,
      "Entry 6"
   }, {
      &test_gadget1_node[7], &test_gadget1_node[5], 0, 0,
      "Entry 7"
   }, {
      &test_gadget1_node[8], &test_gadget1_node[6], 0, 0,
      "Entry 8"
   }, {
      &test_gadget1_node[9], &test_gadget1_node[7], 0, 0,
      "Entry 9"
   }, {
      &test_gadget1_node[10], &test_gadget1_node[8], 0, 0,
      "Entry 10"
   }, {
      &test_gadget1_node[11], &test_gadget1_node[9], 0, 0,
      "Entry 11"
   }, {
      (struct Node *)&test_gadget1_list.lh_Tail, &test_gadget1_node[10], 0, 0,
      "Entry 12"
   }
};
/* STATIC */ struct List  test_gadget1_list = {
   &test_gadget1_node[0], NULL,
   &test_gadget1_node[11], 0, 0
};
STATIC BYTE *test_gadget5_text_array[] = {
   "MX1",
   "MX2",
   "MX3",
   "MX4",
   NULL
};
STATIC BYTE *test_gadget10_text_array[] = {
   "Cycle",
   "Test 1",
   "Test 2",
   "Test 3",
   "Test 4",
   "Test 5",
   NULL
};
STATIC struct GadgetData  test_gadget_data[] = {
   {
      10, 1296, 13, 20, 107, 44,
      "List_view", &test_text_attr[0],
      { 0, 0, &test_gadget1_list }
   }, {
      11, 272, 144, 19, 100, 35,
      "_Palette", &test_text_attr[1],
      { 2, 0, (VOID *)2 }
   }, {
      1, 16, 266, 6, 91, 20,
      "_Button", &test_text_attr[1],
      { 0, 0, (VOID *)0 }
   }, {
      2, 1104, 424, 26, 21, 11,
      "_Check", &test_text_attr[0],
      { 1, 0, (VOID *)0 }
   }, {
      3, 144, 388, 57, 72, 47,
      "_Radio", &test_text_attr[1],
      { 1, 0, &test_gadget5_text_array[0] }
   }, {
      4, 1104, 205, 83, 76, 14,
      "_String", &test_text_attr[0],
      { 10, 0, "String" }
   }, {
      5, 144, 136, 62, 44, 14,
      "_Integer", &test_text_attr[0],
      { 10, 0, (VOID *)123 }
   }, {
      6, 528, 299, 64, 64, 11,
      "Sli_der", &test_text_attr[0],
      { 0, 10, (VOID *)5 }
   }, {
      7, 280, 473, 26, 18, 62,
      "Scro_ller", &test_text_attr[0],
      { 2, 10, (VOID *)5 }
   }, {
      8, 272, 20, 89, 97, 13,
      "C_ycle", &test_text_attr[1],
      { 0, 0, &test_gadget10_text_array[0] }
   }, {
      9, 144, 143, 109, 65, 12,
      "C_ount", &test_text_attr[0],
      { 10, 50, (VOID *)30 }
   }, {
      INTUISUP_DATA_END
   }
};

struct Library  *IntuiSupBase;

	/* Test program */

   LONG
main(VOID)
{
   struct Window  *win;
   APTR ri, gl;

   if (IntuiSupBase = OpenLibrary(IntuiSupName, IntuiSupVersion)) {
      if (ri = IGetRenderInfo(NULL, RENDER_INFO_FLAGS)) {
         if (win = IOpenWindow(ri, &test_new_window, OPEN_WINDOW_FLAGS)) {
            if (gl = ICreateGadgets(ri, &test_gadget_data[0], 0, 0, NULL)) {
               BOOL keepon = TRUE;

               IDisplayBorders(ri, win, &test_border_data[0], 0, 0);
               IDisplayTexts(ri, win, &test_text_data[0], 0, 0, NULL);
               IDisplayGadgets(win, gl);
               do {
                  struct IntuiMessage  *msg;

                  WaitPort(win->UserPort);
                  while (msg = IGetMsg(win->UserPort)) {
                     if (msg->Class == CLOSEWINDOW) {
                        keepon = FALSE;
                     }
                     IReplyMsg(msg);
                  }
               } while (keepon == TRUE);
               IRemoveGadgets(gl);
               IFreeGadgets(gl);
            }
            ICloseWindow(win, FALSE);
         }
         IFreeRenderInfo(ri);
      }
      CloseLibrary(IntuiSupBase);
   }
   return(0L);
}
