www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@xregGui/@waitdlg/waitdlg.m
function h = waitdlg(varargin) %WAITDLG Waitbar dialog constructor % % OBJ = WAITDLG(PROP, VALUE, ...) % Copyright 2000-2010 The MathWorks, Inc. and Ford Global Technologies, Inc. h = xregGui.waitdlg; set(h,varargin{:}); % whether or not we are going to show this, we still need the waitbar (and % hance the figure) created, as the waitbar is referenced directly h.Figure = xregfigure('Name',h.Title,... 'WindowStyle', 'modal', ... 'Visible', 'off', ... 'Resize','off',... 'CloseRequestFcn','',... 'HandleVisibility','on'); h.waitbar=xregGui.waitbar('parent',h.Figure); if h.ShowStopButton ht = 100; else ht = 80; end if ~isempty(h.Parent) xregcenterfigure(h.Figure,[290 ht],h.Parent); else xregcenterfigure(h.Figure,[290 ht]); end if usejava('swing') hComp = com.mathworks.toolbox.mbc.gui.peer.MBCLabelPeer; h.msgJava = mbcwidgets.javacomponent(hComp, 'parent', h.Figure); h.msgJava.Peer.setText(h.Message); hText = h.msgJava; else h.msgHG = uicontrol('Style','text',... 'Parent',h.Figure,... 'String',h.Message,... 'Enable','inactive',... 'HorizontalAlignment','left'); hText = h.msgHG; end HasButton = false; if h.ShowStopButton hStop = uicontrol('Style','pushbutton',... 'Parent',h.Figure,... 'Callback',{@iStop,h},... 'Tag','WaitBarStop',... 'String','Stop'); Buttons= {[] hStop}; HasButton = true; else hStop = []; end if h.ShowCancelButton hCancel = uicontrol('Style','pushbutton',... 'Parent',h.Figure,... 'Callback',{@iCancel,h},... 'Tag','WaitBarCancel',... 'String','Cancel'); Buttons = {hStop hCancel}; HasButton = true; end if HasButton lyt = xreggridbaglayout(h.Figure,... 'dimension',[4 3],... 'gap',5,... 'rowsizes',[15 20 2 25],... 'colsizes',[-1 65 65],... 'border',[20 10 20 10],... 'elements',{hText,h.waitbar,[],[],... [],[],[],Buttons{1},... [],[],[],Buttons{2}},... 'mergeblock',{[1 1],[1 3]},... 'mergeblock',{[2 2],[1 3]},... 'packstatus','off'); else lyt = xreggridbaglayout(h.Figure,... 'correctalg','on',... 'dimension',[2 1],... 'gap',5,... 'rowsizes',[15 20],... 'border',[20 20 20 20],... 'elements',{hText,h.waitbar},... 'packstatus','off'); end set(h.Figure, 'LayoutManager', lyt); set(lyt,'packstatus','on'); % set up listeners for properties h.doSetupL; if showWaitDialog set(h.Figure, 'Visible', 'on'); end drawnow; % ---------------------------------- function show = showWaitDialog % SHOWWAITDIALOG show = ~get( findpackage( 'xregGui' ), 'TestMode' ); % ---------------------------------- function iStop(~,~,h) h.StopState = true; function iCancel(~,~,h) h.CancelState = true;