www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/@conbase/guiTypeChooser.m
function [obj, ok] = guiTypeChooser(obj, classes, varargin) %GUITYPECHOOSER Open a dialog for selecting a new constraint type % % OBJ = GUITYPECHOOSER(OBJ, CLASSES) opens a dialog that allows the user % to select a new constraint type and edit its settings. The constraint % classes that will be made available are contained in the cell array % CLASSES. If the class of OBJ is not included in CLASSES, then it will % be automatically appended. % % Example % classes = {@conlinear, @contable1, @contable2}; % con = guiTypeChooser( tExample( contable1 ), classes ) % % See also CONBASE, % CONBASE/GUITYPEANDFACTORSCHOOSER. % Copyright 2005-2015 The MathWorks, Inc. and Ford Global Technologies, Inc. [OptionObjects, OptionNames, ObjectIndex] = pGenerateObjectList( obj, classes ); hDialog = mbcgui.dialog.MultiObjectDialog( ... 'PageInfoFunction', @generateEditorPages, ... 'DisplaySinglePageAsTab', false, ... 'Title', 'Edit Constraint', ... 'ChooserLabel', 'Constraint type:', ... 'ChooserLabelWidth', 85, ... 'OptionStrings', OptionNames, ... 'OptionFunctions', OptionObjects, ... 'CurrentOption', ObjectIndex, ... 'DialogPanelSize', [580 320], ... 'LayoutFunction', @n_LayoutFunction, ... varargin{:}); ok = hDialog.show; if ok obj = hDialog.Object; end delete(hDialog); function lyt = n_LayoutFunction( dlg, hLabel, hCards ) [lyt, callback] = pCreateChooserLayout( obj, dlg.Figure, hLabel, hCards ); % Listener to keep description and picture updated hListener = event.listener( dlg, 'OptionChanged', @(dlg, evt) callback( dlg.Object ) ); set(lyt, 'UserData', hListener); end end