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

    function h=plottype(fig,strings,initial_selection)
%PLOTTYPE Constructor for the panel which allows
% the user to select from the available types of plot:
% e.g. surface, contour, table.
% h=plottype(fig,strings);
% h=plottype(fig,strings,initial_selection
% fig=figure handle
% strings=cell array of strings containing names of plot types.
% initial_selection=index of item to be selected in the combo box.

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


if (nargin<3)
    initial_selection=1;
end

h=cgsurfview.plottype;
h.Parent = fig;
h.strings=strings;
sc=xregGui.SystemColorsDbl;


pnl = mbcgui.container.layoutpanel(...
    'Parent', fig, ...
    'BorderType', 'beveledout', ...
    'LayoutBorder', [5 5 5 5]);
h.cb = uicontrol('Parent',pnl,'Style','popupmenu',...
    'String',h.strings,'BackgroundColor',sc.WINDOW_BG,...
    'Callback',{@i_Callback,h});
label = xregGui.labelcontrol('parent',pnl,...
    'LabelAlignment','left','gap',5,...
    'LabelSize',1,'ControlSize',1,...
    'LabelSizeMode','relative','ControlSizeMode','relative',...
    'control',h.cb,'string','Plot type:');

set(h.cb,'Value',initial_selection);
h.plottype=initial_selection;
h.plottypeList = handle.listener(h, h.findprop('plottype'), ...
    'PropertyPostSet', @i_sendevent);

set(pnl, 'LayoutComponent', label);
h.layout= pnl;

h.connect(xregfigurehook(fig), 'up');


function i_Callback(control,data,obj)
obj.plottype=get(control,'Value');

function i_sendevent(src, evt)
obj = evt.AffectedObject;
obj.send('PlotTypeChange', handle.EventData(obj,'PlotTypeChange') );