www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@mbcwidgets/@itemfilter/itemfilter.m

    function obj = itemfilter( varargin )
%ITEMFILTER mbcwidgets.itemfilter class constructor 

%  Copyright 2005-2012 The MathWorks, Inc.


% Is the first input argument a udd object derived from me? If it is then
% we are being called as a super class constructor and don't have to
% construct an object
if nargin && isa(varargin{1}, 'mbcwidgets.itemfilter')
	obj = varargin{1};
	varargin(1) = [];
else
	obj = mbcwidgets.itemfilter;
end
% Call the inherited constructor
abstractlayoutcomponent(obj, varargin{:});

filterbox = uicontrol( 'Parent', obj.Parent,...
    'BackgroundColor', 'w',...
    'HorizontalAlignment', 'left',...
    'Enable', 'off',...
    'Style', 'edit',...
    'String', '',...
    'Callback', {@updatefilter, obj});

obj.Filter = xregGui.labelcontrol( 'Parent', obj.Parent,...
    'String', 'Find: ',...
    'Enable', 'off',...
    'ControlSize', 120,...
    'ControlSizeMode', 'absolute',...
    'LabelSizeMode', 'absolute',...
    'LabelSize', 100,...    
    'Control', filterbox );

typepopup = uicontrol( 'Parent', obj.Parent,...
    'BackgroundColor', 'w',...
    'Style', 'popup',...
    'Enable', 'off',...
    'String', obj.AllTypes,...
    'Callback', {@updateselectedtype, obj});

obj.Type = xregGui.labelcontrol( 'Parent', obj.Parent,...
    'String', 'Type: ',...
    'Enable', 'off',...
    'ControlSizeMode', 'absolute',...    
    'ControlSize', 120, ...
    'LabelSizeMode', 'absolute',...
    'LabelSize', 50,...    
    'Control', typepopup );

matchcase = uicontrol( 'Parent', obj.Parent,...
    'Style', 'checkbox',...
    'Enable', 'off',...
    'String', 'Match case',...
    'Callback', {@updatematchcase, obj}); 

obj.Case = xregGui.labelcontrol( 'Parent', obj.Parent,...
    'String', '',...
    'Enable', 'off',...
    'ControlSizeMode', 'absolute',...
    'ControlSize', 120, ...
    'LabelSizeMode', 'absolute',...
    'LabelSize', 100,...    
    'Control', matchcase );

obj.Display = xreggridbaglayout( obj.Parent,...
    'Border', [0 0 0 0],...
    'GapY', 2,...
    'GapX', 2,...
    'Dimension', [2 3],...
    'ColSizes', [250 10 250],...
    'RowSizes', [20 20],...
    'Elements', {obj.Filter, [], obj.Type; obj.Case, [], []} );

function updatematchcase( src, ~, obj )
obj.MatchCase = get( src, 'Value' );
send( obj, 'FilterChanged', handle.EventData( obj, 'FilterChanged' ) );

function updatefilter( src, ~, obj )
obj.FilterString = get( src, 'String' );
send( obj, 'FilterChanged', handle.EventData( obj, 'FilterChanged' ) );

function updateselectedtype( src, ~, obj )
obj.SelectedType = obj.AllTypes{get( src, 'Value' )};
send( obj, 'FilterChanged', handle.EventData( obj, 'FilterChanged' ) );