% Test buttons for increment/decrement & slider
%
%
button_labels = str2mat ( ...
  'Inc', ...
  'Dec');
nbut = size(button_labels,1);

button_calls = str2mat ( ...
  'x = x+1', ...
  'x = x-1');
if nbut ~= size(button_calls, 1), error ('invalid number of callbacks'); end;

% use always figure 1 (delete the old one if necessary)
figs = sort(get(0,'children'));
if ~isempty(figs)
  if figs(1) == 1, delete(1); end;
end;
figs = [figure; figs];

fignum=figs(1);
d=get(fignum,'units');
set(fignum, 'units', 'points');
pos=get(fignum, 'pos');
set(fignum, 'units', d);

figw = pos(3); figh = pos(4);
cw = 7; ch = 10;         % char width and height (in points)
leftm = 5;
buth = ch+4; lineskip = 1;
butw = (1+size(button_labels,2)) * cw;  % include one extra space
blskip = buth+lineskip;
%
% scale to normal coordinates
leftm = leftm/figw; blskip = blskip/figh; butw = butw/figw; buth = buth/figh;
ytop = 0.9;
% create buttons
bh = [];
for ii=1:nbut
  pos = [leftm ytop-(ii-1)*blskip butw buth];
  bh = [bh; mkbut(fignum, button_labels(ii,:), button_calls(ii,:), ...
                  'normal', pos, 'left')];
end;

s = ['x=round(get(slh,''value''))'];
pos = [0.9 0.1 0.03 0.8];
slh=mksli(fignum, s, 'normal', pos, 0, 255, 127);
