home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 15 / AACD15.ISO / AACD / Programming / BGUI / bgui_e / sources / examples / Images.e < prev    next >
Encoding:
Text File  |  1999-08-26  |  7.9 KB  |  190 lines

  1. /* Updated on 11-Aug-96 */
  2.  
  3. OPT OSVERSION=37
  4. OPT PREPROCESS
  5.  
  6. MODULE  'libraries/bgui',
  7.         'libraries/bguim',
  8.         'libraries/gadtools',
  9.         'bgui',
  10.         'bgui/bgui_image',
  11.         'tools/boopsi',
  12.         'utility/tagitem',
  13.         'exec/memory',
  14.         'intuition/screens',
  15.         'intuition/intuition',
  16.         'intuition/classes',
  17.         'intuition/classusr',
  18.         'intuition/gadgetclass'
  19.  
  20. /*
  21. **  Put up a simple requester.
  22. **/
  23. PROC req( win:PTR TO window, gadgets, body:PTR TO CHAR )
  24.     DEF flags
  25.     flags   := BREQF_LOCKWINDOW OR BREQF_CENTERWINDOW OR BREQF_AUTO_ASPECT OR BREQF_FAST_KEYS
  26. ENDPROC BgUI_RequestA( win, [ flags, NIL, gadgets, body, NIL, NIL, "_", 0, NIL, 0], NIL)
  27.  
  28. /*
  29. **  Object ID's.
  30. **/
  31. #define ID_QUIT                 1
  32. #define ID_HELP                 2
  33.  
  34. PROC copyListToChip(data)
  35.   DEF size, mem
  36.   size:=ListLen(data)*SIZEOF LONG
  37.   mem:=NewM(size, MEMF_CHIP)
  38.   CopyMemQuick(data, mem, size)
  39. ENDPROC mem
  40.  
  41. PROC main()
  42.     DEF window:PTR TO window
  43.     DEF wo_window, go_quit, go_help
  44.     DEF signal = 0, rc
  45.     DEF running = TRUE
  46.     DEF helpi1:image, helpi2:image
  47.  
  48.     IF ( bguibase := OpenLibrary( 'bgui.library', BGUIVERSION ) )
  49.         helpi1:=[ 0,   -> Upper left corner
  50.                   0,
  51.                   37,  -> width
  52.                   26,  -> height
  53.                   2,   -> depth
  54.                   copyListToChip( /* Plane 0 */
  55.                             [ $0000,$0020,$0000,$00A0,$0020,$0000,$0143,$E020,
  56.                             $0000,$0A8F,$F820,$0000,$051C,$7C3F,$E000,$0038,
  57.                             $3E00,$0000,$0038,$3E00,$0800,$00FF,$BFFF,$0800,
  58.                             $003C,$3E00,$0800,$07FF,$FF3F,$0800,$0000,$7C00,
  59.                             $0800,$06FF,$7FFD,$0800,$0000,$7000,$0800,$07F7,
  60.                             $FAE7,$0800,$0000,$E000,$0800,$07DE,$FBFD,$0800,
  61.                             $0000,$C000,$0800,$06FD,$F7EF,$0800,$0001,$C000,
  62.                             $0800,$0003,$E000,$0800,$0003,$E1B7,$0800,$0003,
  63.                             $E000,$0800,$0001,$C000,$0800,$0000,$0000,$0800,
  64.                             $0000,$0000,$0800,$7FFF,$FFFF,$F800,
  65.                             /* Plane 1 */
  66.                             $FFFF,$FFD0,$0000,$FEAF,$FFDC,$0000,$FD5C,$1FDF,
  67.                             $0000,$E0B0,$27DF,$C000,$F06B,$9BC0,$0000,$FFD7,
  68.                             $DDFF,$F000,$FFD7,$DDFF,$F000,$FF18,$5C00,$F000,
  69.                             $FFDB,$DDFF,$F000,$F800,$18C0,$F000,$FFFF,$BBFF,
  70.                             $F000,$F900,$B002,$F000,$FFFF,$AFFF,$F000,$F808,
  71.                             $2518,$F000,$FFFF,$5FFF,$F000,$F821,$4402,$F000,
  72.                             $FFFF,$3FFF,$F000,$F902,$8810,$F000,$FFFE,$BFFF,
  73.                             $F000,$FFFD,$DFFF,$F000,$FFFD,$DE48,$F000,$FFFD,
  74.                             $DFFF,$F000,$FFFE,$3FFF,$F000,$FFFF,$FFFF,$F000,
  75.                             $FFFF,$FFFF,$F000,$0000,$0000,$0000 ]:INT), -> image data
  76.                   3, -> planepick
  77.                   0,    -> planeonoff
  78.                   NIL]:image
  79.  
  80.         helpi2:=[ 0,   -> Upper left corner
  81.                   0,
  82.                   37,  -> width
  83.                   26,  -> height
  84.                   2,   -> depth
  85.                   copyListToChip( /* Plane 0 */
  86.                             [ $0000,$0020,$0000,$00A0,$0020,$0000,$0140,$E020,
  87.                             $0000,$0A81,$F020,$0000,$0501,$F03F,$E000,$0001,
  88.                             $F000,$0000,$0001,$F000,$0800,$00FF,$F7FF,$0800,
  89.                             $0000,$E000,$0800,$07FB,$FF3F,$0800,$0000,$E000,
  90.                             $0800,$06FF,$FFFD,$0800,$0000,$E000,$0800,$07F7,
  91.                             $FAE7,$0800,$0000,$4000,$0800,$07DE,$FBFD,$0800,
  92.                             $0000,$4000,$0800,$06FD,$F7EF,$0800,$0000,$E000,
  93.                             $0800,$0001,$F000,$0800,$0001,$F1B7,$0800,$0001,
  94.                             $F000,$0800,$0000,$E000,$0800,$0000,$0000,$0800,
  95.                             $0000,$0000,$0800,$7FFF,$FFFF,$F800,
  96.                             /* Plane 1 */
  97.                             $FFFF,$FFD0,$0000,$FEAF,$FFDC,$0000,$FD5F,$1FDF,
  98.                             $0000,$E0BE,$EFDF,$C000,$F07E,$EFC0,$0000,$FFFE,
  99.                             $EFFF,$F000,$FFFE,$EFFF,$F000,$FF00,$4800,$F000,
  100.                             $FFFF,$5FFF,$F000,$F804,$40C0,$F000,$FFFF,$5FFF,
  101.                             $F000,$F900,$4002,$F000,$FFFF,$5FFF,$F000,$F808,
  102.                             $0518,$F000,$FFFF,$BFFF,$F000,$F821,$0402,$F000,
  103.                             $FFFF,$BFFF,$F000,$F902,$0810,$F000,$FFFF,$5FFF,
  104.                             $F000,$FFFE,$EFFF,$F000,$FFFE,$EE48,$F000,$FFFE,
  105.                             $EFFF,$F000,$FFFF,$1FFF,$F000,$FFFF,$FFFF,$F000,
  106.                             $FFFF,$FFFF,$F000,$0000,$0000,$0000]:INT), -> image data
  107.                   3, -> planepick
  108.                   0,    -> planeonoff
  109.                   NIL]:image
  110.  
  111.         wo_window := WindowObject,
  112.             WINDOW_Title,           'Image Demo',
  113.             WINDOW_AutoAspect,      TRUE,
  114.             WINDOW_AutoKeyLabel,    TRUE,
  115.             WINDOW_MasterGroup,
  116.                 VGroupObject, NormalOffset, NormalSpacing,
  117.                     StartMember,
  118.                         go_help := ButtonObject,
  119.                             BUTTON_Image,           helpi1,
  120.                             BUTTON_SelectedImage,   helpi2,
  121.                             LAB_Label,              '_Help',
  122.                             LAB_Underscore,         "_",
  123.                             LAB_Place,              PLACE_LEFT,
  124.                             FRM_Type,               FRTYPE_BUTTON,
  125.                             FRM_EdgesOnly,          TRUE,
  126.                             GA_ID,                  ID_HELP,
  127.                         EndObject,
  128.                     EndMember,
  129.                     StartMember,
  130.                         HGroupObject,
  131.                             VarSpace( 50 ),
  132.                             StartMember, go_quit  := KeyButton( '_Quit',  ID_QUIT  ), EndMember,
  133.                             VarSpace( 50 ),
  134.                         EndObject, FixMinHeight,
  135.                     EndMember,
  136.                 EndObject,
  137.         EndObject
  138.  
  139.         /*
  140.         **  Object created OK?
  141.         **/
  142.         IF ( wo_window )
  143.             IF ( window := WindowOpen( wo_window ))
  144.                 /*
  145.                 **  Obtain it's wait mask.
  146.                 **/
  147.                 GetAttr( WINDOW_SigMask, wo_window, {signal} );
  148.                 /*
  149.                 **  Event loop...
  150.                 **/
  151.                 WHILE running = TRUE
  152.                     Wait( signal )
  153.                     /*
  154.                     **  Handle events.
  155.                     **/
  156.                     WHILE (( rc := HandleEvent( wo_window )) <> WMHI_NOMORE )
  157.                         /*
  158.                         **  Evaluate return code.
  159.                         **/
  160.                         SELECT rc
  161.                             CASE    WMHI_CLOSEWINDOW
  162.                                     running := FALSE
  163.                             CASE    ID_QUIT
  164.                                     running := FALSE
  165.                             CASE    ID_HELP
  166.                                     req( window, '_Continue', ISEQ_C + 'This small demo shows you how to use\n'+
  167.                                               'standard intuition images in button objects.' )
  168.                         ENDSELECT
  169.                     ENDWHILE
  170.                 ENDWHILE
  171.             ELSE
  172.                 WriteF( 'Could not open the window\n' )
  173.             ENDIF
  174.             /*
  175.             **  Disposing of the window object will
  176.             **  also close the window IF it is
  177.             **  already opened and it will dispose of
  178.             **  all objects attached to it.
  179.             **/
  180.             DisposeObject( wo_window )
  181.         ELSE
  182.             WriteF( 'Could not create the window object\n' )
  183.         ENDIF
  184.         CloseLibrary( bguibase )
  185.     ELSE
  186.         WriteF( 'Can''t open bgui.library v41\n' )
  187.     ENDIF
  188. ENDPROC
  189.  
  190.