www.pudn.com > 精通Matlab综合辅导与指南-源程序.zip > mmenus.m
function mmenus()
%MMENUS Simple menu example.
% MMENUS uses waitforbuttonpress and gco in the callback strings
% to let the user make a menu selection and then select an object
% by clicking on it with the mouse. The callback strings then use
% the set function to apply the property value to the selected object.
% B.R. Littlefield, University of Maine, Orono ME 04469
% 5/30/95
% Copyright (c) 1996 Prentice Hall, Inc.
Hm_line = uimenu(gcf,'label','Line');
Hm_lstyle = uimenu(Hm_line,'label','Line Style');
Hm_lwidth = uimenu(Hm_line,'label','Line Width');
Hm_lcolor = uimenu(Hm_line,'label','Line Color');
uimenu(Hm_lstyle,'Label','Solid',...
'CallBack',['waitforbuttonpress;',...
'if get(gco,''Type'') == ''line'',',...
'set(gco,''LineStyle'',''-''),',...
'end']);
uimenu(Hm_lstyle,'Label','Dotted',...
'CallBack',['waitforbuttonpress;',...
'if get(gco,''Type'') == ''line'',',...
'set(gco,''LineStyle'','':''),',...
'end']);
uimenu(Hm_lstyle,'Label','Dashed',...
'CallBack',['waitforbuttonpress;',...
'if get(gco,''Type'') == ''line'',',...
'set(gco,''LineStyle'',''--''),',...
'end']);
uimenu(Hm_lstyle,'Label','DashDot',...
'CallBack',['waitforbuttonpress;',...
'if get(gco,''Type'') == ''line'',',...
'set(gco,''LineStyle'',''-.''),',...
'end']);
uimenu(Hm_lwidth,'Label','Default',...
'CallBack',['waitforbuttonpress;',...
'if get(gco,''Type'') == ''line'',',...
'set(gco,''LineWidth'',0.5),',...
'end']);
uimenu(Hm_lwidth,'Label','Thick',...
'CallBack',['waitforbuttonpress;',...
'if get(gco,''Type'') == ''line'',',...
'set(gco,''LineWidth'',2.0),',...
'end']);
uimenu(Hm_lwidth,'Label','Thicker',...
'CallBack',['waitforbuttonpress;',...
'if get(gco,''Type'') == ''line'',',...
'set(gco,''LineWidth'',3.0),',...
'end']);
uimenu(Hm_lwidth,'Label','Thickest',...
'CallBack',['waitforbuttonpress;',...
'if get(gco,''Type'') == ''line'',',...
'set(gco,''LineWidth'',4.0),',...
'end']);
uimenu(Hm_lcolor,'Label','Yellow',...
'BackgroundColor','y',...
'CallBack',['waitforbuttonpress;',...
'if get(gco,''Type'') == ''line'',',...
'set(gco,''Color'',''y''),',...
'end']);
uimenu(Hm_lcolor,'Label','Magenta',...
'BackgroundColor','m','ForegroundColor','w',...
'CallBack',['waitforbuttonpress;',...
'if get(gco,''Type'') == ''line'',',...
'set(gco,''Color'',''m''),',...
'end']);
uimenu(Hm_lcolor,'Label','Cyan',...
'BackgroundColor','c',...
'CallBack',['waitforbuttonpress;',...
'if get(gco,''Type'') == ''line'',',...
'set(gco,''Color'',''c''),',...
'end']);
uimenu(Hm_lcolor,'Label','Red',...
'BackgroundColor','r','ForegroundColor','w',...
'CallBack',['waitforbuttonpress;',...
'if get(gco,''Type'') == ''line'',',...
'set(gco,''Color'',''r''),',...
'end']);
uimenu(Hm_lcolor,'Label','Green',...
'BackgroundColor','g',...
'CallBack',['waitforbuttonpress;',...
'if get(gco,''Type'') == ''line'',',...
'set(gco,''Color'',''g''),',...
'end']);
uimenu(Hm_lcolor,'Label','Blue',...
'BackgroundColor','b','ForegroundColor','w',...
'CallBack',['waitforbuttonpress;',...
'if get(gco,''Type'') == ''line'',',...
'set(gco,''Color'',''b''),',...
'end']);
uimenu(Hm_lcolor,'Label','White',...
'BackgroundColor','w',...
'CallBack',['waitforbuttonpress;',...
'if get(gco,''Type'') == ''line'',',...
'set(gco,''Color'',''w''),',...
'end']);
uimenu(Hm_lcolor,'Label','Black',...
'BackgroundColor','k','ForegroundColor','w',...
'CallBack',['waitforbuttonpress;',...
'if get(gco,''Type'') == ''line'',',...
'set(gco,''Color'',''k''),',...
'end']);
Hm_cmap = uimenu(gcf,'Label','Color Map');
uimenu(Hm_cmap,'Label','Lighter','CallBack','brighten(.3)');
uimenu(Hm_cmap,'Label','Darker','CallBack','brighten(-.3)');
uimenu(Hm_cmap,'Label','Default','CallBack','colormap(''default'')');
uimenu(Hm_cmap,'Label','Gray','CallBack','colormap(gray)');
uimenu(Hm_cmap,'Label','Hot','CallBack','colormap(hot)');
uimenu(Hm_cmap,'Label','Cool','CallBack','colormap(cool)');
uimenu(Hm_cmap,'Label','Bone','CallBack','colormap(bone)');
uimenu(Hm_cmap,'Label','Copper','CallBack','colormap(copper)');
uimenu(Hm_cmap,'Label','Pink','CallBack','colormap(pink)');
uimenu(Hm_cmap,'Label','Prism','CallBack','colormap(prism)');
uimenu(Hm_cmap,'Label','Jet','CallBack','colormap(jet)');
uimenu(Hm_cmap,'Label','Flag','CallBack','colormap(flag)');
uimenu(Hm_cmap,'Label','HSV','CallBack','colormap(hsv)');
Hm_quit = uimenu(gcf,'Label','Quit');
uimenu(Hm_quit,'Label','Close Figure','CallBack','close; return');
uimenu(Hm_quit,'Label','Remove Menus',...
'CallBack',[...
'delete(findobj(gcf,''Type'',''uimenu'',''Parent'',gcf)),',...
'drawnow']);