home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 3.ddi / DEMOS.DI$ / BUTTONV.M < prev    next >
Encoding:
Text File  |  1993-03-07  |  1.1 KB  |  28 lines

  1. function buttons = buttonv(loc,intvec,start,callback,arg1,arg2,arg3,arg4)
  2. %BUTTONV Vector of buttons.  Used by CENSUS demo.
  3. %    BUTTONV([xmin ymin],k1:k2,ks,'callback', ... )
  4. %    The lower left corner is [xmin ymin] in figure normalized coordinates.
  5. %    The buttons are labeled with integers k1:k2.
  6. %    Initially, button ks is highlighted.
  7. %    After each button push, a variable named button is set to the
  8. %    button index and the string 'callback' is evaluated.
  9. %    Up to 3 additional optional arguments are extra button labels.
  10.  
  11. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  12.  
  13. del = 12/256;
  14. n = 0;
  15. for k = intvec
  16.    n = n+1;
  17.    buttons(n) = uicontrol('style','push','string',int2str(k), ...
  18.      'units','normal','pos',[loc(1)+k*del loc(2) del del], ...
  19.      'call',['button = ' int2str(n) '; ' callback]);
  20. end
  21. for k = 1:nargin-4
  22.    n = n+1;
  23.    buttons(n) = uicontrol('style','push','string',eval(['arg' int2str(k)]), ...
  24.      'units','normal','pos',[loc(1)+2*(k-1)*del loc(2)-1.5*del 2*del del], ...
  25.      'call',['button = ' int2str(n) '; ' callback]);
  26. end
  27. set(buttons(find(intvec==start)),'back',[.9 .6 .3])
  28.