function BuildUIControls (fig)

global Communication
global ButtonBackColor

h = get(gcf,'Position');

Communication.X0 = h(3)/2;
Communication.Y0 = 0;
Communication.Width = h(3)/2;
Communication.Height = h(4);

%%posFileName      = [850 880 500 40];

%distances between controls for file names
% d1 = distance to the half of the figure
% d2 = width of the filename box, dependes from the width of the figure
% d3 = distance between filename box and browse button
% d4 = width browse button
% d5 = distance to total figure width

% d1             d2          d3  d4 d5
% ---||||||||||||||||||||||||--|||||--
%    begin1                    begin2

dXY  = 20;
d0   = 10;
d1   = dXY + d0;
d3   = 20;
d4   = 65;
d5   = 10;
dSum = d1+d3+d4+d5;
d2 = Communication.Width - dSum;

h1 = 20;
h2 = 40;

FontName = 'Courier';

p1 = Communication.X0 + d1;
p2 = Communication.Y0 + Communication.Height - 10 - h1;
posFileHeader      = [p1 p2 d2 h1];
handles.txtFileHeader = uicontrol(gcf,'UserData','UIControl','Style','text','Max',1,'Min',1,'String','Geography from file:','Position',posFileHeader,...
                                    'HorizontalAlignment','left','BackgroundColor',[.8 .8 .8],'Enable','inactive','Fontname',FontName,...
                                    'Fontsize',12,'FontWeight','bold');

posFileName    = posFileHeader;
posFileName(2) = posFileName(2) - 45;
posFileName(4) = h2;
handles.txtFileName = uicontrol(gcf,'UserData','UIControl','Style','text','Max',1,'Min',1,'String','','Position',posFileName,...
                                    'HorizontalAlignment','left','BackgroundColor',[.95 .95 .95],'Enable','inactive','Fontname',FontName,...
                                    'Tag','txtFileName','Fontsize',10,'FontWeight','bold');

%Browse button                                
posbtnBrowse      = posFileName;
posbtnBrowse(1)   = posFileName(1)+posFileName(3)+d3;
posbtnBrowse(2)   = posFileName(2)+(h2-h1)/2;
posbtnBrowse(3)   = d4;
posbtnBrowse(4)   = h1;
handles.btnFileName = uicontrol(gcf,'UserData','UIControl','Style','pushbutton','String','Browse','Position',posbtnBrowse,...
                                    'Fontname',FontName,...
                                    'FontSize',8,'FontWeight','bold','Callback','clbBtnFilename','Tag','btnFileName');
                                

% Map extents Lower left and Upper right

postxtLowerLeft = posFileName;
postxtLowerLeft(1) = postxtLowerLeft(1) + 50;
postxtLowerLeft(2) = postxtLowerLeft(2) - 50;
postxtLowerLeft(3) = 190;
postxtLowerLeft(4) = h1;
handles.txtLowerLeft = uicontrol(gcf,'UserData','UIControl','Style','text','Max',1,'Min',1,'String','Lower left','Position',postxtLowerLeft,...
                                    'HorizontalAlignment','left','BackgroundColor',[.8 .8 .8],'Enable','inactive','Fontname',FontName,...
                                    'Fontsize',8,'FontWeight','bold');
postxtUpperRight = postxtLowerLeft;
postxtUpperRight(1) = postxtUpperRight(1)+130;

handles.txtUpperRight = uicontrol(gcf,'UserData','UIControl','Style','text','Max',1,'Min',1,'String','Upper right','Position',postxtUpperRight,...
                                    'HorizontalAlignment','left','BackgroundColor',[.8 .8 .8],'Enable','inactive','Fontname',FontName,...
                                    'Fontsize',8,'FontWeight','bold');


postxtX(1) = Communication.X0 +d1;
postxtX(2) = postxtLowerLeft(2) - 30;
postxtX(3) = dXY;
postxtX(4) = h1;

handles.txtX = uicontrol(gcf,'UserData','UIControl','Style','text','Max',1,'Min',1,'String','X','Position',postxtX,...
                                    'HorizontalAlignment','left','BackgroundColor',[.8 .8 .8],'Enable','inactive','Fontname',FontName,...
                                    'Fontsize',10,'FontWeight','bold');



posedtXLowerLeft      = postxtX;
posedtXLowerLeft(1)   = postxtLowerLeft(1);
posedtXLowerLeft(3)   = 100;
handles.edtXLowerLeft = uicontrol(gcf,'UserData','UIControl','Style','edit','Max',1,'Min',1,'String','','Position',posedtXLowerLeft,...
                                    'HorizontalAlignment','left','BackgroundColor',[1 1 1],'Enable','on','Fontname',FontName,...
                                    'Tag','edtXLowerLeft','Fontsize',10,'FontWeight','bold','Callback','clbedtXLowerLeft');

posedtXUpperRight     = postxtX;
posedtXUpperRight(1)  = postxtUpperRight(1);
posedtXUpperRight(3)  = posedtXLowerLeft(3);
handles.edtXLowerLeft = uicontrol(gcf,'UserData','UIControl','Style','edit','Max',1,'Min',1,'String','','Position',posedtXUpperRight,...
                                    'HorizontalAlignment','left','BackgroundColor',[1 1 1],'Enable','on','Fontname',FontName,...
                                    'Tag','edtXUpperRight','Fontsize',10,'FontWeight','bold','Callback','clbedtXUpperRight');
                                
postxtY    = postxtX;
postxtY(2) = postxtY(2)-35;

handles.txtY = uicontrol(gcf,'UserData','UIControl','Style','text','Max',1,'Min',1,'String','Y','Position',postxtY,...
                                    'HorizontalAlignment','left','BackgroundColor',[.8 .8 .8],'Enable','inactive','Fontname',FontName,...
                                    'Fontsize',10,'FontWeight','bold');

posedtYLowerLeft      = postxtY;
posedtYLowerLeft(1)   = postxtLowerLeft(1);
posedtYLowerLeft(3)   = 100;
handles.edtYLowerLeft = uicontrol(gcf,'UserData','UIControl','Style','edit','Max',1,'Min',1,'String','','Position',posedtYLowerLeft,...
                                    'HorizontalAlignment','left','BackgroundColor',[1 1 1],'Enable','on','Fontname',FontName,...
                                    'Tag','edtYLowerLeft','Fontsize',10,'FontWeight','bold','Callback','clbedtYLowerLeft');

posedtYUpperRight      = postxtY;
posedtYUpperRight(1)   = postxtUpperRight(1);
posedtYUpperRight(3)   = posedtYLowerLeft(3);
handles.edtYUpperRight = uicontrol(gcf,'UserData','UIControl','Style','edit','Max',1,'Min',1,'String','','Position',posedtYUpperRight,...
                                    'HorizontalAlignment','left','BackgroundColor',[1 1 1],'Enable','on','Fontname',FontName,...
                                    'Tag','edtYUpperRight','Fontsize',10,'FontWeight','bold','Callback','clbedtYUpperRight');

%Matrix file with results
posMatrixFileHeader    = posFileHeader;
posMatrixFileHeader(2) = posedtYLowerLeft(2)- 45;
handles.txtFileHeader  = uicontrol(gcf,'UserData','UIControl','Style','text','Max',1,'Min',1,'String','Results from file:','Position',posMatrixFileHeader,...
                                    'HorizontalAlignment','left','BackgroundColor',[.8 .8 .8],'Enable','inactive','Fontname',FontName,...
                                    'Fontsize',12,'FontWeight','bold');

posMatrixFileName    = posMatrixFileHeader;
posMatrixFileName(2) = posMatrixFileName(2) - 45;
posMatrixFileName(4) = h2;
handles.txtMatrixFileName = uicontrol(gcf,'UserData','UIControl','Style','text','Max',1,'Min',1,'String','','Position',posMatrixFileName,...
                                    'HorizontalAlignment','left','BackgroundColor',[.95 .95 .95],'Enable','inactive','Fontname',FontName,...
                                    'Tag','txtMatrixFileName','Fontsize',10,'FontWeight','bold');

%Browse button                                
posbtnMatrixBrowse      = posMatrixFileName;
posbtnMatrixBrowse(1)   = posMatrixFileName(1)+posMatrixFileName(3)+d3;
posbtnMatrixBrowse(2)   = posMatrixFileName(2)+(h2-h1)/2;
posbtnMatrixBrowse(3)   = d4;
posbtnMatrixBrowse(4)   = h1;
handles.btnMatrixFileName = uicontrol(gcf,'UserData','UIControl','Style','pushbutton','String','Browse','Position',posbtnMatrixBrowse,...
                                    'Fontname',FontName,'Enable','inactive','BackgroundColor',ButtonBackColor.inactive,...
                                    'FontSize',8,'FontWeight','bold','Callback','clbBtnMatrixFilename','Tag','btnMatrixBrowse');
                                