www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@xregGui/@dialog/pLayout.m
function pLayout(obj) %PLAYOUT Private method to layout the dialog. % % PLAYOUT(OBJ) % Copyright 2007-2015 The MathWorks, Inc. if isempty(obj.ContentLayout) % Create a layout that applies the content border obj.ContentLayout = xreglayerlayout( obj.Figure,... 'PackStatus', 'off'); end set(obj.ContentLayout,... 'Elements', {obj.Content},... 'Border', obj.ContentBorder ); % Create the appropriate buttons buttons = obj.pCreateButtons(); numBtns = length( buttons ); % Delete any existing buttons and the layout they are in if ~isempty(obj.ButtonLayout) % Detach the content layout from the existing grid. old_elements = get(obj.ButtonLayout, 'Elements'); old_elements{1} = []; set(obj.ButtonLayout, 'Elements', old_elements); delete(obj.ButtonLayout); end % Create a layout that adds the buttons elements = [{obj.ContentLayout}, repmat( {[]}, 1, numBtns+2 );... {[]}, {[]} buttons(:)', {[]} ]; obj.ButtonLayout = xreggridbaglayout( obj.Figure,... 'PackStatus', 'off',... 'Dimension', [2 numBtns+3],... 'RowSizes', [-1 25],... 'ColSizes',[0 -1 repmat( 65, 1, numBtns ), 0],... 'Gapx',7,... 'Gapy', 7,... 'Border',[0 7 0 0],... 'mergeblock', {[1 1],[1 numBtns+3]},... 'Elements', elements); TopLayout = obj.ButtonLayout; % Create a layout for the dialog information only if it is required HasInfo = ~isempty(obj.InfoTitle) || ~isempty(obj.InfoString); if HasInfo && isempty(obj.InfoPane) obj.InfoPane = mbcgui.container.InfoPane(... 'Parent', obj.Figure, ... 'Visible', 'off'); end if ~isempty(obj.InfoPane) set(obj.InfoPane, 'Title', obj.InfoTitle, ... 'InfoString', obj.InfoString, ... 'InfoHeight', obj.InfoHeight); end % In order to make sure the info pane repacks at the right time we need to % make the figure's packstatus is on here. set( obj.ButtonLayout, 'PackStatus', 'on'); if HasInfo % Use the InfoPane as the figure's main layout set(obj.InfoPane, 'Center', TopLayout, 'Visible', 'on'); TopLayout = obj.InfoPane; else set(obj.InfoPane, 'Center', [], 'Visible', 'off'); end obj.Figure.LayoutManager = []; obj.Figure.LayoutManager = TopLayout; set(obj.ButtonLayout, 'Visible', 'on' );