home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / OTL-MC7.DMS / in.adf / ansicdemo.lha / ANSI-C / Intuition / frameidemo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  3.2 KB  |  136 lines

  1. /*
  2.  * frameidemo.c - shows frame types from frameiclass
  3.  *
  4.  * (c) Copyright 1992 Commodore-Amiga, Inc.  All Rights Reserved.
  5.  * 
  6.  * For V39, the boopsi frameiclass imageclass has been extended to
  7.  * support a bunch of system-standard frames.  This demo shows
  8.  * the default frame, the standard button frame, the ridge, and
  9.  * the icon drop box, and shows the indentation feature.
  10.  */
  11.  
  12. /*------------------------------------------------------------------------*/
  13.  
  14. #include <stdio.h>
  15. #include <intuition/intuition.h>
  16. #include <intuition/imageclass.h>
  17. #include <pragma/exec_lib.h>
  18. #include <pragma/intuition_lib.h>
  19.  
  20. /*------------------------------------------------------------------------*/
  21.  
  22. void bail_out(int code);
  23.  
  24. /*------------------------------------------------------------------------*/
  25.  
  26. struct NewWindow newwin =
  27.     {
  28.     0,0,        /*  LeftEdge, TopEdge */
  29.     600,200,            /*  Width, Height */
  30.     -1, -1,             /*  DetailPen, BlockPen */
  31.     CLOSEWINDOW | REFRESHWINDOW,    /*  IDCMPFlags */
  32.     WINDOWDRAG | WINDOWSIZING | WINDOWDEPTH | WINDOWCLOSE |
  33.     WFLG_ACTIVATE|SMART_REFRESH,    /* Flags */
  34.     NULL,        /*  FirstGadget */
  35.     NULL,        /*  CheckMark */
  36.     (UBYTE *) "FrameIClass Demo",    /*  Title */
  37.     NULL,        /*  Screen */
  38.     NULL,        /*  BitMap */    
  39.     100,50,        /*  MinWidth, MinHeight */
  40.     640,200,        /*  MaxWidth, MaxHeight */
  41.     WBENCHSCREEN,    /*  Type */
  42.     };
  43.  
  44. /*------------------------------------------------------------------------*/
  45.  
  46. struct GfxBase *GfxBase;
  47. struct IntuitionBase *IntuitionBase;
  48. struct Window *win;
  49. struct Image *frame;
  50.  
  51. /*------------------------------------------------------------------------*/
  52.  
  53. main()
  54.     {
  55.     BOOL terminated;
  56.     struct IntuiMessage *imsg;
  57.     long frametype, recessed;
  58.  
  59.     terminated = FALSE;
  60.     win = NULL;
  61.  
  62.     if (!(GfxBase = (struct GfxBase *)
  63.     OpenLibrary("graphics.library",39L)))
  64.     bail_out(20);
  65.  
  66.     if (!(IntuitionBase = (struct IntuitionBase *)
  67.     OpenLibrary("intuition.library",39L)))
  68.     bail_out(20);
  69.  
  70.     if (!(win = OpenWindow(&newwin)))
  71.     bail_out(20);
  72.  
  73.     for ( recessed = 0; recessed <= 1; recessed++ )
  74.     {
  75.     for ( frametype = 0; frametype <= 3; frametype++ )
  76.     {
  77.         if ( !( frame = NewObject( NULL, "frameiclass",
  78.         IA_FrameType, frametype,
  79.         IA_Recessed, recessed,
  80.         IA_Width, 80,
  81.         IA_Height, 20,
  82.         TAG_DONE ) ) )
  83.         bail_out(20);
  84.  
  85.         DrawImage( win->RPort, frame, 20 + frametype*100,
  86.         win->WScreen->Font->ta_YSize + 12 + recessed*30 );
  87.     }
  88.     }
  89.     while (!terminated)
  90.     {
  91.     Wait (1 << win->UserPort->mp_SigBit);
  92.     while (imsg = (struct IntuiMessage *) GetMsg(win->UserPort))
  93.         {
  94.         if (imsg->Class == CLOSEWINDOW)
  95.         terminated = TRUE;
  96.         else if (imsg->Class == REFRESHWINDOW)
  97.         {
  98.         BeginRefresh(win);
  99.         EndRefresh(win,TRUE);
  100.         }
  101.         ReplyMsg((struct Message *) imsg);
  102.         }
  103.     }
  104.     bail_out(0);
  105.     }
  106.  
  107.  
  108. /*------------------------------------------------------------------------*/
  109.  
  110. /*/ bail_out()
  111.  *
  112.  * Close any allocated or opened stuff.
  113.  */
  114.  
  115. void bail_out(code)
  116.  
  117.     int code;
  118.     {
  119.     if (frame)
  120.     DisposeObject(frame);
  121.  
  122.     if (win)
  123.     CloseWindow(win);
  124.  
  125.     if (IntuitionBase)
  126.     CloseLibrary( ( struct Library *)IntuitionBase);
  127.  
  128.     if (GfxBase)
  129.     CloseLibrary( ( struct Library *)GfxBase);
  130.  
  131.     exit(code);
  132.     }
  133.  
  134.  
  135. /*------------------------------------------------------------------------*/
  136.