function startGUI

% allocations
r = groot;
scrsz	= r.ScreenSize;
figSize	= [400 250];
panelColor	= [0.98 0.98 0.98];
figureColor	= [0.9 0.9 0.9];
textColor	= [0.95 0.95 0.95];
textFontSize1  = 9;
textFontSize2  = 10;

% now, let's create GUI...
fig = figure('units', 'pixels', ...
   'Position', [(scrsz(3) - figSize(1))/2, ...
                (scrsz(4) - figSize(2))/2, ...
                figSize(1), figSize(2)], ...
   'Name', 'Example', 'Tag', 'fig_ex', ...
   'Color', figureColor, 'Menu', 'none', ...
   'NumberTitle', 'off');

panel1 = uipanel('Units', 'pixels', ...
   'Position', [90 180 220 60], 'Title', 'Visibility', ...
   'BackgroundColor', panelColor, 'tag', 'panelVisibility');

text1_Xlabel = uicontrol('Units', 'Normalized', ...
   'Position', [0.1 0.4 0.15 0.075], ...
   'Style', 'Text', 'String', 'X-position:', ...
   'BackgroundColor', figureColor, 'Fontsize', textFontSize1);

text2_Xdata = uicontrol('Units', 'Normalized', ...
   'Position', [0.26 0.4 0.175 0.075], ...
   'Style', 'Text', 'String', '', ...
   'BackgroundColor', textColor, 'Fontsize', textFontSize2);

text3_Ylabel = uicontrol('Units', 'Normalized', ...
   'Position', [0.55 0.4 0.15 0.075], ...
   'Style', 'Text', 'String', 'Y-position:', ...
   'BackgroundColor', figureColor, 'Fontsize', textFontSize1);

text4_Ydata = uicontrol('Units', 'Normalized', ...
   'Position', [0.71 0.4 0.175 0.075], ...
   'Style', 'Text', 'String', '', ...
   'BackgroundColor', textColor, 'Fontsize', textFontSize2);

button = uicontrol('Units', 'Normalized', ...
   'Position', [0.3 0.1 0.4 0.125], ...
   'Style', 'Push', 'String', 'End', ...
   'ForegroundColor', [0.8 0.9 0.9], ...
   'BackgroundColor', [0.1 0.5 0.6], ...
   'Fontsize', textFontSize1);

visibleHandle = uicontrol(panel1, 'Units','Normalized',...
   'Position',[0.225 0.25 0.6 0.5], ...
   'Style','check', 'String','Show position',...
   'Tag','choiceOfVisibility', 'BackgroundColor',panelColor,...
   'TooltipString', 'click to show mouse position');

% set callbacks (actions)
visibleHandle.Callback = @my_cursor;
fig.WindowButtonDownFcn = @my_click;
button.Callback = @(scr,callData) close_my_window;
referencesToTextObjects = [text1_Xlabel text2_Xdata text3_Ylabel text4_Ydata];
guidata(fig, referencesToTextObjects)
end

% Callback for mouse buttons
function my_click(src, ~)
hndls = guidata(src); % we can load the saved data here

if strcmp(src.SelectionType, 'normal') % action for a right mouse button
   if strcmp(hndls(1).FontWeight, 'normal')
      hndls(1).FontWeight = 'bold';
   else
      hndls(1).FontWeight = 'normal';
   end
elseif strcmp(src.SelectionType, 'alt') % action for a left mouse button
   if strcmp(hndls(3).FontWeight, 'normal')
      hndls(3).FontWeight = 'bold';
   else
      hndls(3).FontWeight = 'normal';
   end
else
   disp('You pressed another button.')
end
end

function my_cursor(src, ~)
fig = findobj('Tag', 'fig_ex'); % we can find figure object in different way
% FIXME: potential problem if two instances with "fig_ex" already exist...

if src.Value
   fig.WindowButtonMotionFcn = @(scr, callData) movement; % callback is set on
else
   fig.WindowButtonMotionFcn = []; % callback is disabled
   fig.Children(2).String = 'x';
   fig.Children(4).String = 'x';
end

   function movement % when feature activated and mouse on the move...
      fig.Children(2).String = fig.CurrentPoint(1);
      fig.Children(4).String = fig.CurrentPoint(2);
   end
end

% Function which is called when the figure should be closed
function close_my_window
closereq
end