home *** CD-ROM | disk | FTP | other *** search
/ Megahits 4 / MegaHits_Vol.4.iso / mui / dev / gui / myimagegclass / source / demo.c next >
Encoding:
C/C++ Source or Header  |  1994-10-24  |  25.0 KB  |  480 lines

  1. // -----------------------------------------------------------------------------
  2. // demo.c
  3. // demo program for myimagegclass
  4. // ©1994 Excellent Studios
  5. // 07 Jan 1994
  6. //
  7. // $Id: demo.c,v 1.1 94/01/11 03:03:47 rick Exp Locker: rick $
  8. // -----------------------------------------------------------------------------
  9.  
  10. /* MUI */
  11. #include <libraries/mui.h>
  12.  
  13. /* System */
  14. #include <dos/dos.h>
  15. #include <graphics/gfxmacros.h>
  16.  
  17. /* Prototypes */
  18. #include <clib/alib_protos.h>
  19. #include <proto/exec.h>
  20. #include <proto/dos.h>
  21. #include <proto/graphics.h>
  22. #include <proto/intuition.h>
  23. #include <proto/muimaster.h>
  24. #include <proto/asl.h>
  25.  
  26. /* ANSI C */
  27. #include <stdlib.h>
  28. #include <string.h>
  29. #include <stdio.h>
  30. #include <dos.h>
  31.  
  32. #include <intuition/icclass.h>
  33. #include <intuition/gadgetclass.h>
  34. #include "myimagegclass.h"
  35.  
  36. #include <exec/memory.h>
  37.  
  38. #include "myimagegclass.h"
  39.  
  40. #define TextSpace(str,weight)\
  41.    TextObject,TextFrame,MUIA_Text_Contents,str,MUIA_Weight,weight,MUIA_Background,MUII_TextBack,End
  42. #define KeyImageButton(image,control)\
  43.    ImageObject,\
  44.       ImageButtonFrame,\
  45.       MUIA_InputMode, MUIV_InputMode_RelVerify,\
  46.       MUIA_Image_Spec, image,\
  47.       MUIA_Image_FontMatch, TRUE,\
  48.       MUIA_Background, MUII_ButtonBack,\
  49.       MUIA_ControlChar, control,\
  50.       End
  51. #define AppRetID(gad,attr,attrVal,id)\
  52.    DoMethod(gad,MUIM_Notify,attr,attrVal,app,2,MUIM_Application_ReturnID,id)
  53. // no '-' sign, no negatives allowed in this integer gadget!
  54. #define KeyInteger(contents,maxlen,controlchar)\
  55.     StringObject,\
  56.         StringFrame,\
  57.         MUIA_ControlChar    , controlchar,\
  58.         MUIA_String_MaxLen  , maxlen,\
  59.         MUIA_String_Integer, contents,\
  60.         MUIA_String_Accept, "0123456789",\
  61.         End
  62.  
  63. enum {
  64.    ID_POPUP = 1,
  65.    ID_BEEP,
  66.    ID_SCALEX,
  67.    ID_SCALEY,
  68.    ID_RELX,
  69.    ID_RELY,
  70.    ID_RELWIDTH,
  71.    ID_RELHEIGHT,
  72.    ID_ASPECTRATIO,
  73.    ID_IMAGEBEEP
  74. };
  75.  
  76. // GLOBALS --------------------------------------------------------------
  77.  
  78. struct Library *MUIMasterBase;
  79. Class *myimagegclass;
  80.  
  81. struct FileRequester *loadReq;
  82.  
  83. struct BitMap bitMap;
  84. struct Image image;
  85. APTR app, WI_Pic,WI_Options, i_myImage,i_miniImage,t_name,t_info,g_popup,
  86.      g_scaleX,g_scaleY,g_relX,g_relY,g_aspect,g_relWidth,g_relHeight,g_beep;
  87.  
  88. ULONG sFlags, relWidth = 100, relHeight = 100, beep;
  89.  
  90. USHORT chip excellent0_data[] =
  91. {
  92.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xf000,
  93.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xf000,
  94.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xf000,
  95.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffc0,  0xfff,  0xe000,  0x0,  0x0,  0x3ff,  0xf000,
  96.   0xf800,  0x0,  0x1f,  0xfff8,  0xffff,  0xf9ff,  0xffc0,  0x1fff,  0xe000,  0x0,  0x0,  0x3ff,  0xf000,
  97.   0xf800,  0x0,  0x1f,  0xff80,  0x7fff,  0xf81f,  0xffc0,  0x3fff,  0xe000,  0x0,  0x0,  0x1ff,  0xf000,
  98.   0xf800,  0x0,  0xf,  0xfc00,  0x3fff,  0xf001,  0xffc0,  0x3fff,  0xc002,  0x0,  0x0,  0x1ff,  0xf000,
  99.   0xf800,  0x0,  0xf,  0xf000,  0xfff,  0xc000,  0x1fc0,  0x7fff,  0x800e,  0x0,  0x380,  0xff,  0xf000,
  100.   0xf800,  0x0,  0x7,  0xf800,  0x7ff,  0x8000,  0x3fc0,  0xffff,  0x803c,  0x0,  0x3e0,  0xff,  0xf000,
  101.   0xf800,  0x0,  0x7,  0xfc00,  0x1fe,  0x0,  0xffc0,  0xffff,  0x80fc,  0x0,  0x1ff,  0x7f,  0xf000,
  102.   0xf800,  0xfff,  0xffff,  0xff00,  0xfc,  0x3,  0xffc1,  0xffff,  0x1fc,  0x0,  0xff,  0xc07f,  0xf000,
  103.   0xf800,  0xfff,  0xffff,  0xff80,  0x78,  0x7,  0xffc3,  0xffff,  0x7f8,  0x30,  0x7f,  0xfe3f,  0xf000,
  104.   0xf800,  0xfff,  0xffff,  0xffc0,  0x10,  0xf,  0xffc3,  0xfffe,  0x1ff8,  0x1c,  0x3f,  0xff9f,  0xf000,
  105.   0xf800,  0xfff,  0xffff,  0xfff0,  0x0,  0x3f,  0xffc7,  0xfffe,  0x7ff0,  0xf,  0x803f,  0xffff,  0xf000,
  106.   0xf800,  0xfff,  0xffff,  0xfff8,  0x0,  0x7f,  0xffcf,  0xfffc,  0xfff0,  0xf,  0xc01f,  0xffff,  0xf000,
  107.   0xf800,  0x0,  0x7ff,  0xfffe,  0x0,  0x1ff,  0xffcf,  0xffff,  0xffe0,  0x7,  0xf00f,  0xffff,  0xf000,
  108.   0xf800,  0x0,  0x7ff,  0xffff,  0x0,  0x7ff,  0xffdf,  0xffff,  0xffe0,  0x7,  0xfc0f,  0xffff,  0xf000,
  109.   0xf800,  0x0,  0x7ff,  0xffff,  0x8000,  0xfff,  0xffdf,  0xffff,  0xffc0,  0x3,  0xff07,  0xffff,  0xf000,
  110.   0xf800,  0x0,  0x7ff,  0xffff,  0xe000,  0xfff,  0xffff,  0xffff,  0xffc0,  0x1,  0xffc3,  0xffff,  0xf000,
  111.   0xf800,  0x0,  0x7ff,  0xffff,  0xc000,  0x7ff,  0xffff,  0xffff,  0xff80,  0x1ef1,  0xfff1,  0xffff,  0xf000,
  112.   0xf800,  0x0,  0x7ff,  0xffff,  0x0,  0x3ff,  0xffff,  0xbfff,  0xef80,  0x3f3f,  0xffff,  0xffff,  0xf000,
  113.   0xf800,  0x0,  0x7ff,  0xfffe,  0x0,  0x1ff,  0xffff,  0x3fff,  0xcf00,  0x3f1f,  0xffff,  0xffff,  0xf000,
  114.   0xf800,  0xfff,  0xffff,  0xfffc,  0x0,  0x7f,  0xfffe,  0x3fff,  0x9f01,  0x3f07,  0xfbff,  0xffff,  0xf000,
  115.   0xf800,  0xfff,  0xffff,  0xfff8,  0x0,  0x3f,  0xfffc,  0x7fff,  0x1e06,  0x3f03,  0xfdff,  0xffff,  0xf000,
  116.   0xf800,  0xfff,  0xffff,  0xffe0,  0x10,  0xf,  0xfff0,  0x7ffc,  0x1e38,  0xc00,  0xfc7f,  0xff9f,  0xf000,
  117.   0xf800,  0xfff,  0xffff,  0xffc0,  0x38,  0x7,  0xffe0,  0x7ff8,  0x1e70,  0xc00,  0x7c3f,  0xff87,  0xf000,
  118.   0xf800,  0xfff,  0xffff,  0xff00,  0xfc,  0x1,  0xffc0,  0xffe0,  0x3fc0,  0xc00,  0x1e0f,  0xffc1,  0xf000,
  119.   0xf800,  0xfff,  0xffff,  0xfe00,  0x1fe,  0x0,  0xffc0,  0xffc0,  0x3f80,  0xc00,  0xe07,  0xffc0,  0xf000,
  120.   0xf800,  0x0,  0x1,  0xfc00,  0x3ff,  0x0,  0x7fc0,  0xff80,  0x7f00,  0xc00,  0x201,  0xffe0,  0xf000,
  121.   0xf800,  0x0,  0x3,  0xf000,  0x7ff,  0xc000,  0x1fc1,  0xfe00,  0x7e00,  0xc00,  0x0,  0x7fe0,  0xf000,
  122.   0xf800,  0x0,  0x3,  0xe000,  0xfff,  0xe000,  0xfc1,  0xfe00,  0x7800,  0xc00,  0x0,  0x3fe0,  0xf000,
  123.   0xf800,  0x0,  0x7,  0x8000,  0x3fff,  0xf000,  0xfc3,  0xf800,  0xf000,  0xc00,  0x0,  0xfe0,  0xf000,
  124.   0xf800,  0x0,  0x7,  0xf800,  0x7fff,  0xf800,  0xffc3,  0xf000,  0xe000,  0x1e00,  0x0,  0x7f0,  0xf000,
  125.   0xf800,  0x0,  0xf,  0xffe1,  0xffff,  0xfe0f,  0xffc3,  0xc000,  0x8000,  0xf3c0,  0x0,  0x1f0,  0xf000,
  126.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xfe7f,  0xffc3,  0x8001,  0x1,  0x80e0,  0x0,  0xf8,  0xf000,
  127.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffc6,  0x0,  0x3,  0xf0,  0x0,  0x38,  0xf000,
  128.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffc4,  0x0,  0x2,  0xf8,  0x0,  0x18,  0xf000,
  129.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffc0,  0x0,  0x6,  0xf8,  0x0,  0x4,  0xf000,
  130.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffc0,  0x0,  0x4,  0xf8,  0x0,  0x0,  0xf000,
  131.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffc0,  0x0,  0xc,  0xf8,  0x0,  0x0,  0xf000,
  132.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffc0,  0x0,  0xc,  0xf8,  0x0,  0x0,  0xf000,
  133.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffc0,  0x0,  0xc,  0xf8,  0x0,  0x0,  0xf000,
  134.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffc0,  0x0,  0x3e,  0x1f8,  0x0,  0x0,  0xf000,
  135.   0xffff,  0xf87f,  0xffff,  0xfffe,  0x7fff,  0xf9ff,  0xffc0,  0x0,  0xfe,  0x3fe,  0x0,  0x0,  0xf000,
  136.   0xffff,  0x801f,  0xf800,  0x7ff8,  0x7fff,  0xe1ff,  0xffc0,  0x0,  0xfff,  0xfff,  0xe000,  0x0,  0xf000,
  137.   0xffff,  0x1f,  0xf800,  0x7ff8,  0x7fff,  0xe1ff,  0xffc0,  0x0,  0x7fff,  0xffff,  0xfc00,  0x0,  0xf000,
  138.   0xfffe,  0x1f,  0xf800,  0x7ff8,  0x7fff,  0xe1ff,  0xffc0,  0x7,  0xffff,  0xffff,  0xffc0,  0x0,  0xf000,
  139.   0xfffc,  0xf,  0xf800,  0x3ff8,  0x7fff,  0xe1ff,  0xffc0,  0x7,  0xffff,  0xffff,  0xfff0,  0x0,  0xf000,
  140.   0xfff8,  0xfcf,  0xf87f,  0xfff8,  0x7fff,  0xe1ff,  0xffc0,  0x0,  0x7fff,  0xffff,  0xfff8,  0x0,  0xf000,
  141.   0xfff8,  0x1fff,  0xf87f,  0xfff8,  0x7fff,  0xe1ff,  0xffc0,  0x0,  0x1fff,  0xffff,  0xfff8,  0x0,  0xf000,
  142.   0xfff8,  0x3fff,  0xf87f,  0xfff8,  0x7fff,  0xe1ff,  0xffc0,  0x0,  0x7ff,  0xffff,  0xfff8,  0x0,  0xf000,
  143.   0xfff0,  0x7fff,  0xf87f,  0xfff8,  0x7fff,  0xe1ff,  0xffc0,  0x0,  0x7f,  0xffff,  0xfff8,  0x0,  0xf000,
  144.   0xfff0,  0x7fff,  0xf87f,  0xfff8,  0x7fff,  0xe1ff,  0xffc0,  0x0,  0x1f,  0xffff,  0xfff8,  0x0,  0xf000,
  145.   0xfff0,  0x7fff,  0xf800,  0xfff8,  0x7fff,  0xe1ff,  0xffc0,  0x0,  0x1,  0xffff,  0xfff8,  0x0,  0xf000,
  146.   0xfff0,  0xffff,  0xf800,  0xfff8,  0x7fff,  0xe1ff,  0xffc0,  0x0,  0x0,  0x7fff,  0xfff8,  0x0,  0xf000,
  147.   0xfff0,  0xffff,  0xf800,  0xfff8,  0x7fff,  0xe1ff,  0xffc0,  0x0,  0x0,  0xfff,  0xfff8,  0x0,  0xf000,
  148.   0xfff0,  0xffff,  0xf800,  0xfff8,  0x7fff,  0xe1ff,  0xffc0,  0x0,  0x0,  0xfff,  0xfff8,  0x0,  0xf000,
  149.   0xfff0,  0x7fff,  0xf87f,  0xfff8,  0x7fff,  0xe1ff,  0xffc0,  0x0,  0x0,  0xfff,  0xfff8,  0x0,  0xf000,
  150.   0xfff0,  0x7fff,  0xf87f,  0xfff8,  0x7fff,  0xe1ff,  0xffc0,  0x0,  0x0,  0xfff,  0xfff8,  0x0,  0xf000,
  151.   0xfff0,  0x7fff,  0xf87f,  0xfff8,  0x7fff,  0xe1ff,  0xffc0,  0x0,  0x0,  0xfff,  0xfff8,  0x0,  0xf000,
  152.   0xfff0,  0x3fff,  0xf87f,  0xfff8,  0x7fff,  0xe1ff,  0xffc0,  0x0,  0x0,  0xfff,  0xfff8,  0x0,  0xf000,
  153.   0xfff8,  0x1fef,  0xf87f,  0xfff8,  0x7fff,  0xe1ff,  0xffc0,  0x0,  0x0,  0xfff,  0xfff8,  0x0,  0xf000,
  154.   0xfffc,  0xfcf,  0xf87f,  0xfff8,  0x7fff,  0xe1ff,  0xffc0,  0x0,  0x0,  0xfff,  0xfff8,  0x0,  0xf000,
  155.   0xfffc,  0xf,  0xf800,  0x3ff8,  0x7f,  0xe001,  0xffc0,  0x0,  0x0,  0xfff,  0xfff8,  0x0,  0xf000,
  156.   0xfffe,  0x1f,  0xf800,  0x3ff8,  0x7f,  0xe001,  0xffc0,  0x0,  0x0,  0xfff,  0xfff8,  0x0,  0xf000,
  157.   0xffff,  0x1f,  0xf800,  0x3ff8,  0x7f,  0xe003,  0xffc0,  0x0,  0x0,  0xfff,  0xfff8,  0x0,  0xf000,
  158.   0xffff,  0xc01f,  0xf800,  0x7ff8,  0xff,  0xe003,  0xffc0,  0x0,  0x0,  0xfff,  0xfff8,  0x0,  0xf000,
  159.   0xffff,  0xf87f,  0xffff,  0xffff,  0xffff,  0xffff,  0xffc0,  0x0,  0x0,  0xfff,  0xfff8,  0x0,  0xf000,
  160.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffc0,  0x0,  0x0,  0xfff,  0xfff8,  0x0,  0xf000,
  161.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffe0,  0x0,  0xfff,  0xffff,  0xffff,  0xf000,
  162.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffe0,  0x0,  0xfff,  0xffff,  0xffff,  0xf000,
  163.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffe0,  0x0,  0xfff,  0xffff,  0xffff,  0xf000,
  164.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffe0,  0x0,  0xfff,  0xffff,  0xffff,  0xf000,
  165.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffe0,  0x0,  0xfff,  0xffff,  0xffff,  0xf000,
  166.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffe0,  0x0,  0xfff,  0xffff,  0xffff,  0xf000,
  167.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffe0,  0x0,  0xfff,  0xffff,  0xffff,  0xf000,
  168.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xfff0,  0x0,  0xfff,  0xffff,  0xffff,  0xf000,
  169.   0xffff,  0xffff,  0xffff,  0xfff9,  0xffff,  0xffff,  0xffff,  0xfffe,  0x0,  0xfff,  0xffff,  0xffff,  0xf000,
  170.   0xffc0,  0x3f,  0xffbf,  0xffc1,  0xfff8,  0x0,  0x1fff,  0xffff,  0x8000,  0xfff,  0xffff,  0xffff,  0xf000,
  171.   0xffc0,  0x1f,  0xff8f,  0xffc1,  0xfff8,  0x0,  0x1fff,  0xffff,  0xf800,  0xfff,  0xffff,  0xffff,  0xf000,
  172.   0xffc0,  0x1f,  0xff87,  0xffc1,  0xfff8,  0x0,  0x1fff,  0xffff,  0xf800,  0xfff,  0xffff,  0xffff,  0xf000,
  173.   0xffc0,  0x1f,  0xff83,  0xffc1,  0xfff0,  0x0,  0x1fff,  0xffff,  0xf800,  0xfff,  0x8fff,  0xffff,  0xf000,
  174.   0xffc1,  0xffff,  0xff81,  0xffc1,  0xffff,  0xf83f,  0xffff,  0xffff,  0xf000,  0xffe,  0xfff,  0xffff,  0xf000,
  175.   0xffc1,  0xffff,  0xff80,  0xffc1,  0xffff,  0xf83f,  0xffff,  0xffff,  0xf002,  0xff8,  0x7ff,  0xffff,  0xf000,
  176.   0xffc1,  0xffff,  0xff80,  0x3fc1,  0xffff,  0xf83f,  0xffff,  0xffff,  0xf007,  0xcff0,  0x7ff,  0xffff,  0xf000,
  177.   0xffc1,  0xffff,  0xff80,  0x1fc1,  0xffff,  0xf83f,  0xffff,  0xffff,  0xf007,  0xfff8,  0x7ff,  0xffff,  0xf000,
  178.   0xffc1,  0xffff,  0xff80,  0xfc1,  0xffff,  0xf83f,  0xffff,  0xffff,  0xf00f,  0xfff8,  0x7ff,  0xffff,  0xf000,
  179.   0xffc0,  0x7f,  0xff80,  0x7c1,  0xffff,  0xf83f,  0xffff,  0xffff,  0xf00f,  0xfff8,  0x7ff,  0xffff,  0xf000,
  180.   0xffc0,  0x7f,  0xff82,  0x1c1,  0xffff,  0xf83f,  0xffff,  0xffff,  0xf01f,  0xfffc,  0x7ff,  0xffff,  0xf000,
  181.   0xffc0,  0x7f,  0xff83,  0xc1,  0xffff,  0xf83f,  0xffff,  0xffff,  0xf01f,  0xfffc,  0x7ff,  0xffff,  0xf000,
  182.   0xffc0,  0x7f,  0xff83,  0x8041,  0xffff,  0xf83f,  0xffff,  0xffff,  0xf03f,  0xfffe,  0x7ff,  0xffff,  0xf000,
  183.   0xffc1,  0xffff,  0xff83,  0xc001,  0xffff,  0xf83f,  0xffff,  0xffff,  0xf03f,  0xfffe,  0x3ff,  0xffff,  0xf000,
  184.   0xffc1,  0xffff,  0xff83,  0xf001,  0xffff,  0xf83f,  0xffff,  0xffff,  0xe07f,  0xffff,  0x3ff,  0xffff,  0xf000,
  185.   0xffc1,  0xffff,  0xff83,  0xf801,  0xffff,  0xf83f,  0xffff,  0xffff,  0xe07f,  0xffff,  0x3ff,  0xffff,  0xf000,
  186.   0xffc1,  0xffff,  0xff83,  0xfc01,  0xffff,  0xf83f,  0xffff,  0xffff,  0xe07f,  0xffff,  0x3ff,  0xffff,  0xf000,
  187.   0xffc1,  0xffff,  0xff83,  0xfe01,  0xffff,  0xf83f,  0xffff,  0xffff,  0xe0ff,  0xffff,  0x83ff,  0xffff,  0xf000,
  188.   0xffc1,  0xffff,  0xff83,  0xff01,  0xffff,  0xf83f,  0xffff,  0xffff,  0xe0ff,  0xffff,  0x83ff,  0xffff,  0xf000,
  189.   0xffc0,  0xf,  0xff83,  0xff81,  0xffff,  0xf83f,  0xffff,  0xffff,  0xe1ff,  0xffff,  0xc3ff,  0xffff,  0xf000,
  190.   0xffc0,  0xf,  0xff83,  0xffe1,  0xffff,  0xf83f,  0xffff,  0xffff,  0xe1ff,  0xffff,  0xe3ff,  0xffff,  0xf000,
  191.   0xffc0,  0xf,  0xff83,  0xfff1,  0xffff,  0xf83f,  0xffff,  0xffff,  0xf3ff,  0xffff,  0xe7ff,  0xffff,  0xf000,
  192.   0xffc0,  0x1f,  0xff83,  0xfff9,  0xffff,  0xf83f,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xf000,
  193.   0xffff,  0xffff,  0xffbf,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xf000,
  194.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xf000,
  195.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xf000,
  196.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xf000,
  197.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xf000,
  198.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xf000,
  199.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xf000,
  200.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xf000,
  201.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xf000,
  202.   0xf000,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0xf000,
  203.   0xf000,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0xf000,
  204.   0xf000,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0xf000,
  205.   0xf000,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0xf000,
  206.   0xf000,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x1,  0xfff8,  0x0,  0x0,  0xf000,
  207.   0xf000,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x1,  0xfff8,  0x0,  0x0,  0xf000,
  208.   0xf000,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x1,  0xfff8,  0x0,  0x0,  0xf000,
  209.   0xf000,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0xf000,
  210.   0xf000,  0x7f00,  0xff,  0xe000,  0x781e,  0x3,  0xfc00,  0x1e,  0x0,  0xf00,  0x7,  0xf000,  0xf000,
  211.   0xf001,  0xff80,  0xff,  0xe000,  0x781e,  0x3,  0xff80,  0x1e,  0x0,  0x7ff0,  0x1f,  0xf800,  0xf000,
  212.   0xf003,  0xe300,  0x1ff,  0xe000,  0x781e,  0x3,  0xffc0,  0x1e,  0x1,  0xfff8,  0x1f,  0x3000,  0xf000,
  213.   0xf003,  0xe000,  0x1e,  0x0,  0x781e,  0x3,  0xc1e0,  0x1e,  0x3,  0xe07c,  0x1e,  0x0,  0xf000,
  214.   0xf003,  0xf800,  0x1e,  0x0,  0x781e,  0x3,  0xc1f0,  0x1e,  0x3,  0xc03e,  0x1f,  0xc000,  0xf000,
  215.   0xf001,  0xff00,  0x1e,  0x0,  0x781e,  0x3,  0xc0f0,  0x1e,  0x3,  0x801e,  0xf,  0xf800,  0xf000,
  216.   0xf000,  0x7f80,  0x1e,  0x0,  0x781e,  0x3,  0xc0f0,  0x1e,  0x3,  0x801e,  0x3,  0xfc00,  0xf000,
  217.   0xf000,  0x7c0,  0x1e,  0x0,  0x781e,  0x3,  0xc0f0,  0x1e,  0x3,  0xc03e,  0x0,  0x3c00,  0xf000,
  218.   0xf000,  0x87c0,  0x1e,  0x0,  0x7c3e,  0x3,  0xc1e0,  0x1e,  0x3,  0xe07c,  0x0,  0x3c00,  0xf000,
  219.   0xf001,  0xff80,  0x1e,  0x0,  0x3ffc,  0x3,  0xc7e0,  0x1e,  0x1,  0xfff8,  0x1f,  0xfc00,  0xf000,
  220.   0xf003,  0xff00,  0x1e,  0x0,  0x3ff8,  0x3,  0xff80,  0x1e,  0x0,  0x7ff0,  0x3f,  0xf800,  0xf000,
  221.   0xf001,  0xfe00,  0x1e,  0x0,  0xff0,  0x3,  0xff00,  0x1e,  0x0,  0x3fc0,  0xf,  0xe000,  0xf000,
  222.   0xf000,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0xf000,
  223.   0xf000,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0xf000,
  224.   0xf000,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0xf000,
  225.   0xf000,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0xf000,
  226.   0xf000,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0xf000,
  227.   0xf000,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0x0,  0xf000,
  228.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xf000,
  229.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xf000,
  230.   0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xffff,  0xf000,
  231. /*  end of plane 0 */
  232. };  /* end of excellent0_data[] */
  233.  
  234. struct Image excellent0_image =
  235. {
  236.   0, 0,               /* left, top */
  237.   196, 139, 1,     /* width, height, depth */
  238.   &excellent0_data[0],   /* image data */
  239.   1, 0x0,       /* plane pick, plane on/off */
  240.   NULL              /* next image */
  241. };
  242.  
  243. // PROGRAM ---------------------------------------------------------------------
  244.  
  245. static char *MakeInfoStr(struct Image *img)
  246. {
  247.    static char info[64];
  248.  
  249.    sprintf(info,"%d x %d x %d",img->Width,img->Height,img->Depth);
  250.    return(info);
  251. }
  252.  
  253. /*************************/
  254. /* Init & Fail Functions */
  255. /*************************/
  256.  
  257. static VOID fail(APTR app,char *str)
  258. {
  259.  
  260.     if (app)
  261.         MUI_DisposeObject(app);
  262.  
  263.    if (loadReq)
  264.       MUI_FreeAslRequest(loadReq);
  265.  
  266.     if (MUIMasterBase)
  267.         CloseLibrary(MUIMasterBase);
  268.  
  269.    if (image.ImageData)
  270.       FreeVec(image.ImageData);
  271.  
  272.    if (myimagegclass)
  273.       Free_myimagegclass(myimagegclass);
  274.  
  275.     if (str)
  276.     {
  277.         puts(str);
  278.         exit(20);
  279.     }
  280.     exit(0);
  281. }
  282.  
  283. int CXBRK(void) { return(0); }
  284. int _CXBRK(void) { return(0); }
  285. void chkabort(void) {}
  286.  
  287. static VOID init(VOID)
  288. {
  289.     if (!(MUIMasterBase = OpenLibrary(MUIMASTER_NAME,MUIMASTER_VMIN)))
  290.         fail(NULL,"Failed to open "MUIMASTER_NAME".");
  291.  
  292.    if (!(myimagegclass = Init_myimagegclass()))
  293.       fail(NULL,"Failed to init myimagegclass.");
  294.  
  295.     /*
  296.     ** Create the application.
  297.     */
  298.  
  299.     app = ApplicationObject,
  300.         MUIA_Application_Title      , "myimagegclass Demo",
  301.         MUIA_Application_Version    , "$VER: myimagegclass Demo 1.0  08 Jan 1994",
  302.         MUIA_Application_Copyright  , "©1994 Excellent Studios",
  303.         MUIA_Application_Author     , "Richard Reed",
  304.         MUIA_Application_Description, "Demo program for myimagegclass BOOPSI",
  305.         MUIA_Application_Base       , "myigclass_demo",
  306.  
  307.         SubWindow, WI_Pic = WindowObject,
  308.             MUIA_Window_ID, 'PICT',
  309.             MUIA_Window_Title, "myimagegclass Object",
  310.             MUIA_Window_CloseGadget, FALSE,
  311.  
  312.             WindowContents, i_myImage = MyImageScaledRel(20,20,&excellent0_image,0,sFlags,relWidth,relHeight),
  313.       End,
  314.         SubWindow, WI_Options = WindowObject,
  315.             MUIA_Window_ID, 'OPTS',
  316.             MUIA_Window_Title, "myimagegclass Options",
  317.  
  318.             WindowContents, VGroup,
  319.                Child, HGroup,
  320.                   Child, VGroup,
  321.                      Child, HVSpace,
  322.                   Child, HGroup,
  323.                      Child, KeyLabel1("Image",'i'),
  324.                      Child, t_name = TextSpace("Excellent!",100),
  325.                      Child, g_popup = KeyImageButton(MUII_PopFile,'i'),
  326.                   End,
  327.                   Child, HGroup,
  328.                      Child, Label1("Info"),
  329.                      Child, t_info = TextSpace(MakeInfoStr(&excellent0_image),100),
  330.                   End,
  331.                   Child, HVSpace,
  332.                   Child, HGroup,
  333.                      Child, HVSpace,
  334.                      Child, KeyLabel1("Beep every redraw",'b'),
  335.                      Child, g_beep = KeyCheckMark(beep,'b'),
  336.                      Child, HVSpace,
  337.                   End,
  338.                End,
  339.                Child, i_miniImage = MyImageScaledBorder(50,50,&excellent0_image,0,GAFL_ScaleXYAspect),
  340.             End,
  341.             Child, HGroup,
  342.                GroupFrameT("Scaling Flags"),
  343.                Child, ColGroup(2),
  344.                   Child, KeyLabel1("ScaleX",'x'),
  345.                   Child, g_scaleX = KeyCheckMark(sFlags & GAFL_ScaleX,'x'),
  346.                   Child, KeyLabel1("ScaleY",'y'),
  347.                   Child, g_scaleY = KeyCheckMark(sFlags & GAFL_ScaleY,'y'),
  348.                   Child, KeyLabel1("AspectRatio",'a'),
  349.                   Child, g_aspect = KeyCheckMark(sFlags & GAFL_AspectRatio,'a'),
  350.                End,
  351.                Child, VGroup,
  352.                   GroupFrame,
  353.                   Child, HGroup,
  354.                      Child, HVSpace,
  355.                      Child, ColGroup(2),
  356.                         Child, KeyLabel1("RelX",'r'),
  357.                         Child, g_relX = KeyCheckMark(sFlags & GAFL_RelX,'r'),
  358.                         Child, KeyLabel1("RelY",'e'),
  359.                         Child, g_relY = KeyCheckMark(sFlags & GAFL_RelY,'e'),
  360.                      End,
  361.                   End,
  362.                   Child, ColGroup(2),
  363.                     Child, KeyLabel2("RelWidth",'w'),
  364.                     Child, g_relWidth = KeyInteger(relWidth,5,'w'),
  365.                     Child, KeyLabel2("RelHeight",'h'),
  366.                     Child, g_relHeight = KeyInteger(relHeight,5,'h'),
  367.                   End,
  368.                End,
  369.             End,
  370.          End,
  371.       End,
  372.    End;
  373.  
  374.      /*** application failed ? ***/
  375.     if (!app)
  376.         fail(app, "Creating application failed !");
  377.  
  378.    AppRetID(WI_Options, MUIA_Window_CloseRequest,TRUE,MUIV_Application_ReturnID_Quit);
  379.    AppRetID(g_popup, MUIA_Selected,FALSE, ID_POPUP);
  380.    AppRetID(g_beep, MUIA_Selected,MUIV_EveryTime, ID_BEEP);
  381.    AppRetID(g_scaleX, MUIA_Selected,MUIV_EveryTime, ID_SCALEX);
  382.    AppRetID(g_scaleY, MUIA_Selected,MUIV_EveryTime, ID_SCALEY);
  383.    AppRetID(g_relX, MUIA_Selected,MUIV_EveryTime, ID_RELX);
  384.    AppRetID(g_relY, MUIA_Selected,MUIV_EveryTime, ID_RELY);
  385.    AppRetID(g_relWidth, MUIA_String_Acknowledge,MUIV_EveryTime, ID_RELWIDTH);
  386.    AppRetID(g_relHeight, MUIA_String_Acknowledge,MUIV_EveryTime, ID_RELHEIGHT);
  387.    AppRetID(g_aspect, MUIA_Selected,MUIV_EveryTime, ID_ASPECTRATIO);
  388.    NotifyFromMyImage(i_myImage, ID_IMAGEBEEP);
  389.  
  390.    if (!(loadReq=MUI_AllocAslRequestTags(ASL_FileRequest,
  391.          ASL_Hail, "Load ILBM to Image",
  392.          TAG_DONE)))
  393.       fail(app, "Couldn't allocate file requester!");
  394.  
  395.    set(WI_Pic, MUIA_Window_Open, TRUE);
  396.    set(WI_Options, MUIA_Window_Open, TRUE);
  397. }
  398.  
  399. int main(int argc,char *argv[])
  400. {
  401.     ULONG signals, returnID;
  402.     BOOL running = TRUE;
  403.  
  404.     init();
  405.  
  406.     while (running)
  407.     {
  408.         switch (returnID = DoMethod(app,MUIM_Application_Input,&signals))
  409.         {
  410.            case ID_POPUP:
  411.               // put our application to sleep while displaying the requester
  412.             set(app,MUIA_Application_Sleep,TRUE);
  413.  
  414.             if (MUI_AslRequestTags(loadReq,TAG_DONE))
  415.             {
  416.                char picName[FNSIZE];
  417.  
  418.                if (image.ImageData)
  419.                {
  420.                   FreeVec(image.ImageData);
  421.                   image.ImageData = NULL;
  422.                }
  423.  
  424.                strmfp(picName, loadReq->rf_Dir,loadReq->rf_File);
  425.                if (ReadILBM2Image(picName,&image,NULL))
  426.                {
  427.                   MUI_Request(app,WI_Options,0,"Alert!","Yikes!","An error has occurred reading %s.",picName);
  428.                   set(t_name, MUIA_Text_Contents, "Excellent!"),
  429.                   set(t_info, MUIA_Text_Contents, MakeInfoStr(&excellent0_image));
  430.                   set(i_miniImage, GA_Image, &excellent0_image);
  431.                   set(i_myImage, GA_Image, &excellent0_image);
  432.                }
  433.                else
  434.                {
  435.                   set(t_name, MUIA_Text_Contents, loadReq->rf_File);
  436.                   set(t_info, MUIA_Text_Contents, MakeInfoStr(&image));
  437.                   set(i_miniImage, GA_Image, &image);
  438.                   set(i_myImage, GA_Image, &image);
  439.                }
  440.             }
  441.  
  442.             // wake up our application again
  443.             set(app,MUIA_Application_Sleep,FALSE);
  444.             break;
  445.          case ID_BEEP:
  446.             get(g_beep, MUIA_Selected, &beep);
  447.             set(i_myImage,GA_ID,beep ? ID_IMAGEBEEP:0);
  448.             break;
  449.          case ID_IMAGEBEEP:  DisplayBeep(NULL);  break;
  450.            case ID_SCALEX:  sFlags ^= GAFL_ScaleX;  set(i_myImage,GA_ScaleFlags,sFlags);  break;
  451.            case ID_SCALEY:  sFlags ^= GAFL_ScaleY;  set(i_myImage,GA_ScaleFlags,sFlags);  break;
  452.            case ID_RELX:    sFlags ^= GAFL_RelX;  set(i_myImage,GA_ScaleFlags,sFlags);  break;
  453.            case ID_RELY:    sFlags ^= GAFL_RelY;  set(i_myImage,GA_ScaleFlags,sFlags);  break;
  454.            case ID_RELWIDTH:
  455.             get(g_relWidth, MUIA_String_Integer, &relWidth);
  456.             set(i_myImage, GA_ScaleRelWidth, relWidth);
  457.             break;
  458.            case ID_RELHEIGHT:
  459.             get(g_relHeight, MUIA_String_Integer, &relHeight);
  460.             set(i_myImage, GA_ScaleRelHeight, relHeight);
  461.             break;
  462.            case ID_ASPECTRATIO:  sFlags ^= GAFL_AspectRatio;  set(i_myImage,GA_ScaleFlags,sFlags);  break;
  463.             case MUIV_Application_ReturnID_Quit:
  464.                 running = FALSE;
  465.                 break;
  466.         }
  467.  
  468.         if (running && signals) Wait(signals);
  469.     }
  470.  
  471.     set(WI_Options,MUIA_Window_Open,FALSE);
  472.     set(WI_Pic,MUIA_Window_Open,FALSE);
  473.  
  474. /*
  475. ** Shut down...
  476. */
  477.  
  478.     fail(app,NULL);
  479. }
  480.