function mcs_gui_box(progs,pos,fmt,vbl,style,tag,tip,val,label,bcol,fcol)
%
%
% COPYRIGHT (c) 2008
% 
% Applied Research Laboratories, The University of Texas at Austin
% (ARL:UT)
% All rights reserved.
% 
% This material may be reproduced by or for the U.S. Government
% only. This notice must appear in all copies of this file and its
% derivatives. Further distribution outside the U.S. Government is
% prohibited without the explicit written authorization from the
% Director of the Environmental Sciences Laboratory, ARL:UT.
% 
% THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
% EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE
% IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
% PURPOSE, OR NONINFRINGEMENT.
% 
% IN NO EVENT WILL ARL:UT BE LIABLE FOR ANY DAMAGES WHATSOEVER ARISING
% OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN IF ARL:UT HAS
% BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
mcs_global
%
if nargin<9, label=[]; end
if nargin<10, bcol=[0 0 0]; end
if nargin<11, fcol=[1 1 0]; end
%
cback=['mcs_act(''',tip,''');'];
if strcmp(style,'checkbox'),
	string=tip;
elseif strcmp(style,'listbox') | strcmp(style,'popupmenu') | strcmp(style,'edit') | ...
        strcmp(style,'text'),
	if strcmp(fmt,'%s'),
		str=['string=char(',vbl,');'];
	else
		str=['string=sprintf(''',fmt,''',',vbl,');'];
	end
	eval(str); 
elseif strcmp(style,'edit'),
	str=['string=sprintf(''',fmt,''',',vbl,');'];
	eval(str);
%elseif strcmp(style,'pushbutton'),
else,
	string=tip;
end
%
if strcmp(style,'edit') | strcmp(style,'popupmenu'),
	nrow=size(string,1);
	h1 = uicontrol('Parent',MBOX.figno,'Units','inches', ...
		'BackgroundColor',[1 1 1],'Callback',cback,'Position',pos, ...
		'Style',style,'String',string,'Tag',[tag,tip], ...
		'Value',val,'Max',nrow+1);
elseif strcmp(style,'text'),
% Make background gray for text box;
	h1 = uicontrol('Parent',MBOX.figno,'Units','inches', ...
		'BackgroundColor',[.6 .6 .6], ...
		'Position',pos,'String',string,'Style','text','Tag',[tag,tip]);
elseif strcmp(style,'pushbutton'),
	poslab=[pos(1) pos(2)+pos(4)+.01 pos(3) .2];
	h1 = uicontrol('Parent',MBOX.figno,'Units','inches', ...
		'Callback',cback,'Position',pos, ...
		'BackgroundColor',[.8 0 0],'ForegroundColor',[1 1 1], ...
		'Style',style,'String',string,'Tag',[tag,tip],'Value',val);
else
	h1 = uicontrol('Parent',MBOX.figno,'Units','inches', ...
		'BackgroundColor',[1 1 1],'Callback',cback,'Position',pos, ...
		'Style',style,'String',string,'Tag',[tag,tip], ...
		'Value',val);
end
h2=h1;
if ~isempty(label),
	poslab=[pos(1) pos(2)+pos(4)+.01 pos(3) .2];
	cback2=['mcs_help(''',tip,''');'];
	h2 = uicontrol('Parent',MBOX.figno,'Units','inches', ...
		'BackgroundColor',bcol,'ForegroundColor',fcol,'Callback',cback2, ...
		'Position',poslab,'String',label,'Style','pushbutton', ...
		'Tag',[tag,tip,'label']);
%else
%	poslab=pos;
%	cback2=['mcs_help(''',tip,''');'];
%	h2 = uicontrol('Parent',MBOX.figno,'Units','inches', ...
%		'Callback',cback2,'Position',poslab,'String',string,'Style','text', ...
%		'Tag','label','Visible','off');
end
%
MBOX.nboxtot=MBOX.nboxtot + 1;
nboxtot=MBOX.nboxtot;
MBOX.handle(:,nboxtot)=[h1;h2];
for j=1:length(progs),
	iiprog=progs(j);
	nbox=MBOX.nbox_prog(iiprog) + 1;
	MBOX.nbox_prog(iiprog)=nbox;
	MBOX.prog(iiprog,nbox)=MBOX.nboxtot;
end

