home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / disks / disk399.lzh / PrettyWindows / pwdemo.c < prev    next >
C/C++ Source or Header  |  1990-11-02  |  3KB  |  182 lines

  1. #include <exec/types.h>
  2. #include <exec/exec.h>
  3. #include <intuition/intuition.h>
  4. #include <graphics/gfxbase.h>
  5. #include <graphics/gfx.h>
  6. #include <graphics/gfxmacros.h>
  7.  
  8. /********************************************
  9.  *  PrettyWindows v1.0   by Thom Robertson  *
  10.  ********************************************/
  11.  
  12. extern struct IntuitionBase *IntuitionBase;
  13. extern struct GfxBase *GfxBase;
  14.  
  15. main() {
  16.  
  17. struct Window *win1,*win2,*win3;
  18. int i;
  19.  
  20. char text[7][50] = {
  21. {"This demo shows the usage of"},
  22. {"PrettyWindows V1.0   by Thom Robertson"},
  23. {"PrettyWindows is a set of 3 routines"},
  24. {"which liven up your text windows."},
  25. {"PrettyWindows is freely redistributable"},
  26. {"code, written in LATTICE C 5.04 ."},
  27. {"Press a key or click on this window"},
  28. };
  29.  
  30.  
  31. win1 = 0;
  32. win2 = 0;
  33. win3 = 0;
  34. IntuitionBase = 0;
  35. GfxBase = 0;
  36.  
  37. IntuitionBase = (struct IntuitionBase *) OpenLibrary(
  38.                 "intuition.library",0);
  39. if (IntuitionBase == NULL) {
  40.    printf("intuition won't open!\n");
  41.    goto end;
  42.    }
  43.  
  44. GfxBase = (struct GfxBase *) OpenLibrary("graphics.library",0);
  45. if (GfxBase == NULL)  {
  46.    printf("graph.lib. won't open!\n");
  47.    goto end;
  48.    }
  49.  
  50.  
  51. /* do first window */
  52.  
  53. win1 = makewindow(0,20,20,600,160);
  54. if (win1 == NULL)  {
  55.    printf("Window 1 won't open!\n");
  56.    goto end;
  57.    }
  58.  
  59. prettywindow1(win1,2);
  60.  
  61. SetDrMd(win1->RPort,JAM1);
  62. SetAPen(win1->RPort,0);
  63.  
  64. Move(win1->RPort,100,50);
  65. Text(win1->RPort,text[0],strlen(text[0]));
  66. Move(win1->RPort,100,80);
  67. Text(win1->RPort,text[1],strlen(text[1]));
  68.  
  69. SetAPen(win1->RPort,1);
  70. Move(win1->RPort,100,130);
  71. Text(win1->RPort,text[6],strlen(text[6]));
  72.  
  73. getinput(win1);
  74.  
  75.  
  76. /* do second window */
  77.  
  78. win2 = makewindow(0,10,10,450,110);
  79. if (win2 == NULL)  {
  80.    printf("Window 2 won't open!\n");
  81.    goto end;
  82.    }
  83.  
  84. prettywindow2(win2,0);
  85.  
  86. SetDrMd(win2->RPort,JAM1);
  87. SetAPen(win2->RPort,1);
  88.  
  89. Move(win2->RPort,40,45);
  90. Text(win2->RPort,text[2],strlen(text[2]));
  91. Move(win2->RPort,40,60);
  92. Text(win2->RPort,text[3],strlen(text[3]));
  93.  
  94. SetAPen(win2->RPort,3);
  95. Move(win2->RPort,40,85);
  96. Text(win2->RPort,text[6],strlen(text[6]));
  97.  
  98. getinput(win2);
  99.  
  100. /* do third window */
  101.  
  102. win3 = makewindow(0,150,80,450,110);
  103. if (win3 == NULL)  {
  104.    printf("Window 3 won't open!\n");
  105.    goto end;
  106.    }
  107.  
  108. prettywindow3(win3,3);
  109.  
  110. SetDrMd(win3->RPort,JAM1);
  111. SetAPen(win3->RPort,2);
  112.  
  113. Move(win3->RPort,40,45);
  114. Text(win3->RPort,text[4],strlen(text[4]));
  115. Move(win3->RPort,40,60);
  116. Text(win3->RPort,text[5],strlen(text[5]));
  117.  
  118. SetAPen(win3->RPort,1);
  119. Move(win3->RPort,40,85);
  120. Text(win3->RPort,text[6],strlen(text[6]));
  121.  
  122. getinput(win3);
  123.  
  124. end:
  125.  
  126. if (win1 != 0)
  127.    CloseWindow(win1);
  128. if (win2 != 0)
  129.    CloseWindow(win2);
  130. if (win3 != 0)
  131.    CloseWindow(win3);
  132. if (IntuitionBase != NULL)
  133.    CloseLibrary(IntuitionBase);
  134. if (GfxBase != NULL)
  135.    CloseLibrary(GfxBase);
  136.  
  137.  
  138.  
  139. }  /* end of program */
  140.  
  141.  
  142. getinput(win)
  143. struct Window *win;
  144. {
  145.  
  146. struct IntuiMessage *mess;
  147. ULONG mclass;
  148. USHORT mcode,mqual;
  149. APTR maddr;
  150. LONG Mx,My;
  151.  
  152.    while ((mess = GetMsg(win->UserPort))!= 0) 
  153.       ReplyMsg(mess);
  154.  
  155. while (TRUE) {
  156.    Wait((1<<win->UserPort->mp_SigBit));
  157.    while ((mess = GetMsg(win->UserPort))!= 0) {
  158.  
  159.       mclass = mess->Class;
  160.       mcode = mess->Code;
  161.       maddr = mess->IAddress;
  162.       mqual = mess->Qualifier;
  163.       Mx = mess->MouseX;
  164.       My = mess->MouseY;
  165.       ReplyMsg(mess);
  166.  
  167.       if (mclass == RAWKEY || mclass == MOUSEBUTTONS)
  168.          return(0); 
  169.  
  170.  
  171.  
  172.       }
  173.    }
  174.  
  175.  
  176. }
  177.  
  178.  
  179.  
  180.  
  181.  
  182.