Page 157 - Basics of MATLAB and Beyond
P. 157

uimenu(f,’Label’,’Black’,...
                                         ’Callback’,’set(gcf,’’color’’,’’k’’)’);
                                   uimenu(f,’Label’,’White’,...
                                         ’Callback’,’set(gcf,’’color’’,’’w’’)’);
                                   uimenu(f,’Label’,’Gray’,...
                                         ’Callback’,’set(gcf,’’color’’,[.5 .5 .5])’);
                               g = uimenu(f,’Label’,’Other...’,’Separator’,’on’);
                                   uimenu(g,’Label’,’Parchment’,...
                                         ’Callback’,’set(gcf,’’color’’,[.95 .9 .8])’);
                                   uimenu(g,’Label’,’Vellum’,...
                                         ’Callback’,’set(gcf,’’color’’,[.9 .9 .8])’);
                                   uimenu(g,’Label’,’Cream’,...
                                         ’Callback’,’set(gcf,’’color’’,[.95 .9 .75])’);
                                                           The uimenu item that sets the Figure
                                                           colour to the default has its “accelera-
                                                           tor” property set to “D”, meaning that
                                                           when control-D is pressed while the cur-
                                                           sor is in the Figure window, the callback
                                                           will be executed; in this case the Figure
                                                           will go to its default colour. The “Other
                                                           ... ” menu item has its “separator” set
                                                           to “on”, which draws the line above its
                                                           label. A clear figure (clf) command
                                                           will clear user-created uimenus like this
                               one. The command colormenu is worth looking at as another example
                               of a simple uimenu.
                                    Exercise 19 Generate the following menu:
























                                    (Answer on page 192.)



                               c   2000 by CRC Press LLC
   152   153   154   155   156   157   158   159   160   161   162