www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/+xregdesgui/DesignView.m

    classdef DesignView < mbcgui.multiview.View
    %xregdesgui.DesignView class
    %   xregdesgui.DesignView extends mbcgui.multiview.View.
    %
    %    xregdesgui.DesignView properties:
    %       Parent - Property is of type 'MATLAB array'
    %       Position - Property is of type 'rect'
    %       Enable - Property is of type 'on/off'
    %       Visible - Property is of type 'on/off'
    %       UserData - Property is of type 'MATLAB array'
    %       Tag - Property is of type 'string'
    %       MessageService - Property is of type 'handle'
    %       Options - Property is of type 'handle vector'
    %       Actions - Property is of type 'handle vector'
    %       UIContextMenu - Property is of type 'MATLAB array'
    %
    %    xregdesgui.DesignView methods:
    %       addPrintTitle - Add a title to printing output
    %       canPrint - Check whether component can be printed
    %       gettitle - Return a suitable title for a view
    %       printSize - Returns the preferred printing size for the component
    %       printCopy - Create a new component for printing the component display
    
    %  Copyright 2000-2015 The MathWorks, Inc. and Ford Global Technologies, Inc.
    
    
    methods  % constructor block
        function obj = DesignView(varargin)
        %DESIGNVIEW Construct a new designview object
        %  DESIGNVIEW(Prop, Value, ...) constructs a new designview object.  This
        %  is the base class for all views that plug into the Design Editor.
        
        obj@mbcgui.multiview.View(varargin{ : }); % converted super class constructor call

        end  % designview
        
    end  % constructor block
    
    methods  % public methods
        %----------------------------------------
        function layout = addPrintTitle(obj, comp)
        %ADDPRINTTITLE Add a title to printing output
        %  LAYOUT = ADDPRINTTITLE(OBJ, COMP) adds a title above comp ready for
        %  printing, and returns the compound layout that should be passed out to the
        %  print mechanism.
        
        nm = obj.MessageService.getDataName;
        
        hFig = get(comp, 'Parent');
        titleH = axestext(hFig, ...
            'string',[obj.gettitle ' for "' nm '"'],...
            'fontsize', 11,...
            'fontweight', 'bold',...
            'HorizontalAlignment', 'center',...
            'VerticalAlignment', 'middle',...
            'interpreter', 'none');
        layout = xreggridbaglayout(hFig, ...
            'Dimension', [2 1], ...
            'Rowsizes', [25 -1], ...
            'gapy', 20, ...
            'border', [0 0 0 5], ...
            'elements', {titleH, comp});
        
        end  % addPrintTitle
        
        %----------------------------------------
        function out = canPrint(~)
        %CANPRINT Check whether component can be printed
        %  CANPRINT(OBJ) returns true for designview components.
        
        out = true;
        
        end  % canPrint
        
        %----------------------------------------
        function s = gettitle(obj) %#ok<MANU>
        %GETTITLE Return a suitable title for a view
        %  GETTITLE(OBJ) returns a string to use as the title for the view.
        
        s = 'Design View';
        
        end  % gettitle
        
        %----------------------------------------
        function sz = printSize(obj)
        %PRINTSIZE Returns the preferred printing size for the component
        %  SZ = PRINTSIZE(OBJ) returns a two element vector containing the
        %  preferred width and height for printing the component.  This method adds
        %  a 50 pixels in height to allow for a title
        
        sz = obj.Position(3:4) + [0 50];
        
        end  % printSize
        
        %----------------------------------------
        function newobj = printCopy(~, fig)
        %PRINTCOPY Create a new component for printing the component display
        %  NEWOBJ = PRINTCOPY(OBJ, FIG) creates and returns a handle to a new
        %  component, NEWOBJ, parented by the specified figure, FIG.  The new
        %  object will be used for printing a copy of the component OBJ.
        
        newobj = axestext('parent', fig, ...
            'horizontalalignment', 'center', ...
            'verticalalignment', 'top', ...
            'string', 'Empty Design View');
        
        end  % printcopy
        
    end  % public methods
    
    
end  % classdef