home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 15 / AACD15.ISO / AACD / Programming / BGUI / Examples / ARexx / arrowcontrol.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  2000-05-09  |  3.2 KB  |  122 lines

  1. /* REXX script for rexxbgui.library: listview control with arrow keys */
  2.  
  3. if ~show('l','rexxbgui.library') then do
  4.     if ~addlib('rexxbgui.library',0,-30) then do
  5.         exit(20)
  6.     end
  7.     else nop
  8. end
  9. else nop
  10.  
  11. call bguiopen() /* causes error 12 if it did not work */
  12. /* supply a second argument for a '0' return code instead of an ARexx
  13.    error */
  14.  
  15. signal on syntax /* important: bguiclose() MUST be called */
  16. signal on halt
  17. signal on break_c
  18.  
  19. esc='1B'x
  20. lf='0A'x
  21. cr='0D'x
  22. grspace.narrow=-1
  23. grspace.normal=-2
  24. grspace.wide=-3
  25. FixMinSize=bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight,1)
  26.  
  27. if bguirexxversion(4)=0 then do
  28.     call bguireq(,
  29.         'This script requires at'lf||,
  30.         'least RexxBGUI version 4.','*_Abort','Sorry!')
  31.     rc=0
  32.     signal syntax
  33. end
  34.  
  35. /* using ARexx feature: ,<newline> is translated to nothing */
  36. /* the || are essential - any added space will cause trouble */
  37. /* redefining the same ID makes previous buttons unaccessible */
  38. /* do not redefine winclose etc. */
  39.  
  40. g=bguivgroup(,
  41.     bguiinfo(,
  42.         'info',,'cbRexxBGUI-b new 4.0 feature: listview control with arrow keys',
  43.     )||bguilayout(LGO_FixMinHeight,1)||,
  44.     bguihgroup(,
  45.         bguivarspace(50)||,
  46.         bguivgroup(,
  47.             bguicheckbox('actrl','Enable _arrow control',1)FixMinSize||,
  48.             bguicheckbox('genmsg','_Generate messages for arrow keys',0)FixMinSize||,
  49.             bguicheckbox('doenter','Generate messages for _return key',0)FixMinSize,
  50.         )||,
  51.         bguivarspace(50),
  52.     )||bguilayout(LGO_FixMinHeight,1)||,
  53.     bguilistview(,
  54.         'listv','_Listview',,
  55.         bguilist('entries','Entry 1','Entry 2','Entry 3','Entry 4','Entry 5',,
  56.         'Entry 6','Entry 7','Entry 8','Entry 9','Entry 10','Entry 11',,
  57.         'Entry 12','Entry 13','Entry 14'),
  58.     )||,
  59.     bguihgroup(,
  60.         bguivarspace(50)||,
  61.         bguibutton('quit','_Quit')||,
  62.         bguivarspace(50),
  63.     )||bguilayout(LGO_FixMinHeight,1),
  64. ,grspace.normal,grspace.normal)
  65.  
  66. drop entries.
  67.  
  68. call bguiaddcondit(obj.actrl,obj.genmsg,GA_Selected,0,GA_Disabled,1,GA_Disabled,0)
  69. call bguiaddcondit(obj.actrl,obj.doenter,GA_Selected,0,GA_Disabled,1,GA_Disabled,0)
  70. /* This statement disables the two other checkboxes. For this to work,
  71.    obj.actrl must be initialized to on. */
  72. call bguiset(obj.actrl,,GA_Selected,0)
  73.  
  74. call bguilistvcontrol(,,0,0) /* set up defaults */
  75.  
  76. a=bguiwindow('Arrow control',g,0,0,,arg(1),'mouse')
  77.  
  78. if bguiwinopen(a)=0 then bguierror(12)
  79. id=0
  80. do while bguiwinwaitevent(a,'ID')~=id.winclose
  81.     select
  82.         when id=id.actrl then do
  83.             if 0~=bguiget(obj.actrl,GA_Selected) then do
  84.                 call bguilistvcontrol(obj.listv,a)
  85.             end; else do
  86.                 call bguilistvcontrol()
  87.             end
  88.         end
  89.         when id=id.genmsg then do
  90.             if 0~=bguiget(obj.genmsg,GA_Selected) then do
  91.                 call bguilistvcontrol(,,id.listv)
  92.             end; else do
  93.                 call bguilistvcontrol(,,0)
  94.             end
  95.         end
  96.         when id=id.doenter then do
  97.             if 0~=bguiget(obj.doenter,GA_Selected) then do
  98.                 call bguilistvcontrol(,,,id.enter)
  99.             end; else do
  100.                 call bguilistvcontrol(,,,0)
  101.             end
  102.         end
  103.         when id=id.listv then say 'Received id.listv.'
  104.         when id=id.enter then say 'Received id.enter.'
  105.         when id=id.quit then leave
  106.         when id=id.winclose then nop
  107.         otherwise nop
  108.     end
  109. end
  110. rc=0
  111.  
  112. syntax:
  113. if rc~=0 then say '+++ ['rc']' errortext(rc) 'at line' sigl
  114. call bguiclose()
  115. exit 0
  116.  
  117. break_c:
  118. halt:
  119. rc=0
  120. say '+++ Break at line' sigl
  121. signal syntax
  122.