function c=attribute(c,action,varargin)
%ATTRIBUTE launches the setup file editor options page

%   Copyright (c) 1997-2000 by The MathWorks, Inc.
%   $Revision: 1.10 $  $Date: 2000/07/21 20:23:50 $

c=feval(action,c,varargin{:});

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function c=start(c)

paperFrame=controlsframe(c,'Snapshot Options');

c=controlsmake(c,{'format',...
      'PaperOrientation',...
      'isPrintFrame',...
      'PrintFrameName',...
      'CaptionType',...
      'CaptionString'});

iString=get(c.x.format,'String');
iUserData=get(c.x.format,'UserData');
imgInfo=getimgformat(c,'AUTOSL');
autoIndex=find(strcmp(iUserData,'AUTOSL'));
iString{autoIndex}=sprintf('Automatic (%s)', imgInfo.name );
set(c.x.format,'String',iString);


%cString=[num2str(c.att.PaperSize(1)) 'x' ...
%      num2str(c.att.PaperSize(2))];
%set(c.x.PaperSize,'String',cString);
%   c.x.ImageSizeTitle c.x.ImageSize(1)
%   'indent' {c.x.ImageSize(2) c.x.PaperSize c.x.PaperUnits}
%   [5] [5]

enableControls(c);



paperFrame.FrameContent={
   c.x.formatTitle c.x.format
   [5] [5]
   c.x.PaperOrientationTitle num2cell(c.x.PaperOrientation')
   [5] [5]
   c.x.CaptionTypeTitle {
      c.x.CaptionType(1)
      c.x.CaptionType(2)
      {c.x.CaptionType(3) c.x.CaptionString}
   }
};

c.x.LayoutManager={[5]
   {c.x.isPrintFrame num2cell(c.x.PrintFrameName)}
   [10]
   paperFrame};

c=resize(c);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function c=refresh(c);
%Update component when switching tabs, moving
%deactivating


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function c=resize(c)

c=controlsresize(c);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function c=Update(c,whichControl,varargin)

switch whichControl
case 'PaperSize'
   [c.att.PaperSize,errMsg]=rptgenutil('str2numNxN',...
      c.x.PaperSize,c.att.PaperSize);
   statbar(c,errMsg,~isempty(errMsg));
case 'PaperUnits'
   oldUnits=c.att.PaperUnits;
   c=controlsupdate(c,whichControl,varargin{:});
   newUnits=c.att.PaperUnits;
   c.att.PaperSize=rptgenutil('SizeUnitTransform',...
      c.att.PaperSize,...
      oldUnits,...
      newUnits,...
      c.x.PaperSize);
case 'isPrintFrame'
   c=controlsupdate(c,whichControl,varargin{:});   
   enableControls(c);
case 'ImageSize'
   c=controlsupdate(c,whichControl,varargin{:});   
case 'format'
   c=controlsupdate(c,whichControl,varargin{:});  
   enableControls(c);
case 'CaptionType'
   c=controlsupdate(c,whichControl,varargin{:});  
   enableControls(c);
otherwise
   c=controlsupdate(c,whichControl,varargin{:});   
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function enableControls(c)

set(c.x.PaperOrientation,'Enable',...
    onoff(~strcmp(c.att.format,'png-capture')));

set(c.x.PrintFrameName,'Enable',...
    onoff(c.att.isPrintFrame));

set(c.x.CaptionString,'Enable',...
   onoff(strcmp(c.att.CaptionType,'$manual')));

%   set([c.x.PaperSize c.x.PaperUnits],...
%      'enable',onoff(strcmp(c.att.ImageSize,'manual')));

warnStr=checkframeformat(c);
statbar(c,warnStr);



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function strOnOff=onoff(logOnOff)

if logOnOff
   strOnOff='on';
else
   strOnOff='off';
end

