home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / 3_1EXAM1.DMS / in.adf / intuition / frameidemo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-17  |  3.3 KB  |  138 lines

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