www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@mbcmultiview/@MultiViewPanel/MultiViewPanel.m
function obj = MultiViewPanel(varargin) %MULTIVIEWPANEL Construct a new MultiViewPanel % % OBJ = MULTIVIEWPANEL(PROP, VALUE, ...) constructs a new MultiViewPanel. % This component contains a set of Views housed within ViewContainers % that are arranged in a hierarchy of splitlayouts. % Copyright 2005-2010 The MathWorks, Inc. and Ford Global Technologies, Inc. if nargin && isa(varargin{1}, 'MultiViewPanel') obj = varargin{1}; else obj = mbcmultiview.MultiViewPanel; end obj.abstractlayoutcomponent(varargin{:}); VG = mbcmultiview.ViewGroup; obj.ViewGroup = VG; VG.connect(obj, 'up'); obj.addListeners([... handle.listener(VG, VG.findprop('ViewContainers'), ... 'PropertyPostSet', {@i_checkcloseable, obj}); ... handle.listener(VG, 'SelectedViewChanged', {@i_selviewchange, obj}) ]... ); % Create an empty ViewList if one has not been set if isempty(obj.ViewList) obj.ViewList = mbcmultiview.ViewList; end % Actions the UI can perform A.CloseView = mbcmultiview.StatefulAction(... {@i_closeview, obj}, '&Close View','Close current view'); A.SplitViewV = mbcmultiview.StatefulAction(... {@i_split, obj, 'ud'}, 'Split View &Vertically', ... 'Split current view vertically', xregrespath('verticalSplit.bmp')); A.SplitViewH = mbcmultiview.StatefulAction(... {@i_split, obj, 'lr'}, 'Split View &Horizontally', ... 'Split current view horizontally', xregrespath('horizontalSplit.bmp')); A.CopyView = mbcmultiview.StatefulAction(... {@i_printview, obj, 'clipboard'}, '&Copy View', ... 'Copy current view to clipboard', xregrespath('copy.bmp')); A.PrintView = mbcmultiview.StatefulAction(... {@i_printview, obj, 'printdialog'}, '&Print...', ... 'Print current view', xregrespath('print.bmp')); A.PrintViewQuiet = mbcmultiview.StatefulAction(... {@i_printview, obj, 'printer'}, '&Print', ... 'Print current view', xregrespath('print.bmp')); A.PrintViewPreview = mbcmultiview.StatefulAction(... {@i_printview, obj, 'printpreview'}, 'Print Pre&view','Print preview'); A.PrintViewFigure = mbcmultiview.StatefulAction(... {@i_printtofig, obj}, 'Print To &Figure', ... 'Print to figure', xregrespath('printtofigure.bmp')); A.ChangeView = obj.pCreateViewListActions('change'); A.SplitToView = obj.pCreateViewListActions('split'); A.ViewOptions = mbcmultiview.DynamicActionGroup('', 'View &Options', 'Current view options'); A.ViewOptions.MenuType = 'none'; A.ViewActions = mbcmultiview.DynamicActionGroup('', 'View &Actions', 'Current view actions'); A.ViewActions.MenuType = 'separate'; obj.Actions = A; obj.GlobalViewOptionGroup = mbcmultiview.DynamicActionGroup('', 'Common View Options', 'Additional view options'); obj.GlobalViewOptionGroup.MenuType = 'none'; if ~isempty(obj.GlobalViewOptions) obj.GlobalViewOptionGroup.Actions = obj.GlobalViewOptions; end obj.ContextActionGroup = mbcmultiview.DynamicActionGroup('', 'Additional Actions', 'Context menu actions'); obj.ContextActionGroup.MenuType = 'separate'; if ~isempty(obj.ContextActions) obj.ContextActionGroup.Actions = obj.ContextActions; end % Create the context menu obj.hViewContextMenu = uicontextmenu('Parent', ancestor(obj.Parent, 'figure')); obj.pCreateContextMenu(obj.hViewContextMenu); % Create the container that will house the splittable views obj.hTopLayout = xreglayerlayout(obj.Parent, ... 'Position', obj.Position, ... 'Packstatus', 'off'); % Create the rest of the component's layout obj.Display = pCreateLayout(obj, obj.hTopLayout); % Create the initial set of view objects if obj.pHasSavedLayout obj.restoreViewLayout(obj.ViewLayoutName); else obj.initViewLayout; end set(obj.hTopLayout, 'packstatus', 'on'); % Enable the correct set of actions obj.pUpdateActions; % Hook up property listeners obj.addPropertyListeners(... {'MessageService', 'GlobalViewOptions', 'ContextActions'}, ... {@i_setms, ... {@i_updateAG, obj.GlobalViewOptionGroup}, ... {@i_updateAG, obj.ContextActionGroup}}); function i_checkcloseable(src, evt, obj) % When there is only one view available, make it not closeable hVC = evt.NewValue; A = obj.Actions; hasMultipleViews = (length(hVC)>1); set(hVC, 'Closeable', hasMultipleViews); A.CloseView.Enabled = (hasMultipleViews || strcmpi(obj.Visible, 'off')); function i_selviewchange(src, evt, obj) % Update Actions enabled status obj.pViewSelected; function i_setms(src, evt) obj = evt.AffectedObject; hVC = obj.getViewContainers; if ~isempty(hVC) hV = get(hVC, {'View'}); hV = [hV{:}]; set(hV, 'MessageService', evt.NewValue); end function i_closeview(src, evt, obj) obj.deleteView; function i_split(src, evt, obj, orient) obj.splitView(orient); function i_printview(src, evt, obj, dest) P = xregGui.PointerRepository; ptrID = P.stackSetPointer(obj.Parent, 'watch'); msg = ''; switch dest case 'clipboard' msg = 'Copying current view to clipboard...'; case {'printer', 'printdialog'} msg = 'Printing current view...'; case 'printpreview' msg = 'Generating print preview for current view...'; end if ~isempty(msg) MsgID = obj.pAddStatusMessage(msg); end obj.print(dest); if ~isempty(msg) obj.pRemoveStatusMessage(MsgID); end P.stackRemovePointer(obj.Parent, ptrID) function i_printtofig(src, evt, obj) obj.printToFigure; function i_updateAG(src, evt, AG) AG.Actions = evt.NewValue;