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

  1. /*
  2. **      List1.e
  3. **
  4. **      (C) Copyright 1995-1996 Jaba Development.
  5. **      (C) Copyright 1995-1996 Jan van den Baard.
  6. **          All Rights Reserved.
  7. **
  8. **      Modified by Dominique Dutoit, 5/1/96
  9. **      Updated on 11-Aug-96
  10. */
  11.  
  12. OPT OSVERSION=37
  13. OPT PREPROCESS
  14.  
  15. MODULE 'libraries/bgui',
  16.        'libraries/bguim',
  17.        'libraries/gadtools',
  18.        'bgui',
  19.        'bgui/bgui_image',
  20.        'bgui/bgui_obsolete',
  21.        'tools/boopsi',
  22.        'utility/tagitem',
  23.        'intuition/classes',
  24.        'intuition/classusr',
  25.        'intuition/gadgetclass'
  26.  
  27. /*
  28.  *      Object ID's.
  29.  */
  30. CONST   ID_QUIT= 1
  31.  
  32. /*
  33.  *      Simple button creation macros.
  34.  */
  35. #define FuzzButton(label,id)\
  36.     ButtonObject,\
  37.         LAB_Label,              label,\
  38.         LAB_Underscore,         "_",\
  39.         GA_ID,                  id,\
  40.         FuzzButtonFrame,\
  41.     EndObject
  42.  
  43. PROC main()
  44.         DEF window
  45.         DEF wo_window, tabs, page
  46.         DEF signal = 0, rc
  47.         DEF running = TRUE
  48.         DEF entries
  49.  
  50.         entries := [ 'Entry 1',
  51.                      'Entry 2',
  52.                      'Entry 3',
  53.                      'Entry 4',
  54.                      'Entry 5',
  55.                      'Entry 6',
  56.                      'Entry 7',
  57.                      'Entry 8',
  58.                      'Entry 9',
  59.                      'Entry 10',
  60.                      'Entry 11',
  61.                      'Entry 12',
  62.                      'Entry 13',
  63.                      'Entry 14',
  64.                      'Entry 15',
  65.                      'Entry 16',
  66.                      'Entry 17',
  67.                      'Entry 18',
  68.                      'Entry 19',
  69.                      'Entry 20',
  70.                      NIL ]
  71.  
  72.         /*
  73.         **      Open the library.
  74.         **/
  75.         IF bguibase := OpenLibrary( 'bgui.library', BGUIVERSION )
  76.                 /*
  77.                 **      Build the window object tree.
  78.                 **/
  79.                 wo_window := WindowObject,
  80.                         WINDOW_Title,           'Listview DragNDrop',
  81.                         WINDOW_ScaleWidth,      25,
  82.                         WINDOW_ScaleHeight,     20,
  83.                         WINDOW_RMBTrap,         TRUE,
  84.                         WINDOW_AutoAspect,      TRUE,
  85.                         WINDOW_AutoKeyLabel,    TRUE,
  86.                         WINDOW_MasterGroup,
  87.                             VGroupObject, VOffset( 6 ), Spacing( 6 ),
  88.                                 StartMember,
  89.                                     tabs := Tabs( NIL, [ 'Single-Select', 'Multi-Select', NIL ], 0, 0),
  90.                                 EndMember,
  91.                                 StartMember,
  92.                                     page := PageObject,
  93.                                     PageMember,
  94.                                         VGroupObject, HOffset( 6 ), Spacing( 6 ),
  95.                                             StartMember,
  96.                                                 InfoFixed( NIL, '\ecSingle-Select Drag-n-Drop\nListview object.', NIL, 2), FixMinHeight,
  97.                                             EndMember,
  98.                                             StartMember,
  99.                                                 /*
  100.                                                  *  Create a draggable and droppable listview
  101.                                                  *  and make it show the drop-spot.
  102.                                                  */
  103.                                                 ListviewObject,
  104.                                                     LISTV_EntryArray,       entries,
  105.                                                     LISTV_ShowDropSpot,     TRUE,
  106.                                                     BT_DragObject,          TRUE,
  107.                                                     BT_DropObject,          TRUE,
  108.                                                 EndObject,
  109.                                             EndMember,
  110.                                         EndObject,
  111.                                     PageMember,
  112.                                         VGroupObject, HOffset( 6 ), Spacing( 6 ),
  113.                                             StartMember,
  114.                                                 InfoFixed( NIL, '\ecMulti-Select Drag-n-Drop\nListview object.', NIL, 2 ), FixMinHeight,
  115.                                             EndMember,
  116.                                             StartMember,
  117.                                             /*
  118.                                              *  Create a multi-select, draggable and
  119.                                              *  droppable listview and make it show
  120.                                              *  the drop-spot.
  121.                                              */
  122.                                                 ListviewObject,
  123.                                                     LISTV_MultiSelect,  TRUE,
  124.                                                     LISTV_EntryArray,   entries,
  125.                                                     LISTV_ShowDropSpot, TRUE,
  126.                                                     BT_DragObject,      TRUE,
  127.                                                     BT_DropObject,      TRUE,
  128.                                                 EndObject,
  129.                                             EndMember,
  130.                                         EndObject,
  131.                                     EndObject,
  132.                                 EndMember,
  133.                                 StartMember,
  134.                                     HGroupObject,
  135.                                         VarSpace( DEFAULT_WEIGHT ),
  136.                                         StartMember, FuzzButton( '_Quit', ID_QUIT ), EndMember,
  137.                                         VarSpace( DEFAULT_WEIGHT ),
  138.                                     EndObject, FixMinHeight,
  139.                                 EndMember,
  140.                             EndObject,
  141.                     EndObject
  142.  
  143.                 /*
  144.                 **      Object created OK?
  145.                 **/
  146.                 IF ( wo_window )
  147.                         /*
  148.                         **  Connect the cycle to page.
  149.                         */
  150.                         AddMap( tabs, page, [ MX_Active, PAGE_Active, TAG_END ] )
  151.                         /*
  152.                         **      Open up the window.
  153.                         **/
  154.                         IF ( window := WindowOpen( wo_window ) )
  155.                                 /*
  156.                                 **      Obtain signal mask.
  157.                                 **/
  158.                                 GetAttr( WINDOW_SigMask, wo_window, {signal} )
  159.                                 /*
  160.                                 **      Poll messages.
  161.                                 **/
  162.                                 WHILE running = TRUE
  163.                                         /*
  164.                                         **      Wait for the signal.
  165.                                         **/
  166.                                         Wait( signal )
  167.                                         /*
  168.                                         **      Call uppon the event handler.
  169.                                         **/
  170.                                         WHILE ( rc := HandleEvent( wo_window )) <> WMHI_NOMORE
  171.                                                 SELECT rc
  172.                                                         CASE    WMHI_CLOSEWINDOW
  173.                                                                 running := FALSE
  174.                                                         CASE    ID_QUIT
  175.                                                                 running := FALSE
  176.                                                 ENDSELECT
  177.                                         ENDWHILE
  178.                                 ENDWHILE
  179.                         ELSE
  180.                             WriteF( 'Unable to open the window\n' )
  181.                         ENDIF
  182.                         /*
  183.                         **      Disposing of the object
  184.                         **      will automatically close the window
  185.                         **      and dispose of all objects that
  186.                         **      are attached to the window.
  187.                         **/
  188.                         DisposeObject( wo_window )
  189.                 ELSE
  190.                         WriteF( 'Unable to create a window object\n' )
  191.                 ENDIF
  192.                 CloseLibrary(bguibase)
  193.         ELSE
  194.                 WriteF( 'Unable to open the bgui.library\n' )
  195.         ENDIF
  196. ENDPROC NIL
  197.