www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/cgProjectItemSelector.m

    function [fH, itemList] = cgProjectItemSelector(pPROJ, typeobj, titleStr, descStr, helpTag)
%CGPROJECTITEMSELECTOR Create a GUI to display project items
%
%   ITEMLIST = CGPROJECTITEMSELECTOR(PPROJ, TYPEOBJ, TITLESTR, DESCSTR,
%   HELPTAG) lauches a dialog to allow a user to select a CAGE Project item
%   from a list. The list is filtered using the CGTYPES object provided by
%   TYPEOBJ. The title of the figure is specified in TITLESTR and a
%   description of the items in the list can be passed through DESCSTR. A
%   link to the relevant section in the documentation can be specified in
%   the HELPTAG.
%
%   See also CGTOOLS.PROJECTLIST

%   Copyright 2006-2010 The MathWorks, Inc.

fH = xregdialog('name', titleStr, ...
    'resize', 'off');
xregcenterfigure(fH, [250 300]);
    
t = uicontrol('Parent', fH, ...
    'Style', 'text', ...
    'Enable', 'inactive', ...
    'String', descStr, ...
    'HorizontalAlignment', 'left');

itemList = cgtools.projectList('parent', fH, ...
    'DisplayTypeColumn', false, ...
    'DisplayHeaderRow', false, ...
    'FilterTypeObject', typeobj, ...
    'Project', pPROJ);
dblClickList = handle.listener(itemList, 'Open', {@i_invokeOK, fH});

% OK and cancel buttons
btOK = uicontrol('Parent', fH, ...
    'Style', 'pushbutton', ...
    'String', 'OK', ...
    'Callback', 'set(gcbf, ''tag'', ''ok'', ''visible'', ''off'');');
btCanc = uicontrol('Parent', fH, ...
    'Style', 'pushbutton', ...
    'String', 'Cancel', ...
    'Callback', 'set(gcbf, ''tag'', ''cancel'', ''visible'', ''off'');');
btHelp = cghelpbutton(fH, helpTag);

lyt = xreggridbaglayout(fH, ...
    'packstatus', 'off', ...
    'dimension', [4 4], ...
    'rowsizes', [15 -1 3 25], ...
    'colsizes', [-1 65 65 65], ...
    'gapx', 7, ...
    'gapy', 2, ...
    'border', [7 7 7 10], ...
    'mergeblock', {[1 1], [1 4]}, ...
    'mergeblock', {[2 2], [1 4]}, ...
    'elements', {t, itemList, [], [], ....
        [], [], [], btOK, ...
        [], [], [], btCanc, ...
        [], [], [], btHelp});

fH.LayoutManager = lyt;
fH.Userdata = dblClickList;
set(lyt, 'packstatus', 'on');
    
function i_invokeOK(src, evt, fH)
set(fH, 'Tag', 'ok', 'Visible', 'off');