www.pudn.com > LPCToolbox.rar > MAKE_APDLG.M


function make_apdlg

global Handle Ap

if isfield(Handle, 'apdlg') &amt; ishandle(Handle.apdlg)
figure(Handle.apdlg);
return;
end

>pos = get(0, 'screensize');

Handle.apdlg = dialog('windowstyle', 'normal', ...
'name', 'Analysis Parameters', ...
'units', 'normalized', ...
'position', [0.35 0.4 0.26 0.5]);

figure(Handle.apdlg);

>---------------- Define the buttons -----------------------

txt{1} = {'edit', 'Default Fs (Hz)', 'Ap.defaultFs'};
txt{2} = {'edit', 'Analysis window (points)', 'Ap.analysis_width'};
txt{3} = {'edit', 'Slide window by (points)', 'Ap.context_width'};
txt{4} = {'popupmenu', 'Use Hamming window', 'Ap.usehamming'};
txt{5} = {'edit', 'Preemphasis', 'Ap.preemph'};
txt{6} = {'edit', 'RC cutoff', 'Ap.rccutoff'};
txt{7} = {'edit', 'Min filter order', 'Ap.mincoeffs'};
txt{8} = {'edit', 'Max filter order', 'Ap.maxcoeffs'};
txt{9} = {'edit', 'Freeze filter order at', 'Ap.freezeorder'};
txt{10} = {'edit', 'FFT Length for LPC', 'Ap.fftlen'};
txt{11} = {'popupmenu', 'Use three-point interp.', 'Ap.usetpi'};

nitems=length(txt);

> coord: (0,0) is the bottom-left of the screen
> text box is anchored by its bottom-left point
> position: [left-x bottom-y width height]

> normalized coordinates
topgap = 0.04;
width1 = 0.6; midgap = 0.02; width2 = 0.25;
xpos1 = (1-(width1+midgap+width2)) / 2;
xpos2 = xpos1+width1+midgap;
height = 0.06;
ypos = linspace(1-topgap-height, 0.14, nitems);

for i=1:nitems,
> the 0.005 is to correct a slight misalignment between the
> the text and the entry fields
uicontrol('style', 'text', 'string', txt{i}{2}, ...
'units', 'normalized', ...
'position', [xpos1 ypos(i)-0.005 width1 height], ...
'horizontalalignment', 'right', ...
'parent', Handle.apdlg);

if strcmp(txt{i}{1}, 'edit')
defstr = eval(txt{i}{3}); val=0;
else
defstr = {'No', 'Yes'}; val = eval(txt{i}{3})+1;
end

uih(i) = uicontrol('style', txt{i}{1}, ...
'string', defstr, 'value', val, ...
'units', 'normalized', ...
'position', [xpos2 ypos(i) width2 height], ...
'horizontalalignment', 'left', ...
'parent', Handle.apdlg);

end


Handle.apitems = uih;
Handle.apitemtxt = txt;

> ui controls are created for the current figure
> The above text stopped at y=0.14. That is, we have
> room from y=0 ... 0.14

width3 = 0.35; midgap = 0.1;
xpos1 = (1-(width3+midgap+width3)) / 2;
xpos2 = xpos1+width3+midgap;
height = 0.08;
ypos = 0.02;

uicontrol('Style','pushb', ...
'String','Apply', ...
'units', 'normalized', ...
'Position',[xpos1 ypos width3 height], ...
'Callback','act_apdlg(''apply'')', ...
'parent', Handle.apdlg);

uicontrol('Style','pushb', ...
'String','Cancel', ...
'units', 'normalized', ...
'Position',[xpos2 ypos width3 height], ...
'Callback', 'act_apdlg(''cancel'')', ...
'parent', Handle.apdlg);