www.gusucode.com > mbclayouts 工具箱 matlab 源码程序 > mbclayouts/@xregsnapsplitlayout/xregsnapsplitlayout.m

    function obj=xregsnapsplitlayout(varargin)
%XREGSNAPSPLITLAYOUT Splitlayout variant
% 
%  XREGSNAPSPLITLAYOUT([FIG],prop, arg) constructs a splitlayout that
%  offers the option of fully closing one side of the split.
%

%  Copyright 2000-2010 The MathWorks, Inc. and Ford Global Technologies, Inc.


fig = [];
if nargin
   if mbcgui.util.isComponentParent(varargin{1}) 
      fig = varargin{1};
      varargin(1) = [];
   end
end
if isempty(fig)
    fig = gcf;
end

c = xregcontainer(fig);

ud.split = [0.5 0.5];
ud.splitmem = [0.5 0.5];
ud.orientation = 0;  % left-right orientation by default
ud.behaviour = 1;    % allow snap left/right by default
ud.state = 0;        % current bar position: either snapped at left, right or just dragging in the middle
ud.snapposition = 0; % flag to indicate whether to snap to edge (0) or to minimum split position (1)
ud.callbackstr = '';
ud.innerborders = [0 0 0 0; 0 0 0 0];
ud.minwidth = [0 0];
ud.barstyle = 1;    % Bar style: 0==flat, 1==raised
ud.barwidth = 4;    % Bar size in pixels.

DragBarPeer = com.mathworks.toolbox.mbc.gui.peer.SnapSplitBarPeer;
obj.DragBar = mbcwidgets.javacomponent(DragBarPeer, ...
    'Parent', fig, ...
    'Visible', 'off');
obj.DragBar.Peer.setOrientation('LEFTRIGHT');
obj.Listeners = [];

connectdata(c, obj.DragBar);
set(c,'UserData',ud);
obj = class(obj,'xregsnapsplitlayout',c);

% Attach snap and drag listeners
obj.Listeners = dragcallback(obj);

% look for a visible set in remaining args
if ~any(strcmpi('Visible',varargin(1:2:end)))
    % set ui objects to visible
    set(obj.DragBar,'Visible','on');
end
if ~isempty(varargin)
    obj = set(obj,varargin{:});
else
    repack(obj);
end