www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@roller/roller.m

    function rl=roller(varargin)
%ROLLER   Constructor function for the roller object
%   ROLLER is the creator function for the 'roller' guitool
%   Usage:
%   R=ROLLER
%   R=ROLLER(FIG)
%   R=ROLLER('Property1',Value1,...)
%   R=ROLLER(FIG,'Property1',Value1,...)

%  Copyright 2000-2010 The MathWorks, Inc. and Ford Global Technologies, Inc.



if nargin>0 && mbcgui.util.isComponentParent(varargin{1})
   figh=varargin{1};
   varargin(1)=[];
else
   figh=gcf;
end

% data:
% visible setting (0/1) in rl.frame1
% value in rl.frame2
% object in rl.text1
% callback fields in text2

% set up with default uicontrol stuff
pos=get(0,'DefaultUicontrolPosition');
rl.frame1=uicontrol('Style','frame',...
   'Parent',figh,...
   'Visible','off',...
   'UserData',1,...
   'Enable','inactive');
rl.text1=uicontrol('Style','text',...
   'Parent',figh,...
   'Visible','off',...
   'Position',[pos(1)+1 pos(2)+1 pos(3)-2 pos(4)-2],...
   'Enable','inactive',...
   'Interruptible','off');
set(rl.text1,'ButtonDownFcn',{@mbcgui.util.legacycallback,@rollcb,rl.text1});
rl.frame2=uicontrol('Style','frame',...
   'Parent',figh,...
   'Visible','off',...
   'UserData',0,...
   'Enable','inactive');
ud.callback='';
ud.cbactive=0;
rl.text2=uicontrol('Style','text',...
   'Parent',figh,...
   'Visible','off',...
   'Position',[pos(1)+1 pos(2)+1 pos(3)-2 pos(4)-2],...
   'ButtonDownFcn',{@mbcgui.util.legacycallback,@rollcb,rl.text1},...
   'Enable','inactive',...
   'Interruptible','off',...
   'UserData',ud);

rl=class(rl,'roller');
builtin('set',rl.text1,'userdata',rl);

if ~any(strcmpi('visible',varargin(1:2:end)))
   set([rl.frame1;rl.text1],'Visible','on');
end
% set extra props if specified
if ~isempty(varargin)
   rl=set(rl,varargin{:});
end