www.gusucode.com > sigdemos 工具箱matlab源码程序 > sigdemos/render_fullaudiotoolbar.m
function [htoolbar, haudiobtns] = render_fullaudiotoolbar(h) %RENDER_FULLAUDIOTOOLBAR Create complete audio toolbar. % [HTOOLBAR, HBUTTONS] = RENDER_FULLAUDIOTOOLBAR(HFIG) creates a new % toolbar with go to start, rewind, record, play, pause, stop, fast % forward, and go to end buttons that will operate on an audioplayer % and an audiorecorder object. A new toolbar will be added to the % figure HFIG. Handles to the new toolbar and array of pushbuttons % are returned. % % RENDER_FULLAUDIOTOOLBAR(HTOOLBAR) adds the audio buttons in % sequence to toolbar HTOOLBAR. % Author(s): B. Wherry % Copyright 1984-2012 The MathWorks, Inc. narginchk(1,1); hType = get(h, 'Type'); % if h is the handle to a figure, add a new toolbar to it if strcmp(hType, 'figure'), htoolbar = uitoolbar(h); set(htoolbar, 'Tag', 'FullAudioToolbar'); % if h is the handle to a toolbar, add our toolbar buttons to it elseif strcmp(hType, 'uitoolbar'), htoolbar = h; % if h is something else, error else error(message('signal:render_fullaudiotoolbar:GUIErr')); end % Load audio icons icons = load('uiscope_icons'); % stick all the icons into app data for swapping in/out, etc. setappdata(htoolbar, 'audioButtonIcons', icons); pushbtns = {icons.goto_start_default,... icons.rewind_default,... icons.record_off,... icons.play_off,... icons.pause_default,... icons.stop_default,... icons.ffwd_default,... icons.goto_end_default}; tooltips = {'Go to beginning',... 'Rewind',... 'Record',... 'Play',... 'Pause',... 'Stop',... 'Fast forward',... 'Go to end'}; tags = {'goto_beg',... 'rewind',... 'record',... 'play',... 'pause',... 'stop',... 'ffwd',... 'goto_end'}; sep = {'On','Off','Off','Off','Off','Off','Off','Off'}; fcns = menus_cbs; btncbs = {fcns.gtbeg_cb,... fcns.rewind_cb,... fcns.record_cb,... fcns.play_cb,... fcns.pause_cb,... fcns.stop_cb,... fcns.ffwd_cb,... fcns.gtend_cb}; % Render the PushButtons for i = 1:length(pushbtns), haudiobtns(i) = uipushtool('CData',pushbtns{i},... 'Parent', htoolbar,... 'ClickedCallback',btncbs{i},... 'Tag', tags{i},... 'Separator', sep{i},... 'TooltipString', tooltips{i}); end