www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/+mbcgui/+multiview/PanelTitleViewContainer.m

    classdef PanelTitleViewContainer < mbcgui.multiview.ViewContainer
    %mbcgui.multiview.PanelTitleViewContainer class
    %   mbcgui.multiview.PanelTitleViewContainer extends mbcgui.multiview.ViewContainer.
    %
    %    mbcgui.multiview.PanelTitleViewContainer 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'
    %       BackgroundColor - Property is of type 'color'
    %       Closeable - Property is of type 'bool'
    %       Selected - Property is of type 'bool'
    %       View - Property is of type 'handle'
    %       UIContextMenu - Property is of type 'MATLAB array'
    %       PanelHandle - Property is of type 'MATLAB array'

    %  Copyright 2005-2015 The MathWorks, Inc. and Ford Global Technologies, Inc.
    
    properties (Access=protected, AbortSet)
        %HJAVATITLE Property is of type 'handle'
        hJavaTitle = [];
        %HLAYOUT Property is of type 'MATLAB array'
        hLayout = [];
    end
    
    methods  % constructor block
        function obj = PanelTitleViewContainer(varargin)
        %PANELTITLEVIEWCONTAINER Constructor for PanelTitleViewContainer object
        %
        %  OBJ = PANELTITLEVIEWCONTAINER (PROP, VALUE, ...) constructs a new
        %  PanelTitleViewContainer object.
        
        obj@mbcgui.multiview.ViewContainer(varargin{ : }); % converted super class constructor call
        
        
        P = com.mathworks.toolbox.mbc.gui.peer.InternalTitleBarPeer;
        obj.hJavaTitle = mbcwidgets.javacomponent(P, ...
            'Parent', obj.PanelHandle, ...
            'Visible', 'on');
        obj.hJavaTitle.UIContextMenu = obj.UIContextMenu;
        obj.hJavaTitle.Peer.setSelected(obj.Selected);
        obj.hJavaTitle.Peer.setCloseable(obj.Closeable);
        if ~isempty(obj.View)
            obj.hJavaTitle.Peer.setTitle(obj.View.gettitle);
        end
        obj.pConfigureTitle(obj.hJavaTitle);
        
        obj.hLayout = xreggridbaglayout(obj.PanelHandle, ...
            'dimension', [2 1], ...
            'rowsizes', [19 -1], ...
            'colsizes', -1);
        
        % Update the view configuration after the layout is constructed
        obj.pPostSetView();
        
        % Hook up title bar buttons to fire events on this object
        obj.addListeners(...
            [handle.listener(obj.hJavaTitle.Peer, 'Close', {@i_fireclose, obj}); ...
            handle.listener(obj.hJavaTitle.Peer, 'SplitLR', {@i_firesplitLR, obj}); ...
            handle.listener(obj.hJavaTitle.Peer, 'SplitUD', {@i_firesplitUD, obj}); ...
            handle.listener(obj.hJavaTitle.Peer, 'MousePressed', {@i_firebtndown, obj})] ...
            );
        
        end  % PanelTitleViewContainer
        
    end  % constructor block
    
    methods (Access=protected) % protected methods
        %----------------------------------------
        function pConfigureTitle(obj, hTitle) %#ok<INUSD>
        %PCONFIGURETITLE Configure the title bar object
        %
        %  PCONFIGURETITLE(OBJ, TITLE) is called to configure the object that is
        %  used as the main title in the PanelTitleViewContainer.  Subclasses
        %  should override this method to alter the look of the title.
        
        % Default look is appropriate for this object
        
        end  % pConfigureTitle
        
        %----------------------------------------
        function L = pGetLayout(obj, view)
        %PGETLAYOUT Get the container's layout
        %
        %  PGETLAYOUT(OBJ, VIEW) is called when the View property is changed.  This
        %  method sets the view and a title into a layout and returns it.
        
        L = obj.hLayout;
        set(L, 'elements', {obj.hJavaTitle, view});
        
        end  % pGetLayout
        
        %----------------------------------------
        function pPostSetView(obj)
        %PPOSTSETVIEW Notify method called after the view is set
        %
        %  PPOSTSETVIEW(OBJ) is called in response to the View property being set.
        
        pPostSetView@mbcgui.multiview.ViewContainer(obj);
        
        if ~isempty(obj.View) && ~isempty(obj.hJavaTitle)
            obj.hJavaTitle.Peer.setTitle(obj.View.gettitle);
        end
        
        end  % pPostSetView
        
        %----------------------------------------
        function setSelected(obj)
        setSelected@mbcgui.multiview.ViewContainer(obj)
        if ~isempty(obj.hJavaTitle)
            obj.hJavaTitle.Peer.setSelected(obj.Selected);
        end
        end
        
        %----------------------------------------
        function setUIContextMenu(obj)
        setUIContextMenu@mbcgui.multiview.ViewContainer(obj)
        
        if ~isempty(obj.hJavaTitle)
            obj.hJavaTitle.UIContextMenu = obj.UIContextMenu;
        end
        end
        
        %----------------------------------------
        function setCloseable(obj)
        setCloseable@mbcgui.multiview.ViewContainer(obj)
        if ~isempty(obj.hJavaTitle)
            obj.hJavaTitle.Peer.setCloseable(obj.Closeable);
        end
        end  % setCloseable
    end % protected methods
    
end  % classdef

function i_fireclose(~, ~, obj)
obj.notify('Close');
end  % i_fireclose

function i_firesplitLR(~, ~, obj)
data.Orientation = 'lr';
obj.notify('Split', xregEventData(data));
end  % i_firesplitLR

function i_firesplitUD(~, ~, obj)
data.Orientation = 'ud';
obj.notify('Split', xregEventData(data));
end  % i_firesplitUD

function i_firebtndown(~, ~, obj)
obj.notify('ButtonDown');
end  % i_firebtndown